diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b32d1b442..d713d0f493 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -740,7 +740,8 @@ jobs: 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. Runners that keep their own ~/.m2 skip the cache. + # 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: | @@ -751,7 +752,9 @@ jobs: echo "cache=false" >> "$GITHUB_OUTPUT" else mkdir -p "$jars" "$(dirname "$m2")" - ln -sfn "$(cd "$jars" && pwd)" "$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 @@ -759,7 +762,7 @@ jobs: if: steps.robolectric-jars.outputs.cache == 'true' uses: actions/cache/restore@v4 with: - path: ../robolectric-jars + 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 @@ -773,7 +776,16 @@ jobs: run: | set -o pipefail mkdir -p app/build - ./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PndkVersion="$NDK_VERSION" 2>&1 | tee app/build/unit-tests.log + # 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. @@ -800,7 +812,7 @@ jobs: if: always() && steps.robolectric-jars-final.outputs.save == 'true' uses: actions/cache/save@v4 with: - path: ../robolectric-jars + path: ${{ steps.robolectric-jars.outputs.path }} key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }} - name: Upload unit test diagnostics diff --git a/app/build.gradle b/app/build.gradle index e851dd0596..70336a0472 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -284,6 +284,12 @@ def stageRuntimeAssets = tasks.register('stageRuntimeAssets', Sync) { into(runtimeAssetsDir) } android.sourceSets.main.assets.setSrcDirs([runtimeAssetsDir]) +def stageGraphicsNotices = tasks.register('stageGraphicsNotices', Copy) { + from(layout.projectDirectory.file('src/main/cpp/shaders/THIRD_PARTY_NOTICES.txt')) + into(layout.buildDirectory.dir('graphicsNotices/licenses/graphics')) +} +android.sourceSets.main.assets.srcDir(layout.buildDirectory.dir('graphicsNotices')) +tasks.named('preBuild').configure { dependsOn(stageGraphicsNotices) } if (vitureSdkDir) android.sourceSets.main.assets.srcDir(layout.buildDirectory.dir('vitureAssets')) if (uvcDir) { def stageUvcNotices = tasks.register('stageUvcNotices', Copy) { diff --git a/app/src/debug/java/com/droiddeck/launcher/ui/LauncherPreviews.kt b/app/src/debug/java/com/droiddeck/launcher/ui/LauncherPreviews.kt index 681b32a10b..0ab0ab8216 100644 --- a/app/src/debug/java/com/droiddeck/launcher/ui/LauncherPreviews.kt +++ b/app/src/debug/java/com/droiddeck/launcher/ui/LauncherPreviews.kt @@ -3,6 +3,9 @@ package com.droiddeck.launcher.ui import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.ui.unit.dp import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 55b75d36df..566226306e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,6 +33,9 @@ + + diff --git a/app/src/main/cpp/fakeinput_steam.cpp b/app/src/main/cpp/fakeinput_steam.cpp index e6e4a2b6ac..856501cb3c 100644 --- a/app/src/main/cpp/fakeinput_steam.cpp +++ b/app/src/main/cpp/fakeinput_steam.cpp @@ -25,6 +25,7 @@ #include #endif #include +#include #include #include #include @@ -711,6 +712,19 @@ ring_header_is_valid(const FakeInputRingHeader *ring) { ring->capacity == FAKE_INPUT_RING_CAPACITY; } +__attribute__((visibility("hidden"))) static int ring_wait(const FakeInputRingHeader *ring, uint64_t seen, long ns) { + struct timespec wait = {0, ns}; + if (syscall(SYS_futex, &ring->write_seq, FUTEX_WAIT, static_cast(seen), &wait, nullptr, 0) == 0 || + errno == EAGAIN || errno == ETIMEDOUT) + return 0; + if (errno == EINTR) return -1; + return nanosleep(&wait, nullptr); +} + +__attribute__((visibility("hidden"))) static void ring_wake(const FakeInputRingHeader *ring) { + syscall(SYS_futex, &ring->write_seq, FUTEX_WAKE, INT_MAX, nullptr, nullptr, 0); +} + struct SnapshotState { uint64_t sequence = 0; uint64_t write_seq = 0; @@ -1167,6 +1181,7 @@ __attribute__((visibility("hidden"))) static void flush_uinput(UinputWriter &w) __atomic_thread_fence(__ATOMIC_RELEASE); __atomic_store_n(&ring->snapshot_seq, sequence + 2, __ATOMIC_RELEASE); __atomic_store_n(&ring->write_seq, write_seq, __ATOMIC_RELEASE); + ring_wake(ring); } __attribute__((visibility("hidden"))) static ssize_t @@ -1540,6 +1555,12 @@ __attribute__((visibility("hidden"))) static void sleep_us(int us) { nanosleep(&interval, nullptr); } +__attribute__((visibility("hidden"))) static void +report_wait(const FakeInputRingHeader *ring, bool fresh, uint64_t seen, int us) { + if (fresh) ring_wait(ring, seen, us * 1000L); + else sleep_us(us); +} + __attribute__((visibility("hidden"))) static uint64_t monotonic_us() { struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); @@ -1712,7 +1733,8 @@ __attribute__((visibility("hidden"))) static void *deck_report_thread(void *arg) int32_t axes[8] = {}; DeckExtras extras; while (live_pad_type() == PAD_TYPE_DECK) { - if (read_snapshot(self->ring, snap) && snap.generation == ring_generation(self->ring)) { + bool fresh = read_snapshot(self->ring, snap); + if (fresh && snap.generation == ring_generation(self->ring)) { buttons = snap.buttons; memcpy(axes, snap.axes, sizeof(axes)); } @@ -1722,7 +1744,7 @@ __attribute__((visibility("hidden"))) static void *deck_report_thread(void *arg) if (send(self->peer, report, sizeof(report), MSG_DONTWAIT | MSG_NOSIGNAL) < 0 && errno != EAGAIN && errno != EWOULDBLOCK) break; - sleep_us(controller_report_interval_us(DECK_REPORT_INTERVAL_US)); + report_wait(self->ring, fresh, snap.write_seq, controller_report_interval_us(DECK_REPORT_INTERVAL_US)); } syscall(SYS_close, self->peer); munmap(self->ring, self->mapping_size); @@ -1828,7 +1850,8 @@ __attribute__((visibility("hidden"))) static void *sony_report_thread(void *arg) SonyTouch touch; const uint64_t start_us = monotonic_us(); while (live_pad_type() == type) { - if (read_snapshot(self->ring, snap) && snap.generation == ring_generation(self->ring)) { + bool fresh = read_snapshot(self->ring, snap); + if (fresh && snap.generation == ring_generation(self->ring)) { buttons = snap.buttons; memcpy(axes, snap.axes, sizeof(axes)); } @@ -1838,7 +1861,7 @@ __attribute__((visibility("hidden"))) static void *sony_report_thread(void *arg) if (send(self->peer, report, sizeof(report), MSG_DONTWAIT | MSG_NOSIGNAL) < 0 && errno != EAGAIN && errno != EWOULDBLOCK) break; - sleep_us(controller_report_interval_us(DECK_REPORT_INTERVAL_US)); + report_wait(self->ring, fresh, snap.write_seq, controller_report_interval_us(DECK_REPORT_INTERVAL_US)); } syscall(SYS_close, self->peer); munmap(self->ring, self->mapping_size); @@ -2037,7 +2060,8 @@ __attribute__((visibility("hidden"))) static void *triton_pad_thread(void *arg) DeckExtras extras; const uint64_t start_us = monotonic_us(); while (live_pad_type() == PAD_TYPE_STEAM) { - if (read_snapshot(self->ring, snap) && snap.generation == ring_generation(self->ring)) { + bool fresh = read_snapshot(self->ring, snap); + if (fresh && snap.generation == ring_generation(self->ring)) { buttons = snap.buttons; memcpy(axes, snap.axes, sizeof(axes)); } @@ -2048,7 +2072,7 @@ __attribute__((visibility("hidden"))) static void *triton_pad_thread(void *arg) if (send(self->peer, report, sizeof(report), MSG_DONTWAIT | MSG_NOSIGNAL) < 0 && errno != EAGAIN && errno != EWOULDBLOCK) break; - sleep_us(controller_report_interval_us(TRITON_REPORT_INTERVAL_US)); + report_wait(self->ring, fresh, snap.write_seq, controller_report_interval_us(TRITON_REPORT_INTERVAL_US)); } syscall(SYS_close, self->peer); munmap(self->ring, self->mapping_size); @@ -4016,6 +4040,7 @@ static ssize_t read_input(int fd, void *buf, size_t count) { errno = ENODEV; return -1; } + bool idle = false; for (int attempt = 0; attempt < 8; ++attempt) { size_t requested = count / sizeof(struct input_event); if (fake.keyframe_remaining == 0) { @@ -4037,7 +4062,10 @@ static ssize_t read_input(int fd, void *buf, size_t count) { capture_keyframe(fake, snap); } else { size_t events = std::min(requested, snap.write_seq - fake.read_seq); - if (events == 0) break; + if (events == 0) { + idle = true; + break; + } const uint8_t *ring_events = reinterpret_cast(fake.ring) + FAKE_INPUT_RING_HEADER_SIZE; std::vector input_events(events); @@ -4083,9 +4111,14 @@ static ssize_t read_input(int fd, void *buf, size_t count) { errno = EAGAIN; return -1; } + const FakeInputRingHeader *ring = fake.ring; + uint64_t seen = fake.read_seq; guard.unlock(); +#ifdef __GLIBC__ + pthread_testcancel(); +#endif struct timespec sleep_time = {0, backoff_ns}; - int result = nanosleep(&sleep_time, nullptr); + int result = idle ? ring_wait(ring, seen, backoff_ns) : nanosleep(&sleep_time, nullptr); guard.lock(); if (result < 0) return -1; if (low_latency(LATENCY_CONTROLLER)) backoff_ns = kLowLatencyRingWaitUs * 1000; @@ -4097,6 +4130,24 @@ EXPORT ssize_t read(int fd, void *buf, size_t count) { return read_input(fd, buf, count); } +// glibc's fortify failure; bionic (DroidDeck-Bionic preloads this library into its Wine processes) has no +// __chk_fail, and a library naming it there cannot be loaded, which stops every Wine program from starting. +#if defined(__BIONIC__) +[[noreturn]] static void fakeinput_chk_fail(void) { abort(); } +#else +extern "C" [[noreturn]] void __chk_fail(void); +[[noreturn]] static void fakeinput_chk_fail(void) { __chk_fail(); } +#endif + +/* Programs built with _FORTIFY_SOURCE (Flatpak runtimes among them) call these instead of read, poll + * and ppoll, and glibc's versions go straight to the kernel. */ +EXPORT ssize_t __read_chk(int fd, void *buf, size_t count, size_t buflen) { + static auto next_read_chk = reinterpret_cast(dlsym(RTLD_NEXT, "__read_chk")); + if (count > buflen) fakeinput_chk_fail(); + if (next_read_chk && !is_fake_input_fd(fd)) return next_read_chk(fd, buf, count, buflen); + return read_input(fd, buf, count); +} + EXPORT ssize_t readv(int fd, const struct iovec *iov, int iovcnt) { if (!is_fake_input_fd(fd)) return syscall(SYS_readv, fd, iov, iovcnt); if (iovcnt < 0 || iovcnt > IOV_MAX) { @@ -4345,6 +4396,17 @@ EXPORT int ppoll(struct pollfd *fds, nfds_t nfds, return my_ppoll(fds, nfds, timeout, sigmask); } +EXPORT int __poll_chk(struct pollfd *fds, nfds_t nfds, int timeout, size_t fdslen) { + if (fdslen / sizeof(*fds) < nfds) fakeinput_chk_fail(); + return poll(fds, nfds, timeout); +} + +EXPORT int __ppoll_chk(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, + const sigset_t *sigmask, size_t fdslen) { + if (fdslen / sizeof(*fds) < nfds) fakeinput_chk_fail(); + return ppoll(fds, nfds, timeout, sigmask); +} + EXPORT int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { const auto my_select = next_symbol(Next::select); diff --git a/app/src/main/cpp/framegen/ddfg/ddfg_engine.cpp b/app/src/main/cpp/framegen/ddfg/ddfg_engine.cpp index 6e87890b3f..034f2c4d55 100644 --- a/app/src/main/cpp/framegen/ddfg/ddfg_engine.cpp +++ b/app/src/main/cpp/framegen/ddfg/ddfg_engine.cpp @@ -27,7 +27,31 @@ VkImageMemoryBarrier bar(VkImage img, VkImageLayout from, VkImageLayout to, } Engine::Engine() = default; -Engine::~Engine() { destroyRing(); fg_.destroy(); } +Engine::~Engine() { (void)destroy(); } + +bool Engine::destroy() { + if (!fg_.destroy()) { + DDFG_LOGE("native: retaining the input ring because GPU completion is unknown"); + return false; + } + if (!destroyRing(true)) { + DDFG_LOGE("native: could not release the input ring during teardown"); + return false; + } + dev_ = VK_NULL_HANDLE; + unavailable_ = true; + return true; +} + +void Engine::abandon() { + fg_.abandon(); + ring_[0] = Slot{}; + ring_[1] = Slot{}; + dev_ = VK_NULL_HANDLE; + queue_ = VK_NULL_HANDLE; + phys_ = VK_NULL_HANDLE; + unavailable_ = true; +} bool Engine::init(const VkTable& table, VkPhysicalDevice phys, VkDevice dev, uint32_t queueFamily, VkQueue queue) { @@ -59,15 +83,29 @@ bool Engine::prepare(uint32_t w, uint32_t h, VkFormat fmt) { if (unavailable_ || w == 0 || h == 0 || fmt == VK_FORMAT_UNDEFINED) return false; if (builtW_ == w && builtH_ == h && builtFmt_ == fmt && fg_.valid()) return true; - - if (!fg_.onResize(VkExtent2D{w, h}, fmt, false)) { + const bool formatChanged = fmt != builtFmt_; + if (!fg_.onResize(VkExtent2D{w, h}, fmt, formatChanged)) { DDFG_LOGE("native: onResize %ux%u failed; frame generation unavailable", w, h); unavailable_ = true; return false; } - destroyRing(); + bool deviceLost = false; + if (!destroyRing(false, &deviceLost)) { + DDFG_LOGE("native: could not safely release the previous input ring"); + unavailable_ = true; + return false; + } + if (deviceLost) { + DDFG_LOGE("native: device lost while releasing the input ring"); + unavailable_ = true; + return false; + } for (Slot& s : ring_) { - if (!makeSlot(s, w, h, fmt)) { destroyRing(); unavailable_ = true; return false; } + if (!makeSlot(s, w, h, fmt)) { + destroyRing(true); + unavailable_ = true; + return false; + } } builtW_ = w; builtH_ = h; builtFmt_ = fmt; history_ = 0; curr_ = 0; frames_ = 0; @@ -178,11 +216,37 @@ void Engine::destroySlot(Slot& s) { s = Slot{}; } -void Engine::destroyRing() { - if (dev_ == VK_NULL_HANDLE || !dd_.DeviceWaitIdle) return; - if (ring_[0].img || ring_[1].img) dd_.DeviceWaitIdle(dev_); - destroySlot(ring_[0]); destroySlot(ring_[1]); +bool Engine::destroyRing(bool deviceIdleConfirmed, bool* deviceLost) { + if (deviceLost) *deviceLost = false; + const bool hasResources = ring_[0].img || ring_[0].mem || ring_[0].view || + ring_[1].img || ring_[1].mem || ring_[1].view; + if (!hasResources) { + history_ = 0; + return true; + } + if (dev_ == VK_NULL_HANDLE) { + DDFG_LOGE("native: cannot release the input ring without a valid device"); + return false; + } + if (!deviceIdleConfirmed) { + if (!dd_.DeviceWaitIdle) { + DDFG_LOGE("native: cannot release the input ring without vkDeviceWaitIdle"); + return false; + } + const VkResult result = dd_.DeviceWaitIdle(dev_); + if (result == VK_ERROR_DEVICE_LOST) { + if (deviceLost) *deviceLost = true; + unavailable_ = true; + } else if (result != VK_SUCCESS) { + DDFG_LOGE("native: DeviceWaitIdle failed (%d); retaining the input ring", (int)result); + unavailable_ = true; + return false; + } + } + destroySlot(ring_[0]); + destroySlot(ring_[1]); history_ = 0; + return true; } } diff --git a/app/src/main/cpp/framegen/ddfg/ddfg_engine.h b/app/src/main/cpp/framegen/ddfg/ddfg_engine.h index 55c1ef8fa0..aff10a9033 100644 --- a/app/src/main/cpp/framegen/ddfg/ddfg_engine.h +++ b/app/src/main/cpp/framegen/ddfg/ddfg_engine.h @@ -36,13 +36,15 @@ public: uint32_t width, uint32_t height); void reset(); + bool destroy(); + void abandon(); private: struct Slot { VkImage img = VK_NULL_HANDLE; VkDeviceMemory mem = VK_NULL_HANDLE; VkImageView view = VK_NULL_HANDLE; bool valid = false; }; bool makeSlot(Slot& s, uint32_t w, uint32_t h, VkFormat fmt); void destroySlot(Slot& s); - void destroyRing(); + bool destroyRing(bool deviceIdleConfirmed = false, bool* deviceLost = nullptr); uint32_t memType(uint32_t bits, VkMemoryPropertyFlags props) const; DeviceDispatch dd_{}; diff --git a/app/src/main/cpp/framegen/ddfg/embedded_shaders.hpp b/app/src/main/cpp/framegen/ddfg/embedded_shaders.hpp index 61f5c154c7..af09e777d6 100644 --- a/app/src/main/cpp/framegen/ddfg/embedded_shaders.hpp +++ b/app/src/main/cpp/framegen/ddfg/embedded_shaders.hpp @@ -6,8 +6,216 @@ static const uint32_t OF3_LUMA_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00 static const size_t OF3_LUMA_LEN = 481; static const uint32_t OF3_DOWNSAMPLE_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x0000008au,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x0000000du,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00030005u,0x00000009u,0x00646967u,0x00080005u,0x0000000du,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x00000012u,0x006d6964u,0x00040005u,0x00000016u,0x74734475u,0x00000000u,0x00040005u,0x00000030u,0x44637273u,0x00006d69u,0x00040005u,0x00000034u,0x63725375u,0x00000000u,0x00040005u,0x0000003au,0x65736162u,0x00000000u,0x00030005u,0x00000044u,0x00000068u,0x00030005u,0x0000004au,0x00000061u,0x00030005u,0x00000059u,0x00000062u,0x00030005u,0x00000065u,0x00000063u,0x00030005u,0x00000071u,0x00000064u,0x00040047u,0x0000000du,0x0000000bu,0x0000001cu,0x00030047u,0x00000016u,0x00000019u,0x00040047u,0x00000016u,0x00000021u,0x00000030u,0x00040047u,0x00000016u,0x00000022u,0x00000000u,0x00040047u,0x00000034u,0x00000021u,0x00000020u,0x00040047u,0x00000034u,0x00000022u,0x00000000u,0x00040047u,0x00000089u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u,0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00040020u,0x00000008u,0x00000007u,0x00000007u,0x00040015u,0x0000000au,0x00000020u,0x00000000u,0x00040017u,0x0000000bu,0x0000000au,0x00000003u,0x00040020u,0x0000000cu,0x00000001u,0x0000000bu,0x0004003bu,0x0000000cu,0x0000000du,0x00000001u,0x00040017u,0x0000000eu,0x0000000au,0x00000002u,0x00030016u,0x00000013u,0x00000020u,0x00090019u,0x00000014u,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000003u,0x00040020u,0x00000015u,0x00000000u,0x00000014u,0x0004003bu,0x00000015u,0x00000016u,0x00000000u,0x00020014u,0x00000019u,0x0004002bu,0x0000000au,0x0000001au,0x00000000u,0x00040020u,0x0000001bu,0x00000007u,0x00000006u,0x0004002bu,0x0000000au,0x00000024u,0x00000001u,0x00040017u,0x0000002eu,0x00000013u,0x00000002u,0x00040020u,0x0000002fu,0x00000007u,0x0000002eu,0x00090019u,0x00000031u,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000032u,0x00000031u,0x00040020u,0x00000033u,0x00000000u,0x00000032u,0x0004003bu,0x00000033u,0x00000034u,0x00000000u,0x0004002bu,0x00000006u,0x00000036u,0x00000000u,0x0004002bu,0x00000013u,0x0000003du,0x40000000u,0x0004002bu,0x00000013u,0x0000003fu,0x3f800000u,0x0004002bu,0x00000013u,0x00000045u,0x3f000000u,0x00040020u,0x00000049u,0x00000007u,0x00000013u,0x0004002bu,0x00000013u,0x00000055u,0x00000000u,0x00040017u,0x00000056u,0x00000013u,0x00000004u,0x0004002bu,0x00000013u,0x00000085u,0x3e800000u,0x0004002bu,0x0000000au,0x00000088u,0x00000010u,0x0006002cu,0x0000000bu,0x00000089u,0x00000088u,0x00000088u,0x00000024u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000008u,0x00000009u,0x00000007u,0x0004003bu,0x00000008u,0x00000012u,0x00000007u,0x0004003bu,0x0000002fu,0x00000030u,0x00000007u,0x0004003bu,0x0000002fu,0x0000003au,0x00000007u,0x0004003bu,0x0000002fu,0x00000044u,0x00000007u,0x0004003bu,0x00000049u,0x0000004au,0x00000007u,0x0004003bu,0x00000049u,0x00000059u,0x00000007u,0x0004003bu,0x00000049u,0x00000065u,0x00000007u,0x0004003bu,0x00000049u,0x00000071u,0x00000007u,0x0004003du,0x0000000bu,0x0000000fu,0x0000000du,0x0007004fu,0x0000000eu,0x00000010u,0x0000000fu,0x0000000fu,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x00000011u,0x00000010u,0x0003003eu,0x00000009u,0x00000011u,0x0004003du,0x00000014u,0x00000017u,0x00000016u,0x00040068u,0x00000007u,0x00000018u,0x00000017u,0x0003003eu,0x00000012u,0x00000018u,0x00050041u,0x0000001bu,0x0000001cu,0x00000009u,0x0000001au,0x0004003du,0x00000006u,0x0000001du,0x0000001cu,0x00050041u,0x0000001bu,0x0000001eu,0x00000012u,0x0000001au,0x0004003du,0x00000006u,0x0000001fu,0x0000001eu,0x000500afu,0x00000019u,0x00000020u,0x0000001du,0x0000001fu,0x000400a8u,0x00000019u,0x00000021u,0x00000020u,0x000300f7u,0x00000023u,0x00000000u,0x000400fau,0x00000021u,0x00000022u,0x00000023u,0x000200f8u,0x00000022u,0x00050041u,0x0000001bu,0x00000025u,0x00000009u,0x00000024u,0x0004003du,0x00000006u,0x00000026u,0x00000025u,0x00050041u,0x0000001bu,0x00000027u,0x00000012u,0x00000024u,0x0004003du,0x00000006u,0x00000028u,0x00000027u,0x000500afu,0x00000019u,0x00000029u,0x00000026u,0x00000028u,0x000200f9u,0x00000023u,0x000200f8u,0x00000023u,0x000700f5u,0x00000019u,0x0000002au,0x00000020u,0x00000005u,0x00000029u,0x00000022u,0x000300f7u,0x0000002cu,0x00000000u,0x000400fau,0x0000002au,0x0000002bu,0x0000002cu,0x000200f8u,0x0000002bu,0x000100fdu,0x000200f8u,0x0000002cu,0x0004003du,0x00000032u,0x00000035u,0x00000034u,0x00040064u,0x00000031u,0x00000037u,0x00000035u,0x00050067u,0x00000007u,0x00000038u,0x00000037u,0x00000036u,0x0004006fu,0x0000002eu,0x00000039u,0x00000038u,0x0003003eu,0x00000030u,0x00000039u,0x0004003du,0x00000007u,0x0000003bu,0x00000009u,0x0004006fu,0x0000002eu,0x0000003cu,0x0000003bu,0x0005008eu,0x0000002eu,0x0000003eu,0x0000003cu,0x0000003du,0x00050050u,0x0000002eu,0x00000040u,0x0000003fu,0x0000003fu,0x00050081u,0x0000002eu,0x00000041u,0x0000003eu,0x00000040u,0x0004003du,0x0000002eu,0x00000042u,0x00000030u,0x00050088u,0x0000002eu,0x00000043u,0x00000041u,0x00000042u,0x0003003eu,0x0000003au,0x00000043u,0x0004003du,0x0000002eu,0x00000046u,0x00000030u,0x00050050u,0x0000002eu,0x00000047u,0x00000045u,0x00000045u,0x00050088u,0x0000002eu,0x00000048u,0x00000047u,0x00000046u,0x0003003eu,0x00000044u,0x00000048u,0x0004003du,0x00000032u,0x0000004bu,0x00000034u,0x0004003du,0x0000002eu,0x0000004cu,0x0000003au,0x00050041u,0x00000049u,0x0000004du,0x00000044u,0x0000001au,0x0004003du,0x00000013u,0x0000004eu,0x0000004du,0x0004007fu,0x00000013u,0x0000004fu,0x0000004eu,0x00050041u,0x00000049u,0x00000050u,0x00000044u,0x00000024u,0x0004003du,0x00000013u,0x00000051u,0x00000050u,0x0004007fu,0x00000013u,0x00000052u,0x00000051u,0x00050050u,0x0000002eu,0x00000053u,0x0000004fu,0x00000052u,0x00050081u,0x0000002eu,0x00000054u,0x0000004cu,0x00000053u,0x00070058u,0x00000056u,0x00000057u,0x0000004bu,0x00000054u,0x00000002u,0x00000055u,0x00050051u,0x00000013u,0x00000058u,0x00000057u,0x00000000u,0x0003003eu,0x0000004au,0x00000058u,0x0004003du,0x00000032u,0x0000005au,0x00000034u,0x0004003du,0x0000002eu,0x0000005bu,0x0000003au,0x00050041u,0x00000049u,0x0000005cu,0x00000044u,0x0000001au,0x0004003du,0x00000013u,0x0000005du,0x0000005cu,0x00050041u,0x00000049u,0x0000005eu,0x00000044u,0x00000024u,0x0004003du,0x00000013u,0x0000005fu,0x0000005eu,0x0004007fu,0x00000013u,0x00000060u,0x0000005fu,0x00050050u,0x0000002eu,0x00000061u,0x0000005du,0x00000060u,0x00050081u,0x0000002eu,0x00000062u,0x0000005bu,0x00000061u,0x00070058u,0x00000056u,0x00000063u,0x0000005au,0x00000062u,0x00000002u,0x00000055u,0x00050051u,0x00000013u,0x00000064u,0x00000063u,0x00000000u,0x0003003eu,0x00000059u,0x00000064u,0x0004003du,0x00000032u,0x00000066u,0x00000034u,0x0004003du,0x0000002eu,0x00000067u,0x0000003au,0x00050041u,0x00000049u,0x00000068u,0x00000044u,0x0000001au,0x0004003du,0x00000013u,0x00000069u,0x00000068u,0x0004007fu,0x00000013u,0x0000006au,0x00000069u,0x00050041u,0x00000049u,0x0000006bu,0x00000044u,0x00000024u,0x0004003du,0x00000013u,0x0000006cu,0x0000006bu,0x00050050u,0x0000002eu,0x0000006du,0x0000006au,0x0000006cu,0x00050081u,0x0000002eu,0x0000006eu,0x00000067u,0x0000006du,0x00070058u,0x00000056u,0x0000006fu,0x00000066u,0x0000006eu,0x00000002u,0x00000055u,0x00050051u,0x00000013u,0x00000070u,0x0000006fu,0x00000000u,0x0003003eu,0x00000065u,0x00000070u,0x0004003du,0x00000032u,0x00000072u,0x00000034u,0x0004003du,0x0000002eu,0x00000073u,0x0000003au,0x00050041u,0x00000049u,0x00000074u,0x00000044u,0x0000001au,0x0004003du,0x00000013u,0x00000075u,0x00000074u,0x00050041u,0x00000049u,0x00000076u,0x00000044u,0x00000024u,0x0004003du,0x00000013u,0x00000077u,0x00000076u,0x00050050u,0x0000002eu,0x00000078u,0x00000075u,0x00000077u,0x00050081u,0x0000002eu,0x00000079u,0x00000073u,0x00000078u,0x00070058u,0x00000056u,0x0000007au,0x00000072u,0x00000079u,0x00000002u,0x00000055u,0x00050051u,0x00000013u,0x0000007bu,0x0000007au,0x00000000u,0x0003003eu,0x00000071u,0x0000007bu,0x0004003du,0x00000014u,0x0000007cu,0x00000016u,0x0004003du,0x00000007u,0x0000007du,0x00000009u,0x0004003du,0x00000013u,0x0000007eu,0x0000004au,0x0004003du,0x00000013u,0x0000007fu,0x00000059u,0x00050081u,0x00000013u,0x00000080u,0x0000007eu,0x0000007fu,0x0004003du,0x00000013u,0x00000081u,0x00000065u,0x00050081u,0x00000013u,0x00000082u,0x00000080u,0x00000081u,0x0004003du,0x00000013u,0x00000083u,0x00000071u,0x00050081u,0x00000013u,0x00000084u,0x00000082u,0x00000083u,0x00050085u,0x00000013u,0x00000086u,0x00000084u,0x00000085u,0x00070050u,0x00000056u,0x00000087u,0x00000086u,0x00000055u,0x00000055u,0x00000055u,0x00040063u,0x0000007cu,0x0000007du,0x00000087u,0x000100fdu,0x00010038u}; static const size_t OF3_DOWNSAMPLE_LEN = 753; -static const uint32_t OF3_FLOW_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000185u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x0000000du,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00030005u,0x00000009u,0x00646967u,0x00080005u,0x0000000du,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x00000012u,0x006d6964u,0x00040005u,0x00000016u,0x6f6c4675u,0x00000077u,0x00040005u,0x00000030u,0x44766e69u,0x00006d69u,0x00030005u,0x00000036u,0x00007675u,0x00040005u,0x0000003fu,0x654c6f74u,0x006c6576u,0x00030005u,0x00000040u,0x00000055u,0x00060006u,0x00000040u,0x00000000u,0x776f6c66u,0x6c616353u,0x00000065u,0x00050006u,0x00000040u,0x00000001u,0x6576656cu,0x0000006cu,0x00050006u,0x00000040u,0x00000002u,0x30646170u,0x00000000u,0x00050006u,0x00000040u,0x00000003u,0x31646170u,0x00000000u,0x00030005u,0x00000042u,0x00000000u,0x00050005u,0x0000004au,0x64657270u,0x6c6c7546u,0x00000000u,0x00050005u,0x0000004eu,0x65725075u,0x74636964u,0x0000726fu,0x00050005u,0x00000055u,0x64657270u,0x6576654cu,0x0000006cu,0x00040005u,0x00000059u,0x74736562u,0x00646153u,0x00050005u,0x0000005bu,0x74736562u,0x70736944u,0x00000000u,0x00030005u,0x0000005du,0x00007973u,0x00030005u,0x00000067u,0x00007873u,0x00040005u,0x0000006fu,0x646e6163u,0x00000000u,0x00030005u,0x00000077u,0x00646173u,0x00030005u,0x00000078u,0x00007962u,0x00030005u,0x00000081u,0x00007862u,0x00030005u,0x00000089u,0x00006f62u,0x00030005u,0x0000008fu,0x00000070u,0x00050005u,0x00000090u,0x6d754c75u,0x65725061u,0x00000076u,0x00030005u,0x00000099u,0x00000063u,0x00050005u,0x0000009au,0x6d754c75u,0x72754361u,0x00000072u,0x00040005u,0x000000cau,0x43646173u,0x00000000u,0x00040005u,0x000000ccu,0x58646173u,0x0000006du,0x00040005u,0x000000cdu,0x58646173u,0x00000070u,0x00040005u,0x000000ceu,0x59646173u,0x0000006du,0x00040005u,0x000000cfu,0x59646173u,0x00000070u,0x00030005u,0x000000d0u,0x00007962u,0x00030005u,0x000000d8u,0x00007862u,0x00030005u,0x000000e0u,0x00006f62u,0x00030005u,0x000000e6u,0x00000070u,0x00040005u,0x000000efu,0x646e6163u,0x00006d58u,0x00040005u,0x000000f4u,0x646e6163u,0x00007058u,0x00040005u,0x000000f8u,0x646e6163u,0x00006d59u,0x00040005u,0x000000fcu,0x646e6163u,0x00007059u,0x00030005u,0x00000148u,0x00007864u,0x00030005u,0x00000149u,0x00007964u,0x00040005u,0x0000014au,0x6f6e6564u,0x0000586du,0x00040005u,0x00000152u,0x6f6e6564u,0x0000596du,0x00050005u,0x00000176u,0x776f6c66u,0x6c6c7546u,0x00000000u,0x00040047u,0x0000000du,0x0000000bu,0x0000001cu,0x00030047u,0x00000016u,0x00000019u,0x00040047u,0x00000016u,0x00000021u,0x00000030u,0x00040047u,0x00000016u,0x00000022u,0x00000000u,0x00030047u,0x00000040u,0x00000002u,0x00050048u,0x00000040u,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x00000040u,0x00000001u,0x00000023u,0x00000004u,0x00050048u,0x00000040u,0x00000002u,0x00000023u,0x00000008u,0x00050048u,0x00000040u,0x00000003u,0x00000023u,0x0000000cu,0x00040047u,0x00000042u,0x00000021u,0x00000000u,0x00040047u,0x00000042u,0x00000022u,0x00000000u,0x00040047u,0x0000004eu,0x00000021u,0x00000022u,0x00040047u,0x0000004eu,0x00000022u,0x00000000u,0x00040047u,0x00000090u,0x00000021u,0x00000020u,0x00040047u,0x00000090u,0x00000022u,0x00000000u,0x00040047u,0x0000009au,0x00000021u,0x00000021u,0x00040047u,0x0000009au,0x00000022u,0x00000000u,0x00040047u,0x00000184u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u,0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00040020u,0x00000008u,0x00000007u,0x00000007u,0x00040015u,0x0000000au,0x00000020u,0x00000000u,0x00040017u,0x0000000bu,0x0000000au,0x00000003u,0x00040020u,0x0000000cu,0x00000001u,0x0000000bu,0x0004003bu,0x0000000cu,0x0000000du,0x00000001u,0x00040017u,0x0000000eu,0x0000000au,0x00000002u,0x00030016u,0x00000013u,0x00000020u,0x00090019u,0x00000014u,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u,0x00000015u,0x00000000u,0x00000014u,0x0004003bu,0x00000015u,0x00000016u,0x00000000u,0x00020014u,0x00000019u,0x0004002bu,0x0000000au,0x0000001au,0x00000000u,0x00040020u,0x0000001bu,0x00000007u,0x00000006u,0x0004002bu,0x0000000au,0x00000024u,0x00000001u,0x00040017u,0x0000002eu,0x00000013u,0x00000002u,0x00040020u,0x0000002fu,0x00000007u,0x0000002eu,0x0004002bu,0x00000013u,0x00000031u,0x3f800000u,0x0004002bu,0x00000013u,0x00000039u,0x3f000000u,0x00040020u,0x0000003eu,0x00000007u,0x00000013u,0x0006001eu,0x00000040u,0x00000013u,0x0000000au,0x0000000au,0x0000000au,0x00040020u,0x00000041u,0x00000002u,0x00000040u,0x0004003bu,0x00000041u,0x00000042u,0x00000002u,0x0004002bu,0x00000006u,0x00000043u,0x00000001u,0x00040020u,0x00000044u,0x00000002u,0x0000000au,0x00090019u,0x0000004bu,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x0000004cu,0x0000004bu,0x00040020u,0x0000004du,0x00000000u,0x0000004cu,0x0004003bu,0x0000004du,0x0000004eu,0x00000000u,0x0004002bu,0x00000013u,0x00000051u,0x00000000u,0x00040017u,0x00000052u,0x00000013u,0x00000004u,0x0004002bu,0x00000013u,0x0000005au,0x7f7fffffu,0x0004002bu,0x00000006u,0x0000005eu,0xfffffffdu,0x0004002bu,0x00000006u,0x00000065u,0x00000003u,0x0004002bu,0x00000006u,0x00000079u,0xffffffffu,0x0004003bu,0x0000004du,0x00000090u,0x00000000u,0x0004003bu,0x0000004du,0x0000009au,0x00000000u,0x0004002bu,0x00000013u,0x000000afu,0x3bc49ba6u,0x0004002bu,0x00000013u,0x000000f1u,0xbf800000u,0x0005002cu,0x0000002eu,0x000000f2u,0x000000f1u,0x00000051u,0x0005002cu,0x0000002eu,0x000000f6u,0x00000031u,0x00000051u,0x0005002cu,0x0000002eu,0x000000fau,0x00000051u,0x000000f1u,0x0005002cu,0x0000002eu,0x000000feu,0x00000051u,0x00000031u,0x0004002bu,0x00000013u,0x0000014cu,0x40000000u,0x0004002bu,0x00000013u,0x0000015au,0x358637bdu,0x0004002bu,0x00000013u,0x00000164u,0xbf000000u,0x0004002bu,0x0000000au,0x00000183u,0x00000010u,0x0006002cu,0x0000000bu,0x00000184u,0x00000183u,0x00000183u,0x00000024u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000008u,0x00000009u,0x00000007u,0x0004003bu,0x00000008u,0x00000012u,0x00000007u,0x0004003bu,0x0000002fu,0x00000030u,0x00000007u,0x0004003bu,0x0000002fu,0x00000036u,0x00000007u,0x0004003bu,0x0000003eu,0x0000003fu,0x00000007u,0x0004003bu,0x0000002fu,0x0000004au,0x00000007u,0x0004003bu,0x0000002fu,0x00000055u,0x00000007u,0x0004003bu,0x0000003eu,0x00000059u,0x00000007u,0x0004003bu,0x0000002fu,0x0000005bu,0x00000007u,0x0004003bu,0x0000001bu,0x0000005du,0x00000007u,0x0004003bu,0x0000001bu,0x00000067u,0x00000007u,0x0004003bu,0x0000002fu,0x0000006fu,0x00000007u,0x0004003bu,0x0000003eu,0x00000077u,0x00000007u,0x0004003bu,0x0000001bu,0x00000078u,0x00000007u,0x0004003bu,0x0000001bu,0x00000081u,0x00000007u,0x0004003bu,0x0000002fu,0x00000089u,0x00000007u,0x0004003bu,0x0000003eu,0x0000008fu,0x00000007u,0x0004003bu,0x0000003eu,0x00000099u,0x00000007u,0x0004003bu,0x0000003eu,0x000000cau,0x00000007u,0x0004003bu,0x0000003eu,0x000000ccu,0x00000007u,0x0004003bu,0x0000003eu,0x000000cdu,0x00000007u,0x0004003bu,0x0000003eu,0x000000ceu,0x00000007u,0x0004003bu,0x0000003eu,0x000000cfu,0x00000007u,0x0004003bu,0x0000001bu,0x000000d0u,0x00000007u,0x0004003bu,0x0000001bu,0x000000d8u,0x00000007u,0x0004003bu,0x0000002fu,0x000000e0u,0x00000007u,0x0004003bu,0x0000003eu,0x000000e6u,0x00000007u,0x0004003bu,0x0000002fu,0x000000efu,0x00000007u,0x0004003bu,0x0000002fu,0x000000f4u,0x00000007u,0x0004003bu,0x0000002fu,0x000000f8u,0x00000007u,0x0004003bu,0x0000002fu,0x000000fcu,0x00000007u,0x0004003bu,0x0000003eu,0x00000148u,0x00000007u,0x0004003bu,0x0000003eu,0x00000149u,0x00000007u,0x0004003bu,0x0000003eu,0x0000014au,0x00000007u,0x0004003bu,0x0000003eu,0x00000152u,0x00000007u,0x0004003bu,0x0000002fu,0x00000176u,0x00000007u,0x0004003du,0x0000000bu,0x0000000fu,0x0000000du,0x0007004fu,0x0000000eu,0x00000010u,0x0000000fu,0x0000000fu,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x00000011u,0x00000010u,0x0003003eu,0x00000009u,0x00000011u,0x0004003du,0x00000014u,0x00000017u,0x00000016u,0x00040068u,0x00000007u,0x00000018u,0x00000017u,0x0003003eu,0x00000012u,0x00000018u,0x00050041u,0x0000001bu,0x0000001cu,0x00000009u,0x0000001au,0x0004003du,0x00000006u,0x0000001du,0x0000001cu,0x00050041u,0x0000001bu,0x0000001eu,0x00000012u,0x0000001au,0x0004003du,0x00000006u,0x0000001fu,0x0000001eu,0x000500afu,0x00000019u,0x00000020u,0x0000001du,0x0000001fu,0x000400a8u,0x00000019u,0x00000021u,0x00000020u,0x000300f7u,0x00000023u,0x00000000u,0x000400fau,0x00000021u,0x00000022u,0x00000023u,0x000200f8u,0x00000022u,0x00050041u,0x0000001bu,0x00000025u,0x00000009u,0x00000024u,0x0004003du,0x00000006u,0x00000026u,0x00000025u,0x00050041u,0x0000001bu,0x00000027u,0x00000012u,0x00000024u,0x0004003du,0x00000006u,0x00000028u,0x00000027u,0x000500afu,0x00000019u,0x00000029u,0x00000026u,0x00000028u,0x000200f9u,0x00000023u,0x000200f8u,0x00000023u,0x000700f5u,0x00000019u,0x0000002au,0x00000020u,0x00000005u,0x00000029u,0x00000022u,0x000300f7u,0x0000002cu,0x00000000u,0x000400fau,0x0000002au,0x0000002bu,0x0000002cu,0x000200f8u,0x0000002bu,0x000100fdu,0x000200f8u,0x0000002cu,0x0004003du,0x00000007u,0x00000032u,0x00000012u,0x0004006fu,0x0000002eu,0x00000033u,0x00000032u,0x00050050u,0x0000002eu,0x00000034u,0x00000031u,0x00000031u,0x00050088u,0x0000002eu,0x00000035u,0x00000034u,0x00000033u,0x0003003eu,0x00000030u,0x00000035u,0x0004003du,0x00000007u,0x00000037u,0x00000009u,0x0004006fu,0x0000002eu,0x00000038u,0x00000037u,0x00050050u,0x0000002eu,0x0000003au,0x00000039u,0x00000039u,0x00050081u,0x0000002eu,0x0000003bu,0x00000038u,0x0000003au,0x0004003du,0x0000002eu,0x0000003cu,0x00000030u,0x00050085u,0x0000002eu,0x0000003du,0x0000003bu,0x0000003cu,0x0003003eu,0x00000036u,0x0000003du,0x00050041u,0x00000044u,0x00000045u,0x00000042u,0x00000043u,0x0004003du,0x0000000au,0x00000046u,0x00000045u,0x00040070u,0x00000013u,0x00000047u,0x00000046u,0x0004007fu,0x00000013u,0x00000048u,0x00000047u,0x0006000cu,0x00000013u,0x00000049u,0x00000001u,0x0000001du,0x00000048u,0x0003003eu,0x0000003fu,0x00000049u,0x0004003du,0x0000004cu,0x0000004fu,0x0000004eu,0x0004003du,0x0000002eu,0x00000050u,0x00000036u,0x00070058u,0x00000052u,0x00000053u,0x0000004fu,0x00000050u,0x00000002u,0x00000051u,0x0007004fu,0x0000002eu,0x00000054u,0x00000053u,0x00000053u,0x00000000u,0x00000001u,0x0003003eu,0x0000004au,0x00000054u,0x0004003du,0x0000002eu,0x00000056u,0x0000004au,0x0004003du,0x00000013u,0x00000057u,0x0000003fu,0x0005008eu,0x0000002eu,0x00000058u,0x00000056u,0x00000057u,0x0003003eu,0x00000055u,0x00000058u,0x0003003eu,0x00000059u,0x0000005au,0x0004003du,0x0000002eu,0x0000005cu,0x00000055u,0x0003003eu,0x0000005bu,0x0000005cu,0x0003003eu,0x0000005du,0x0000005eu,0x000200f9u,0x0000005fu,0x000200f8u,0x0000005fu,0x000400f6u,0x00000061u,0x00000062u,0x00000000u,0x000200f9u,0x00000063u,0x000200f8u,0x00000063u,0x0004003du,0x00000006u,0x00000064u,0x0000005du,0x000500b3u,0x00000019u,0x00000066u,0x00000064u,0x00000065u,0x000400fau,0x00000066u,0x00000060u,0x00000061u,0x000200f8u,0x00000060u,0x0003003eu,0x00000067u,0x0000005eu,0x000200f9u,0x00000068u,0x000200f8u,0x00000068u,0x000400f6u,0x0000006au,0x0000006bu,0x00000000u,0x000200f9u,0x0000006cu,0x000200f8u,0x0000006cu,0x0004003du,0x00000006u,0x0000006du,0x00000067u,0x000500b3u,0x00000019u,0x0000006eu,0x0000006du,0x00000065u,0x000400fau,0x0000006eu,0x00000069u,0x0000006au,0x000200f8u,0x00000069u,0x0004003du,0x0000002eu,0x00000070u,0x00000055u,0x0004003du,0x00000006u,0x00000071u,0x00000067u,0x0004006fu,0x00000013u,0x00000072u,0x00000071u,0x0004003du,0x00000006u,0x00000073u,0x0000005du,0x0004006fu,0x00000013u,0x00000074u,0x00000073u,0x00050050u,0x0000002eu,0x00000075u,0x00000072u,0x00000074u,0x00050081u,0x0000002eu,0x00000076u,0x00000070u,0x00000075u,0x0003003eu,0x0000006fu,0x00000076u,0x0003003eu,0x00000077u,0x00000051u,0x0003003eu,0x00000078u,0x00000079u,0x000200f9u,0x0000007au,0x000200f8u,0x0000007au,0x000400f6u,0x0000007cu,0x0000007du,0x00000000u,0x000200f9u,0x0000007eu,0x000200f8u,0x0000007eu,0x0004003du,0x00000006u,0x0000007fu,0x00000078u,0x000500b3u,0x00000019u,0x00000080u,0x0000007fu,0x00000043u,0x000400fau,0x00000080u,0x0000007bu,0x0000007cu,0x000200f8u,0x0000007bu,0x0003003eu,0x00000081u,0x00000079u,0x000200f9u,0x00000082u,0x000200f8u,0x00000082u,0x000400f6u,0x00000084u,0x00000085u,0x00000000u,0x000200f9u,0x00000086u,0x000200f8u,0x00000086u,0x0004003du,0x00000006u,0x00000087u,0x00000081u,0x000500b3u,0x00000019u,0x00000088u,0x00000087u,0x00000043u,0x000400fau,0x00000088u,0x00000083u,0x00000084u,0x000200f8u,0x00000083u,0x0004003du,0x00000006u,0x0000008au,0x00000081u,0x0004006fu,0x00000013u,0x0000008bu,0x0000008au,0x0004003du,0x00000006u,0x0000008cu,0x00000078u,0x0004006fu,0x00000013u,0x0000008du,0x0000008cu,0x00050050u,0x0000002eu,0x0000008eu,0x0000008bu,0x0000008du,0x0003003eu,0x00000089u,0x0000008eu,0x0004003du,0x0000004cu,0x00000091u,0x00000090u,0x0004003du,0x0000002eu,0x00000092u,0x00000036u,0x0004003du,0x0000002eu,0x00000093u,0x00000089u,0x0004003du,0x0000002eu,0x00000094u,0x00000030u,0x00050085u,0x0000002eu,0x00000095u,0x00000093u,0x00000094u,0x00050081u,0x0000002eu,0x00000096u,0x00000092u,0x00000095u,0x00070058u,0x00000052u,0x00000097u,0x00000091u,0x00000096u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000098u,0x00000097u,0x00000000u,0x0003003eu,0x0000008fu,0x00000098u,0x0004003du,0x0000004cu,0x0000009bu,0x0000009au,0x0004003du,0x0000002eu,0x0000009cu,0x00000036u,0x0004003du,0x0000002eu,0x0000009du,0x00000089u,0x0004003du,0x0000002eu,0x0000009eu,0x0000006fu,0x00050081u,0x0000002eu,0x0000009fu,0x0000009du,0x0000009eu,0x0004003du,0x0000002eu,0x000000a0u,0x00000030u,0x00050085u,0x0000002eu,0x000000a1u,0x0000009fu,0x000000a0u,0x00050081u,0x0000002eu,0x000000a2u,0x0000009cu,0x000000a1u,0x00070058u,0x00000052u,0x000000a3u,0x0000009bu,0x000000a2u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x000000a4u,0x000000a3u,0x00000000u,0x0003003eu,0x00000099u,0x000000a4u,0x0004003du,0x00000013u,0x000000a5u,0x0000008fu,0x0004003du,0x00000013u,0x000000a6u,0x00000099u,0x00050083u,0x00000013u,0x000000a7u,0x000000a5u,0x000000a6u,0x0006000cu,0x00000013u,0x000000a8u,0x00000001u,0x00000004u,0x000000a7u,0x0004003du,0x00000013u,0x000000a9u,0x00000077u,0x00050081u,0x00000013u,0x000000aau,0x000000a9u,0x000000a8u,0x0003003eu,0x00000077u,0x000000aau,0x000200f9u,0x00000085u,0x000200f8u,0x00000085u,0x0004003du,0x00000006u,0x000000abu,0x00000081u,0x00050080u,0x00000006u,0x000000acu,0x000000abu,0x00000043u,0x0003003eu,0x00000081u,0x000000acu,0x000200f9u,0x00000082u,0x000200f8u,0x00000084u,0x000200f9u,0x0000007du,0x000200f8u,0x0000007du,0x0004003du,0x00000006u,0x000000adu,0x00000078u,0x00050080u,0x00000006u,0x000000aeu,0x000000adu,0x00000043u,0x0003003eu,0x00000078u,0x000000aeu,0x000200f9u,0x0000007au,0x000200f8u,0x0000007cu,0x0004003du,0x00000006u,0x000000b0u,0x00000067u,0x0004006fu,0x00000013u,0x000000b1u,0x000000b0u,0x0006000cu,0x00000013u,0x000000b2u,0x00000001u,0x00000004u,0x000000b1u,0x0004003du,0x00000006u,0x000000b3u,0x0000005du,0x0004006fu,0x00000013u,0x000000b4u,0x000000b3u,0x0006000cu,0x00000013u,0x000000b5u,0x00000001u,0x00000004u,0x000000b4u,0x00050081u,0x00000013u,0x000000b6u,0x000000b2u,0x000000b5u,0x00050085u,0x00000013u,0x000000b7u,0x000000afu,0x000000b6u,0x0004003du,0x00000013u,0x000000b8u,0x00000077u,0x00050081u,0x00000013u,0x000000b9u,0x000000b8u,0x000000b7u,0x0003003eu,0x00000077u,0x000000b9u,0x0004003du,0x00000013u,0x000000bau,0x00000077u,0x0004003du,0x00000013u,0x000000bbu,0x00000059u,0x000500b8u,0x00000019u,0x000000bcu,0x000000bau,0x000000bbu,0x000300f7u,0x000000beu,0x00000000u,0x000400fau,0x000000bcu,0x000000bdu,0x000000beu,0x000200f8u,0x000000bdu,0x0004003du,0x00000013u,0x000000bfu,0x00000077u,0x0003003eu,0x00000059u,0x000000bfu,0x0004003du,0x0000002eu,0x000000c0u,0x0000006fu,0x0003003eu,0x0000005bu,0x000000c0u,0x000200f9u,0x000000beu,0x000200f8u,0x000000beu,0x000200f9u,0x0000006bu,0x000200f8u,0x0000006bu,0x0004003du,0x00000006u,0x000000c1u,0x00000067u,0x00050080u,0x00000006u,0x000000c2u,0x000000c1u,0x00000043u,0x0003003eu,0x00000067u,0x000000c2u,0x000200f9u,0x00000068u,0x000200f8u,0x0000006au,0x000200f9u,0x00000062u,0x000200f8u,0x00000062u,0x0004003du,0x00000006u,0x000000c3u,0x0000005du,0x00050080u,0x00000006u,0x000000c4u,0x000000c3u,0x00000043u,0x0003003eu,0x0000005du,0x000000c4u,0x000200f9u,0x0000005fu,0x000200f8u,0x00000061u,0x00050041u,0x00000044u,0x000000c5u,0x00000042u,0x00000043u,0x0004003du,0x0000000au,0x000000c6u,0x000000c5u,0x000500aau,0x00000019u,0x000000c7u,0x000000c6u,0x0000001au,0x000300f7u,0x000000c9u,0x00000000u,0x000400fau,0x000000c7u,0x000000c8u,0x000000c9u,0x000200f8u,0x000000c8u,0x0004003du,0x00000013u,0x000000cbu,0x00000059u,0x0003003eu,0x000000cau,0x000000cbu,0x0003003eu,0x000000ccu,0x00000051u,0x0003003eu,0x000000cdu,0x00000051u,0x0003003eu,0x000000ceu,0x00000051u,0x0003003eu,0x000000cfu,0x00000051u,0x0003003eu,0x000000d0u,0x00000079u,0x000200f9u,0x000000d1u,0x000200f8u,0x000000d1u,0x000400f6u,0x000000d3u,0x000000d4u,0x00000000u,0x000200f9u,0x000000d5u,0x000200f8u,0x000000d5u,0x0004003du,0x00000006u,0x000000d6u,0x000000d0u,0x000500b3u,0x00000019u,0x000000d7u,0x000000d6u,0x00000043u,0x000400fau,0x000000d7u,0x000000d2u,0x000000d3u,0x000200f8u,0x000000d2u,0x0003003eu,0x000000d8u,0x00000079u,0x000200f9u,0x000000d9u,0x000200f8u,0x000000d9u,0x000400f6u,0x000000dbu,0x000000dcu,0x00000000u,0x000200f9u,0x000000ddu,0x000200f8u,0x000000ddu,0x0004003du,0x00000006u,0x000000deu,0x000000d8u,0x000500b3u,0x00000019u,0x000000dfu,0x000000deu,0x00000043u,0x000400fau,0x000000dfu,0x000000dau,0x000000dbu,0x000200f8u,0x000000dau,0x0004003du,0x00000006u,0x000000e1u,0x000000d8u,0x0004006fu,0x00000013u,0x000000e2u,0x000000e1u,0x0004003du,0x00000006u,0x000000e3u,0x000000d0u,0x0004006fu,0x00000013u,0x000000e4u,0x000000e3u,0x00050050u,0x0000002eu,0x000000e5u,0x000000e2u,0x000000e4u,0x0003003eu,0x000000e0u,0x000000e5u,0x0004003du,0x0000004cu,0x000000e7u,0x00000090u,0x0004003du,0x0000002eu,0x000000e8u,0x00000036u,0x0004003du,0x0000002eu,0x000000e9u,0x000000e0u,0x0004003du,0x0000002eu,0x000000eau,0x00000030u,0x00050085u,0x0000002eu,0x000000ebu,0x000000e9u,0x000000eau,0x00050081u,0x0000002eu,0x000000ecu,0x000000e8u,0x000000ebu,0x00070058u,0x00000052u,0x000000edu,0x000000e7u,0x000000ecu,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x000000eeu,0x000000edu,0x00000000u,0x0003003eu,0x000000e6u,0x000000eeu,0x0004003du,0x0000002eu,0x000000f0u,0x0000005bu,0x00050081u,0x0000002eu,0x000000f3u,0x000000f0u,0x000000f2u,0x0003003eu,0x000000efu,0x000000f3u,0x0004003du,0x0000002eu,0x000000f5u,0x0000005bu,0x00050081u,0x0000002eu,0x000000f7u,0x000000f5u,0x000000f6u,0x0003003eu,0x000000f4u,0x000000f7u,0x0004003du,0x0000002eu,0x000000f9u,0x0000005bu,0x00050081u,0x0000002eu,0x000000fbu,0x000000f9u,0x000000fau,0x0003003eu,0x000000f8u,0x000000fbu,0x0004003du,0x0000002eu,0x000000fdu,0x0000005bu,0x00050081u,0x0000002eu,0x000000ffu,0x000000fdu,0x000000feu,0x0003003eu,0x000000fcu,0x000000ffu,0x0004003du,0x00000013u,0x00000100u,0x000000e6u,0x0004003du,0x0000004cu,0x00000101u,0x0000009au,0x0004003du,0x0000002eu,0x00000102u,0x00000036u,0x0004003du,0x0000002eu,0x00000103u,0x000000e0u,0x0004003du,0x0000002eu,0x00000104u,0x000000efu,0x00050081u,0x0000002eu,0x00000105u,0x00000103u,0x00000104u,0x0004003du,0x0000002eu,0x00000106u,0x00000030u,0x00050085u,0x0000002eu,0x00000107u,0x00000105u,0x00000106u,0x00050081u,0x0000002eu,0x00000108u,0x00000102u,0x00000107u,0x00070058u,0x00000052u,0x00000109u,0x00000101u,0x00000108u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x0000010au,0x00000109u,0x00000000u,0x00050083u,0x00000013u,0x0000010bu,0x00000100u,0x0000010au,0x0006000cu,0x00000013u,0x0000010cu,0x00000001u,0x00000004u,0x0000010bu,0x0004003du,0x00000013u,0x0000010du,0x000000ccu,0x00050081u,0x00000013u,0x0000010eu,0x0000010du,0x0000010cu,0x0003003eu,0x000000ccu,0x0000010eu,0x0004003du,0x00000013u,0x0000010fu,0x000000e6u,0x0004003du,0x0000004cu,0x00000110u,0x0000009au,0x0004003du,0x0000002eu,0x00000111u,0x00000036u,0x0004003du,0x0000002eu,0x00000112u,0x000000e0u,0x0004003du,0x0000002eu,0x00000113u,0x000000f4u,0x00050081u,0x0000002eu,0x00000114u,0x00000112u,0x00000113u,0x0004003du,0x0000002eu,0x00000115u,0x00000030u,0x00050085u,0x0000002eu,0x00000116u,0x00000114u,0x00000115u,0x00050081u,0x0000002eu,0x00000117u,0x00000111u,0x00000116u,0x00070058u,0x00000052u,0x00000118u,0x00000110u,0x00000117u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000119u,0x00000118u,0x00000000u,0x00050083u,0x00000013u,0x0000011au,0x0000010fu,0x00000119u,0x0006000cu,0x00000013u,0x0000011bu,0x00000001u,0x00000004u,0x0000011au,0x0004003du,0x00000013u,0x0000011cu,0x000000cdu,0x00050081u,0x00000013u,0x0000011du,0x0000011cu,0x0000011bu,0x0003003eu,0x000000cdu,0x0000011du,0x0004003du,0x00000013u,0x0000011eu,0x000000e6u,0x0004003du,0x0000004cu,0x0000011fu,0x0000009au,0x0004003du,0x0000002eu,0x00000120u,0x00000036u,0x0004003du,0x0000002eu,0x00000121u,0x000000e0u,0x0004003du,0x0000002eu,0x00000122u,0x000000f8u,0x00050081u,0x0000002eu,0x00000123u,0x00000121u,0x00000122u,0x0004003du,0x0000002eu,0x00000124u,0x00000030u,0x00050085u,0x0000002eu,0x00000125u,0x00000123u,0x00000124u,0x00050081u,0x0000002eu,0x00000126u,0x00000120u,0x00000125u,0x00070058u,0x00000052u,0x00000127u,0x0000011fu,0x00000126u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000128u,0x00000127u,0x00000000u,0x00050083u,0x00000013u,0x00000129u,0x0000011eu,0x00000128u,0x0006000cu,0x00000013u,0x0000012au,0x00000001u,0x00000004u,0x00000129u,0x0004003du,0x00000013u,0x0000012bu,0x000000ceu,0x00050081u,0x00000013u,0x0000012cu,0x0000012bu,0x0000012au,0x0003003eu,0x000000ceu,0x0000012cu,0x0004003du,0x00000013u,0x0000012du,0x000000e6u,0x0004003du,0x0000004cu,0x0000012eu,0x0000009au,0x0004003du,0x0000002eu,0x0000012fu,0x00000036u,0x0004003du,0x0000002eu,0x00000130u,0x000000e0u,0x0004003du,0x0000002eu,0x00000131u,0x000000fcu,0x00050081u,0x0000002eu,0x00000132u,0x00000130u,0x00000131u,0x0004003du,0x0000002eu,0x00000133u,0x00000030u,0x00050085u,0x0000002eu,0x00000134u,0x00000132u,0x00000133u,0x00050081u,0x0000002eu,0x00000135u,0x0000012fu,0x00000134u,0x00070058u,0x00000052u,0x00000136u,0x0000012eu,0x00000135u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000137u,0x00000136u,0x00000000u,0x00050083u,0x00000013u,0x00000138u,0x0000012du,0x00000137u,0x0006000cu,0x00000013u,0x00000139u,0x00000001u,0x00000004u,0x00000138u,0x0004003du,0x00000013u,0x0000013au,0x000000cfu,0x00050081u,0x00000013u,0x0000013bu,0x0000013au,0x00000139u,0x0003003eu,0x000000cfu,0x0000013bu,0x000200f9u,0x000000dcu,0x000200f8u,0x000000dcu,0x0004003du,0x00000006u,0x0000013cu,0x000000d8u,0x00050080u,0x00000006u,0x0000013du,0x0000013cu,0x00000043u,0x0003003eu,0x000000d8u,0x0000013du,0x000200f9u,0x000000d9u,0x000200f8u,0x000000dbu,0x000200f9u,0x000000d4u,0x000200f8u,0x000000d4u,0x0004003du,0x00000006u,0x0000013eu,0x000000d0u,0x00050080u,0x00000006u,0x0000013fu,0x0000013eu,0x00000043u,0x0003003eu,0x000000d0u,0x0000013fu,0x000200f9u,0x000000d1u,0x000200f8u,0x000000d3u,0x0004003du,0x00000013u,0x00000140u,0x000000ccu,0x00050081u,0x00000013u,0x00000141u,0x00000140u,0x000000afu,0x0003003eu,0x000000ccu,0x00000141u,0x0004003du,0x00000013u,0x00000142u,0x000000cdu,0x00050081u,0x00000013u,0x00000143u,0x00000142u,0x000000afu,0x0003003eu,0x000000cdu,0x00000143u,0x0004003du,0x00000013u,0x00000144u,0x000000ceu,0x00050081u,0x00000013u,0x00000145u,0x00000144u,0x000000afu,0x0003003eu,0x000000ceu,0x00000145u,0x0004003du,0x00000013u,0x00000146u,0x000000cfu,0x00050081u,0x00000013u,0x00000147u,0x00000146u,0x000000afu,0x0003003eu,0x000000cfu,0x00000147u,0x0003003eu,0x00000148u,0x00000051u,0x0003003eu,0x00000149u,0x00000051u,0x0004003du,0x00000013u,0x0000014bu,0x000000ccu,0x0004003du,0x00000013u,0x0000014du,0x000000cau,0x00050085u,0x00000013u,0x0000014eu,0x0000014cu,0x0000014du,0x00050083u,0x00000013u,0x0000014fu,0x0000014bu,0x0000014eu,0x0004003du,0x00000013u,0x00000150u,0x000000cdu,0x00050081u,0x00000013u,0x00000151u,0x0000014fu,0x00000150u,0x0003003eu,0x0000014au,0x00000151u,0x0004003du,0x00000013u,0x00000153u,0x000000ceu,0x0004003du,0x00000013u,0x00000154u,0x000000cau,0x00050085u,0x00000013u,0x00000155u,0x0000014cu,0x00000154u,0x00050083u,0x00000013u,0x00000156u,0x00000153u,0x00000155u,0x0004003du,0x00000013u,0x00000157u,0x000000cfu,0x00050081u,0x00000013u,0x00000158u,0x00000156u,0x00000157u,0x0003003eu,0x00000152u,0x00000158u,0x0004003du,0x00000013u,0x00000159u,0x0000014au,0x000500bau,0x00000019u,0x0000015bu,0x00000159u,0x0000015au,0x000300f7u,0x0000015du,0x00000000u,0x000400fau,0x0000015bu,0x0000015cu,0x0000015du,0x000200f8u,0x0000015cu,0x0004003du,0x00000013u,0x0000015eu,0x000000ccu,0x0004003du,0x00000013u,0x0000015fu,0x000000cdu,0x00050083u,0x00000013u,0x00000160u,0x0000015eu,0x0000015fu,0x00050085u,0x00000013u,0x00000161u,0x00000039u,0x00000160u,0x0004003du,0x00000013u,0x00000162u,0x0000014au,0x00050088u,0x00000013u,0x00000163u,0x00000161u,0x00000162u,0x0008000cu,0x00000013u,0x00000165u,0x00000001u,0x0000002bu,0x00000163u,0x00000164u,0x00000039u,0x0003003eu,0x00000148u,0x00000165u,0x000200f9u,0x0000015du,0x000200f8u,0x0000015du,0x0004003du,0x00000013u,0x00000166u,0x00000152u,0x000500bau,0x00000019u,0x00000167u,0x00000166u,0x0000015au,0x000300f7u,0x00000169u,0x00000000u,0x000400fau,0x00000167u,0x00000168u,0x00000169u,0x000200f8u,0x00000168u,0x0004003du,0x00000013u,0x0000016au,0x000000ceu,0x0004003du,0x00000013u,0x0000016bu,0x000000cfu,0x00050083u,0x00000013u,0x0000016cu,0x0000016au,0x0000016bu,0x00050085u,0x00000013u,0x0000016du,0x00000039u,0x0000016cu,0x0004003du,0x00000013u,0x0000016eu,0x00000152u,0x00050088u,0x00000013u,0x0000016fu,0x0000016du,0x0000016eu,0x0008000cu,0x00000013u,0x00000170u,0x00000001u,0x0000002bu,0x0000016fu,0x00000164u,0x00000039u,0x0003003eu,0x00000149u,0x00000170u,0x000200f9u,0x00000169u,0x000200f8u,0x00000169u,0x0004003du,0x00000013u,0x00000171u,0x00000148u,0x0004003du,0x00000013u,0x00000172u,0x00000149u,0x00050050u,0x0000002eu,0x00000173u,0x00000171u,0x00000172u,0x0004003du,0x0000002eu,0x00000174u,0x0000005bu,0x00050081u,0x0000002eu,0x00000175u,0x00000174u,0x00000173u,0x0003003eu,0x0000005bu,0x00000175u,0x000200f9u,0x000000c9u,0x000200f8u,0x000000c9u,0x0004003du,0x0000002eu,0x00000177u,0x0000005bu,0x00050041u,0x00000044u,0x00000178u,0x00000042u,0x00000043u,0x0004003du,0x0000000au,0x00000179u,0x00000178u,0x00040070u,0x00000013u,0x0000017au,0x00000179u,0x0006000cu,0x00000013u,0x0000017bu,0x00000001u,0x0000001du,0x0000017au,0x0005008eu,0x0000002eu,0x0000017cu,0x00000177u,0x0000017bu,0x0003003eu,0x00000176u,0x0000017cu,0x0004003du,0x00000014u,0x0000017du,0x00000016u,0x0004003du,0x00000007u,0x0000017eu,0x00000009u,0x0004003du,0x0000002eu,0x0000017fu,0x00000176u,0x00050051u,0x00000013u,0x00000180u,0x0000017fu,0x00000000u,0x00050051u,0x00000013u,0x00000181u,0x0000017fu,0x00000001u,0x00070050u,0x00000052u,0x00000182u,0x00000180u,0x00000181u,0x00000051u,0x00000051u,0x00040063u,0x0000017du,0x0000017eu,0x00000182u,0x000100fdu,0x00010038u}; -static const size_t OF3_FLOW_LEN = 2253; +static const uint32_t OF3_FLOW_SPV[] = { + 0x07230203u,0x00010300u,0x0008000bu,0x000001feu,0x00000000u,0x00020011u,0x00000001u,0x00020011u, + 0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu, + 0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x0000000du, + 0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u, + 0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00080005u,0x0000000du,0x475f6c67u, + 0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00040005u,0x00000016u,0x6f6c4675u, + 0x00000077u,0x00030005u,0x00000040u,0x00000055u,0x00060006u,0x00000040u,0x00000000u,0x776f6c66u, + 0x6c616353u,0x00000065u,0x00050006u,0x00000040u,0x00000001u,0x6576656cu,0x0000006cu,0x00050006u, + 0x00000040u,0x00000002u,0x30646170u,0x00000000u,0x00050006u,0x00000040u,0x00000003u,0x31646170u, + 0x00000000u,0x00030005u,0x00000042u,0x00000000u,0x00050005u,0x0000004eu,0x65725075u,0x74636964u, + 0x0000726fu,0x00050005u,0x0000007bu,0x76657270u,0x63746150u,0x00000068u,0x00050005u,0x0000007du, + 0x6d754c75u,0x65725061u,0x00000076u,0x00050005u,0x000000c9u,0x6d754c75u,0x72754361u,0x00000072u, + 0x00040047u,0x0000000du,0x0000000bu,0x0000001cu,0x00030047u,0x00000016u,0x00000019u,0x00040047u, + 0x00000016u,0x00000021u,0x00000030u,0x00040047u,0x00000016u,0x00000022u,0x00000000u,0x00030047u, + 0x00000040u,0x00000002u,0x00050048u,0x00000040u,0x00000000u,0x00000023u,0x00000000u,0x00050048u, + 0x00000040u,0x00000001u,0x00000023u,0x00000004u,0x00050048u,0x00000040u,0x00000002u,0x00000023u, + 0x00000008u,0x00050048u,0x00000040u,0x00000003u,0x00000023u,0x0000000cu,0x00040047u,0x00000042u, + 0x00000021u,0x00000000u,0x00040047u,0x00000042u,0x00000022u,0x00000000u,0x00040047u,0x0000004eu, + 0x00000021u,0x00000022u,0x00040047u,0x0000004eu,0x00000022u,0x00000000u,0x00040047u,0x0000007du, + 0x00000021u,0x00000020u,0x00040047u,0x0000007du,0x00000022u,0x00000000u,0x00040047u,0x000000c9u, + 0x00000021u,0x00000021u,0x00040047u,0x000000c9u,0x00000022u,0x00000000u,0x00040047u,0x000001b3u, + 0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u, + 0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00040015u, + 0x0000000au,0x00000020u,0x00000000u,0x00040017u,0x0000000bu,0x0000000au,0x00000003u,0x00040020u, + 0x0000000cu,0x00000001u,0x0000000bu,0x0004003bu,0x0000000cu,0x0000000du,0x00000001u,0x00040017u, + 0x0000000eu,0x0000000au,0x00000002u,0x00030016u,0x00000013u,0x00000020u,0x00090019u,0x00000014u, + 0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u, + 0x00000015u,0x00000000u,0x00000014u,0x0004003bu,0x00000015u,0x00000016u,0x00000000u,0x00020014u, + 0x00000019u,0x0004002bu,0x0000000au,0x0000001au,0x00000000u,0x0004002bu,0x0000000au,0x00000024u, + 0x00000001u,0x00040017u,0x0000002eu,0x00000013u,0x00000002u,0x0004002bu,0x00000013u,0x00000031u, + 0x3f800000u,0x0004002bu,0x00000013u,0x00000039u,0x3f000000u,0x00040020u,0x0000003eu,0x00000007u, + 0x00000013u,0x0006001eu,0x00000040u,0x00000013u,0x0000000au,0x0000000au,0x0000000au,0x00040020u, + 0x00000041u,0x00000002u,0x00000040u,0x0004003bu,0x00000041u,0x00000042u,0x00000002u,0x0004002bu, + 0x00000006u,0x00000043u,0x00000001u,0x00040020u,0x00000044u,0x00000002u,0x0000000au,0x00090019u, + 0x0000004bu,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u, + 0x0003001bu,0x0000004cu,0x0000004bu,0x00040020u,0x0000004du,0x00000000u,0x0000004cu,0x0004003bu, + 0x0000004du,0x0000004eu,0x00000000u,0x0004002bu,0x00000013u,0x00000051u,0x00000000u,0x00040017u, + 0x00000052u,0x00000013u,0x00000004u,0x0004002bu,0x00000006u,0x0000005au,0xffffffffu,0x0004002bu, + 0x00000006u,0x0000006du,0x00000003u,0x0004002bu,0x0000000au,0x00000078u,0x00000009u,0x0004001cu, + 0x00000079u,0x00000013u,0x00000078u,0x00040020u,0x0000007au,0x00000007u,0x00000079u,0x0004003bu, + 0x0000004du,0x0000007du,0x00000000u,0x0004002bu,0x00000013u,0x0000008cu,0x7f7fffffu,0x0004002bu, + 0x00000006u,0x00000090u,0xfffffffdu,0x0004003bu,0x0000004du,0x000000c9u,0x00000000u,0x0004002bu, + 0x00000013u,0x000000deu,0x3bc49ba6u,0x0004002bu,0x00000013u,0x00000120u,0xbf800000u,0x0005002cu, + 0x0000002eu,0x00000121u,0x00000120u,0x00000051u,0x0005002cu,0x0000002eu,0x00000125u,0x00000031u, + 0x00000051u,0x0005002cu,0x0000002eu,0x00000129u,0x00000051u,0x00000120u,0x0005002cu,0x0000002eu, + 0x0000012du,0x00000051u,0x00000031u,0x0004002bu,0x00000013u,0x0000017bu,0x40000000u,0x0004002bu, + 0x00000013u,0x00000189u,0x358637bdu,0x0004002bu,0x00000013u,0x00000193u,0xbf000000u,0x0004002bu, + 0x0000000au,0x000001b2u,0x00000010u,0x0006002cu,0x0000000bu,0x000001b3u,0x000001b2u,0x000001b2u, + 0x00000024u,0x0005002cu,0x0000002eu,0x000001efu,0x00000031u,0x00000031u,0x0005002cu,0x0000002eu, + 0x000001f0u,0x00000039u,0x00000039u,0x00040017u,0x000001fbu,0x00000019u,0x00000002u,0x00050036u, + 0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x0000007au, + 0x0000007bu,0x00000007u,0x000300f7u,0x000001b4u,0x00000000u,0x000300fbu,0x0000001au,0x000001b5u, + 0x000200f8u,0x000001b5u,0x0004003du,0x0000000bu,0x0000000fu,0x0000000du,0x0007004fu,0x0000000eu, + 0x00000010u,0x0000000fu,0x0000000fu,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x00000011u, + 0x00000010u,0x0004003du,0x00000014u,0x00000017u,0x00000016u,0x00040068u,0x00000007u,0x00000018u, + 0x00000017u,0x00050051u,0x00000006u,0x0000001du,0x00000011u,0x00000000u,0x00050051u,0x00000006u, + 0x0000001fu,0x00000018u,0x00000000u,0x000500afu,0x00000019u,0x00000020u,0x0000001du,0x0000001fu, + 0x000400a8u,0x00000019u,0x00000021u,0x00000020u,0x000300f7u,0x00000023u,0x00000000u,0x000400fau, + 0x00000021u,0x00000022u,0x00000023u,0x000200f8u,0x00000022u,0x00050051u,0x00000006u,0x00000026u, + 0x00000011u,0x00000001u,0x00050051u,0x00000006u,0x00000028u,0x00000018u,0x00000001u,0x000500afu, + 0x00000019u,0x00000029u,0x00000026u,0x00000028u,0x000200f9u,0x00000023u,0x000200f8u,0x00000023u, + 0x000700f5u,0x00000019u,0x0000002au,0x00000020u,0x000001b5u,0x00000029u,0x00000022u,0x000300f7u, + 0x0000002cu,0x00000000u,0x000400fau,0x0000002au,0x0000002bu,0x0000002cu,0x000200f8u,0x0000002bu, + 0x000200f9u,0x000001b4u,0x000200f8u,0x0000002cu,0x0004006fu,0x0000002eu,0x00000033u,0x00000018u, + 0x00050088u,0x0000002eu,0x00000035u,0x000001efu,0x00000033u,0x0004006fu,0x0000002eu,0x00000038u, + 0x00000011u,0x00050081u,0x0000002eu,0x0000003bu,0x00000038u,0x000001f0u,0x00050085u,0x0000002eu, + 0x0000003du,0x0000003bu,0x00000035u,0x00050041u,0x00000044u,0x00000045u,0x00000042u,0x00000043u, + 0x0004003du,0x0000000au,0x00000046u,0x00000045u,0x00040070u,0x00000013u,0x00000047u,0x00000046u, + 0x0004007fu,0x00000013u,0x00000048u,0x00000047u,0x0006000cu,0x00000013u,0x00000049u,0x00000001u, + 0x0000001du,0x00000048u,0x0004003du,0x0000004cu,0x0000004fu,0x0000004eu,0x00070058u,0x00000052u, + 0x00000053u,0x0000004fu,0x0000003du,0x00000002u,0x00000051u,0x0007004fu,0x0000002eu,0x00000054u, + 0x00000053u,0x00000053u,0x00000000u,0x00000001u,0x0005008eu,0x0000002eu,0x00000058u,0x00000054u, + 0x00000049u,0x000200f9u,0x0000005bu,0x000200f8u,0x0000005bu,0x000700f5u,0x00000006u,0x000001beu, + 0x0000005au,0x0000002cu,0x0000008au,0x0000005eu,0x000500b3u,0x00000019u,0x00000061u,0x000001beu, + 0x00000043u,0x000400f6u,0x0000005du,0x0000005eu,0x00000000u,0x000400fau,0x00000061u,0x0000005cu, + 0x0000005du,0x000200f8u,0x0000005cu,0x000200f9u,0x00000063u,0x000200f8u,0x00000063u,0x000700f5u, + 0x00000006u,0x000001e4u,0x0000005au,0x0000005cu,0x00000070u,0x00000064u,0x000500b3u,0x00000019u, + 0x00000069u,0x000001e4u,0x00000043u,0x000400f6u,0x00000065u,0x00000064u,0x00000000u,0x000400fau, + 0x00000069u,0x00000064u,0x00000065u,0x000200f8u,0x00000064u,0x00050080u,0x00000006u,0x0000006cu, + 0x000001beu,0x00000043u,0x00050084u,0x00000006u,0x0000006eu,0x0000006cu,0x0000006du,0x00050080u, + 0x00000006u,0x00000070u,0x000001e4u,0x00000043u,0x00050080u,0x00000006u,0x00000071u,0x0000006eu, + 0x00000070u,0x0004006fu,0x00000013u,0x00000074u,0x000001e4u,0x0004006fu,0x00000013u,0x00000076u, + 0x000001beu,0x00050050u,0x0000002eu,0x00000077u,0x00000074u,0x00000076u,0x0004003du,0x0000004cu, + 0x0000007eu,0x0000007du,0x00050085u,0x0000002eu,0x00000082u,0x00000077u,0x00000035u,0x00050081u, + 0x0000002eu,0x00000083u,0x0000003du,0x00000082u,0x00070058u,0x00000052u,0x00000084u,0x0000007eu, + 0x00000083u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000085u,0x00000084u,0x00000000u, + 0x00050041u,0x0000003eu,0x00000086u,0x0000007bu,0x00000071u,0x0003003eu,0x00000086u,0x00000085u, + 0x000200f9u,0x00000063u,0x000200f8u,0x00000065u,0x000200f9u,0x0000005eu,0x000200f8u,0x0000005eu, + 0x00050080u,0x00000006u,0x0000008au,0x000001beu,0x00000043u,0x000200f9u,0x0000005bu,0x000200f8u, + 0x0000005du,0x000200f9u,0x00000091u,0x000200f8u,0x00000091u,0x000700f5u,0x0000002eu,0x000001cfu, + 0x00000058u,0x0000005du,0x000001e6u,0x00000094u,0x000700f5u,0x00000013u,0x000001c0u,0x0000008cu, + 0x0000005du,0x000001dfu,0x00000094u,0x000700f5u,0x00000006u,0x000001bfu,0x00000090u,0x0000005du, + 0x000000f3u,0x00000094u,0x000500b3u,0x00000019u,0x00000097u,0x000001bfu,0x0000006du,0x000400f6u, + 0x00000093u,0x00000094u,0x00000000u,0x000400fau,0x00000097u,0x00000092u,0x00000093u,0x000200f8u, + 0x00000092u,0x000200f9u,0x00000099u,0x000200f8u,0x00000099u,0x000700f5u,0x00000013u,0x000001dfu, + 0x000001c0u,0x00000092u,0x000001fau,0x0000009cu,0x000700f5u,0x00000006u,0x000001d8u,0x00000090u, + 0x00000092u,0x000000f1u,0x0000009cu,0x000700f5u,0x0000002eu,0x000001e6u,0x000001cfu,0x00000092u, + 0x000001fdu,0x0000009cu,0x000500b3u,0x00000019u,0x0000009fu,0x000001d8u,0x0000006du,0x000400f6u, + 0x0000009bu,0x0000009cu,0x00000000u,0x000400fau,0x0000009fu,0x0000009au,0x0000009bu,0x000200f8u, + 0x0000009au,0x0004006fu,0x00000013u,0x000000a3u,0x000001d8u,0x0004006fu,0x00000013u,0x000000a5u, + 0x000001bfu,0x00050050u,0x0000002eu,0x000000a6u,0x000000a3u,0x000000a5u,0x00050081u,0x0000002eu, + 0x000000a7u,0x00000058u,0x000000a6u,0x000200f9u,0x000000aau,0x000200f8u,0x000000aau,0x000700f5u, + 0x00000013u,0x000001ddu,0x00000051u,0x0000009au,0x000001e3u,0x000000adu,0x000700f5u,0x00000006u, + 0x000001dau,0x0000005au,0x0000009au,0x000000ddu,0x000000adu,0x000500b3u,0x00000019u,0x000000b0u, + 0x000001dau,0x00000043u,0x000400f6u,0x000000acu,0x000000adu,0x00000000u,0x000400fau,0x000000b0u, + 0x000000abu,0x000000acu,0x000200f8u,0x000000abu,0x000200f9u,0x000000b2u,0x000200f8u,0x000000b2u, + 0x000700f5u,0x00000013u,0x000001e3u,0x000001ddu,0x000000abu,0x000000d9u,0x000000b3u,0x000700f5u, + 0x00000006u,0x000001e1u,0x0000005au,0x000000abu,0x000000c4u,0x000000b3u,0x000500b3u,0x00000019u, + 0x000000b8u,0x000001e1u,0x00000043u,0x000400f6u,0x000000b4u,0x000000b3u,0x00000000u,0x000400fau, + 0x000000b8u,0x000000b3u,0x000000b4u,0x000200f8u,0x000000b3u,0x0004006fu,0x00000013u,0x000000bbu, + 0x000001e1u,0x0004006fu,0x00000013u,0x000000bdu,0x000001dau,0x00050050u,0x0000002eu,0x000000beu, + 0x000000bbu,0x000000bdu,0x00050080u,0x00000006u,0x000000c1u,0x000001dau,0x00000043u,0x00050084u, + 0x00000006u,0x000000c2u,0x000000c1u,0x0000006du,0x00050080u,0x00000006u,0x000000c4u,0x000001e1u, + 0x00000043u,0x00050080u,0x00000006u,0x000000c5u,0x000000c2u,0x000000c4u,0x00050041u,0x0000003eu, + 0x000000c6u,0x0000007bu,0x000000c5u,0x0004003du,0x00000013u,0x000000c7u,0x000000c6u,0x0004003du, + 0x0000004cu,0x000000cau,0x000000c9u,0x00050081u,0x0000002eu,0x000000ceu,0x000000beu,0x000000a7u, + 0x00050085u,0x0000002eu,0x000000d0u,0x000000ceu,0x00000035u,0x00050081u,0x0000002eu,0x000000d1u, + 0x0000003du,0x000000d0u,0x00070058u,0x00000052u,0x000000d2u,0x000000cau,0x000000d1u,0x00000002u, + 0x00000051u,0x00050051u,0x00000013u,0x000000d3u,0x000000d2u,0x00000000u,0x00050083u,0x00000013u, + 0x000000d6u,0x000000c7u,0x000000d3u,0x0006000cu,0x00000013u,0x000000d7u,0x00000001u,0x00000004u, + 0x000000d6u,0x00050081u,0x00000013u,0x000000d9u,0x000001e3u,0x000000d7u,0x000200f9u,0x000000b2u, + 0x000200f8u,0x000000b4u,0x000200f9u,0x000000adu,0x000200f8u,0x000000adu,0x00050080u,0x00000006u, + 0x000000ddu,0x000001dau,0x00000043u,0x000200f9u,0x000000aau,0x000200f8u,0x000000acu,0x0006000cu, + 0x00000013u,0x000000e1u,0x00000001u,0x00000004u,0x000000a3u,0x0006000cu,0x00000013u,0x000000e4u, + 0x00000001u,0x00000004u,0x000000a5u,0x00050081u,0x00000013u,0x000000e5u,0x000000e1u,0x000000e4u, + 0x00050085u,0x00000013u,0x000000e6u,0x000000deu,0x000000e5u,0x00050081u,0x00000013u,0x000000e8u, + 0x000001ddu,0x000000e6u,0x000500b8u,0x00000019u,0x000000ebu,0x000000e8u,0x000001dfu,0x000600a9u, + 0x00000013u,0x000001fau,0x000000ebu,0x000000e8u,0x000001dfu,0x00050050u,0x000001fbu,0x000001fcu, + 0x000000ebu,0x000000ebu,0x000600a9u,0x0000002eu,0x000001fdu,0x000001fcu,0x000000a7u,0x000001e6u, + 0x000200f9u,0x0000009cu,0x000200f8u,0x0000009cu,0x00050080u,0x00000006u,0x000000f1u,0x000001d8u, + 0x00000043u,0x000200f9u,0x00000099u,0x000200f8u,0x0000009bu,0x000200f9u,0x00000094u,0x000200f8u, + 0x00000094u,0x00050080u,0x00000006u,0x000000f3u,0x000001bfu,0x00000043u,0x000200f9u,0x00000091u, + 0x000200f8u,0x00000093u,0x000500aau,0x00000019u,0x000000f6u,0x00000046u,0x0000001au,0x000300f7u, + 0x000000f8u,0x00000000u,0x000400fau,0x000000f6u,0x000000f7u,0x000000f8u,0x000200f8u,0x000000f7u, + 0x000200f9u,0x00000100u,0x000200f8u,0x00000100u,0x000700f5u,0x00000013u,0x000001c5u,0x00000051u, + 0x000000f7u,0x000001d7u,0x00000103u,0x000700f5u,0x00000013u,0x000001c4u,0x00000051u,0x000000f7u, + 0x000001d6u,0x00000103u,0x000700f5u,0x00000013u,0x000001c3u,0x00000051u,0x000000f7u,0x000001d5u, + 0x00000103u,0x000700f5u,0x00000013u,0x000001c2u,0x00000051u,0x000000f7u,0x000001d4u,0x00000103u, + 0x000700f5u,0x00000006u,0x000001c1u,0x0000005au,0x000000f7u,0x0000016eu,0x00000103u,0x000500b3u, + 0x00000019u,0x00000106u,0x000001c1u,0x00000043u,0x000400f6u,0x00000102u,0x00000103u,0x00000000u, + 0x000400fau,0x00000106u,0x00000101u,0x00000102u,0x000200f8u,0x00000101u,0x000200f9u,0x00000108u, + 0x000200f8u,0x00000108u,0x000700f5u,0x00000013u,0x000001d7u,0x000001c5u,0x00000101u,0x0000016au, + 0x00000109u,0x000700f5u,0x00000013u,0x000001d6u,0x000001c4u,0x00000101u,0x0000015bu,0x00000109u, + 0x000700f5u,0x00000013u,0x000001d5u,0x000001c3u,0x00000101u,0x0000014cu,0x00000109u,0x000700f5u, + 0x00000013u,0x000001d4u,0x000001c2u,0x00000101u,0x0000013du,0x00000109u,0x000700f5u,0x00000006u, + 0x000001d1u,0x0000005au,0x00000101u,0x0000011au,0x00000109u,0x000500b3u,0x00000019u,0x0000010eu, + 0x000001d1u,0x00000043u,0x000400f6u,0x0000010au,0x00000109u,0x00000000u,0x000400fau,0x0000010eu, + 0x00000109u,0x0000010au,0x000200f8u,0x00000109u,0x0004006fu,0x00000013u,0x00000111u,0x000001d1u, + 0x0004006fu,0x00000013u,0x00000113u,0x000001c1u,0x00050050u,0x0000002eu,0x00000114u,0x00000111u, + 0x00000113u,0x00050080u,0x00000006u,0x00000117u,0x000001c1u,0x00000043u,0x00050084u,0x00000006u, + 0x00000118u,0x00000117u,0x0000006du,0x00050080u,0x00000006u,0x0000011au,0x000001d1u,0x00000043u, + 0x00050080u,0x00000006u,0x0000011bu,0x00000118u,0x0000011au,0x00050041u,0x0000003eu,0x0000011cu, + 0x0000007bu,0x0000011bu,0x0004003du,0x00000013u,0x0000011du,0x0000011cu,0x00050081u,0x0000002eu, + 0x00000122u,0x000001cfu,0x00000121u,0x00050081u,0x0000002eu,0x00000126u,0x000001cfu,0x00000125u, + 0x00050081u,0x0000002eu,0x0000012au,0x000001cfu,0x00000129u,0x00050081u,0x0000002eu,0x0000012eu, + 0x000001cfu,0x0000012du,0x0004003du,0x0000004cu,0x00000130u,0x000000c9u,0x00050081u,0x0000002eu, + 0x00000134u,0x00000114u,0x00000122u,0x00050085u,0x0000002eu,0x00000136u,0x00000134u,0x00000035u, + 0x00050081u,0x0000002eu,0x00000137u,0x0000003du,0x00000136u,0x00070058u,0x00000052u,0x00000138u, + 0x00000130u,0x00000137u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000139u,0x00000138u, + 0x00000000u,0x00050083u,0x00000013u,0x0000013au,0x0000011du,0x00000139u,0x0006000cu,0x00000013u, + 0x0000013bu,0x00000001u,0x00000004u,0x0000013au,0x00050081u,0x00000013u,0x0000013du,0x000001d4u, + 0x0000013bu,0x0004003du,0x0000004cu,0x0000013fu,0x000000c9u,0x00050081u,0x0000002eu,0x00000143u, + 0x00000114u,0x00000126u,0x00050085u,0x0000002eu,0x00000145u,0x00000143u,0x00000035u,0x00050081u, + 0x0000002eu,0x00000146u,0x0000003du,0x00000145u,0x00070058u,0x00000052u,0x00000147u,0x0000013fu, + 0x00000146u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000148u,0x00000147u,0x00000000u, + 0x00050083u,0x00000013u,0x00000149u,0x0000011du,0x00000148u,0x0006000cu,0x00000013u,0x0000014au, + 0x00000001u,0x00000004u,0x00000149u,0x00050081u,0x00000013u,0x0000014cu,0x000001d5u,0x0000014au, + 0x0004003du,0x0000004cu,0x0000014eu,0x000000c9u,0x00050081u,0x0000002eu,0x00000152u,0x00000114u, + 0x0000012au,0x00050085u,0x0000002eu,0x00000154u,0x00000152u,0x00000035u,0x00050081u,0x0000002eu, + 0x00000155u,0x0000003du,0x00000154u,0x00070058u,0x00000052u,0x00000156u,0x0000014eu,0x00000155u, + 0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000157u,0x00000156u,0x00000000u,0x00050083u, + 0x00000013u,0x00000158u,0x0000011du,0x00000157u,0x0006000cu,0x00000013u,0x00000159u,0x00000001u, + 0x00000004u,0x00000158u,0x00050081u,0x00000013u,0x0000015bu,0x000001d6u,0x00000159u,0x0004003du, + 0x0000004cu,0x0000015du,0x000000c9u,0x00050081u,0x0000002eu,0x00000161u,0x00000114u,0x0000012eu, + 0x00050085u,0x0000002eu,0x00000163u,0x00000161u,0x00000035u,0x00050081u,0x0000002eu,0x00000164u, + 0x0000003du,0x00000163u,0x00070058u,0x00000052u,0x00000165u,0x0000015du,0x00000164u,0x00000002u, + 0x00000051u,0x00050051u,0x00000013u,0x00000166u,0x00000165u,0x00000000u,0x00050083u,0x00000013u, + 0x00000167u,0x0000011du,0x00000166u,0x0006000cu,0x00000013u,0x00000168u,0x00000001u,0x00000004u, + 0x00000167u,0x00050081u,0x00000013u,0x0000016au,0x000001d7u,0x00000168u,0x000200f9u,0x00000108u, + 0x000200f8u,0x0000010au,0x000200f9u,0x00000103u,0x000200f8u,0x00000103u,0x00050080u,0x00000006u, + 0x0000016eu,0x000001c1u,0x00000043u,0x000200f9u,0x00000100u,0x000200f8u,0x00000102u,0x00050081u, + 0x00000013u,0x00000170u,0x000001c2u,0x000000deu,0x00050081u,0x00000013u,0x00000172u,0x000001c3u, + 0x000000deu,0x00050081u,0x00000013u,0x00000174u,0x000001c4u,0x000000deu,0x00050081u,0x00000013u, + 0x00000176u,0x000001c5u,0x000000deu,0x00050085u,0x00000013u,0x0000017du,0x0000017bu,0x000001c0u, + 0x00050083u,0x00000013u,0x0000017eu,0x00000170u,0x0000017du,0x00050081u,0x00000013u,0x00000180u, + 0x0000017eu,0x00000172u,0x00050083u,0x00000013u,0x00000185u,0x00000174u,0x0000017du,0x00050081u, + 0x00000013u,0x00000187u,0x00000185u,0x00000176u,0x000500bau,0x00000019u,0x0000018au,0x00000180u, + 0x00000189u,0x000300f7u,0x0000018cu,0x00000000u,0x000400fau,0x0000018au,0x0000018bu,0x0000018cu, + 0x000200f8u,0x0000018bu,0x00050083u,0x00000013u,0x000001f8u,0x000001c2u,0x000001c3u,0x00050085u, + 0x00000013u,0x00000190u,0x00000039u,0x000001f8u,0x00050088u,0x00000013u,0x00000192u,0x00000190u, + 0x00000180u,0x0008000cu,0x00000013u,0x00000194u,0x00000001u,0x0000002bu,0x00000192u,0x00000193u, + 0x00000039u,0x000200f9u,0x0000018cu,0x000200f8u,0x0000018cu,0x000700f5u,0x00000013u,0x000001c9u, + 0x00000051u,0x00000102u,0x00000194u,0x0000018bu,0x000500bau,0x00000019u,0x00000196u,0x00000187u, + 0x00000189u,0x000300f7u,0x00000198u,0x00000000u,0x000400fau,0x00000196u,0x00000197u,0x00000198u, + 0x000200f8u,0x00000197u,0x00050083u,0x00000013u,0x000001f9u,0x000001c4u,0x000001c5u,0x00050085u, + 0x00000013u,0x0000019cu,0x00000039u,0x000001f9u,0x00050088u,0x00000013u,0x0000019eu,0x0000019cu, + 0x00000187u,0x0008000cu,0x00000013u,0x0000019fu,0x00000001u,0x0000002bu,0x0000019eu,0x00000193u, + 0x00000039u,0x000200f9u,0x00000198u,0x000200f8u,0x00000198u,0x000700f5u,0x00000013u,0x000001cau, + 0x00000051u,0x0000018cu,0x0000019fu,0x00000197u,0x00050050u,0x0000002eu,0x000001a2u,0x000001c9u, + 0x000001cau,0x00050081u,0x0000002eu,0x000001a4u,0x000001cfu,0x000001a2u,0x000200f9u,0x000000f8u, + 0x000200f8u,0x000000f8u,0x000700f5u,0x0000002eu,0x000001d0u,0x000001cfu,0x00000093u,0x000001a4u, + 0x00000198u,0x0006000cu,0x00000013u,0x000001aau,0x00000001u,0x0000001du,0x00000047u,0x0005008eu, + 0x0000002eu,0x000001abu,0x000001d0u,0x000001aau,0x0004003du,0x00000014u,0x000001acu,0x00000016u, + 0x00050051u,0x00000013u,0x000001afu,0x000001abu,0x00000000u,0x00050051u,0x00000013u,0x000001b0u, + 0x000001abu,0x00000001u,0x00070050u,0x00000052u,0x000001b1u,0x000001afu,0x000001b0u,0x00000051u, + 0x00000051u,0x00040063u,0x000001acu,0x00000011u,0x000001b1u,0x000200f9u,0x000001b4u,0x000200f8u, + 0x000001b4u,0x000100fdu,0x00010038u +}; +static const size_t OF3_FLOW_LEN = sizeof(OF3_FLOW_SPV) / sizeof(OF3_FLOW_SPV[0]); static const uint32_t OF3_EXPAND_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000124u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x00000049u,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00080005u,0x0000000eu,0x3564656du,0x3b316628u,0x663b3166u,0x31663b31u,0x3b31663bu,0x00000000u,0x00030005u,0x00000009u,0x00000061u,0x00030005u,0x0000000au,0x00000062u,0x00030005u,0x0000000bu,0x00000063u,0x00030005u,0x0000000cu,0x00000064u,0x00030005u,0x0000000du,0x00000065u,0x00030005u,0x00000010u,0x00000078u,0x00030005u,0x00000034u,0x00000079u,0x00030005u,0x00000045u,0x00646967u,0x00080005u,0x00000049u,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x0000004eu,0x006d6964u,0x00040005u,0x00000051u,0x64774675u,0x00000000u,0x00030005u,0x0000006bu,0x00007675u,0x00030005u,0x00000074u,0x00007366u,0x00050005u,0x00000079u,0x6f6c4675u,0x6e694677u,0x00000065u,0x00030005u,0x00000081u,0x00000063u,0x00030005u,0x00000088u,0x00006d78u,0x00030005u,0x00000091u,0x00007078u,0x00030005u,0x0000009au,0x00006d79u,0x00030005u,0x000000a3u,0x00007079u,0x00030005u,0x000000acu,0x00000064u,0x00040005u,0x000000adu,0x61726170u,0x0000006du,0x00040005u,0x000000b0u,0x61726170u,0x0000006du,0x00040005u,0x000000b3u,0x61726170u,0x0000006du,0x00040005u,0x000000b6u,0x61726170u,0x0000006du,0x00040005u,0x000000b9u,0x61726170u,0x0000006du,0x00040005u,0x000000bdu,0x61726170u,0x0000006du,0x00040005u,0x000000c0u,0x61726170u,0x0000006du,0x00040005u,0x000000c3u,0x61726170u,0x0000006du,0x00040005u,0x000000c6u,0x61726170u,0x0000006du,0x00040005u,0x000000c9u,0x61726170u,0x0000006du,0x00030005u,0x000000ceu,0x00000071u,0x00030005u,0x000000d2u,0x00787067u,0x00030005u,0x000000d3u,0x00004d47u,0x00050006u,0x000000d3u,0x00000000u,0x694c6d67u,0x0000006eu,0x00050006u,0x000000d3u,0x00000001u,0x694c6d67u,0x0000546eu,0x00050006u,0x000000d3u,0x00000002u,0x70416d67u,0x00000070u,0x00050006u,0x000000d3u,0x00000003u,0x70416d67u,0x00005470u,0x00030005u,0x000000d5u,0x00000000u,0x00030005u,0x000000fdu,0x00003241u,0x00040005u,0x0000010bu,0x6c6c7566u,0x00000000u,0x00040005u,0x00000117u,0x64774275u,0x00000000u,0x00030005u,0x00000121u,0x00000055u,0x00060006u,0x00000121u,0x00000000u,0x776f6c66u,0x6c616353u,0x00000065u,0x00050006u,0x00000121u,0x00000001u,0x6576656cu,0x0000006cu,0x00050006u,0x00000121u,0x00000002u,0x30646170u,0x00000000u,0x00050006u,0x00000121u,0x00000003u,0x31646170u,0x00000000u,0x00030005u,0x00000123u,0x00000000u,0x00040047u,0x00000049u,0x0000000bu,0x0000001cu,0x00030047u,0x00000051u,0x00000019u,0x00040047u,0x00000051u,0x00000021u,0x00000030u,0x00040047u,0x00000051u,0x00000022u,0x00000000u,0x00040047u,0x00000079u,0x00000021u,0x00000020u,0x00040047u,0x00000079u,0x00000022u,0x00000000u,0x00030047u,0x000000d3u,0x00000002u,0x00050048u,0x000000d3u,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x000000d3u,0x00000001u,0x00000023u,0x00000010u,0x00050048u,0x000000d3u,0x00000002u,0x00000023u,0x00000020u,0x00050048u,0x000000d3u,0x00000003u,0x00000023u,0x00000030u,0x00040047u,0x000000d5u,0x00000021u,0x00000001u,0x00040047u,0x000000d5u,0x00000022u,0x00000000u,0x00030047u,0x00000117u,0x00000019u,0x00040047u,0x00000117u,0x00000021u,0x00000031u,0x00040047u,0x00000117u,0x00000022u,0x00000000u,0x00040047u,0x00000120u,0x0000000bu,0x00000019u,0x00030047u,0x00000121u,0x00000002u,0x00050048u,0x00000121u,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x00000121u,0x00000001u,0x00000023u,0x00000004u,0x00050048u,0x00000121u,0x00000002u,0x00000023u,0x00000008u,0x00050048u,0x00000121u,0x00000003u,0x00000023u,0x0000000cu,0x00040047u,0x00000123u,0x00000021u,0x00000000u,0x00040047u,0x00000123u,0x00000022u,0x00000000u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00030016u,0x00000006u,0x00000020u,0x00040020u,0x00000007u,0x00000007u,0x00000006u,0x00080021u,0x00000008u,0x00000006u,0x00000007u,0x00000007u,0x00000007u,0x00000007u,0x00000007u,0x00040015u,0x00000042u,0x00000020u,0x00000001u,0x00040017u,0x00000043u,0x00000042u,0x00000002u,0x00040020u,0x00000044u,0x00000007u,0x00000043u,0x00040015u,0x00000046u,0x00000020u,0x00000000u,0x00040017u,0x00000047u,0x00000046u,0x00000003u,0x00040020u,0x00000048u,0x00000001u,0x00000047u,0x0004003bu,0x00000048u,0x00000049u,0x00000001u,0x00040017u,0x0000004au,0x00000046u,0x00000002u,0x00090019u,0x0000004fu,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u,0x00000050u,0x00000000u,0x0000004fu,0x0004003bu,0x00000050u,0x00000051u,0x00000000u,0x00020014u,0x00000054u,0x0004002bu,0x00000046u,0x00000055u,0x00000000u,0x00040020u,0x00000056u,0x00000007u,0x00000042u,0x0004002bu,0x00000046u,0x0000005fu,0x00000001u,0x00040017u,0x00000069u,0x00000006u,0x00000002u,0x00040020u,0x0000006au,0x00000007u,0x00000069u,0x0004002bu,0x00000006u,0x0000006eu,0x3f000000u,0x0004002bu,0x00000006u,0x00000075u,0x3f800000u,0x00090019u,0x00000076u,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000077u,0x00000076u,0x00040020u,0x00000078u,0x00000000u,0x00000077u,0x0004003bu,0x00000078u,0x00000079u,0x00000000u,0x0004002bu,0x00000042u,0x0000007bu,0x00000000u,0x0004002bu,0x00000006u,0x00000084u,0x00000000u,0x00040017u,0x00000085u,0x00000006u,0x00000004u,0x0006001eu,0x000000d3u,0x00000085u,0x00000085u,0x00000085u,0x00000085u,0x00040020u,0x000000d4u,0x00000002u,0x000000d3u,0x0004003bu,0x000000d4u,0x000000d5u,0x00000002u,0x0004002bu,0x00000042u,0x000000d6u,0x00000002u,0x00040020u,0x000000d7u,0x00000002u,0x00000006u,0x0004002bu,0x00000046u,0x000000ddu,0x00000002u,0x0004002bu,0x00000042u,0x000000e4u,0x00000003u,0x0004002bu,0x00000046u,0x000000edu,0x00000003u,0x00040018u,0x000000fbu,0x00000069u,0x00000002u,0x00040020u,0x000000fcu,0x00000007u,0x000000fbu,0x0004003bu,0x00000050u,0x00000117u,0x00000000u,0x0004002bu,0x00000046u,0x0000011fu,0x00000010u,0x0006002cu,0x00000047u,0x00000120u,0x0000011fu,0x0000011fu,0x0000005fu,0x0006001eu,0x00000121u,0x00000006u,0x00000046u,0x00000046u,0x00000046u,0x00040020u,0x00000122u,0x00000002u,0x00000121u,0x0004003bu,0x00000122u,0x00000123u,0x00000002u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000044u,0x00000045u,0x00000007u,0x0004003bu,0x00000044u,0x0000004eu,0x00000007u,0x0004003bu,0x0000006au,0x0000006bu,0x00000007u,0x0004003bu,0x0000006au,0x00000074u,0x00000007u,0x0004003bu,0x0000006au,0x00000081u,0x00000007u,0x0004003bu,0x0000006au,0x00000088u,0x00000007u,0x0004003bu,0x0000006au,0x00000091u,0x00000007u,0x0004003bu,0x0000006au,0x0000009au,0x00000007u,0x0004003bu,0x0000006au,0x000000a3u,0x00000007u,0x0004003bu,0x0000006au,0x000000acu,0x00000007u,0x0004003bu,0x00000007u,0x000000adu,0x00000007u,0x0004003bu,0x00000007u,0x000000b0u,0x00000007u,0x0004003bu,0x00000007u,0x000000b3u,0x00000007u,0x0004003bu,0x00000007u,0x000000b6u,0x00000007u,0x0004003bu,0x00000007u,0x000000b9u,0x00000007u,0x0004003bu,0x00000007u,0x000000bdu,0x00000007u,0x0004003bu,0x00000007u,0x000000c0u,0x00000007u,0x0004003bu,0x00000007u,0x000000c3u,0x00000007u,0x0004003bu,0x00000007u,0x000000c6u,0x00000007u,0x0004003bu,0x00000007u,0x000000c9u,0x00000007u,0x0004003bu,0x0000006au,0x000000ceu,0x00000007u,0x0004003bu,0x0000006au,0x000000d2u,0x00000007u,0x0004003bu,0x000000fcu,0x000000fdu,0x00000007u,0x0004003bu,0x0000006au,0x0000010bu,0x00000007u,0x0004003du,0x00000047u,0x0000004bu,0x00000049u,0x0007004fu,0x0000004au,0x0000004cu,0x0000004bu,0x0000004bu,0x00000000u,0x00000001u,0x0004007cu,0x00000043u,0x0000004du,0x0000004cu,0x0003003eu,0x00000045u,0x0000004du,0x0004003du,0x0000004fu,0x00000052u,0x00000051u,0x00040068u,0x00000043u,0x00000053u,0x00000052u,0x0003003eu,0x0000004eu,0x00000053u,0x00050041u,0x00000056u,0x00000057u,0x00000045u,0x00000055u,0x0004003du,0x00000042u,0x00000058u,0x00000057u,0x00050041u,0x00000056u,0x00000059u,0x0000004eu,0x00000055u,0x0004003du,0x00000042u,0x0000005au,0x00000059u,0x000500afu,0x00000054u,0x0000005bu,0x00000058u,0x0000005au,0x000400a8u,0x00000054u,0x0000005cu,0x0000005bu,0x000300f7u,0x0000005eu,0x00000000u,0x000400fau,0x0000005cu,0x0000005du,0x0000005eu,0x000200f8u,0x0000005du,0x00050041u,0x00000056u,0x00000060u,0x00000045u,0x0000005fu,0x0004003du,0x00000042u,0x00000061u,0x00000060u,0x00050041u,0x00000056u,0x00000062u,0x0000004eu,0x0000005fu,0x0004003du,0x00000042u,0x00000063u,0x00000062u,0x000500afu,0x00000054u,0x00000064u,0x00000061u,0x00000063u,0x000200f9u,0x0000005eu,0x000200f8u,0x0000005eu,0x000700f5u,0x00000054u,0x00000065u,0x0000005bu,0x00000005u,0x00000064u,0x0000005du,0x000300f7u,0x00000067u,0x00000000u,0x000400fau,0x00000065u,0x00000066u,0x00000067u,0x000200f8u,0x00000066u,0x000100fdu,0x000200f8u,0x00000067u,0x0004003du,0x00000043u,0x0000006cu,0x00000045u,0x0004006fu,0x00000069u,0x0000006du,0x0000006cu,0x00050050u,0x00000069u,0x0000006fu,0x0000006eu,0x0000006eu,0x00050081u,0x00000069u,0x00000070u,0x0000006du,0x0000006fu,0x0004003du,0x00000043u,0x00000071u,0x0000004eu,0x0004006fu,0x00000069u,0x00000072u,0x00000071u,0x00050088u,0x00000069u,0x00000073u,0x00000070u,0x00000072u,0x0003003eu,0x0000006bu,0x00000073u,0x0004003du,0x00000077u,0x0000007au,0x00000079u,0x00040064u,0x00000076u,0x0000007cu,0x0000007au,0x00050067u,0x00000043u,0x0000007du,0x0000007cu,0x0000007bu,0x0004006fu,0x00000069u,0x0000007eu,0x0000007du,0x00050050u,0x00000069u,0x0000007fu,0x00000075u,0x00000075u,0x00050088u,0x00000069u,0x00000080u,0x0000007fu,0x0000007eu,0x0003003eu,0x00000074u,0x00000080u,0x0004003du,0x00000077u,0x00000082u,0x00000079u,0x0004003du,0x00000069u,0x00000083u,0x0000006bu,0x00070058u,0x00000085u,0x00000086u,0x00000082u,0x00000083u,0x00000002u,0x00000084u,0x0007004fu,0x00000069u,0x00000087u,0x00000086u,0x00000086u,0x00000000u,0x00000001u,0x0003003eu,0x00000081u,0x00000087u,0x0004003du,0x00000077u,0x00000089u,0x00000079u,0x0004003du,0x00000069u,0x0000008au,0x0000006bu,0x00050041u,0x00000007u,0x0000008bu,0x00000074u,0x00000055u,0x0004003du,0x00000006u,0x0000008cu,0x0000008bu,0x00050050u,0x00000069u,0x0000008du,0x0000008cu,0x00000084u,0x00050083u,0x00000069u,0x0000008eu,0x0000008au,0x0000008du,0x00070058u,0x00000085u,0x0000008fu,0x00000089u,0x0000008eu,0x00000002u,0x00000084u,0x0007004fu,0x00000069u,0x00000090u,0x0000008fu,0x0000008fu,0x00000000u,0x00000001u,0x0003003eu,0x00000088u,0x00000090u,0x0004003du,0x00000077u,0x00000092u,0x00000079u,0x0004003du,0x00000069u,0x00000093u,0x0000006bu,0x00050041u,0x00000007u,0x00000094u,0x00000074u,0x00000055u,0x0004003du,0x00000006u,0x00000095u,0x00000094u,0x00050050u,0x00000069u,0x00000096u,0x00000095u,0x00000084u,0x00050081u,0x00000069u,0x00000097u,0x00000093u,0x00000096u,0x00070058u,0x00000085u,0x00000098u,0x00000092u,0x00000097u,0x00000002u,0x00000084u,0x0007004fu,0x00000069u,0x00000099u,0x00000098u,0x00000098u,0x00000000u,0x00000001u,0x0003003eu,0x00000091u,0x00000099u,0x0004003du,0x00000077u,0x0000009bu,0x00000079u,0x0004003du,0x00000069u,0x0000009cu,0x0000006bu,0x00050041u,0x00000007u,0x0000009du,0x00000074u,0x0000005fu,0x0004003du,0x00000006u,0x0000009eu,0x0000009du,0x00050050u,0x00000069u,0x0000009fu,0x00000084u,0x0000009eu,0x00050083u,0x00000069u,0x000000a0u,0x0000009cu,0x0000009fu,0x00070058u,0x00000085u,0x000000a1u,0x0000009bu,0x000000a0u,0x00000002u,0x00000084u,0x0007004fu,0x00000069u,0x000000a2u,0x000000a1u,0x000000a1u,0x00000000u,0x00000001u,0x0003003eu,0x0000009au,0x000000a2u,0x0004003du,0x00000077u,0x000000a4u,0x00000079u,0x0004003du,0x00000069u,0x000000a5u,0x0000006bu,0x00050041u,0x00000007u,0x000000a6u,0x00000074u,0x0000005fu,0x0004003du,0x00000006u,0x000000a7u,0x000000a6u,0x00050050u,0x00000069u,0x000000a8u,0x00000084u,0x000000a7u,0x00050081u,0x00000069u,0x000000a9u,0x000000a5u,0x000000a8u,0x00070058u,0x00000085u,0x000000aau,0x000000a4u,0x000000a9u,0x00000002u,0x00000084u,0x0007004fu,0x00000069u,0x000000abu,0x000000aau,0x000000aau,0x00000000u,0x00000001u,0x0003003eu,0x000000a3u,0x000000abu,0x00050041u,0x00000007u,0x000000aeu,0x00000081u,0x00000055u,0x0004003du,0x00000006u,0x000000afu,0x000000aeu,0x0003003eu,0x000000adu,0x000000afu,0x00050041u,0x00000007u,0x000000b1u,0x00000088u,0x00000055u,0x0004003du,0x00000006u,0x000000b2u,0x000000b1u,0x0003003eu,0x000000b0u,0x000000b2u,0x00050041u,0x00000007u,0x000000b4u,0x00000091u,0x00000055u,0x0004003du,0x00000006u,0x000000b5u,0x000000b4u,0x0003003eu,0x000000b3u,0x000000b5u,0x00050041u,0x00000007u,0x000000b7u,0x0000009au,0x00000055u,0x0004003du,0x00000006u,0x000000b8u,0x000000b7u,0x0003003eu,0x000000b6u,0x000000b8u,0x00050041u,0x00000007u,0x000000bau,0x000000a3u,0x00000055u,0x0004003du,0x00000006u,0x000000bbu,0x000000bau,0x0003003eu,0x000000b9u,0x000000bbu,0x00090039u,0x00000006u,0x000000bcu,0x0000000eu,0x000000adu,0x000000b0u,0x000000b3u,0x000000b6u,0x000000b9u,0x00050041u,0x00000007u,0x000000beu,0x00000081u,0x0000005fu,0x0004003du,0x00000006u,0x000000bfu,0x000000beu,0x0003003eu,0x000000bdu,0x000000bfu,0x00050041u,0x00000007u,0x000000c1u,0x00000088u,0x0000005fu,0x0004003du,0x00000006u,0x000000c2u,0x000000c1u,0x0003003eu,0x000000c0u,0x000000c2u,0x00050041u,0x00000007u,0x000000c4u,0x00000091u,0x0000005fu,0x0004003du,0x00000006u,0x000000c5u,0x000000c4u,0x0003003eu,0x000000c3u,0x000000c5u,0x00050041u,0x00000007u,0x000000c7u,0x0000009au,0x0000005fu,0x0004003du,0x00000006u,0x000000c8u,0x000000c7u,0x0003003eu,0x000000c6u,0x000000c8u,0x00050041u,0x00000007u,0x000000cau,0x000000a3u,0x0000005fu,0x0004003du,0x00000006u,0x000000cbu,0x000000cau,0x0003003eu,0x000000c9u,0x000000cbu,0x00090039u,0x00000006u,0x000000ccu,0x0000000eu,0x000000bdu,0x000000c0u,0x000000c3u,0x000000c6u,0x000000c9u,0x00050050u,0x00000069u,0x000000cdu,0x000000bcu,0x000000ccu,0x0003003eu,0x000000acu,0x000000cdu,0x0004003du,0x00000069u,0x000000cfu,0x0000006bu,0x00050050u,0x00000069u,0x000000d0u,0x0000006eu,0x0000006eu,0x00050083u,0x00000069u,0x000000d1u,0x000000cfu,0x000000d0u,0x0003003eu,0x000000ceu,0x000000d1u,0x00060041u,0x000000d7u,0x000000d8u,0x000000d5u,0x000000d6u,0x00000055u,0x0004003du,0x00000006u,0x000000d9u,0x000000d8u,0x00050041u,0x00000007u,0x000000dau,0x000000ceu,0x00000055u,0x0004003du,0x00000006u,0x000000dbu,0x000000dau,0x00050085u,0x00000006u,0x000000dcu,0x000000d9u,0x000000dbu,0x00060041u,0x000000d7u,0x000000deu,0x000000d5u,0x000000d6u,0x000000ddu,0x0004003du,0x00000006u,0x000000dfu,0x000000deu,0x00050041u,0x00000007u,0x000000e0u,0x000000ceu,0x0000005fu,0x0004003du,0x00000006u,0x000000e1u,0x000000e0u,0x00050085u,0x00000006u,0x000000e2u,0x000000dfu,0x000000e1u,0x00050081u,0x00000006u,0x000000e3u,0x000000dcu,0x000000e2u,0x00060041u,0x000000d7u,0x000000e5u,0x000000d5u,0x000000e4u,0x00000055u,0x0004003du,0x00000006u,0x000000e6u,0x000000e5u,0x00050081u,0x00000006u,0x000000e7u,0x000000e3u,0x000000e6u,0x00060041u,0x000000d7u,0x000000e8u,0x000000d5u,0x000000d6u,0x0000005fu,0x0004003du,0x00000006u,0x000000e9u,0x000000e8u,0x00050041u,0x00000007u,0x000000eau,0x000000ceu,0x00000055u,0x0004003du,0x00000006u,0x000000ebu,0x000000eau,0x00050085u,0x00000006u,0x000000ecu,0x000000e9u,0x000000ebu,0x00060041u,0x000000d7u,0x000000eeu,0x000000d5u,0x000000d6u,0x000000edu,0x0004003du,0x00000006u,0x000000efu,0x000000eeu,0x00050041u,0x00000007u,0x000000f0u,0x000000ceu,0x0000005fu,0x0004003du,0x00000006u,0x000000f1u,0x000000f0u,0x00050085u,0x00000006u,0x000000f2u,0x000000efu,0x000000f1u,0x00050081u,0x00000006u,0x000000f3u,0x000000ecu,0x000000f2u,0x00060041u,0x000000d7u,0x000000f4u,0x000000d5u,0x000000e4u,0x0000005fu,0x0004003du,0x00000006u,0x000000f5u,0x000000f4u,0x00050081u,0x00000006u,0x000000f6u,0x000000f3u,0x000000f5u,0x00050050u,0x00000069u,0x000000f7u,0x000000e7u,0x000000f6u,0x0004003du,0x00000043u,0x000000f8u,0x0000004eu,0x0004006fu,0x00000069u,0x000000f9u,0x000000f8u,0x00050085u,0x00000069u,0x000000fau,0x000000f7u,0x000000f9u,0x0003003eu,0x000000d2u,0x000000fau,0x00060041u,0x000000d7u,0x000000feu,0x000000d5u,0x000000d6u,0x00000055u,0x0004003du,0x00000006u,0x000000ffu,0x000000feu,0x00050081u,0x00000006u,0x00000100u,0x00000075u,0x000000ffu,0x00060041u,0x000000d7u,0x00000101u,0x000000d5u,0x000000d6u,0x0000005fu,0x0004003du,0x00000006u,0x00000102u,0x00000101u,0x00060041u,0x000000d7u,0x00000103u,0x000000d5u,0x000000d6u,0x000000ddu,0x0004003du,0x00000006u,0x00000104u,0x00000103u,0x00060041u,0x000000d7u,0x00000105u,0x000000d5u,0x000000d6u,0x000000edu,0x0004003du,0x00000006u,0x00000106u,0x00000105u,0x00050081u,0x00000006u,0x00000107u,0x00000075u,0x00000106u,0x00050050u,0x00000069u,0x00000108u,0x00000100u,0x00000102u,0x00050050u,0x00000069u,0x00000109u,0x00000104u,0x00000107u,0x00050050u,0x000000fbu,0x0000010au,0x00000108u,0x00000109u,0x0003003eu,0x000000fdu,0x0000010au,0x0004003du,0x00000069u,0x0000010cu,0x000000d2u,0x0004003du,0x000000fbu,0x0000010du,0x000000fdu,0x0004003du,0x00000069u,0x0000010eu,0x000000acu,0x00050091u,0x00000069u,0x0000010fu,0x0000010du,0x0000010eu,0x00050081u,0x00000069u,0x00000110u,0x0000010cu,0x0000010fu,0x0003003eu,0x0000010bu,0x00000110u,0x0004003du,0x0000004fu,0x00000111u,0x00000051u,0x0004003du,0x00000043u,0x00000112u,0x00000045u,0x0004003du,0x00000069u,0x00000113u,0x0000010bu,0x00050051u,0x00000006u,0x00000114u,0x00000113u,0x00000000u,0x00050051u,0x00000006u,0x00000115u,0x00000113u,0x00000001u,0x00070050u,0x00000085u,0x00000116u,0x00000114u,0x00000115u,0x00000084u,0x00000075u,0x00040063u,0x00000111u,0x00000112u,0x00000116u,0x0004003du,0x0000004fu,0x00000118u,0x00000117u,0x0004003du,0x00000043u,0x00000119u,0x00000045u,0x0004003du,0x00000069u,0x0000011au,0x0000010bu,0x0004007fu,0x00000069u,0x0000011bu,0x0000011au,0x00050051u,0x00000006u,0x0000011cu,0x0000011bu,0x00000000u,0x00050051u,0x00000006u,0x0000011du,0x0000011bu,0x00000001u,0x00070050u,0x00000085u,0x0000011eu,0x0000011cu,0x0000011du,0x00000084u,0x00000075u,0x00040063u,0x00000118u,0x00000119u,0x0000011eu,0x000100fdu,0x00010038u,0x00050036u,0x00000006u,0x0000000eu,0x00000000u,0x00000008u,0x00030037u,0x00000007u,0x00000009u,0x00030037u,0x00000007u,0x0000000au,0x00030037u,0x00000007u,0x0000000bu,0x00030037u,0x00000007u,0x0000000cu,0x00030037u,0x00000007u,0x0000000du,0x000200f8u,0x0000000fu,0x0004003bu,0x00000007u,0x00000010u,0x00000007u,0x0004003bu,0x00000007u,0x00000034u,0x00000007u,0x0004003du,0x00000006u,0x00000011u,0x00000009u,0x0004003du,0x00000006u,0x00000012u,0x0000000au,0x0007000cu,0x00000006u,0x00000013u,0x00000001u,0x00000025u,0x00000011u,0x00000012u,0x0003003eu,0x00000010u,0x00000013u,0x0004003du,0x00000006u,0x00000014u,0x00000009u,0x0004003du,0x00000006u,0x00000015u,0x0000000au,0x0007000cu,0x00000006u,0x00000016u,0x00000001u,0x00000028u,0x00000014u,0x00000015u,0x0003003eu,0x00000009u,0x00000016u,0x0004003du,0x00000006u,0x00000017u,0x00000010u,0x0003003eu,0x0000000au,0x00000017u,0x0004003du,0x00000006u,0x00000018u,0x0000000bu,0x0004003du,0x00000006u,0x00000019u,0x0000000cu,0x0007000cu,0x00000006u,0x0000001au,0x00000001u,0x00000025u,0x00000018u,0x00000019u,0x0003003eu,0x00000010u,0x0000001au,0x0004003du,0x00000006u,0x0000001bu,0x0000000bu,0x0004003du,0x00000006u,0x0000001cu,0x0000000cu,0x0007000cu,0x00000006u,0x0000001du,0x00000001u,0x00000028u,0x0000001bu,0x0000001cu,0x0003003eu,0x0000000bu,0x0000001du,0x0004003du,0x00000006u,0x0000001eu,0x00000010u,0x0003003eu,0x0000000cu,0x0000001eu,0x0004003du,0x00000006u,0x0000001fu,0x00000009u,0x0004003du,0x00000006u,0x00000020u,0x0000000bu,0x0007000cu,0x00000006u,0x00000021u,0x00000001u,0x00000025u,0x0000001fu,0x00000020u,0x0003003eu,0x00000010u,0x00000021u,0x0004003du,0x00000006u,0x00000022u,0x00000009u,0x0004003du,0x00000006u,0x00000023u,0x0000000bu,0x0007000cu,0x00000006u,0x00000024u,0x00000001u,0x00000028u,0x00000022u,0x00000023u,0x0003003eu,0x00000009u,0x00000024u,0x0004003du,0x00000006u,0x00000025u,0x00000010u,0x0003003eu,0x0000000bu,0x00000025u,0x0004003du,0x00000006u,0x00000026u,0x0000000au,0x0004003du,0x00000006u,0x00000027u,0x0000000cu,0x0007000cu,0x00000006u,0x00000028u,0x00000001u,0x00000025u,0x00000026u,0x00000027u,0x0003003eu,0x00000010u,0x00000028u,0x0004003du,0x00000006u,0x00000029u,0x0000000au,0x0004003du,0x00000006u,0x0000002au,0x0000000cu,0x0007000cu,0x00000006u,0x0000002bu,0x00000001u,0x00000028u,0x00000029u,0x0000002au,0x0003003eu,0x0000000au,0x0000002bu,0x0004003du,0x00000006u,0x0000002cu,0x00000010u,0x0003003eu,0x0000000cu,0x0000002cu,0x0004003du,0x00000006u,0x0000002du,0x0000000au,0x0004003du,0x00000006u,0x0000002eu,0x0000000bu,0x0007000cu,0x00000006u,0x0000002fu,0x00000001u,0x00000025u,0x0000002du,0x0000002eu,0x0003003eu,0x00000010u,0x0000002fu,0x0004003du,0x00000006u,0x00000030u,0x0000000au,0x0004003du,0x00000006u,0x00000031u,0x0000000bu,0x0007000cu,0x00000006u,0x00000032u,0x00000001u,0x00000028u,0x00000030u,0x00000031u,0x0003003eu,0x0000000au,0x00000032u,0x0004003du,0x00000006u,0x00000033u,0x00000010u,0x0003003eu,0x0000000bu,0x00000033u,0x0004003du,0x00000006u,0x00000035u,0x0000000au,0x0004003du,0x00000006u,0x00000036u,0x0000000du,0x0007000cu,0x00000006u,0x00000037u,0x00000001u,0x00000025u,0x00000035u,0x00000036u,0x0003003eu,0x00000034u,0x00000037u,0x0004003du,0x00000006u,0x00000038u,0x0000000au,0x0004003du,0x00000006u,0x00000039u,0x0000000du,0x0007000cu,0x00000006u,0x0000003au,0x00000001u,0x00000028u,0x00000038u,0x00000039u,0x0003003eu,0x00000010u,0x0000003au,0x0004003du,0x00000006u,0x0000003bu,0x00000034u,0x0004003du,0x00000006u,0x0000003cu,0x0000000bu,0x0007000cu,0x00000006u,0x0000003du,0x00000001u,0x00000028u,0x0000003bu,0x0000003cu,0x0004003du,0x00000006u,0x0000003eu,0x00000010u,0x0007000cu,0x00000006u,0x0000003fu,0x00000001u,0x00000025u,0x0000003du,0x0000003eu,0x000200feu,0x0000003fu,0x00010038u}; static const size_t OF3_EXPAND_LEN = 1798; static const uint32_t OF3_FLOW_M4_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000151u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x000000f6u,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00080005u,0x00000010u,0x636f6c62u,0x6461536bu,0x31327328u,0x3132733bu,0x3266763bu,0x0000003bu,0x00030005u,0x0000000du,0x00000061u,0x00030005u,0x0000000eu,0x00000062u,0x00040005u,0x0000000fu,0x646e6163u,0x00000000u,0x00070005u,0x00000016u,0x766c6f73u,0x32732865u,0x32733b31u,0x66763b31u,0x00003b32u,0x00030005u,0x00000013u,0x00000061u,0x00030005u,0x00000014u,0x00000062u,0x00040005u,0x00000015u,0x64657270u,0x00000000u,0x00030005u,0x00000019u,0x00646173u,0x00030005u,0x0000001du,0x00007962u,0x00030005u,0x00000028u,0x00007862u,0x00030005u,0x00000030u,0x00006f62u,0x00030005u,0x00000036u,0x00006170u,0x00030005u,0x00000039u,0x00765567u,0x00050005u,0x0000003cu,0x766e4967u,0x616d754cu,0x00000000u,0x00030005u,0x00000045u,0x00006270u,0x00040005u,0x0000005du,0x74736562u,0x00646153u,0x00050005u,0x0000005fu,0x74736562u,0x70736944u,0x00000000u,0x00030005u,0x00000061u,0x00007973u,0x00030005u,0x0000006bu,0x00007873u,0x00040005u,0x00000073u,0x646e6163u,0x00000000u,0x00030005u,0x0000007bu,0x00646173u,0x00040005u,0x0000007cu,0x61726170u,0x0000006du,0x00030005u,0x00000095u,0x00000055u,0x00060006u,0x00000095u,0x00000000u,0x776f6c66u,0x6c616353u,0x00000065u,0x00050006u,0x00000095u,0x00000001u,0x6576656cu,0x0000006cu,0x00050006u,0x00000095u,0x00000002u,0x6c63636fu,0x00006f4cu,0x00050006u,0x00000095u,0x00000003u,0x6c63636fu,0x00006948u,0x00030005u,0x00000097u,0x00000000u,0x00040005u,0x0000009eu,0x43646173u,0x00000000u,0x00040005u,0x000000a1u,0x58646173u,0x0000006du,0x00040005u,0x000000a6u,0x61726170u,0x0000006du,0x00040005u,0x000000a9u,0x58646173u,0x00000070u,0x00040005u,0x000000aeu,0x61726170u,0x0000006du,0x00040005u,0x000000b1u,0x59646173u,0x0000006du,0x00040005u,0x000000b5u,0x61726170u,0x0000006du,0x00040005u,0x000000b8u,0x59646173u,0x00000070u,0x00040005u,0x000000bcu,0x61726170u,0x0000006du,0x00030005u,0x000000bfu,0x00007864u,0x00030005u,0x000000c0u,0x00007964u,0x00040005u,0x000000c1u,0x6f6e6564u,0x0000586du,0x00040005u,0x000000c9u,0x6f6e6564u,0x0000596du,0x00030005u,0x000000f3u,0x00646967u,0x00080005u,0x000000f6u,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x000000fbu,0x006d6964u,0x00040005u,0x000000feu,0x6f6c4675u,0x00000077u,0x00050005u,0x0000011au,0x6d754c75u,0x72754361u,0x00000072u,0x00040005u,0x00000122u,0x654c6f74u,0x006c6576u,0x00040005u,0x00000129u,0x64657270u,0x00000000u,0x00050005u,0x0000012au,0x65725075u,0x74636964u,0x0000726fu,0x00030005u,0x0000012eu,0x00647766u,0x00050005u,0x0000012fu,0x6d754c75u,0x65725061u,0x00000076u,0x00040005u,0x00000134u,0x61726170u,0x0000006du,0x00030005u,0x00000136u,0x00647762u,0x00040005u,0x0000013bu,0x61726170u,0x0000006du,0x00040005u,0x0000013du,0x75466f74u,0x00006c6cu,0x00030047u,0x00000095u,0x00000002u,0x00050048u,0x00000095u,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x00000095u,0x00000001u,0x00000023u,0x00000004u,0x00050048u,0x00000095u,0x00000002u,0x00000023u,0x00000008u,0x00050048u,0x00000095u,0x00000003u,0x00000023u,0x0000000cu,0x00040047u,0x00000097u,0x00000021u,0x00000000u,0x00040047u,0x00000097u,0x00000022u,0x00000000u,0x00040047u,0x000000f6u,0x0000000bu,0x0000001cu,0x00030047u,0x000000feu,0x00000019u,0x00040047u,0x000000feu,0x00000021u,0x00000030u,0x00040047u,0x000000feu,0x00000022u,0x00000000u,0x00040047u,0x0000011au,0x00000021u,0x00000021u,0x00040047u,0x0000011au,0x00000022u,0x00000000u,0x00040047u,0x0000012au,0x00000021u,0x00000022u,0x00040047u,0x0000012au,0x00000022u,0x00000000u,0x00040047u,0x0000012fu,0x00000021u,0x00000020u,0x00040047u,0x0000012fu,0x00000022u,0x00000000u,0x00040047u,0x00000150u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00030016u,0x00000006u,0x00000020u,0x00090019u,0x00000007u,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000008u,0x00000007u,0x00040020u,0x00000009u,0x00000000u,0x00000008u,0x00040017u,0x0000000au,0x00000006u,0x00000002u,0x00040020u,0x0000000bu,0x00000007u,0x0000000au,0x00060021u,0x0000000cu,0x00000006u,0x00000009u,0x00000009u,0x0000000bu,0x00060021u,0x00000012u,0x0000000au,0x00000009u,0x00000009u,0x0000000bu,0x00040020u,0x00000018u,0x00000007u,0x00000006u,0x0004002bu,0x00000006u,0x0000001au,0x00000000u,0x00040015u,0x0000001bu,0x00000020u,0x00000001u,0x00040020u,0x0000001cu,0x00000007u,0x0000001bu,0x0004002bu,0x0000001bu,0x0000001eu,0xffffffffu,0x0004002bu,0x0000001bu,0x00000025u,0x00000001u,0x00020014u,0x00000026u,0x00040020u,0x00000038u,0x00000006u,0x0000000au,0x0004003bu,0x00000038u,0x00000039u,0x00000006u,0x0004003bu,0x00000038u,0x0000003cu,0x00000006u,0x00040017u,0x00000040u,0x00000006u,0x00000004u,0x00040015u,0x00000042u,0x00000020u,0x00000000u,0x0004002bu,0x00000042u,0x00000043u,0x00000000u,0x0004002bu,0x00000006u,0x0000005eu,0x7f7fffffu,0x0004002bu,0x0000001bu,0x00000062u,0xfffffffdu,0x0004002bu,0x0000001bu,0x00000069u,0x00000003u,0x0004002bu,0x00000006u,0x0000007fu,0x3b03126fu,0x0006001eu,0x00000095u,0x00000006u,0x00000042u,0x00000006u,0x00000006u,0x00040020u,0x00000096u,0x00000002u,0x00000095u,0x0004003bu,0x00000096u,0x00000097u,0x00000002u,0x00040020u,0x00000098u,0x00000002u,0x00000042u,0x0004002bu,0x00000006u,0x000000a3u,0xbf800000u,0x0005002cu,0x0000000au,0x000000a4u,0x000000a3u,0x0000001au,0x0004002bu,0x00000006u,0x000000abu,0x3f800000u,0x0005002cu,0x0000000au,0x000000acu,0x000000abu,0x0000001au,0x0005002cu,0x0000000au,0x000000b3u,0x0000001au,0x000000a3u,0x0005002cu,0x0000000au,0x000000bau,0x0000001au,0x000000abu,0x0004002bu,0x00000006u,0x000000c3u,0x40000000u,0x0004002bu,0x00000006u,0x000000d1u,0x358637bdu,0x0004002bu,0x00000006u,0x000000d5u,0x3f000000u,0x0004002bu,0x00000006u,0x000000dcu,0xbf000000u,0x00040017u,0x000000f1u,0x0000001bu,0x00000002u,0x00040020u,0x000000f2u,0x00000007u,0x000000f1u,0x00040017u,0x000000f4u,0x00000042u,0x00000003u,0x00040020u,0x000000f5u,0x00000001u,0x000000f4u,0x0004003bu,0x000000f5u,0x000000f6u,0x00000001u,0x00040017u,0x000000f7u,0x00000042u,0x00000002u,0x00090019u,0x000000fcu,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u,0x000000fdu,0x00000000u,0x000000fcu,0x0004003bu,0x000000fdu,0x000000feu,0x00000000u,0x0004002bu,0x00000042u,0x00000109u,0x00000001u,0x0004003bu,0x00000009u,0x0000011au,0x00000000u,0x0004002bu,0x0000001bu,0x0000011cu,0x00000000u,0x00040020u,0x00000128u,0x00000007u,0x00000040u,0x0004003bu,0x00000009u,0x0000012au,0x00000000u,0x0004003bu,0x00000009u,0x0000012fu,0x00000000u,0x0004002bu,0x00000042u,0x0000014fu,0x00000010u,0x0006002cu,0x000000f4u,0x00000150u,0x0000014fu,0x0000014fu,0x00000109u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x000000f2u,0x000000f3u,0x00000007u,0x0004003bu,0x000000f2u,0x000000fbu,0x00000007u,0x0004003bu,0x00000018u,0x00000122u,0x00000007u,0x0004003bu,0x00000128u,0x00000129u,0x00000007u,0x0004003bu,0x0000000bu,0x0000012eu,0x00000007u,0x0004003bu,0x0000000bu,0x00000134u,0x00000007u,0x0004003bu,0x0000000bu,0x00000136u,0x00000007u,0x0004003bu,0x0000000bu,0x0000013bu,0x00000007u,0x0004003bu,0x00000018u,0x0000013du,0x00000007u,0x0004003du,0x000000f4u,0x000000f8u,0x000000f6u,0x0007004fu,0x000000f7u,0x000000f9u,0x000000f8u,0x000000f8u,0x00000000u,0x00000001u,0x0004007cu,0x000000f1u,0x000000fau,0x000000f9u,0x0003003eu,0x000000f3u,0x000000fau,0x0004003du,0x000000fcu,0x000000ffu,0x000000feu,0x00040068u,0x000000f1u,0x00000100u,0x000000ffu,0x0003003eu,0x000000fbu,0x00000100u,0x00050041u,0x0000001cu,0x00000101u,0x000000f3u,0x00000043u,0x0004003du,0x0000001bu,0x00000102u,0x00000101u,0x00050041u,0x0000001cu,0x00000103u,0x000000fbu,0x00000043u,0x0004003du,0x0000001bu,0x00000104u,0x00000103u,0x000500afu,0x00000026u,0x00000105u,0x00000102u,0x00000104u,0x000400a8u,0x00000026u,0x00000106u,0x00000105u,0x000300f7u,0x00000108u,0x00000000u,0x000400fau,0x00000106u,0x00000107u,0x00000108u,0x000200f8u,0x00000107u,0x00050041u,0x0000001cu,0x0000010au,0x000000f3u,0x00000109u,0x0004003du,0x0000001bu,0x0000010bu,0x0000010au,0x00050041u,0x0000001cu,0x0000010cu,0x000000fbu,0x00000109u,0x0004003du,0x0000001bu,0x0000010du,0x0000010cu,0x000500afu,0x00000026u,0x0000010eu,0x0000010bu,0x0000010du,0x000200f9u,0x00000108u,0x000200f8u,0x00000108u,0x000700f5u,0x00000026u,0x0000010fu,0x00000105u,0x00000005u,0x0000010eu,0x00000107u,0x000300f7u,0x00000111u,0x00000000u,0x000400fau,0x0000010fu,0x00000110u,0x00000111u,0x000200f8u,0x00000110u,0x000100fdu,0x000200f8u,0x00000111u,0x0004003du,0x000000f1u,0x00000113u,0x000000f3u,0x0004006fu,0x0000000au,0x00000114u,0x00000113u,0x00050050u,0x0000000au,0x00000115u,0x000000d5u,0x000000d5u,0x00050081u,0x0000000au,0x00000116u,0x00000114u,0x00000115u,0x0004003du,0x000000f1u,0x00000117u,0x000000fbu,0x0004006fu,0x0000000au,0x00000118u,0x00000117u,0x00050088u,0x0000000au,0x00000119u,0x00000116u,0x00000118u,0x0003003eu,0x00000039u,0x00000119u,0x0004003du,0x00000008u,0x0000011bu,0x0000011au,0x00040064u,0x00000007u,0x0000011du,0x0000011bu,0x00050067u,0x000000f1u,0x0000011eu,0x0000011du,0x0000011cu,0x0004006fu,0x0000000au,0x0000011fu,0x0000011eu,0x00050050u,0x0000000au,0x00000120u,0x000000abu,0x000000abu,0x00050088u,0x0000000au,0x00000121u,0x00000120u,0x0000011fu,0x0003003eu,0x0000003cu,0x00000121u,0x00050041u,0x00000098u,0x00000123u,0x00000097u,0x00000025u,0x0004003du,0x00000042u,0x00000124u,0x00000123u,0x00040070u,0x00000006u,0x00000125u,0x00000124u,0x0004007fu,0x00000006u,0x00000126u,0x00000125u,0x0006000cu,0x00000006u,0x00000127u,0x00000001u,0x0000001du,0x00000126u,0x0003003eu,0x00000122u,0x00000127u,0x0004003du,0x00000008u,0x0000012bu,0x0000012au,0x0004003du,0x0000000au,0x0000012cu,0x00000039u,0x00070058u,0x00000040u,0x0000012du,0x0000012bu,0x0000012cu,0x00000002u,0x0000001au,0x0003003eu,0x00000129u,0x0000012du,0x0004003du,0x00000040u,0x00000130u,0x00000129u,0x0007004fu,0x0000000au,0x00000131u,0x00000130u,0x00000130u,0x00000000u,0x00000001u,0x0004003du,0x00000006u,0x00000132u,0x00000122u,0x0005008eu,0x0000000au,0x00000133u,0x00000131u,0x00000132u,0x0003003eu,0x00000134u,0x00000133u,0x00070039u,0x0000000au,0x00000135u,0x00000016u,0x0000012fu,0x0000011au,0x00000134u,0x0003003eu,0x0000012eu,0x00000135u,0x0004003du,0x00000040u,0x00000137u,0x00000129u,0x0007004fu,0x0000000au,0x00000138u,0x00000137u,0x00000137u,0x00000002u,0x00000003u,0x0004003du,0x00000006u,0x00000139u,0x00000122u,0x0005008eu,0x0000000au,0x0000013au,0x00000138u,0x00000139u,0x0003003eu,0x0000013bu,0x0000013au,0x00070039u,0x0000000au,0x0000013cu,0x00000016u,0x0000011au,0x0000012fu,0x0000013bu,0x0003003eu,0x00000136u,0x0000013cu,0x00050041u,0x00000098u,0x0000013eu,0x00000097u,0x00000025u,0x0004003du,0x00000042u,0x0000013fu,0x0000013eu,0x00040070u,0x00000006u,0x00000140u,0x0000013fu,0x0006000cu,0x00000006u,0x00000141u,0x00000001u,0x0000001du,0x00000140u,0x0003003eu,0x0000013du,0x00000141u,0x0004003du,0x000000fcu,0x00000142u,0x000000feu,0x0004003du,0x000000f1u,0x00000143u,0x000000f3u,0x0004003du,0x0000000au,0x00000144u,0x0000012eu,0x0004003du,0x00000006u,0x00000145u,0x0000013du,0x0005008eu,0x0000000au,0x00000146u,0x00000144u,0x00000145u,0x0004003du,0x0000000au,0x00000147u,0x00000136u,0x0004003du,0x00000006u,0x00000148u,0x0000013du,0x0005008eu,0x0000000au,0x00000149u,0x00000147u,0x00000148u,0x00050051u,0x00000006u,0x0000014au,0x00000146u,0x00000000u,0x00050051u,0x00000006u,0x0000014bu,0x00000146u,0x00000001u,0x00050051u,0x00000006u,0x0000014cu,0x00000149u,0x00000000u,0x00050051u,0x00000006u,0x0000014du,0x00000149u,0x00000001u,0x00070050u,0x00000040u,0x0000014eu,0x0000014au,0x0000014bu,0x0000014cu,0x0000014du,0x00040063u,0x00000142u,0x00000143u,0x0000014eu,0x000100fdu,0x00010038u,0x00050036u,0x00000006u,0x00000010u,0x00000000u,0x0000000cu,0x00030037u,0x00000009u,0x0000000du,0x00030037u,0x00000009u,0x0000000eu,0x00030037u,0x0000000bu,0x0000000fu,0x000200f8u,0x00000011u,0x0004003bu,0x00000018u,0x00000019u,0x00000007u,0x0004003bu,0x0000001cu,0x0000001du,0x00000007u,0x0004003bu,0x0000001cu,0x00000028u,0x00000007u,0x0004003bu,0x0000000bu,0x00000030u,0x00000007u,0x0004003bu,0x00000018u,0x00000036u,0x00000007u,0x0004003bu,0x00000018u,0x00000045u,0x00000007u,0x0003003eu,0x00000019u,0x0000001au,0x0003003eu,0x0000001du,0x0000001eu,0x000200f9u,0x0000001fu,0x000200f8u,0x0000001fu,0x000400f6u,0x00000021u,0x00000022u,0x00000000u,0x000200f9u,0x00000023u,0x000200f8u,0x00000023u,0x0004003du,0x0000001bu,0x00000024u,0x0000001du,0x000500b3u,0x00000026u,0x00000027u,0x00000024u,0x00000025u,0x000400fau,0x00000027u,0x00000020u,0x00000021u,0x000200f8u,0x00000020u,0x0003003eu,0x00000028u,0x0000001eu,0x000200f9u,0x00000029u,0x000200f8u,0x00000029u,0x000400f6u,0x0000002bu,0x0000002cu,0x00000000u,0x000200f9u,0x0000002du,0x000200f8u,0x0000002du,0x0004003du,0x0000001bu,0x0000002eu,0x00000028u,0x000500b3u,0x00000026u,0x0000002fu,0x0000002eu,0x00000025u,0x000400fau,0x0000002fu,0x0000002au,0x0000002bu,0x000200f8u,0x0000002au,0x0004003du,0x0000001bu,0x00000031u,0x00000028u,0x0004006fu,0x00000006u,0x00000032u,0x00000031u,0x0004003du,0x0000001bu,0x00000033u,0x0000001du,0x0004006fu,0x00000006u,0x00000034u,0x00000033u,0x00050050u,0x0000000au,0x00000035u,0x00000032u,0x00000034u,0x0003003eu,0x00000030u,0x00000035u,0x0004003du,0x00000008u,0x00000037u,0x0000000du,0x0004003du,0x0000000au,0x0000003au,0x00000039u,0x0004003du,0x0000000au,0x0000003bu,0x00000030u,0x0004003du,0x0000000au,0x0000003du,0x0000003cu,0x00050085u,0x0000000au,0x0000003eu,0x0000003bu,0x0000003du,0x00050081u,0x0000000au,0x0000003fu,0x0000003au,0x0000003eu,0x00070058u,0x00000040u,0x00000041u,0x00000037u,0x0000003fu,0x00000002u,0x0000001au,0x00050051u,0x00000006u,0x00000044u,0x00000041u,0x00000000u,0x0003003eu,0x00000036u,0x00000044u,0x0004003du,0x00000008u,0x00000046u,0x0000000eu,0x0004003du,0x0000000au,0x00000047u,0x00000039u,0x0004003du,0x0000000au,0x00000048u,0x00000030u,0x0004003du,0x0000000au,0x00000049u,0x0000000fu,0x00050081u,0x0000000au,0x0000004au,0x00000048u,0x00000049u,0x0004003du,0x0000000au,0x0000004bu,0x0000003cu,0x00050085u,0x0000000au,0x0000004cu,0x0000004au,0x0000004bu,0x00050081u,0x0000000au,0x0000004du,0x00000047u,0x0000004cu,0x00070058u,0x00000040u,0x0000004eu,0x00000046u,0x0000004du,0x00000002u,0x0000001au,0x00050051u,0x00000006u,0x0000004fu,0x0000004eu,0x00000000u,0x0003003eu,0x00000045u,0x0000004fu,0x0004003du,0x00000006u,0x00000050u,0x00000036u,0x0004003du,0x00000006u,0x00000051u,0x00000045u,0x00050083u,0x00000006u,0x00000052u,0x00000050u,0x00000051u,0x0006000cu,0x00000006u,0x00000053u,0x00000001u,0x00000004u,0x00000052u,0x0004003du,0x00000006u,0x00000054u,0x00000019u,0x00050081u,0x00000006u,0x00000055u,0x00000054u,0x00000053u,0x0003003eu,0x00000019u,0x00000055u,0x000200f9u,0x0000002cu,0x000200f8u,0x0000002cu,0x0004003du,0x0000001bu,0x00000056u,0x00000028u,0x00050080u,0x0000001bu,0x00000057u,0x00000056u,0x00000025u,0x0003003eu,0x00000028u,0x00000057u,0x000200f9u,0x00000029u,0x000200f8u,0x0000002bu,0x000200f9u,0x00000022u,0x000200f8u,0x00000022u,0x0004003du,0x0000001bu,0x00000058u,0x0000001du,0x00050080u,0x0000001bu,0x00000059u,0x00000058u,0x00000025u,0x0003003eu,0x0000001du,0x00000059u,0x000200f9u,0x0000001fu,0x000200f8u,0x00000021u,0x0004003du,0x00000006u,0x0000005au,0x00000019u,0x000200feu,0x0000005au,0x00010038u,0x00050036u,0x0000000au,0x00000016u,0x00000000u,0x00000012u,0x00030037u,0x00000009u,0x00000013u,0x00030037u,0x00000009u,0x00000014u,0x00030037u,0x0000000bu,0x00000015u,0x000200f8u,0x00000017u,0x0004003bu,0x00000018u,0x0000005du,0x00000007u,0x0004003bu,0x0000000bu,0x0000005fu,0x00000007u,0x0004003bu,0x0000001cu,0x00000061u,0x00000007u,0x0004003bu,0x0000001cu,0x0000006bu,0x00000007u,0x0004003bu,0x0000000bu,0x00000073u,0x00000007u,0x0004003bu,0x00000018u,0x0000007bu,0x00000007u,0x0004003bu,0x0000000bu,0x0000007cu,0x00000007u,0x0004003bu,0x00000018u,0x0000009eu,0x00000007u,0x0004003bu,0x00000018u,0x000000a1u,0x00000007u,0x0004003bu,0x0000000bu,0x000000a6u,0x00000007u,0x0004003bu,0x00000018u,0x000000a9u,0x00000007u,0x0004003bu,0x0000000bu,0x000000aeu,0x00000007u,0x0004003bu,0x00000018u,0x000000b1u,0x00000007u,0x0004003bu,0x0000000bu,0x000000b5u,0x00000007u,0x0004003bu,0x00000018u,0x000000b8u,0x00000007u,0x0004003bu,0x0000000bu,0x000000bcu,0x00000007u,0x0004003bu,0x00000018u,0x000000bfu,0x00000007u,0x0004003bu,0x00000018u,0x000000c0u,0x00000007u,0x0004003bu,0x00000018u,0x000000c1u,0x00000007u,0x0004003bu,0x00000018u,0x000000c9u,0x00000007u,0x0003003eu,0x0000005du,0x0000005eu,0x0004003du,0x0000000au,0x00000060u,0x00000015u,0x0003003eu,0x0000005fu,0x00000060u,0x0003003eu,0x00000061u,0x00000062u,0x000200f9u,0x00000063u,0x000200f8u,0x00000063u,0x000400f6u,0x00000065u,0x00000066u,0x00000000u,0x000200f9u,0x00000067u,0x000200f8u,0x00000067u,0x0004003du,0x0000001bu,0x00000068u,0x00000061u,0x000500b3u,0x00000026u,0x0000006au,0x00000068u,0x00000069u,0x000400fau,0x0000006au,0x00000064u,0x00000065u,0x000200f8u,0x00000064u,0x0003003eu,0x0000006bu,0x00000062u,0x000200f9u,0x0000006cu,0x000200f8u,0x0000006cu,0x000400f6u,0x0000006eu,0x0000006fu,0x00000000u,0x000200f9u,0x00000070u,0x000200f8u,0x00000070u,0x0004003du,0x0000001bu,0x00000071u,0x0000006bu,0x000500b3u,0x00000026u,0x00000072u,0x00000071u,0x00000069u,0x000400fau,0x00000072u,0x0000006du,0x0000006eu,0x000200f8u,0x0000006du,0x0004003du,0x0000000au,0x00000074u,0x00000015u,0x0004003du,0x0000001bu,0x00000075u,0x0000006bu,0x0004006fu,0x00000006u,0x00000076u,0x00000075u,0x0004003du,0x0000001bu,0x00000077u,0x00000061u,0x0004006fu,0x00000006u,0x00000078u,0x00000077u,0x00050050u,0x0000000au,0x00000079u,0x00000076u,0x00000078u,0x00050081u,0x0000000au,0x0000007au,0x00000074u,0x00000079u,0x0003003eu,0x00000073u,0x0000007au,0x0004003du,0x0000000au,0x0000007du,0x00000073u,0x0003003eu,0x0000007cu,0x0000007du,0x00070039u,0x00000006u,0x0000007eu,0x00000010u,0x00000013u,0x00000014u,0x0000007cu,0x0003003eu,0x0000007bu,0x0000007eu,0x0004003du,0x0000001bu,0x00000080u,0x0000006bu,0x0004006fu,0x00000006u,0x00000081u,0x00000080u,0x0006000cu,0x00000006u,0x00000082u,0x00000001u,0x00000004u,0x00000081u,0x0004003du,0x0000001bu,0x00000083u,0x00000061u,0x0004006fu,0x00000006u,0x00000084u,0x00000083u,0x0006000cu,0x00000006u,0x00000085u,0x00000001u,0x00000004u,0x00000084u,0x00050081u,0x00000006u,0x00000086u,0x00000082u,0x00000085u,0x00050085u,0x00000006u,0x00000087u,0x0000007fu,0x00000086u,0x0004003du,0x00000006u,0x00000088u,0x0000007bu,0x00050081u,0x00000006u,0x00000089u,0x00000088u,0x00000087u,0x0003003eu,0x0000007bu,0x00000089u,0x0004003du,0x00000006u,0x0000008au,0x0000007bu,0x0004003du,0x00000006u,0x0000008bu,0x0000005du,0x000500b8u,0x00000026u,0x0000008cu,0x0000008au,0x0000008bu,0x000300f7u,0x0000008eu,0x00000000u,0x000400fau,0x0000008cu,0x0000008du,0x0000008eu,0x000200f8u,0x0000008du,0x0004003du,0x00000006u,0x0000008fu,0x0000007bu,0x0003003eu,0x0000005du,0x0000008fu,0x0004003du,0x0000000au,0x00000090u,0x00000073u,0x0003003eu,0x0000005fu,0x00000090u,0x000200f9u,0x0000008eu,0x000200f8u,0x0000008eu,0x000200f9u,0x0000006fu,0x000200f8u,0x0000006fu,0x0004003du,0x0000001bu,0x00000091u,0x0000006bu,0x00050080u,0x0000001bu,0x00000092u,0x00000091u,0x00000025u,0x0003003eu,0x0000006bu,0x00000092u,0x000200f9u,0x0000006cu,0x000200f8u,0x0000006eu,0x000200f9u,0x00000066u,0x000200f8u,0x00000066u,0x0004003du,0x0000001bu,0x00000093u,0x00000061u,0x00050080u,0x0000001bu,0x00000094u,0x00000093u,0x00000025u,0x0003003eu,0x00000061u,0x00000094u,0x000200f9u,0x00000063u,0x000200f8u,0x00000065u,0x00050041u,0x00000098u,0x00000099u,0x00000097u,0x00000025u,0x0004003du,0x00000042u,0x0000009au,0x00000099u,0x000500aau,0x00000026u,0x0000009bu,0x0000009au,0x00000043u,0x000300f7u,0x0000009du,0x00000000u,0x000400fau,0x0000009bu,0x0000009cu,0x0000009du,0x000200f8u,0x0000009cu,0x0004003du,0x00000006u,0x0000009fu,0x0000005du,0x00050083u,0x00000006u,0x000000a0u,0x0000009fu,0x0000001au,0x0003003eu,0x0000009eu,0x000000a0u,0x0004003du,0x0000000au,0x000000a2u,0x0000005fu,0x00050081u,0x0000000au,0x000000a5u,0x000000a2u,0x000000a4u,0x0003003eu,0x000000a6u,0x000000a5u,0x00070039u,0x00000006u,0x000000a7u,0x00000010u,0x00000013u,0x00000014u,0x000000a6u,0x00050081u,0x00000006u,0x000000a8u,0x000000a7u,0x0000007fu,0x0003003eu,0x000000a1u,0x000000a8u,0x0004003du,0x0000000au,0x000000aau,0x0000005fu,0x00050081u,0x0000000au,0x000000adu,0x000000aau,0x000000acu,0x0003003eu,0x000000aeu,0x000000adu,0x00070039u,0x00000006u,0x000000afu,0x00000010u,0x00000013u,0x00000014u,0x000000aeu,0x00050081u,0x00000006u,0x000000b0u,0x000000afu,0x0000007fu,0x0003003eu,0x000000a9u,0x000000b0u,0x0004003du,0x0000000au,0x000000b2u,0x0000005fu,0x00050081u,0x0000000au,0x000000b4u,0x000000b2u,0x000000b3u,0x0003003eu,0x000000b5u,0x000000b4u,0x00070039u,0x00000006u,0x000000b6u,0x00000010u,0x00000013u,0x00000014u,0x000000b5u,0x00050081u,0x00000006u,0x000000b7u,0x000000b6u,0x0000007fu,0x0003003eu,0x000000b1u,0x000000b7u,0x0004003du,0x0000000au,0x000000b9u,0x0000005fu,0x00050081u,0x0000000au,0x000000bbu,0x000000b9u,0x000000bau,0x0003003eu,0x000000bcu,0x000000bbu,0x00070039u,0x00000006u,0x000000bdu,0x00000010u,0x00000013u,0x00000014u,0x000000bcu,0x00050081u,0x00000006u,0x000000beu,0x000000bdu,0x0000007fu,0x0003003eu,0x000000b8u,0x000000beu,0x0003003eu,0x000000bfu,0x0000001au,0x0003003eu,0x000000c0u,0x0000001au,0x0004003du,0x00000006u,0x000000c2u,0x000000a1u,0x0004003du,0x00000006u,0x000000c4u,0x0000009eu,0x00050085u,0x00000006u,0x000000c5u,0x000000c3u,0x000000c4u,0x00050083u,0x00000006u,0x000000c6u,0x000000c2u,0x000000c5u,0x0004003du,0x00000006u,0x000000c7u,0x000000a9u,0x00050081u,0x00000006u,0x000000c8u,0x000000c6u,0x000000c7u,0x0003003eu,0x000000c1u,0x000000c8u,0x0004003du,0x00000006u,0x000000cau,0x000000b1u,0x0004003du,0x00000006u,0x000000cbu,0x0000009eu,0x00050085u,0x00000006u,0x000000ccu,0x000000c3u,0x000000cbu,0x00050083u,0x00000006u,0x000000cdu,0x000000cau,0x000000ccu,0x0004003du,0x00000006u,0x000000ceu,0x000000b8u,0x00050081u,0x00000006u,0x000000cfu,0x000000cdu,0x000000ceu,0x0003003eu,0x000000c9u,0x000000cfu,0x0004003du,0x00000006u,0x000000d0u,0x000000c1u,0x000500bau,0x00000026u,0x000000d2u,0x000000d0u,0x000000d1u,0x000300f7u,0x000000d4u,0x00000000u,0x000400fau,0x000000d2u,0x000000d3u,0x000000d4u,0x000200f8u,0x000000d3u,0x0004003du,0x00000006u,0x000000d6u,0x000000a1u,0x0004003du,0x00000006u,0x000000d7u,0x000000a9u,0x00050083u,0x00000006u,0x000000d8u,0x000000d6u,0x000000d7u,0x00050085u,0x00000006u,0x000000d9u,0x000000d5u,0x000000d8u,0x0004003du,0x00000006u,0x000000dau,0x000000c1u,0x00050088u,0x00000006u,0x000000dbu,0x000000d9u,0x000000dau,0x0008000cu,0x00000006u,0x000000ddu,0x00000001u,0x0000002bu,0x000000dbu,0x000000dcu,0x000000d5u,0x0003003eu,0x000000bfu,0x000000ddu,0x000200f9u,0x000000d4u,0x000200f8u,0x000000d4u,0x0004003du,0x00000006u,0x000000deu,0x000000c9u,0x000500bau,0x00000026u,0x000000dfu,0x000000deu,0x000000d1u,0x000300f7u,0x000000e1u,0x00000000u,0x000400fau,0x000000dfu,0x000000e0u,0x000000e1u,0x000200f8u,0x000000e0u,0x0004003du,0x00000006u,0x000000e2u,0x000000b1u,0x0004003du,0x00000006u,0x000000e3u,0x000000b8u,0x00050083u,0x00000006u,0x000000e4u,0x000000e2u,0x000000e3u,0x00050085u,0x00000006u,0x000000e5u,0x000000d5u,0x000000e4u,0x0004003du,0x00000006u,0x000000e6u,0x000000c9u,0x00050088u,0x00000006u,0x000000e7u,0x000000e5u,0x000000e6u,0x0008000cu,0x00000006u,0x000000e8u,0x00000001u,0x0000002bu,0x000000e7u,0x000000dcu,0x000000d5u,0x0003003eu,0x000000c0u,0x000000e8u,0x000200f9u,0x000000e1u,0x000200f8u,0x000000e1u,0x0004003du,0x00000006u,0x000000e9u,0x000000bfu,0x0004003du,0x00000006u,0x000000eau,0x000000c0u,0x00050050u,0x0000000au,0x000000ebu,0x000000e9u,0x000000eau,0x0004003du,0x0000000au,0x000000ecu,0x0000005fu,0x00050081u,0x0000000au,0x000000edu,0x000000ecu,0x000000ebu,0x0003003eu,0x0000005fu,0x000000edu,0x000200f9u,0x0000009du,0x000200f8u,0x0000009du,0x0004003du,0x0000000au,0x000000eeu,0x0000005fu,0x000200feu,0x000000eeu,0x00010038u}; @@ -18,8 +226,8 @@ static const uint32_t OF3_GM_REDUCE_SPV[] = {0x07230203u,0x00010300u,0x0008000bu static const size_t OF3_GM_REDUCE_LEN = 2584; static const uint32_t OF3_GM_PREWARP_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000074u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x0000000du,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00030005u,0x00000009u,0x00646967u,0x00080005u,0x0000000du,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x00000012u,0x006d6964u,0x00040005u,0x00000016u,0x74734475u,0x00000000u,0x00030005u,0x00000030u,0x00007675u,0x00030005u,0x00000039u,0x00000071u,0x00040005u,0x0000003du,0x6c6f6370u,0x00000030u,0x00030005u,0x0000003fu,0x00004d47u,0x00050006u,0x0000003fu,0x00000000u,0x694c6d67u,0x0000006eu,0x00050006u,0x0000003fu,0x00000001u,0x694c6d67u,0x0000546eu,0x00050006u,0x0000003fu,0x00000002u,0x70416d67u,0x00000070u,0x00050006u,0x0000003fu,0x00000003u,0x70416d67u,0x00005470u,0x00030005u,0x00000041u,0x00000000u,0x00040005u,0x00000049u,0x6c6f6370u,0x00000031u,0x00040005u,0x00000051u,0x72537675u,0x00000063u,0x00030005u,0x00000064u,0x00000076u,0x00040005u,0x00000068u,0x72754375u,0x00000072u,0x00040047u,0x0000000du,0x0000000bu,0x0000001cu,0x00030047u,0x00000016u,0x00000019u,0x00040047u,0x00000016u,0x00000021u,0x00000030u,0x00040047u,0x00000016u,0x00000022u,0x00000000u,0x00030047u,0x0000003fu,0x00000002u,0x00050048u,0x0000003fu,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x0000003fu,0x00000001u,0x00000023u,0x00000010u,0x00050048u,0x0000003fu,0x00000002u,0x00000023u,0x00000020u,0x00050048u,0x0000003fu,0x00000003u,0x00000023u,0x00000030u,0x00040047u,0x00000041u,0x00000021u,0x00000001u,0x00040047u,0x00000041u,0x00000022u,0x00000000u,0x00040047u,0x00000068u,0x00000021u,0x00000020u,0x00040047u,0x00000068u,0x00000022u,0x00000000u,0x00040047u,0x00000073u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u,0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00040020u,0x00000008u,0x00000007u,0x00000007u,0x00040015u,0x0000000au,0x00000020u,0x00000000u,0x00040017u,0x0000000bu,0x0000000au,0x00000003u,0x00040020u,0x0000000cu,0x00000001u,0x0000000bu,0x0004003bu,0x0000000cu,0x0000000du,0x00000001u,0x00040017u,0x0000000eu,0x0000000au,0x00000002u,0x00030016u,0x00000013u,0x00000020u,0x00090019u,0x00000014u,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000003u,0x00040020u,0x00000015u,0x00000000u,0x00000014u,0x0004003bu,0x00000015u,0x00000016u,0x00000000u,0x00020014u,0x00000019u,0x0004002bu,0x0000000au,0x0000001au,0x00000000u,0x00040020u,0x0000001bu,0x00000007u,0x00000006u,0x0004002bu,0x0000000au,0x00000024u,0x00000001u,0x00040017u,0x0000002eu,0x00000013u,0x00000002u,0x00040020u,0x0000002fu,0x00000007u,0x0000002eu,0x0004002bu,0x00000013u,0x00000033u,0x3f000000u,0x00040017u,0x0000003eu,0x00000013u,0x00000004u,0x0006001eu,0x0000003fu,0x0000003eu,0x0000003eu,0x0000003eu,0x0000003eu,0x00040020u,0x00000040u,0x00000002u,0x0000003fu,0x0004003bu,0x00000040u,0x00000041u,0x00000002u,0x0004002bu,0x00000006u,0x00000042u,0x00000002u,0x00040020u,0x00000043u,0x00000002u,0x00000013u,0x0004002bu,0x0000000au,0x0000004au,0x00000002u,0x0004002bu,0x0000000au,0x0000004du,0x00000003u,0x00040020u,0x00000054u,0x00000007u,0x00000013u,0x0004002bu,0x00000006u,0x0000005eu,0x00000003u,0x00040020u,0x0000005fu,0x00000002u,0x0000003eu,0x00090019u,0x00000065u,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000066u,0x00000065u,0x00040020u,0x00000067u,0x00000000u,0x00000066u,0x0004003bu,0x00000067u,0x00000068u,0x00000000u,0x0004002bu,0x00000013u,0x0000006bu,0x00000000u,0x0004002bu,0x0000000au,0x00000072u,0x00000010u,0x0006002cu,0x0000000bu,0x00000073u,0x00000072u,0x00000072u,0x00000024u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000008u,0x00000009u,0x00000007u,0x0004003bu,0x00000008u,0x00000012u,0x00000007u,0x0004003bu,0x0000002fu,0x00000030u,0x00000007u,0x0004003bu,0x0000002fu,0x00000039u,0x00000007u,0x0004003bu,0x0000002fu,0x0000003du,0x00000007u,0x0004003bu,0x0000002fu,0x00000049u,0x00000007u,0x0004003bu,0x0000002fu,0x00000051u,0x00000007u,0x0004003bu,0x00000054u,0x00000064u,0x00000007u,0x0004003du,0x0000000bu,0x0000000fu,0x0000000du,0x0007004fu,0x0000000eu,0x00000010u,0x0000000fu,0x0000000fu,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x00000011u,0x00000010u,0x0003003eu,0x00000009u,0x00000011u,0x0004003du,0x00000014u,0x00000017u,0x00000016u,0x00040068u,0x00000007u,0x00000018u,0x00000017u,0x0003003eu,0x00000012u,0x00000018u,0x00050041u,0x0000001bu,0x0000001cu,0x00000009u,0x0000001au,0x0004003du,0x00000006u,0x0000001du,0x0000001cu,0x00050041u,0x0000001bu,0x0000001eu,0x00000012u,0x0000001au,0x0004003du,0x00000006u,0x0000001fu,0x0000001eu,0x000500afu,0x00000019u,0x00000020u,0x0000001du,0x0000001fu,0x000400a8u,0x00000019u,0x00000021u,0x00000020u,0x000300f7u,0x00000023u,0x00000000u,0x000400fau,0x00000021u,0x00000022u,0x00000023u,0x000200f8u,0x00000022u,0x00050041u,0x0000001bu,0x00000025u,0x00000009u,0x00000024u,0x0004003du,0x00000006u,0x00000026u,0x00000025u,0x00050041u,0x0000001bu,0x00000027u,0x00000012u,0x00000024u,0x0004003du,0x00000006u,0x00000028u,0x00000027u,0x000500afu,0x00000019u,0x00000029u,0x00000026u,0x00000028u,0x000200f9u,0x00000023u,0x000200f8u,0x00000023u,0x000700f5u,0x00000019u,0x0000002au,0x00000020u,0x00000005u,0x00000029u,0x00000022u,0x000300f7u,0x0000002cu,0x00000000u,0x000400fau,0x0000002au,0x0000002bu,0x0000002cu,0x000200f8u,0x0000002bu,0x000100fdu,0x000200f8u,0x0000002cu,0x0004003du,0x00000007u,0x00000031u,0x00000009u,0x0004006fu,0x0000002eu,0x00000032u,0x00000031u,0x00050050u,0x0000002eu,0x00000034u,0x00000033u,0x00000033u,0x00050081u,0x0000002eu,0x00000035u,0x00000032u,0x00000034u,0x0004003du,0x00000007u,0x00000036u,0x00000012u,0x0004006fu,0x0000002eu,0x00000037u,0x00000036u,0x00050088u,0x0000002eu,0x00000038u,0x00000035u,0x00000037u,0x0003003eu,0x00000030u,0x00000038u,0x0004003du,0x0000002eu,0x0000003au,0x00000030u,0x00050050u,0x0000002eu,0x0000003bu,0x00000033u,0x00000033u,0x00050083u,0x0000002eu,0x0000003cu,0x0000003au,0x0000003bu,0x0003003eu,0x00000039u,0x0000003cu,0x00060041u,0x00000043u,0x00000044u,0x00000041u,0x00000042u,0x0000001au,0x0004003du,0x00000013u,0x00000045u,0x00000044u,0x00060041u,0x00000043u,0x00000046u,0x00000041u,0x00000042u,0x00000024u,0x0004003du,0x00000013u,0x00000047u,0x00000046u,0x00050050u,0x0000002eu,0x00000048u,0x00000045u,0x00000047u,0x0003003eu,0x0000003du,0x00000048u,0x00060041u,0x00000043u,0x0000004bu,0x00000041u,0x00000042u,0x0000004au,0x0004003du,0x00000013u,0x0000004cu,0x0000004bu,0x00060041u,0x00000043u,0x0000004eu,0x00000041u,0x00000042u,0x0000004du,0x0004003du,0x00000013u,0x0000004fu,0x0000004eu,0x00050050u,0x0000002eu,0x00000050u,0x0000004cu,0x0000004fu,0x0003003eu,0x00000049u,0x00000050u,0x0004003du,0x0000002eu,0x00000052u,0x00000030u,0x0004003du,0x0000002eu,0x00000053u,0x0000003du,0x00050041u,0x00000054u,0x00000055u,0x00000039u,0x0000001au,0x0004003du,0x00000013u,0x00000056u,0x00000055u,0x0005008eu,0x0000002eu,0x00000057u,0x00000053u,0x00000056u,0x00050081u,0x0000002eu,0x00000058u,0x00000052u,0x00000057u,0x0004003du,0x0000002eu,0x00000059u,0x00000049u,0x00050041u,0x00000054u,0x0000005au,0x00000039u,0x00000024u,0x0004003du,0x00000013u,0x0000005bu,0x0000005au,0x0005008eu,0x0000002eu,0x0000005cu,0x00000059u,0x0000005bu,0x00050081u,0x0000002eu,0x0000005du,0x00000058u,0x0000005cu,0x00050041u,0x0000005fu,0x00000060u,0x00000041u,0x0000005eu,0x0004003du,0x0000003eu,0x00000061u,0x00000060u,0x0007004fu,0x0000002eu,0x00000062u,0x00000061u,0x00000061u,0x00000000u,0x00000001u,0x00050081u,0x0000002eu,0x00000063u,0x0000005du,0x00000062u,0x0003003eu,0x00000051u,0x00000063u,0x0004003du,0x00000066u,0x00000069u,0x00000068u,0x0004003du,0x0000002eu,0x0000006au,0x00000051u,0x00070058u,0x0000003eu,0x0000006cu,0x00000069u,0x0000006au,0x00000002u,0x0000006bu,0x00050051u,0x00000013u,0x0000006du,0x0000006cu,0x00000000u,0x0003003eu,0x00000064u,0x0000006du,0x0004003du,0x00000014u,0x0000006eu,0x00000016u,0x0004003du,0x00000007u,0x0000006fu,0x00000009u,0x0004003du,0x00000013u,0x00000070u,0x00000064u,0x00070050u,0x0000003eu,0x00000071u,0x00000070u,0x0000006bu,0x0000006bu,0x0000006bu,0x00040063u,0x0000006eu,0x0000006fu,0x00000071u,0x000100fdu,0x00010038u}; static const size_t OF3_GM_PREWARP_LEN = 706; -static const uint32_t OF3_FLOWREG_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000144u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x00000037u,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00060005u,0x0000000eu,0x63746566u,0x76285568u,0x763b3269u,0x003b3269u,0x00030005u,0x0000000cu,0x00000070u,0x00030005u,0x0000000du,0x006d6964u,0x00060005u,0x00000013u,0x63746566u,0x76284c68u,0x763b3269u,0x003b3269u,0x00030005u,0x00000011u,0x00000070u,0x00030005u,0x00000012u,0x006d6964u,0x00040005u,0x00000018u,0x6f6c4675u,0x006e4977u,0x00040005u,0x00000026u,0x6d754c75u,0x00000061u,0x00030005u,0x00000034u,0x00646967u,0x00080005u,0x00000037u,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x0000003cu,0x006d6964u,0x00030005u,0x00000055u,0x00007464u,0x00030005u,0x00000056u,0x00000055u,0x00050006u,0x00000056u,0x00000000u,0x61726170u,0x0000736du,0x00030005u,0x00000058u,0x00000000u,0x00040005u,0x0000005cu,0x626d616cu,0x00006164u,0x00050005u,0x0000005fu,0x65676465u,0x68706c41u,0x00000061u,0x00040005u,0x00000063u,0x54737065u,0x00000056u,0x00030005u,0x00000068u,0x00004375u,0x00040005u,0x00000069u,0x61726170u,0x0000006du,0x00040005u,0x0000006bu,0x61726170u,0x0000006du,0x00030005u,0x0000006eu,0x00004c75u,0x00040005u,0x00000073u,0x61726170u,0x0000006du,0x00040005u,0x00000074u,0x61726170u,0x0000006du,0x00030005u,0x00000077u,0x00005275u,0x00040005u,0x0000007bu,0x61726170u,0x0000006du,0x00040005u,0x0000007cu,0x61726170u,0x0000006du,0x00030005u,0x0000007fu,0x00005575u,0x00040005u,0x00000083u,0x61726170u,0x0000006du,0x00040005u,0x00000084u,0x61726170u,0x0000006du,0x00030005u,0x00000087u,0x00004475u,0x00040005u,0x0000008bu,0x61726170u,0x0000006du,0x00040005u,0x0000008cu,0x61726170u,0x0000006du,0x00040005u,0x0000008fu,0x6d69646cu,0x00000000u,0x00030005u,0x00000093u,0x00004c6cu,0x00040005u,0x00000096u,0x61726170u,0x0000006du,0x00040005u,0x00000097u,0x61726170u,0x0000006du,0x00030005u,0x0000009au,0x0000526cu,0x00040005u,0x0000009du,0x61726170u,0x0000006du,0x00040005u,0x0000009eu,0x61726170u,0x0000006du,0x00030005u,0x000000a1u,0x0000556cu,0x00040005u,0x000000a4u,0x61726170u,0x0000006du,0x00040005u,0x000000a5u,0x61726170u,0x0000006du,0x00030005u,0x000000a8u,0x0000446cu,0x00040005u,0x000000abu,0x61726170u,0x0000006du,0x00040005u,0x000000acu,0x61726170u,0x0000006du,0x00040005u,0x000000afu,0x67616d67u,0x00000000u,0x00030005u,0x000000bbu,0x00000067u,0x00030005u,0x000000c4u,0x00004c64u,0x00030005u,0x000000c8u,0x00005264u,0x00030005u,0x000000ccu,0x00005564u,0x00030005u,0x000000d0u,0x00004464u,0x00030005u,0x000000d4u,0x00003265u,0x00030005u,0x000000d8u,0x00004c77u,0x00030005u,0x000000e1u,0x00005277u,0x00030005u,0x000000eau,0x00005577u,0x00030005u,0x000000f3u,0x00004477u,0x00040005u,0x000000fcu,0x576d7573u,0x00000000u,0x00040005u,0x00000104u,0x576d7573u,0x00000055u,0x00040005u,0x00000114u,0x66694475u,0x00000066u,0x00030005u,0x00000120u,0x00003066u,0x00050005u,0x00000121u,0x6f6c4675u,0x73624f77u,0x00000000u,0x00040005u,0x0000012au,0x74656874u,0x00000061u,0x00030005u,0x0000012eu,0x00000072u,0x00040005u,0x00000132u,0x77654e75u,0x00000000u,0x00050005u,0x0000013eu,0x6f6c4675u,0x74754f77u,0x00000000u,0x00040047u,0x00000018u,0x00000021u,0x00000020u,0x00040047u,0x00000018u,0x00000022u,0x00000000u,0x00040047u,0x00000026u,0x00000021u,0x00000022u,0x00040047u,0x00000026u,0x00000022u,0x00000000u,0x00040047u,0x00000037u,0x0000000bu,0x0000001cu,0x00030047u,0x00000056u,0x00000002u,0x00050048u,0x00000056u,0x00000000u,0x00000023u,0x00000000u,0x00040047u,0x00000058u,0x00000021u,0x00000000u,0x00040047u,0x00000058u,0x00000022u,0x00000000u,0x00040047u,0x00000121u,0x00000021u,0x00000021u,0x00040047u,0x00000121u,0x00000022u,0x00000000u,0x00030047u,0x0000013eu,0x00000019u,0x00040047u,0x0000013eu,0x00000021u,0x00000030u,0x00040047u,0x0000013eu,0x00000022u,0x00000000u,0x00040047u,0x00000143u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u,0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00040020u,0x00000008u,0x00000007u,0x00000007u,0x00030016u,0x00000009u,0x00000020u,0x00040017u,0x0000000au,0x00000009u,0x00000004u,0x00050021u,0x0000000bu,0x0000000au,0x00000008u,0x00000008u,0x00050021u,0x00000010u,0x00000009u,0x00000008u,0x00000008u,0x00090019u,0x00000015u,0x00000009u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000016u,0x00000015u,0x00040020u,0x00000017u,0x00000000u,0x00000016u,0x0004003bu,0x00000017u,0x00000018u,0x00000000u,0x0004002bu,0x00000006u,0x0000001bu,0x00000000u,0x0005002cu,0x00000007u,0x0000001cu,0x0000001bu,0x0000001bu,0x0004002bu,0x00000006u,0x0000001eu,0x00000001u,0x0004003bu,0x00000017u,0x00000026u,0x00000000u,0x00040015u,0x0000002fu,0x00000020u,0x00000000u,0x0004002bu,0x0000002fu,0x00000030u,0x00000000u,0x00040017u,0x00000035u,0x0000002fu,0x00000003u,0x00040020u,0x00000036u,0x00000001u,0x00000035u,0x0004003bu,0x00000036u,0x00000037u,0x00000001u,0x00040017u,0x00000038u,0x0000002fu,0x00000002u,0x00020014u,0x00000040u,0x00040020u,0x00000041u,0x00000007u,0x00000006u,0x0004002bu,0x0000002fu,0x0000004au,0x00000001u,0x00040020u,0x00000054u,0x00000007u,0x00000009u,0x0003001eu,0x00000056u,0x0000000au,0x00040020u,0x00000057u,0x00000002u,0x00000056u,0x0004003bu,0x00000057u,0x00000058u,0x00000002u,0x00040020u,0x00000059u,0x00000002u,0x00000009u,0x0004002bu,0x0000002fu,0x00000060u,0x00000002u,0x0004002bu,0x0000002fu,0x00000064u,0x00000003u,0x00040020u,0x00000067u,0x00000007u,0x0000000au,0x0004002bu,0x00000006u,0x00000070u,0xffffffffu,0x0005002cu,0x00000007u,0x00000071u,0x00000070u,0x0000001bu,0x0005002cu,0x00000007u,0x00000079u,0x0000001eu,0x0000001bu,0x0005002cu,0x00000007u,0x00000081u,0x0000001bu,0x00000070u,0x0005002cu,0x00000007u,0x00000089u,0x0000001bu,0x0000001eu,0x0004002bu,0x00000009u,0x000000b0u,0x3f000000u,0x00040017u,0x000000b7u,0x00000009u,0x00000002u,0x0004002bu,0x00000009u,0x000000c1u,0x3d4ccccdu,0x0004002bu,0x00000009u,0x000000c2u,0x3f800000u,0x0004003bu,0x00000017u,0x00000121u,0x00000000u,0x00090019u,0x0000013cu,0x00000009u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u,0x0000013du,0x00000000u,0x0000013cu,0x0004003bu,0x0000013du,0x0000013eu,0x00000000u,0x0004002bu,0x0000002fu,0x00000142u,0x00000010u,0x0006002cu,0x00000035u,0x00000143u,0x00000142u,0x00000142u,0x0000004au,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000008u,0x00000034u,0x00000007u,0x0004003bu,0x00000008u,0x0000003cu,0x00000007u,0x0004003bu,0x00000054u,0x00000055u,0x00000007u,0x0004003bu,0x00000054u,0x0000005cu,0x00000007u,0x0004003bu,0x00000054u,0x0000005fu,0x00000007u,0x0004003bu,0x00000054u,0x00000063u,0x00000007u,0x0004003bu,0x00000067u,0x00000068u,0x00000007u,0x0004003bu,0x00000008u,0x00000069u,0x00000007u,0x0004003bu,0x00000008u,0x0000006bu,0x00000007u,0x0004003bu,0x00000067u,0x0000006eu,0x00000007u,0x0004003bu,0x00000008u,0x00000073u,0x00000007u,0x0004003bu,0x00000008u,0x00000074u,0x00000007u,0x0004003bu,0x00000067u,0x00000077u,0x00000007u,0x0004003bu,0x00000008u,0x0000007bu,0x00000007u,0x0004003bu,0x00000008u,0x0000007cu,0x00000007u,0x0004003bu,0x00000067u,0x0000007fu,0x00000007u,0x0004003bu,0x00000008u,0x00000083u,0x00000007u,0x0004003bu,0x00000008u,0x00000084u,0x00000007u,0x0004003bu,0x00000067u,0x00000087u,0x00000007u,0x0004003bu,0x00000008u,0x0000008bu,0x00000007u,0x0004003bu,0x00000008u,0x0000008cu,0x00000007u,0x0004003bu,0x00000008u,0x0000008fu,0x00000007u,0x0004003bu,0x00000054u,0x00000093u,0x00000007u,0x0004003bu,0x00000008u,0x00000096u,0x00000007u,0x0004003bu,0x00000008u,0x00000097u,0x00000007u,0x0004003bu,0x00000054u,0x0000009au,0x00000007u,0x0004003bu,0x00000008u,0x0000009du,0x00000007u,0x0004003bu,0x00000008u,0x0000009eu,0x00000007u,0x0004003bu,0x00000054u,0x000000a1u,0x00000007u,0x0004003bu,0x00000008u,0x000000a4u,0x00000007u,0x0004003bu,0x00000008u,0x000000a5u,0x00000007u,0x0004003bu,0x00000054u,0x000000a8u,0x00000007u,0x0004003bu,0x00000008u,0x000000abu,0x00000007u,0x0004003bu,0x00000008u,0x000000acu,0x00000007u,0x0004003bu,0x00000054u,0x000000afu,0x00000007u,0x0004003bu,0x00000054u,0x000000bbu,0x00000007u,0x0004003bu,0x00000067u,0x000000c4u,0x00000007u,0x0004003bu,0x00000067u,0x000000c8u,0x00000007u,0x0004003bu,0x00000067u,0x000000ccu,0x00000007u,0x0004003bu,0x00000067u,0x000000d0u,0x00000007u,0x0004003bu,0x00000054u,0x000000d4u,0x00000007u,0x0004003bu,0x00000054u,0x000000d8u,0x00000007u,0x0004003bu,0x00000054u,0x000000e1u,0x00000007u,0x0004003bu,0x00000054u,0x000000eau,0x00000007u,0x0004003bu,0x00000054u,0x000000f3u,0x00000007u,0x0004003bu,0x00000054u,0x000000fcu,0x00000007u,0x0004003bu,0x00000067u,0x00000104u,0x00000007u,0x0004003bu,0x00000067u,0x00000114u,0x00000007u,0x0004003bu,0x00000067u,0x00000120u,0x00000007u,0x0004003bu,0x00000054u,0x0000012au,0x00000007u,0x0004003bu,0x00000067u,0x0000012eu,0x00000007u,0x0004003bu,0x00000067u,0x00000132u,0x00000007u,0x0004003du,0x00000035u,0x00000039u,0x00000037u,0x0007004fu,0x00000038u,0x0000003au,0x00000039u,0x00000039u,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x0000003bu,0x0000003au,0x0003003eu,0x00000034u,0x0000003bu,0x0004003du,0x00000016u,0x0000003du,0x00000018u,0x00040064u,0x00000015u,0x0000003eu,0x0000003du,0x00050067u,0x00000007u,0x0000003fu,0x0000003eu,0x0000001bu,0x0003003eu,0x0000003cu,0x0000003fu,0x00050041u,0x00000041u,0x00000042u,0x00000034u,0x00000030u,0x0004003du,0x00000006u,0x00000043u,0x00000042u,0x00050041u,0x00000041u,0x00000044u,0x0000003cu,0x00000030u,0x0004003du,0x00000006u,0x00000045u,0x00000044u,0x000500afu,0x00000040u,0x00000046u,0x00000043u,0x00000045u,0x000400a8u,0x00000040u,0x00000047u,0x00000046u,0x000300f7u,0x00000049u,0x00000000u,0x000400fau,0x00000047u,0x00000048u,0x00000049u,0x000200f8u,0x00000048u,0x00050041u,0x00000041u,0x0000004bu,0x00000034u,0x0000004au,0x0004003du,0x00000006u,0x0000004cu,0x0000004bu,0x00050041u,0x00000041u,0x0000004du,0x0000003cu,0x0000004au,0x0004003du,0x00000006u,0x0000004eu,0x0000004du,0x000500afu,0x00000040u,0x0000004fu,0x0000004cu,0x0000004eu,0x000200f9u,0x00000049u,0x000200f8u,0x00000049u,0x000700f5u,0x00000040u,0x00000050u,0x00000046u,0x00000005u,0x0000004fu,0x00000048u,0x000300f7u,0x00000052u,0x00000000u,0x000400fau,0x00000050u,0x00000051u,0x00000052u,0x000200f8u,0x00000051u,0x000100fdu,0x000200f8u,0x00000052u,0x00060041u,0x00000059u,0x0000005au,0x00000058u,0x0000001bu,0x00000030u,0x0004003du,0x00000009u,0x0000005bu,0x0000005au,0x0003003eu,0x00000055u,0x0000005bu,0x00060041u,0x00000059u,0x0000005du,0x00000058u,0x0000001bu,0x0000004au,0x0004003du,0x00000009u,0x0000005eu,0x0000005du,0x0003003eu,0x0000005cu,0x0000005eu,0x00060041u,0x00000059u,0x00000061u,0x00000058u,0x0000001bu,0x00000060u,0x0004003du,0x00000009u,0x00000062u,0x00000061u,0x0003003eu,0x0000005fu,0x00000062u,0x00060041u,0x00000059u,0x00000065u,0x00000058u,0x0000001bu,0x00000064u,0x0004003du,0x00000009u,0x00000066u,0x00000065u,0x0003003eu,0x00000063u,0x00000066u,0x0004003du,0x00000007u,0x0000006au,0x00000034u,0x0003003eu,0x00000069u,0x0000006au,0x0004003du,0x00000007u,0x0000006cu,0x0000003cu,0x0003003eu,0x0000006bu,0x0000006cu,0x00060039u,0x0000000au,0x0000006du,0x0000000eu,0x00000069u,0x0000006bu,0x0003003eu,0x00000068u,0x0000006du,0x0004003du,0x00000007u,0x0000006fu,0x00000034u,0x00050080u,0x00000007u,0x00000072u,0x0000006fu,0x00000071u,0x0003003eu,0x00000073u,0x00000072u,0x0004003du,0x00000007u,0x00000075u,0x0000003cu,0x0003003eu,0x00000074u,0x00000075u,0x00060039u,0x0000000au,0x00000076u,0x0000000eu,0x00000073u,0x00000074u,0x0003003eu,0x0000006eu,0x00000076u,0x0004003du,0x00000007u,0x00000078u,0x00000034u,0x00050080u,0x00000007u,0x0000007au,0x00000078u,0x00000079u,0x0003003eu,0x0000007bu,0x0000007au,0x0004003du,0x00000007u,0x0000007du,0x0000003cu,0x0003003eu,0x0000007cu,0x0000007du,0x00060039u,0x0000000au,0x0000007eu,0x0000000eu,0x0000007bu,0x0000007cu,0x0003003eu,0x00000077u,0x0000007eu,0x0004003du,0x00000007u,0x00000080u,0x00000034u,0x00050080u,0x00000007u,0x00000082u,0x00000080u,0x00000081u,0x0003003eu,0x00000083u,0x00000082u,0x0004003du,0x00000007u,0x00000085u,0x0000003cu,0x0003003eu,0x00000084u,0x00000085u,0x00060039u,0x0000000au,0x00000086u,0x0000000eu,0x00000083u,0x00000084u,0x0003003eu,0x0000007fu,0x00000086u,0x0004003du,0x00000007u,0x00000088u,0x00000034u,0x00050080u,0x00000007u,0x0000008au,0x00000088u,0x00000089u,0x0003003eu,0x0000008bu,0x0000008au,0x0004003du,0x00000007u,0x0000008du,0x0000003cu,0x0003003eu,0x0000008cu,0x0000008du,0x00060039u,0x0000000au,0x0000008eu,0x0000000eu,0x0000008bu,0x0000008cu,0x0003003eu,0x00000087u,0x0000008eu,0x0004003du,0x00000016u,0x00000090u,0x00000026u,0x00040064u,0x00000015u,0x00000091u,0x00000090u,0x00050067u,0x00000007u,0x00000092u,0x00000091u,0x0000001bu,0x0003003eu,0x0000008fu,0x00000092u,0x0004003du,0x00000007u,0x00000094u,0x00000034u,0x00050080u,0x00000007u,0x00000095u,0x00000094u,0x00000071u,0x0003003eu,0x00000096u,0x00000095u,0x0004003du,0x00000007u,0x00000098u,0x0000008fu,0x0003003eu,0x00000097u,0x00000098u,0x00060039u,0x00000009u,0x00000099u,0x00000013u,0x00000096u,0x00000097u,0x0003003eu,0x00000093u,0x00000099u,0x0004003du,0x00000007u,0x0000009bu,0x00000034u,0x00050080u,0x00000007u,0x0000009cu,0x0000009bu,0x00000079u,0x0003003eu,0x0000009du,0x0000009cu,0x0004003du,0x00000007u,0x0000009fu,0x0000008fu,0x0003003eu,0x0000009eu,0x0000009fu,0x00060039u,0x00000009u,0x000000a0u,0x00000013u,0x0000009du,0x0000009eu,0x0003003eu,0x0000009au,0x000000a0u,0x0004003du,0x00000007u,0x000000a2u,0x00000034u,0x00050080u,0x00000007u,0x000000a3u,0x000000a2u,0x00000081u,0x0003003eu,0x000000a4u,0x000000a3u,0x0004003du,0x00000007u,0x000000a6u,0x0000008fu,0x0003003eu,0x000000a5u,0x000000a6u,0x00060039u,0x00000009u,0x000000a7u,0x00000013u,0x000000a4u,0x000000a5u,0x0003003eu,0x000000a1u,0x000000a7u,0x0004003du,0x00000007u,0x000000a9u,0x00000034u,0x00050080u,0x00000007u,0x000000aau,0x000000a9u,0x00000089u,0x0003003eu,0x000000abu,0x000000aau,0x0004003du,0x00000007u,0x000000adu,0x0000008fu,0x0003003eu,0x000000acu,0x000000adu,0x00060039u,0x00000009u,0x000000aeu,0x00000013u,0x000000abu,0x000000acu,0x0003003eu,0x000000a8u,0x000000aeu,0x0004003du,0x00000009u,0x000000b1u,0x0000009au,0x0004003du,0x00000009u,0x000000b2u,0x00000093u,0x00050083u,0x00000009u,0x000000b3u,0x000000b1u,0x000000b2u,0x0004003du,0x00000009u,0x000000b4u,0x000000a8u,0x0004003du,0x00000009u,0x000000b5u,0x000000a1u,0x00050083u,0x00000009u,0x000000b6u,0x000000b4u,0x000000b5u,0x00050050u,0x000000b7u,0x000000b8u,0x000000b3u,0x000000b6u,0x0006000cu,0x00000009u,0x000000b9u,0x00000001u,0x00000042u,0x000000b8u,0x00050085u,0x00000009u,0x000000bau,0x000000b0u,0x000000b9u,0x0003003eu,0x000000afu,0x000000bau,0x0004003du,0x00000009u,0x000000bcu,0x0000005fu,0x0004007fu,0x00000009u,0x000000bdu,0x000000bcu,0x0004003du,0x00000009u,0x000000beu,0x000000afu,0x00050085u,0x00000009u,0x000000bfu,0x000000bdu,0x000000beu,0x0006000cu,0x00000009u,0x000000c0u,0x00000001u,0x0000001bu,0x000000bfu,0x0008000cu,0x00000009u,0x000000c3u,0x00000001u,0x0000002bu,0x000000c0u,0x000000c1u,0x000000c2u,0x0003003eu,0x000000bbu,0x000000c3u,0x0004003du,0x0000000au,0x000000c5u,0x0000006eu,0x0004003du,0x0000000au,0x000000c6u,0x00000068u,0x00050083u,0x0000000au,0x000000c7u,0x000000c5u,0x000000c6u,0x0003003eu,0x000000c4u,0x000000c7u,0x0004003du,0x0000000au,0x000000c9u,0x00000077u,0x0004003du,0x0000000au,0x000000cau,0x00000068u,0x00050083u,0x0000000au,0x000000cbu,0x000000c9u,0x000000cau,0x0003003eu,0x000000c8u,0x000000cbu,0x0004003du,0x0000000au,0x000000cdu,0x0000007fu,0x0004003du,0x0000000au,0x000000ceu,0x00000068u,0x00050083u,0x0000000au,0x000000cfu,0x000000cdu,0x000000ceu,0x0003003eu,0x000000ccu,0x000000cfu,0x0004003du,0x0000000au,0x000000d1u,0x00000087u,0x0004003du,0x0000000au,0x000000d2u,0x00000068u,0x00050083u,0x0000000au,0x000000d3u,0x000000d1u,0x000000d2u,0x0003003eu,0x000000d0u,0x000000d3u,0x0004003du,0x00000009u,0x000000d5u,0x00000063u,0x0004003du,0x00000009u,0x000000d6u,0x00000063u,0x00050085u,0x00000009u,0x000000d7u,0x000000d5u,0x000000d6u,0x0003003eu,0x000000d4u,0x000000d7u,0x0004003du,0x00000009u,0x000000d9u,0x000000bbu,0x0004003du,0x0000000au,0x000000dau,0x000000c4u,0x0004003du,0x0000000au,0x000000dbu,0x000000c4u,0x00050094u,0x00000009u,0x000000dcu,0x000000dau,0x000000dbu,0x0004003du,0x00000009u,0x000000ddu,0x000000d4u,0x00050081u,0x00000009u,0x000000deu,0x000000dcu,0x000000ddu,0x0006000cu,0x00000009u,0x000000dfu,0x00000001u,0x00000020u,0x000000deu,0x00050085u,0x00000009u,0x000000e0u,0x000000d9u,0x000000dfu,0x0003003eu,0x000000d8u,0x000000e0u,0x0004003du,0x00000009u,0x000000e2u,0x000000bbu,0x0004003du,0x0000000au,0x000000e3u,0x000000c8u,0x0004003du,0x0000000au,0x000000e4u,0x000000c8u,0x00050094u,0x00000009u,0x000000e5u,0x000000e3u,0x000000e4u,0x0004003du,0x00000009u,0x000000e6u,0x000000d4u,0x00050081u,0x00000009u,0x000000e7u,0x000000e5u,0x000000e6u,0x0006000cu,0x00000009u,0x000000e8u,0x00000001u,0x00000020u,0x000000e7u,0x00050085u,0x00000009u,0x000000e9u,0x000000e2u,0x000000e8u,0x0003003eu,0x000000e1u,0x000000e9u,0x0004003du,0x00000009u,0x000000ebu,0x000000bbu,0x0004003du,0x0000000au,0x000000ecu,0x000000ccu,0x0004003du,0x0000000au,0x000000edu,0x000000ccu,0x00050094u,0x00000009u,0x000000eeu,0x000000ecu,0x000000edu,0x0004003du,0x00000009u,0x000000efu,0x000000d4u,0x00050081u,0x00000009u,0x000000f0u,0x000000eeu,0x000000efu,0x0006000cu,0x00000009u,0x000000f1u,0x00000001u,0x00000020u,0x000000f0u,0x00050085u,0x00000009u,0x000000f2u,0x000000ebu,0x000000f1u,0x0003003eu,0x000000eau,0x000000f2u,0x0004003du,0x00000009u,0x000000f4u,0x000000bbu,0x0004003du,0x0000000au,0x000000f5u,0x000000d0u,0x0004003du,0x0000000au,0x000000f6u,0x000000d0u,0x00050094u,0x00000009u,0x000000f7u,0x000000f5u,0x000000f6u,0x0004003du,0x00000009u,0x000000f8u,0x000000d4u,0x00050081u,0x00000009u,0x000000f9u,0x000000f7u,0x000000f8u,0x0006000cu,0x00000009u,0x000000fau,0x00000001u,0x00000020u,0x000000f9u,0x00050085u,0x00000009u,0x000000fbu,0x000000f4u,0x000000fau,0x0003003eu,0x000000f3u,0x000000fbu,0x0004003du,0x00000009u,0x000000fdu,0x000000d8u,0x0004003du,0x00000009u,0x000000feu,0x000000e1u,0x00050081u,0x00000009u,0x000000ffu,0x000000fdu,0x000000feu,0x0004003du,0x00000009u,0x00000100u,0x000000eau,0x00050081u,0x00000009u,0x00000101u,0x000000ffu,0x00000100u,0x0004003du,0x00000009u,0x00000102u,0x000000f3u,0x00050081u,0x00000009u,0x00000103u,0x00000101u,0x00000102u,0x0003003eu,0x000000fcu,0x00000103u,0x0004003du,0x00000009u,0x00000105u,0x000000d8u,0x0004003du,0x0000000au,0x00000106u,0x0000006eu,0x0005008eu,0x0000000au,0x00000107u,0x00000106u,0x00000105u,0x0004003du,0x00000009u,0x00000108u,0x000000e1u,0x0004003du,0x0000000au,0x00000109u,0x00000077u,0x0005008eu,0x0000000au,0x0000010au,0x00000109u,0x00000108u,0x00050081u,0x0000000au,0x0000010bu,0x00000107u,0x0000010au,0x0004003du,0x00000009u,0x0000010cu,0x000000eau,0x0004003du,0x0000000au,0x0000010du,0x0000007fu,0x0005008eu,0x0000000au,0x0000010eu,0x0000010du,0x0000010cu,0x00050081u,0x0000000au,0x0000010fu,0x0000010bu,0x0000010eu,0x0004003du,0x00000009u,0x00000110u,0x000000f3u,0x0004003du,0x0000000au,0x00000111u,0x00000087u,0x0005008eu,0x0000000au,0x00000112u,0x00000111u,0x00000110u,0x00050081u,0x0000000au,0x00000113u,0x0000010fu,0x00000112u,0x0003003eu,0x00000104u,0x00000113u,0x0004003du,0x0000000au,0x00000115u,0x00000068u,0x0004003du,0x00000009u,0x00000116u,0x00000055u,0x0004003du,0x0000000au,0x00000117u,0x00000104u,0x0005008eu,0x0000000au,0x00000118u,0x00000117u,0x00000116u,0x00050081u,0x0000000au,0x00000119u,0x00000115u,0x00000118u,0x0004003du,0x00000009u,0x0000011au,0x00000055u,0x0004003du,0x00000009u,0x0000011bu,0x000000fcu,0x00050085u,0x00000009u,0x0000011cu,0x0000011au,0x0000011bu,0x00050081u,0x00000009u,0x0000011du,0x000000c2u,0x0000011cu,0x00070050u,0x0000000au,0x0000011eu,0x0000011du,0x0000011du,0x0000011du,0x0000011du,0x00050088u,0x0000000au,0x0000011fu,0x00000119u,0x0000011eu,0x0003003eu,0x00000114u,0x0000011fu,0x0004003du,0x00000016u,0x00000122u,0x00000121u,0x0004003du,0x00000007u,0x00000123u,0x00000034u,0x0004003du,0x00000007u,0x00000124u,0x0000003cu,0x00050050u,0x00000007u,0x00000125u,0x0000001eu,0x0000001eu,0x00050082u,0x00000007u,0x00000126u,0x00000124u,0x00000125u,0x0008000cu,0x00000007u,0x00000127u,0x00000001u,0x0000002du,0x00000123u,0x0000001cu,0x00000126u,0x00040064u,0x00000015u,0x00000128u,0x00000122u,0x0007005fu,0x0000000au,0x00000129u,0x00000128u,0x00000127u,0x00000002u,0x0000001bu,0x0003003eu,0x00000120u,0x00000129u,0x0004003du,0x00000009u,0x0000012bu,0x00000055u,0x0004003du,0x00000009u,0x0000012cu,0x0000005cu,0x00050085u,0x00000009u,0x0000012du,0x0000012bu,0x0000012cu,0x0003003eu,0x0000012au,0x0000012du,0x0004003du,0x0000000au,0x0000012fu,0x00000114u,0x0004003du,0x0000000au,0x00000130u,0x00000120u,0x00050083u,0x0000000au,0x00000131u,0x0000012fu,0x00000130u,0x0003003eu,0x0000012eu,0x00000131u,0x0004003du,0x0000000au,0x00000133u,0x00000114u,0x0004003du,0x0000000au,0x00000134u,0x0000012eu,0x0004003du,0x00000009u,0x00000135u,0x0000012au,0x0004007fu,0x00000009u,0x00000136u,0x00000135u,0x00070050u,0x0000000au,0x00000137u,0x00000136u,0x00000136u,0x00000136u,0x00000136u,0x0004003du,0x00000009u,0x00000138u,0x0000012au,0x00070050u,0x0000000au,0x00000139u,0x00000138u,0x00000138u,0x00000138u,0x00000138u,0x0008000cu,0x0000000au,0x0000013au,0x00000001u,0x0000002bu,0x00000134u,0x00000137u,0x00000139u,0x00050083u,0x0000000au,0x0000013bu,0x00000133u,0x0000013au,0x0003003eu,0x00000132u,0x0000013bu,0x0004003du,0x0000013cu,0x0000013fu,0x0000013eu,0x0004003du,0x00000007u,0x00000140u,0x00000034u,0x0004003du,0x0000000au,0x00000141u,0x00000132u,0x00040063u,0x0000013fu,0x00000140u,0x00000141u,0x000100fdu,0x00010038u,0x00050036u,0x0000000au,0x0000000eu,0x00000000u,0x0000000bu,0x00030037u,0x00000008u,0x0000000cu,0x00030037u,0x00000008u,0x0000000du,0x000200f8u,0x0000000fu,0x0004003du,0x00000016u,0x00000019u,0x00000018u,0x0004003du,0x00000007u,0x0000001au,0x0000000cu,0x0004003du,0x00000007u,0x0000001du,0x0000000du,0x00050050u,0x00000007u,0x0000001fu,0x0000001eu,0x0000001eu,0x00050082u,0x00000007u,0x00000020u,0x0000001du,0x0000001fu,0x0008000cu,0x00000007u,0x00000021u,0x00000001u,0x0000002du,0x0000001au,0x0000001cu,0x00000020u,0x00040064u,0x00000015u,0x00000022u,0x00000019u,0x0007005fu,0x0000000au,0x00000023u,0x00000022u,0x00000021u,0x00000002u,0x0000001bu,0x000200feu,0x00000023u,0x00010038u,0x00050036u,0x00000009u,0x00000013u,0x00000000u,0x00000010u,0x00030037u,0x00000008u,0x00000011u,0x00030037u,0x00000008u,0x00000012u,0x000200f8u,0x00000014u,0x0004003du,0x00000016u,0x00000027u,0x00000026u,0x0004003du,0x00000007u,0x00000028u,0x00000011u,0x0004003du,0x00000007u,0x00000029u,0x00000012u,0x00050050u,0x00000007u,0x0000002au,0x0000001eu,0x0000001eu,0x00050082u,0x00000007u,0x0000002bu,0x00000029u,0x0000002au,0x0008000cu,0x00000007u,0x0000002cu,0x00000001u,0x0000002du,0x00000028u,0x0000001cu,0x0000002bu,0x00040064u,0x00000015u,0x0000002du,0x00000027u,0x0007005fu,0x0000000au,0x0000002eu,0x0000002du,0x0000002cu,0x00000002u,0x0000001bu,0x00050051u,0x00000009u,0x00000031u,0x0000002eu,0x00000000u,0x000200feu,0x00000031u,0x00010038u}; -static const size_t OF3_FLOWREG_LEN = 1936; +static const uint32_t OF3_FLOWREG_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000196u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x00000037u,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00040005u,0x00000018u,0x6f6c4675u,0x006e4977u,0x00040005u,0x00000026u,0x6d754c75u,0x00000061u,0x00080005u,0x00000037u,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x00000056u,0x00000055u,0x00050006u,0x00000056u,0x00000000u,0x61726170u,0x0000736du,0x00030005u,0x00000058u,0x00000000u,0x00050005u,0x00000118u,0x6f6c4675u,0x73624f77u,0x00000000u,0x00050005u,0x00000131u,0x6f6c4675u,0x74754f77u,0x00000000u,0x00040047u,0x00000018u,0x00000021u,0x00000020u,0x00040047u,0x00000018u,0x00000022u,0x00000000u,0x00040047u,0x00000026u,0x00000021u,0x00000022u,0x00040047u,0x00000026u,0x00000022u,0x00000000u,0x00040047u,0x00000037u,0x0000000bu,0x0000001cu,0x00030047u,0x00000056u,0x00000002u,0x00050048u,0x00000056u,0x00000000u,0x00000023u,0x00000000u,0x00040047u,0x00000058u,0x00000021u,0x00000000u,0x00040047u,0x00000058u,0x00000022u,0x00000000u,0x00040047u,0x00000118u,0x00000021u,0x00000021u,0x00040047u,0x00000118u,0x00000022u,0x00000000u,0x00030047u,0x00000131u,0x00000019u,0x00040047u,0x00000131u,0x00000021u,0x00000030u,0x00040047u,0x00000131u,0x00000022u,0x00000000u,0x00040047u,0x00000136u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u,0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00030016u,0x00000009u,0x00000020u,0x00040017u,0x0000000au,0x00000009u,0x00000004u,0x00090019u,0x00000015u,0x00000009u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000016u,0x00000015u,0x00040020u,0x00000017u,0x00000000u,0x00000016u,0x0004003bu,0x00000017u,0x00000018u,0x00000000u,0x0004002bu,0x00000006u,0x0000001bu,0x00000000u,0x0005002cu,0x00000007u,0x0000001cu,0x0000001bu,0x0000001bu,0x0004002bu,0x00000006u,0x0000001eu,0x00000001u,0x0004003bu,0x00000017u,0x00000026u,0x00000000u,0x00040015u,0x0000002fu,0x00000020u,0x00000000u,0x0004002bu,0x0000002fu,0x00000030u,0x00000000u,0x00040017u,0x00000035u,0x0000002fu,0x00000003u,0x00040020u,0x00000036u,0x00000001u,0x00000035u,0x0004003bu,0x00000036u,0x00000037u,0x00000001u,0x00040017u,0x00000038u,0x0000002fu,0x00000002u,0x00020014u,0x00000040u,0x0004002bu,0x0000002fu,0x0000004au,0x00000001u,0x0003001eu,0x00000056u,0x0000000au,0x00040020u,0x00000057u,0x00000002u,0x00000056u,0x0004003bu,0x00000057u,0x00000058u,0x00000002u,0x00040020u,0x00000059u,0x00000002u,0x00000009u,0x0004002bu,0x0000002fu,0x00000060u,0x00000002u,0x0004002bu,0x0000002fu,0x00000064u,0x00000003u,0x0004002bu,0x00000006u,0x0000006fu,0xffffffffu,0x0005002cu,0x00000007u,0x00000070u,0x0000006fu,0x0000001bu,0x0005002cu,0x00000007u,0x00000078u,0x0000001eu,0x0000001bu,0x0005002cu,0x00000007u,0x00000080u,0x0000001bu,0x0000006fu,0x0005002cu,0x00000007u,0x00000088u,0x0000001bu,0x0000001eu,0x0004002bu,0x00000009u,0x000000abu,0x3f000000u,0x00040017u,0x000000b2u,0x00000009u,0x00000002u,0x0004002bu,0x00000009u,0x000000bcu,0x3d4ccccdu,0x0004002bu,0x00000009u,0x000000bdu,0x3f800000u,0x0004003bu,0x00000017u,0x00000118u,0x00000000u,0x00090019u,0x0000012fu,0x00000009u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u,0x00000130u,0x00000000u,0x0000012fu,0x0004003bu,0x00000130u,0x00000131u,0x00000000u,0x0004002bu,0x0000002fu,0x00000135u,0x00000010u,0x0006002cu,0x00000035u,0x00000136u,0x00000135u,0x00000135u,0x0000004au,0x0005002cu,0x00000007u,0x00000195u,0x0000001eu,0x0000001eu,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x000300f7u,0x00000137u,0x00000000u,0x000300fbu,0x00000030u,0x00000138u,0x000200f8u,0x00000138u,0x0004003du,0x00000035u,0x00000039u,0x00000037u,0x0007004fu,0x00000038u,0x0000003au,0x00000039u,0x00000039u,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x0000003bu,0x0000003au,0x0004003du,0x00000016u,0x0000003du,0x00000018u,0x00040064u,0x00000015u,0x0000003eu,0x0000003du,0x00050067u,0x00000007u,0x0000003fu,0x0000003eu,0x0000001bu,0x00050051u,0x00000006u,0x00000043u,0x0000003bu,0x00000000u,0x00050051u,0x00000006u,0x00000045u,0x0000003fu,0x00000000u,0x000500afu,0x00000040u,0x00000046u,0x00000043u,0x00000045u,0x000400a8u,0x00000040u,0x00000047u,0x00000046u,0x000300f7u,0x00000049u,0x00000000u,0x000400fau,0x00000047u,0x00000048u,0x00000049u,0x000200f8u,0x00000048u,0x00050051u,0x00000006u,0x0000004cu,0x0000003bu,0x00000001u,0x00050051u,0x00000006u,0x0000004eu,0x0000003fu,0x00000001u,0x000500afu,0x00000040u,0x0000004fu,0x0000004cu,0x0000004eu,0x000200f9u,0x00000049u,0x000200f8u,0x00000049u,0x000700f5u,0x00000040u,0x00000050u,0x00000046u,0x00000138u,0x0000004fu,0x00000048u,0x000300f7u,0x00000052u,0x00000000u,0x000400fau,0x00000050u,0x00000051u,0x00000052u,0x000200f8u,0x00000051u,0x000200f9u,0x00000137u,0x000200f8u,0x00000052u,0x00060041u,0x00000059u,0x0000005au,0x00000058u,0x0000001bu,0x00000030u,0x0004003du,0x00000009u,0x0000005bu,0x0000005au,0x00060041u,0x00000059u,0x0000005du,0x00000058u,0x0000001bu,0x0000004au,0x0004003du,0x00000009u,0x0000005eu,0x0000005du,0x00060041u,0x00000059u,0x00000061u,0x00000058u,0x0000001bu,0x00000060u,0x0004003du,0x00000009u,0x00000062u,0x00000061u,0x00060041u,0x00000059u,0x00000065u,0x00000058u,0x0000001bu,0x00000064u,0x0004003du,0x00000009u,0x00000066u,0x00000065u,0x0004003du,0x00000016u,0x00000069u,0x00000018u,0x00040064u,0x00000015u,0x0000006bu,0x00000069u,0x0007005fu,0x0000000au,0x0000006cu,0x0000006bu,0x0000003bu,0x00000002u,0x0000001bu,0x00050080u,0x00000007u,0x00000071u,0x0000003bu,0x00000070u,0x0004003du,0x00000016u,0x0000013fu,0x00000018u,0x00050082u,0x00000007u,0x00000143u,0x0000003fu,0x00000195u,0x0008000cu,0x00000007u,0x00000144u,0x00000001u,0x0000002du,0x00000071u,0x0000001cu,0x00000143u,0x00040064u,0x00000015u,0x00000145u,0x0000013fu,0x0007005fu,0x0000000au,0x00000146u,0x00000145u,0x00000144u,0x00000002u,0x0000001bu,0x00050080u,0x00000007u,0x00000079u,0x0000003bu,0x00000078u,0x0004003du,0x00000016u,0x00000149u,0x00000018u,0x0008000cu,0x00000007u,0x0000014eu,0x00000001u,0x0000002du,0x00000079u,0x0000001cu,0x00000143u,0x00040064u,0x00000015u,0x0000014fu,0x00000149u,0x0007005fu,0x0000000au,0x00000150u,0x0000014fu,0x0000014eu,0x00000002u,0x0000001bu,0x00050080u,0x00000007u,0x00000081u,0x0000003bu,0x00000080u,0x0004003du,0x00000016u,0x00000153u,0x00000018u,0x0008000cu,0x00000007u,0x00000158u,0x00000001u,0x0000002du,0x00000081u,0x0000001cu,0x00000143u,0x00040064u,0x00000015u,0x00000159u,0x00000153u,0x0007005fu,0x0000000au,0x0000015au,0x00000159u,0x00000158u,0x00000002u,0x0000001bu,0x00050080u,0x00000007u,0x00000089u,0x0000003bu,0x00000088u,0x0004003du,0x00000016u,0x0000015du,0x00000018u,0x0008000cu,0x00000007u,0x00000162u,0x00000001u,0x0000002du,0x00000089u,0x0000001cu,0x00000143u,0x00040064u,0x00000015u,0x00000163u,0x0000015du,0x0007005fu,0x0000000au,0x00000164u,0x00000163u,0x00000162u,0x00000002u,0x0000001bu,0x0004003du,0x00000016u,0x00000167u,0x00000026u,0x00040064u,0x00000015u,0x0000016du,0x00000167u,0x0007005fu,0x0000000au,0x0000016eu,0x0000016du,0x00000144u,0x00000002u,0x0000001bu,0x00050051u,0x00000009u,0x0000016fu,0x0000016eu,0x00000000u,0x0004003du,0x00000016u,0x00000172u,0x00000026u,0x00040064u,0x00000015u,0x00000178u,0x00000172u,0x0007005fu,0x0000000au,0x00000179u,0x00000178u,0x0000014eu,0x00000002u,0x0000001bu,0x00050051u,0x00000009u,0x0000017au,0x00000179u,0x00000000u,0x0004003du,0x00000016u,0x0000017du,0x00000026u,0x00040064u,0x00000015u,0x00000183u,0x0000017du,0x0007005fu,0x0000000au,0x00000184u,0x00000183u,0x00000158u,0x00000002u,0x0000001bu,0x00050051u,0x00000009u,0x00000185u,0x00000184u,0x00000000u,0x0004003du,0x00000016u,0x00000188u,0x00000026u,0x00040064u,0x00000015u,0x0000018eu,0x00000188u,0x0007005fu,0x0000000au,0x0000018fu,0x0000018eu,0x00000162u,0x00000002u,0x0000001bu,0x00050051u,0x00000009u,0x00000190u,0x0000018fu,0x00000000u,0x00050083u,0x00000009u,0x000000aeu,0x0000017au,0x0000016fu,0x00050083u,0x00000009u,0x000000b1u,0x00000190u,0x00000185u,0x00050050u,0x000000b2u,0x000000b3u,0x000000aeu,0x000000b1u,0x0006000cu,0x00000009u,0x000000b4u,0x00000001u,0x00000042u,0x000000b3u,0x00050085u,0x00000009u,0x000000b5u,0x000000abu,0x000000b4u,0x0004007fu,0x00000009u,0x000000b8u,0x00000062u,0x00050085u,0x00000009u,0x000000bau,0x000000b8u,0x000000b5u,0x0006000cu,0x00000009u,0x000000bbu,0x00000001u,0x0000001bu,0x000000bau,0x0008000cu,0x00000009u,0x000000beu,0x00000001u,0x0000002bu,0x000000bbu,0x000000bcu,0x000000bdu,0x00050083u,0x0000000au,0x000000c2u,0x00000146u,0x0000006cu,0x00050083u,0x0000000au,0x000000c6u,0x00000150u,0x0000006cu,0x00050083u,0x0000000au,0x000000cau,0x0000015au,0x0000006cu,0x00050083u,0x0000000au,0x000000ceu,0x00000164u,0x0000006cu,0x00050085u,0x00000009u,0x000000d2u,0x00000066u,0x00000066u,0x00050094u,0x00000009u,0x000000d6u,0x000000c2u,0x000000c2u,0x00050081u,0x00000009u,0x000000d8u,0x000000d6u,0x000000d2u,0x0006000cu,0x00000009u,0x000000d9u,0x00000001u,0x00000020u,0x000000d8u,0x00050094u,0x00000009u,0x000000ddu,0x000000c6u,0x000000c6u,0x00050081u,0x00000009u,0x000000dfu,0x000000ddu,0x000000d2u,0x0006000cu,0x00000009u,0x000000e0u,0x00000001u,0x00000020u,0x000000dfu,0x00050094u,0x00000009u,0x000000e4u,0x000000cau,0x000000cau,0x00050081u,0x00000009u,0x000000e6u,0x000000e4u,0x000000d2u,0x0006000cu,0x00000009u,0x000000e7u,0x00000001u,0x00000020u,0x000000e6u,0x00050094u,0x00000009u,0x000000ebu,0x000000ceu,0x000000ceu,0x00050081u,0x00000009u,0x000000edu,0x000000ebu,0x000000d2u,0x0006000cu,0x00000009u,0x000000eeu,0x00000001u,0x00000020u,0x000000edu,0x00050081u,0x00000009u,0x000000f3u,0x000000d9u,0x000000e0u,0x00050081u,0x00000009u,0x000000f5u,0x000000f3u,0x000000e7u,0x00050081u,0x00000009u,0x000000f7u,0x000000f5u,0x000000eeu,0x00050085u,0x00000009u,0x000000f8u,0x000000beu,0x000000f7u,0x0005008eu,0x0000000au,0x000000fdu,0x00000146u,0x000000d9u,0x0005008eu,0x0000000au,0x00000100u,0x00000150u,0x000000e0u,0x00050081u,0x0000000au,0x00000101u,0x000000fdu,0x00000100u,0x0005008eu,0x0000000au,0x00000104u,0x0000015au,0x000000e7u,0x00050081u,0x0000000au,0x00000105u,0x00000101u,0x00000104u,0x0005008eu,0x0000000au,0x00000108u,0x00000164u,0x000000eeu,0x00050081u,0x0000000au,0x00000109u,0x00000105u,0x00000108u,0x0005008eu,0x0000000au,0x0000010au,0x00000109u,0x000000beu,0x0005008eu,0x0000000au,0x0000010fu,0x0000010au,0x0000005bu,0x00050081u,0x0000000au,0x00000110u,0x0000006cu,0x0000010fu,0x00050085u,0x00000009u,0x00000113u,0x0000005bu,0x000000f8u,0x00050081u,0x00000009u,0x00000114u,0x000000bdu,0x00000113u,0x00070050u,0x0000000au,0x00000115u,0x00000114u,0x00000114u,0x00000114u,0x00000114u,0x00050088u,0x0000000au,0x00000116u,0x00000110u,0x00000115u,0x0004003du,0x00000016u,0x00000119u,0x00000118u,0x00040064u,0x00000015u,0x0000011bu,0x00000119u,0x0007005fu,0x0000000au,0x0000011cu,0x0000011bu,0x0000003bu,0x00000002u,0x0000001bu,0x00050085u,0x00000009u,0x00000120u,0x0000005bu,0x0000005eu,0x00050083u,0x0000000au,0x00000124u,0x00000116u,0x0000011cu,0x0004007fu,0x00000009u,0x00000129u,0x00000120u,0x00070050u,0x0000000au,0x0000012au,0x00000129u,0x00000129u,0x00000129u,0x00000129u,0x00070050u,0x0000000au,0x0000012cu,0x00000120u,0x00000120u,0x00000120u,0x00000120u,0x0008000cu,0x0000000au,0x0000012du,0x00000001u,0x0000002bu,0x00000124u,0x0000012au,0x0000012cu,0x00050083u,0x0000000au,0x0000012eu,0x00000116u,0x0000012du,0x0004003du,0x0000012fu,0x00000132u,0x00000131u,0x00040063u,0x00000132u,0x0000003bu,0x0000012eu,0x000200f9u,0x00000137u,0x000200f8u,0x00000137u,0x000100fdu,0x00010038u}; +static const size_t OF3_FLOWREG_LEN = 981; static const uint32_t DDFG_SYNTH_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000208u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x0000001cu,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00050005u,0x0000000bu,0x616d756cu,0x33667628u,0x0000003bu,0x00030005u,0x0000000au,0x00000063u,0x00030005u,0x00000018u,0x00646967u,0x00080005u,0x0000001cu,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x00000021u,0x006d6964u,0x00040005u,0x00000024u,0x74754f75u,0x00000000u,0x00040005u,0x0000003eu,0x44766e69u,0x00006d69u,0x00030005u,0x00000044u,0x00007675u,0x00030005u,0x0000004du,0x00000055u,0x00060006u,0x0000004du,0x00000000u,0x776f6c66u,0x6c616353u,0x00000065u,0x00050006u,0x0000004du,0x00000001u,0x68706c61u,0x00000061u,0x00050006u,0x0000004du,0x00000002u,0x61746562u,0x00000000u,0x00050006u,0x0000004du,0x00000003u,0x626d616cu,0x00006164u,0x00050006u,0x0000004du,0x00000004u,0x69737065u,0x006e6f6cu,0x00060006u,0x0000004du,0x00000005u,0x746f6870u,0x6163536fu,0x0000656cu,0x00050006u,0x0000004du,0x00000006u,0x30646170u,0x00000000u,0x00050006u,0x0000004du,0x00000007u,0x31646170u,0x00000000u,0x00050006u,0x0000004du,0x00000008u,0x52647568u,0x00746365u,0x00030005u,0x0000004fu,0x00000000u,0x00040005u,0x0000008cu,0x72754375u,0x00000072u,0x00030005u,0x00000098u,0x00676264u,0x00030005u,0x0000009fu,0x00007366u,0x00040005u,0x000000a9u,0x64774273u,0x00000000u,0x00050005u,0x000000aau,0x6f6c4675u,0x64774277u,0x00000000u,0x00040005u,0x000000aeu,0x64774673u,0x00000000u,0x00050005u,0x000000afu,0x6f6c4675u,0x64774677u,0x00000000u,0x00030005u,0x000000b3u,0x00313046u,0x00030005u,0x000000bau,0x00303146u,0x00040005u,0x000000c1u,0x31306663u,0x00000000u,0x00040005u,0x000000c5u,0x30316663u,0x00000000u,0x00030005u,0x000000c9u,0x0031306du,0x00030005u,0x000000d5u,0x0030316du,0x00030005u,0x000000e0u,0x00004170u,0x00030005u,0x000000e8u,0x00004270u,0x00030005u,0x000000f0u,0x00003043u,0x00040005u,0x000000f1u,0x65725075u,0x00000076u,0x00030005u,0x000000f6u,0x00003143u,0x00030005u,0x000000fbu,0x00004165u,0x00040005u,0x000000fcu,0x61726170u,0x0000006du,0x00040005u,0x0000010cu,0x61726170u,0x0000006du,0x00030005u,0x00000111u,0x00004265u,0x00040005u,0x00000112u,0x61726170u,0x0000006du,0x00040005u,0x00000122u,0x61726170u,0x0000006du,0x00040005u,0x00000127u,0x76556266u,0x00000000u,0x00040005u,0x0000012bu,0x65526266u,0x00646973u,0x00040005u,0x00000138u,0x736e6f63u,0x00747369u,0x00030005u,0x00000149u,0x0000305au,0x00030005u,0x00000157u,0x0000315au,0x00040005u,0x00000163u,0x30756174u,0x00000000u,0x00040005u,0x00000167u,0x31756174u,0x00000000u,0x00040005u,0x0000016au,0x78616d7au,0x00000000u,0x00030005u,0x0000016eu,0x00003057u,0x00030005u,0x00000179u,0x00003157u,0x00040005u,0x00000183u,0x6d757357u,0x00000000u,0x00040005u,0x00000187u,0x70726177u,0x00006465u,0x00050005u,0x000001a0u,0x736f7263u,0x64616673u,0x00000065u,0x00050005u,0x000001adu,0x746f6870u,0x7272456fu,0x00000000u,0x00050005u,0x000001b1u,0x746f6870u,0x7572546fu,0x00007473u,0x00040005u,0x000001b7u,0x73757274u,0x00000074u,0x00040005u,0x000001c3u,0x76657270u,0x00000043u,0x00040005u,0x000001c8u,0x72727563u,0x00000043u,0x00050005u,0x000001cdu,0x746e6f63u,0x44746e65u,0x00666669u,0x00050005u,0x000001d2u,0x72746e75u,0x65747375u,0x00000064u,0x00040005u,0x000001d7u,0x44676962u,0x00666669u,0x00050005u,0x000001dcu,0x70616e73u,0x75436f54u,0x00007272u,0x00040005u,0x000001e5u,0x6374756fu,0x00000000u,0x00030005u,0x000001eeu,0x0067616du,0x00030005u,0x000001f2u,0x0000006eu,0x00030005u,0x000001f6u,0x00746173u,0x00040047u,0x0000001cu,0x0000000bu,0x0000001cu,0x00030047u,0x00000024u,0x00000019u,0x00040047u,0x00000024u,0x00000021u,0x00000030u,0x00040047u,0x00000024u,0x00000022u,0x00000000u,0x00030047u,0x0000004du,0x00000002u,0x00050048u,0x0000004du,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x0000004du,0x00000001u,0x00000023u,0x00000004u,0x00050048u,0x0000004du,0x00000002u,0x00000023u,0x00000008u,0x00050048u,0x0000004du,0x00000003u,0x00000023u,0x0000000cu,0x00050048u,0x0000004du,0x00000004u,0x00000023u,0x00000010u,0x00050048u,0x0000004du,0x00000005u,0x00000023u,0x00000014u,0x00050048u,0x0000004du,0x00000006u,0x00000023u,0x00000018u,0x00050048u,0x0000004du,0x00000007u,0x00000023u,0x0000001cu,0x00050048u,0x0000004du,0x00000008u,0x00000023u,0x00000020u,0x00040047u,0x0000004fu,0x00000021u,0x00000000u,0x00040047u,0x0000004fu,0x00000022u,0x00000000u,0x00040047u,0x0000008cu,0x00000021u,0x00000021u,0x00040047u,0x0000008cu,0x00000022u,0x00000000u,0x00040047u,0x000000aau,0x00000021u,0x00000023u,0x00040047u,0x000000aau,0x00000022u,0x00000000u,0x00040047u,0x000000afu,0x00000021u,0x00000022u,0x00040047u,0x000000afu,0x00000022u,0x00000000u,0x00040047u,0x000000f1u,0x00000021u,0x00000020u,0x00040047u,0x000000f1u,0x00000022u,0x00000000u,0x00040047u,0x00000207u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00030016u,0x00000006u,0x00000020u,0x00040017u,0x00000007u,0x00000006u,0x00000003u,0x00040020u,0x00000008u,0x00000007u,0x00000007u,0x00040021u,0x00000009u,0x00000006u,0x00000008u,0x0004002bu,0x00000006u,0x0000000eu,0x3e59b3d0u,0x0004002bu,0x00000006u,0x0000000fu,0x3f371759u,0x0004002bu,0x00000006u,0x00000010u,0x3d93dd98u,0x0006002cu,0x00000007u,0x00000011u,0x0000000eu,0x0000000fu,0x00000010u,0x00040015u,0x00000015u,0x00000020u,0x00000001u,0x00040017u,0x00000016u,0x00000015u,0x00000002u,0x00040020u,0x00000017u,0x00000007u,0x00000016u,0x00040015u,0x00000019u,0x00000020u,0x00000000u,0x00040017u,0x0000001au,0x00000019u,0x00000003u,0x00040020u,0x0000001bu,0x00000001u,0x0000001au,0x0004003bu,0x0000001bu,0x0000001cu,0x00000001u,0x00040017u,0x0000001du,0x00000019u,0x00000002u,0x00090019u,0x00000022u,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000004u,0x00040020u,0x00000023u,0x00000000u,0x00000022u,0x0004003bu,0x00000023u,0x00000024u,0x00000000u,0x00020014u,0x00000027u,0x0004002bu,0x00000019u,0x00000028u,0x00000000u,0x00040020u,0x00000029u,0x00000007u,0x00000015u,0x0004002bu,0x00000019u,0x00000032u,0x00000001u,0x00040017u,0x0000003cu,0x00000006u,0x00000002u,0x00040020u,0x0000003du,0x00000007u,0x0000003cu,0x0004002bu,0x00000006u,0x0000003fu,0x3f800000u,0x0004002bu,0x00000006u,0x00000047u,0x3f000000u,0x00040017u,0x0000004cu,0x00000006u,0x00000004u,0x000b001eu,0x0000004du,0x00000006u,0x00000006u,0x00000006u,0x00000006u,0x00000006u,0x00000006u,0x00000006u,0x00000006u,0x0000004cu,0x00040020u,0x0000004eu,0x00000002u,0x0000004du,0x0004003bu,0x0000004eu,0x0000004fu,0x00000002u,0x0004002bu,0x00000015u,0x00000050u,0x00000008u,0x00040020u,0x00000051u,0x00000002u,0x00000006u,0x0004002bu,0x00000019u,0x00000054u,0x00000002u,0x0004002bu,0x00000019u,0x0000005cu,0x00000003u,0x00090019u,0x00000089u,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x0000008au,0x00000089u,0x00040020u,0x0000008bu,0x00000000u,0x0000008au,0x0004003bu,0x0000008bu,0x0000008cu,0x00000000u,0x0004002bu,0x00000006u,0x0000008fu,0x00000000u,0x00040020u,0x00000097u,0x00000007u,0x00000027u,0x0004002bu,0x00000015u,0x00000099u,0x00000000u,0x0004002bu,0x00000006u,0x0000009cu,0x40600000u,0x00040020u,0x0000009eu,0x00000007u,0x00000006u,0x00040020u,0x000000a8u,0x00000007u,0x0000004cu,0x0004003bu,0x0000008bu,0x000000aau,0x00000000u,0x0004003bu,0x0000008bu,0x000000afu,0x00000000u,0x0004002bu,0x00000006u,0x000000cdu,0x3dcccccdu,0x0004002bu,0x00000015u,0x000000e2u,0x00000001u,0x0004003bu,0x0000008bu,0x000000f1u,0x00000000u,0x0004002bu,0x00000015u,0x0000014au,0x00000005u,0x0004002bu,0x00000015u,0x0000014fu,0x00000003u,0x0004002bu,0x00000015u,0x00000170u,0x00000002u,0x0004002bu,0x00000006u,0x00000189u,0x322bcc77u,0x0004002bu,0x00000006u,0x000001b2u,0x3d23d70au,0x0004002bu,0x00000006u,0x000001b3u,0x3e3851ecu,0x0004002bu,0x00000015u,0x000001bcu,0x00000004u,0x0004002bu,0x00000006u,0x000001d3u,0x3e800000u,0x0004002bu,0x00000006u,0x000001d8u,0x3e4ccccdu,0x0004002bu,0x00000006u,0x000001d9u,0x3ecccccdu,0x0004002bu,0x00000019u,0x00000206u,0x00000010u,0x0006002cu,0x0000001au,0x00000207u,0x00000206u,0x00000206u,0x00000032u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000017u,0x00000018u,0x00000007u,0x0004003bu,0x00000017u,0x00000021u,0x00000007u,0x0004003bu,0x0000003du,0x0000003eu,0x00000007u,0x0004003bu,0x0000003du,0x00000044u,0x00000007u,0x0004003bu,0x00000097u,0x00000098u,0x00000007u,0x0004003bu,0x0000009eu,0x0000009fu,0x00000007u,0x0004003bu,0x0000009eu,0x000000a1u,0x00000007u,0x0004003bu,0x000000a8u,0x000000a9u,0x00000007u,0x0004003bu,0x000000a8u,0x000000aeu,0x00000007u,0x0004003bu,0x0000003du,0x000000b3u,0x00000007u,0x0004003bu,0x0000003du,0x000000bau,0x00000007u,0x0004003bu,0x0000009eu,0x000000c1u,0x00000007u,0x0004003bu,0x0000009eu,0x000000c5u,0x00000007u,0x0004003bu,0x0000009eu,0x000000c9u,0x00000007u,0x0004003bu,0x0000009eu,0x000000d5u,0x00000007u,0x0004003bu,0x0000003du,0x000000e0u,0x00000007u,0x0004003bu,0x0000003du,0x000000e8u,0x00000007u,0x0004003bu,0x00000008u,0x000000f0u,0x00000007u,0x0004003bu,0x00000008u,0x000000f6u,0x00000007u,0x0004003bu,0x0000009eu,0x000000fbu,0x00000007u,0x0004003bu,0x00000008u,0x000000fcu,0x00000007u,0x0004003bu,0x00000008u,0x0000010cu,0x00000007u,0x0004003bu,0x0000009eu,0x00000111u,0x00000007u,0x0004003bu,0x00000008u,0x00000112u,0x00000007u,0x0004003bu,0x00000008u,0x00000122u,0x00000007u,0x0004003bu,0x0000003du,0x00000127u,0x00000007u,0x0004003bu,0x0000009eu,0x0000012bu,0x00000007u,0x0004003bu,0x0000009eu,0x00000138u,0x00000007u,0x0004003bu,0x0000009eu,0x00000149u,0x00000007u,0x0004003bu,0x0000009eu,0x00000157u,0x00000007u,0x0004003bu,0x0000009eu,0x00000163u,0x00000007u,0x0004003bu,0x0000009eu,0x00000167u,0x00000007u,0x0004003bu,0x0000009eu,0x0000016au,0x00000007u,0x0004003bu,0x0000009eu,0x0000016eu,0x00000007u,0x0004003bu,0x0000009eu,0x00000179u,0x00000007u,0x0004003bu,0x0000009eu,0x00000183u,0x00000007u,0x0004003bu,0x00000008u,0x00000187u,0x00000007u,0x0004003bu,0x00000008u,0x0000018bu,0x00000007u,0x0004003bu,0x00000008u,0x000001a0u,0x00000007u,0x0004003bu,0x0000009eu,0x000001adu,0x00000007u,0x0004003bu,0x0000009eu,0x000001b1u,0x00000007u,0x0004003bu,0x0000009eu,0x000001b7u,0x00000007u,0x0004003bu,0x00000008u,0x000001c3u,0x00000007u,0x0004003bu,0x00000008u,0x000001c8u,0x00000007u,0x0004003bu,0x0000009eu,0x000001cdu,0x00000007u,0x0004003bu,0x0000009eu,0x000001d2u,0x00000007u,0x0004003bu,0x0000009eu,0x000001d7u,0x00000007u,0x0004003bu,0x0000009eu,0x000001dcu,0x00000007u,0x0004003bu,0x00000008u,0x000001e5u,0x00000007u,0x0004003bu,0x0000009eu,0x000001eeu,0x00000007u,0x0004003bu,0x0000009eu,0x000001f2u,0x00000007u,0x0004003bu,0x0000009eu,0x000001f6u,0x00000007u,0x0004003du,0x0000001au,0x0000001eu,0x0000001cu,0x0007004fu,0x0000001du,0x0000001fu,0x0000001eu,0x0000001eu,0x00000000u,0x00000001u,0x0004007cu,0x00000016u,0x00000020u,0x0000001fu,0x0003003eu,0x00000018u,0x00000020u,0x0004003du,0x00000022u,0x00000025u,0x00000024u,0x00040068u,0x00000016u,0x00000026u,0x00000025u,0x0003003eu,0x00000021u,0x00000026u,0x00050041u,0x00000029u,0x0000002au,0x00000018u,0x00000028u,0x0004003du,0x00000015u,0x0000002bu,0x0000002au,0x00050041u,0x00000029u,0x0000002cu,0x00000021u,0x00000028u,0x0004003du,0x00000015u,0x0000002du,0x0000002cu,0x000500afu,0x00000027u,0x0000002eu,0x0000002bu,0x0000002du,0x000400a8u,0x00000027u,0x0000002fu,0x0000002eu,0x000300f7u,0x00000031u,0x00000000u,0x000400fau,0x0000002fu,0x00000030u,0x00000031u,0x000200f8u,0x00000030u,0x00050041u,0x00000029u,0x00000033u,0x00000018u,0x00000032u,0x0004003du,0x00000015u,0x00000034u,0x00000033u,0x00050041u,0x00000029u,0x00000035u,0x00000021u,0x00000032u,0x0004003du,0x00000015u,0x00000036u,0x00000035u,0x000500afu,0x00000027u,0x00000037u,0x00000034u,0x00000036u,0x000200f9u,0x00000031u,0x000200f8u,0x00000031u,0x000700f5u,0x00000027u,0x00000038u,0x0000002eu,0x00000005u,0x00000037u,0x00000030u,0x000300f7u,0x0000003au,0x00000000u,0x000400fau,0x00000038u,0x00000039u,0x0000003au,0x000200f8u,0x00000039u,0x000100fdu,0x000200f8u,0x0000003au,0x0004003du,0x00000016u,0x00000040u,0x00000021u,0x0004006fu,0x0000003cu,0x00000041u,0x00000040u,0x00050050u,0x0000003cu,0x00000042u,0x0000003fu,0x0000003fu,0x00050088u,0x0000003cu,0x00000043u,0x00000042u,0x00000041u,0x0003003eu,0x0000003eu,0x00000043u,0x0004003du,0x00000016u,0x00000045u,0x00000018u,0x0004006fu,0x0000003cu,0x00000046u,0x00000045u,0x00050050u,0x0000003cu,0x00000048u,0x00000047u,0x00000047u,0x00050081u,0x0000003cu,0x00000049u,0x00000046u,0x00000048u,0x0004003du,0x0000003cu,0x0000004au,0x0000003eu,0x00050085u,0x0000003cu,0x0000004bu,0x00000049u,0x0000004au,0x0003003eu,0x00000044u,0x0000004bu,0x00060041u,0x00000051u,0x00000052u,0x0000004fu,0x00000050u,0x00000028u,0x0004003du,0x00000006u,0x00000053u,0x00000052u,0x00060041u,0x00000051u,0x00000055u,0x0000004fu,0x00000050u,0x00000054u,0x0004003du,0x00000006u,0x00000056u,0x00000055u,0x000500b8u,0x00000027u,0x00000057u,0x00000053u,0x00000056u,0x000300f7u,0x00000059u,0x00000000u,0x000400fau,0x00000057u,0x00000058u,0x00000059u,0x000200f8u,0x00000058u,0x00060041u,0x00000051u,0x0000005au,0x0000004fu,0x00000050u,0x00000032u,0x0004003du,0x00000006u,0x0000005bu,0x0000005au,0x00060041u,0x00000051u,0x0000005du,0x0000004fu,0x00000050u,0x0000005cu,0x0004003du,0x00000006u,0x0000005eu,0x0000005du,0x000500b8u,0x00000027u,0x0000005fu,0x0000005bu,0x0000005eu,0x000200f9u,0x00000059u,0x000200f8u,0x00000059u,0x000700f5u,0x00000027u,0x00000060u,0x00000057u,0x0000003au,0x0000005fu,0x00000058u,0x000300f7u,0x00000062u,0x00000000u,0x000400fau,0x00000060u,0x00000061u,0x00000062u,0x000200f8u,0x00000061u,0x00050041u,0x00000029u,0x00000063u,0x00000018u,0x00000028u,0x0004003du,0x00000015u,0x00000064u,0x00000063u,0x0004006fu,0x00000006u,0x00000065u,0x00000064u,0x00060041u,0x00000051u,0x00000066u,0x0000004fu,0x00000050u,0x00000028u,0x0004003du,0x00000006u,0x00000067u,0x00000066u,0x000500beu,0x00000027u,0x00000068u,0x00000065u,0x00000067u,0x000200f9u,0x00000062u,0x000200f8u,0x00000062u,0x000700f5u,0x00000027u,0x00000069u,0x00000060u,0x00000059u,0x00000068u,0x00000061u,0x000300f7u,0x0000006bu,0x00000000u,0x000400fau,0x00000069u,0x0000006au,0x0000006bu,0x000200f8u,0x0000006au,0x00050041u,0x00000029u,0x0000006cu,0x00000018u,0x00000028u,0x0004003du,0x00000015u,0x0000006du,0x0000006cu,0x0004006fu,0x00000006u,0x0000006eu,0x0000006du,0x00060041u,0x00000051u,0x0000006fu,0x0000004fu,0x00000050u,0x00000054u,0x0004003du,0x00000006u,0x00000070u,0x0000006fu,0x000500b8u,0x00000027u,0x00000071u,0x0000006eu,0x00000070u,0x000200f9u,0x0000006bu,0x000200f8u,0x0000006bu,0x000700f5u,0x00000027u,0x00000072u,0x00000069u,0x00000062u,0x00000071u,0x0000006au,0x000300f7u,0x00000074u,0x00000000u,0x000400fau,0x00000072u,0x00000073u,0x00000074u,0x000200f8u,0x00000073u,0x00050041u,0x00000029u,0x00000075u,0x00000018u,0x00000032u,0x0004003du,0x00000015u,0x00000076u,0x00000075u,0x0004006fu,0x00000006u,0x00000077u,0x00000076u,0x00060041u,0x00000051u,0x00000078u,0x0000004fu,0x00000050u,0x00000032u,0x0004003du,0x00000006u,0x00000079u,0x00000078u,0x000500beu,0x00000027u,0x0000007au,0x00000077u,0x00000079u,0x000200f9u,0x00000074u,0x000200f8u,0x00000074u,0x000700f5u,0x00000027u,0x0000007bu,0x00000072u,0x0000006bu,0x0000007au,0x00000073u,0x000300f7u,0x0000007du,0x00000000u,0x000400fau,0x0000007bu,0x0000007cu,0x0000007du,0x000200f8u,0x0000007cu,0x00050041u,0x00000029u,0x0000007eu,0x00000018u,0x00000032u,0x0004003du,0x00000015u,0x0000007fu,0x0000007eu,0x0004006fu,0x00000006u,0x00000080u,0x0000007fu,0x00060041u,0x00000051u,0x00000081u,0x0000004fu,0x00000050u,0x0000005cu,0x0004003du,0x00000006u,0x00000082u,0x00000081u,0x000500b8u,0x00000027u,0x00000083u,0x00000080u,0x00000082u,0x000200f9u,0x0000007du,0x000200f8u,0x0000007du,0x000700f5u,0x00000027u,0x00000084u,0x0000007bu,0x00000074u,0x00000083u,0x0000007cu,0x000300f7u,0x00000086u,0x00000000u,0x000400fau,0x00000084u,0x00000085u,0x00000086u,0x000200f8u,0x00000085u,0x0004003du,0x00000022u,0x00000087u,0x00000024u,0x0004003du,0x00000016u,0x00000088u,0x00000018u,0x0004003du,0x0000008au,0x0000008du,0x0000008cu,0x0004003du,0x0000003cu,0x0000008eu,0x00000044u,0x00070058u,0x0000004cu,0x00000090u,0x0000008du,0x0000008eu,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x00000091u,0x00000090u,0x00000090u,0x00000000u,0x00000001u,0x00000002u,0x00050051u,0x00000006u,0x00000092u,0x00000091u,0x00000000u,0x00050051u,0x00000006u,0x00000093u,0x00000091u,0x00000001u,0x00050051u,0x00000006u,0x00000094u,0x00000091u,0x00000002u,0x00070050u,0x0000004cu,0x00000095u,0x00000092u,0x00000093u,0x00000094u,0x0000003fu,0x00040063u,0x00000087u,0x00000088u,0x00000095u,0x000100fdu,0x000200f8u,0x00000086u,0x00050041u,0x00000051u,0x0000009au,0x0000004fu,0x00000099u,0x0004003du,0x00000006u,0x0000009bu,0x0000009au,0x000500bau,0x00000027u,0x0000009du,0x0000009bu,0x0000009cu,0x0003003eu,0x00000098u,0x0000009du,0x0004003du,0x00000027u,0x000000a0u,0x00000098u,0x000300f7u,0x000000a3u,0x00000000u,0x000400fau,0x000000a0u,0x000000a2u,0x000000a4u,0x000200f8u,0x000000a2u,0x0003003eu,0x000000a1u,0x0000003fu,0x000200f9u,0x000000a3u,0x000200f8u,0x000000a4u,0x00050041u,0x00000051u,0x000000a5u,0x0000004fu,0x00000099u,0x0004003du,0x00000006u,0x000000a6u,0x000000a5u,0x0003003eu,0x000000a1u,0x000000a6u,0x000200f9u,0x000000a3u,0x000200f8u,0x000000a3u,0x0004003du,0x00000006u,0x000000a7u,0x000000a1u,0x0003003eu,0x0000009fu,0x000000a7u,0x0004003du,0x0000008au,0x000000abu,0x000000aau,0x0004003du,0x0000003cu,0x000000acu,0x00000044u,0x00070058u,0x0000004cu,0x000000adu,0x000000abu,0x000000acu,0x00000002u,0x0000008fu,0x0003003eu,0x000000a9u,0x000000adu,0x0004003du,0x0000008au,0x000000b0u,0x000000afu,0x0004003du,0x0000003cu,0x000000b1u,0x00000044u,0x00070058u,0x0000004cu,0x000000b2u,0x000000b0u,0x000000b1u,0x00000002u,0x0000008fu,0x0003003eu,0x000000aeu,0x000000b2u,0x0004003du,0x0000004cu,0x000000b4u,0x000000a9u,0x0007004fu,0x0000003cu,0x000000b5u,0x000000b4u,0x000000b4u,0x00000000u,0x00000001u,0x0004003du,0x00000006u,0x000000b6u,0x0000009fu,0x0005008eu,0x0000003cu,0x000000b7u,0x000000b5u,0x000000b6u,0x0004003du,0x0000003cu,0x000000b8u,0x0000003eu,0x00050085u,0x0000003cu,0x000000b9u,0x000000b7u,0x000000b8u,0x0003003eu,0x000000b3u,0x000000b9u,0x0004003du,0x0000004cu,0x000000bbu,0x000000aeu,0x0007004fu,0x0000003cu,0x000000bcu,0x000000bbu,0x000000bbu,0x00000000u,0x00000001u,0x0004003du,0x00000006u,0x000000bdu,0x0000009fu,0x0005008eu,0x0000003cu,0x000000beu,0x000000bcu,0x000000bdu,0x0004003du,0x0000003cu,0x000000bfu,0x0000003eu,0x00050085u,0x0000003cu,0x000000c0u,0x000000beu,0x000000bfu,0x0003003eu,0x000000bau,0x000000c0u,0x00050041u,0x0000009eu,0x000000c2u,0x000000a9u,0x0000005cu,0x0004003du,0x00000006u,0x000000c3u,0x000000c2u,0x0008000cu,0x00000006u,0x000000c4u,0x00000001u,0x0000002bu,0x000000c3u,0x0000008fu,0x0000003fu,0x0003003eu,0x000000c1u,0x000000c4u,0x00050041u,0x0000009eu,0x000000c6u,0x000000aeu,0x0000005cu,0x0004003du,0x00000006u,0x000000c7u,0x000000c6u,0x0008000cu,0x00000006u,0x000000c8u,0x00000001u,0x0000002bu,0x000000c7u,0x0000008fu,0x0000003fu,0x0003003eu,0x000000c5u,0x000000c8u,0x0004003du,0x0000003cu,0x000000cau,0x000000b3u,0x0006000cu,0x00000006u,0x000000cbu,0x00000001u,0x00000042u,0x000000cau,0x0003003eu,0x000000c9u,0x000000cbu,0x0004003du,0x00000006u,0x000000ccu,0x000000c9u,0x000500bau,0x00000027u,0x000000ceu,0x000000ccu,0x000000cdu,0x000300f7u,0x000000d0u,0x00000000u,0x000400fau,0x000000ceu,0x000000cfu,0x000000d0u,0x000200f8u,0x000000cfu,0x0004003du,0x00000006u,0x000000d1u,0x000000c9u,0x00050088u,0x00000006u,0x000000d2u,0x000000cdu,0x000000d1u,0x0004003du,0x0000003cu,0x000000d3u,0x000000b3u,0x0005008eu,0x0000003cu,0x000000d4u,0x000000d3u,0x000000d2u,0x0003003eu,0x000000b3u,0x000000d4u,0x000200f9u,0x000000d0u,0x000200f8u,0x000000d0u,0x0004003du,0x0000003cu,0x000000d6u,0x000000bau,0x0006000cu,0x00000006u,0x000000d7u,0x00000001u,0x00000042u,0x000000d6u,0x0003003eu,0x000000d5u,0x000000d7u,0x0004003du,0x00000006u,0x000000d8u,0x000000d5u,0x000500bau,0x00000027u,0x000000d9u,0x000000d8u,0x000000cdu,0x000300f7u,0x000000dbu,0x00000000u,0x000400fau,0x000000d9u,0x000000dau,0x000000dbu,0x000200f8u,0x000000dau,0x0004003du,0x00000006u,0x000000dcu,0x000000d5u,0x00050088u,0x00000006u,0x000000ddu,0x000000cdu,0x000000dcu,0x0004003du,0x0000003cu,0x000000deu,0x000000bau,0x0005008eu,0x0000003cu,0x000000dfu,0x000000deu,0x000000ddu,0x0003003eu,0x000000bau,0x000000dfu,0x000200f9u,0x000000dbu,0x000200f8u,0x000000dbu,0x0004003du,0x0000003cu,0x000000e1u,0x00000044u,0x00050041u,0x00000051u,0x000000e3u,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x000000e4u,0x000000e3u,0x0004003du,0x0000003cu,0x000000e5u,0x000000b3u,0x0005008eu,0x0000003cu,0x000000e6u,0x000000e5u,0x000000e4u,0x00050083u,0x0000003cu,0x000000e7u,0x000000e1u,0x000000e6u,0x0003003eu,0x000000e0u,0x000000e7u,0x0004003du,0x0000003cu,0x000000e9u,0x00000044u,0x00050041u,0x00000051u,0x000000eau,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x000000ebu,0x000000eau,0x00050083u,0x00000006u,0x000000ecu,0x0000003fu,0x000000ebu,0x0004003du,0x0000003cu,0x000000edu,0x000000bau,0x0005008eu,0x0000003cu,0x000000eeu,0x000000edu,0x000000ecu,0x00050083u,0x0000003cu,0x000000efu,0x000000e9u,0x000000eeu,0x0003003eu,0x000000e8u,0x000000efu,0x0004003du,0x0000008au,0x000000f2u,0x000000f1u,0x0004003du,0x0000003cu,0x000000f3u,0x000000e0u,0x00070058u,0x0000004cu,0x000000f4u,0x000000f2u,0x000000f3u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000000f5u,0x000000f4u,0x000000f4u,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x000000f0u,0x000000f5u,0x0004003du,0x0000008au,0x000000f7u,0x0000008cu,0x0004003du,0x0000003cu,0x000000f8u,0x000000e8u,0x00070058u,0x0000004cu,0x000000f9u,0x000000f7u,0x000000f8u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000000fau,0x000000f9u,0x000000f9u,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x000000f6u,0x000000fau,0x0004003du,0x00000007u,0x000000fdu,0x000000f0u,0x0003003eu,0x000000fcu,0x000000fdu,0x00050039u,0x00000006u,0x000000feu,0x0000000bu,0x000000fcu,0x0004003du,0x0000008au,0x000000ffu,0x0000008cu,0x0004003du,0x0000003cu,0x00000100u,0x000000e0u,0x0004003du,0x0000008au,0x00000101u,0x000000aau,0x0004003du,0x0000003cu,0x00000102u,0x000000e0u,0x00070058u,0x0000004cu,0x00000103u,0x00000101u,0x00000102u,0x00000002u,0x0000008fu,0x0007004fu,0x0000003cu,0x00000104u,0x00000103u,0x00000103u,0x00000000u,0x00000001u,0x00050041u,0x00000051u,0x00000105u,0x0000004fu,0x00000099u,0x0004003du,0x00000006u,0x00000106u,0x00000105u,0x0005008eu,0x0000003cu,0x00000107u,0x00000104u,0x00000106u,0x0004003du,0x0000003cu,0x00000108u,0x0000003eu,0x00050085u,0x0000003cu,0x00000109u,0x00000107u,0x00000108u,0x00050081u,0x0000003cu,0x0000010au,0x00000100u,0x00000109u,0x00070058u,0x0000004cu,0x0000010bu,0x000000ffu,0x0000010au,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x0000010du,0x0000010bu,0x0000010bu,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x0000010cu,0x0000010du,0x00050039u,0x00000006u,0x0000010eu,0x0000000bu,0x0000010cu,0x00050083u,0x00000006u,0x0000010fu,0x000000feu,0x0000010eu,0x0006000cu,0x00000006u,0x00000110u,0x00000001u,0x00000004u,0x0000010fu,0x0003003eu,0x000000fbu,0x00000110u,0x0004003du,0x00000007u,0x00000113u,0x000000f6u,0x0003003eu,0x00000112u,0x00000113u,0x00050039u,0x00000006u,0x00000114u,0x0000000bu,0x00000112u,0x0004003du,0x0000008au,0x00000115u,0x000000f1u,0x0004003du,0x0000003cu,0x00000116u,0x000000e8u,0x0004003du,0x0000008au,0x00000117u,0x000000afu,0x0004003du,0x0000003cu,0x00000118u,0x000000e8u,0x00070058u,0x0000004cu,0x00000119u,0x00000117u,0x00000118u,0x00000002u,0x0000008fu,0x0007004fu,0x0000003cu,0x0000011au,0x00000119u,0x00000119u,0x00000000u,0x00000001u,0x00050041u,0x00000051u,0x0000011bu,0x0000004fu,0x00000099u,0x0004003du,0x00000006u,0x0000011cu,0x0000011bu,0x0005008eu,0x0000003cu,0x0000011du,0x0000011au,0x0000011cu,0x0004003du,0x0000003cu,0x0000011eu,0x0000003eu,0x00050085u,0x0000003cu,0x0000011fu,0x0000011du,0x0000011eu,0x00050081u,0x0000003cu,0x00000120u,0x00000116u,0x0000011fu,0x00070058u,0x0000004cu,0x00000121u,0x00000115u,0x00000120u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x00000123u,0x00000121u,0x00000121u,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x00000122u,0x00000123u,0x00050039u,0x00000006u,0x00000124u,0x0000000bu,0x00000122u,0x00050083u,0x00000006u,0x00000125u,0x00000114u,0x00000124u,0x0006000cu,0x00000006u,0x00000126u,0x00000001u,0x00000004u,0x00000125u,0x0003003eu,0x00000111u,0x00000126u,0x0004003du,0x0000003cu,0x00000128u,0x00000044u,0x0004003du,0x0000003cu,0x00000129u,0x000000b3u,0x00050081u,0x0000003cu,0x0000012au,0x00000128u,0x00000129u,0x0003003eu,0x00000127u,0x0000012au,0x0004003du,0x0000003cu,0x0000012cu,0x000000b3u,0x0004003du,0x0000008au,0x0000012du,0x000000afu,0x0004003du,0x0000003cu,0x0000012eu,0x00000127u,0x00070058u,0x0000004cu,0x0000012fu,0x0000012du,0x0000012eu,0x00000002u,0x0000008fu,0x0007004fu,0x0000003cu,0x00000130u,0x0000012fu,0x0000012fu,0x00000000u,0x00000001u,0x00050041u,0x00000051u,0x00000131u,0x0000004fu,0x00000099u,0x0004003du,0x00000006u,0x00000132u,0x00000131u,0x0005008eu,0x0000003cu,0x00000133u,0x00000130u,0x00000132u,0x0004003du,0x0000003cu,0x00000134u,0x0000003eu,0x00050085u,0x0000003cu,0x00000135u,0x00000133u,0x00000134u,0x00050081u,0x0000003cu,0x00000136u,0x0000012cu,0x00000135u,0x0006000cu,0x00000006u,0x00000137u,0x00000001u,0x00000042u,0x00000136u,0x0003003eu,0x0000012bu,0x00000137u,0x0004003du,0x00000006u,0x00000139u,0x000000c1u,0x0004003du,0x00000006u,0x0000013au,0x000000c5u,0x0007000cu,0x00000006u,0x0000013bu,0x00000001u,0x00000025u,0x00000139u,0x0000013au,0x0004003du,0x00000006u,0x0000013cu,0x0000012bu,0x0004007fu,0x00000006u,0x0000013du,0x0000013cu,0x0004003du,0x0000003cu,0x0000013eu,0x000000b3u,0x0006000cu,0x00000006u,0x0000013fu,0x00000001u,0x00000042u,0x0000013eu,0x0004003du,0x0000003cu,0x00000140u,0x000000bau,0x0006000cu,0x00000006u,0x00000141u,0x00000001u,0x00000042u,0x00000140u,0x00050081u,0x00000006u,0x00000142u,0x0000013fu,0x00000141u,0x00050041u,0x0000009eu,0x00000143u,0x0000003eu,0x00000028u,0x0004003du,0x00000006u,0x00000144u,0x00000143u,0x00050081u,0x00000006u,0x00000145u,0x00000142u,0x00000144u,0x00050088u,0x00000006u,0x00000146u,0x0000013du,0x00000145u,0x0006000cu,0x00000006u,0x00000147u,0x00000001u,0x0000001bu,0x00000146u,0x00050085u,0x00000006u,0x00000148u,0x0000013bu,0x00000147u,0x0003003eu,0x00000138u,0x00000148u,0x00050041u,0x00000051u,0x0000014bu,0x0000004fu,0x0000014au,0x0004003du,0x00000006u,0x0000014cu,0x0000014bu,0x0004003du,0x00000006u,0x0000014du,0x000000fbu,0x00050085u,0x00000006u,0x0000014eu,0x0000014cu,0x0000014du,0x00050041u,0x00000051u,0x00000150u,0x0000004fu,0x0000014fu,0x0004003du,0x00000006u,0x00000151u,0x00000150u,0x0004003du,0x00000006u,0x00000152u,0x00000138u,0x00050083u,0x00000006u,0x00000153u,0x0000003fu,0x00000152u,0x00050085u,0x00000006u,0x00000154u,0x00000151u,0x00000153u,0x00050081u,0x00000006u,0x00000155u,0x0000014eu,0x00000154u,0x0004007fu,0x00000006u,0x00000156u,0x00000155u,0x0003003eu,0x00000149u,0x00000156u,0x00050041u,0x00000051u,0x00000158u,0x0000004fu,0x0000014au,0x0004003du,0x00000006u,0x00000159u,0x00000158u,0x0004003du,0x00000006u,0x0000015au,0x00000111u,0x00050085u,0x00000006u,0x0000015bu,0x00000159u,0x0000015au,0x00050041u,0x00000051u,0x0000015cu,0x0000004fu,0x0000014fu,0x0004003du,0x00000006u,0x0000015du,0x0000015cu,0x0004003du,0x00000006u,0x0000015eu,0x00000138u,0x00050083u,0x00000006u,0x0000015fu,0x0000003fu,0x0000015eu,0x00050085u,0x00000006u,0x00000160u,0x0000015du,0x0000015fu,0x00050081u,0x00000006u,0x00000161u,0x0000015bu,0x00000160u,0x0004007fu,0x00000006u,0x00000162u,0x00000161u,0x0003003eu,0x00000157u,0x00000162u,0x00050041u,0x00000051u,0x00000164u,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x00000165u,0x00000164u,0x00050083u,0x00000006u,0x00000166u,0x0000003fu,0x00000165u,0x0003003eu,0x00000163u,0x00000166u,0x00050041u,0x00000051u,0x00000168u,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x00000169u,0x00000168u,0x0003003eu,0x00000167u,0x00000169u,0x0004003du,0x00000006u,0x0000016bu,0x00000149u,0x0004003du,0x00000006u,0x0000016cu,0x00000157u,0x0007000cu,0x00000006u,0x0000016du,0x00000001u,0x00000028u,0x0000016bu,0x0000016cu,0x0003003eu,0x0000016au,0x0000016du,0x0004003du,0x00000006u,0x0000016fu,0x00000163u,0x00050041u,0x00000051u,0x00000171u,0x0000004fu,0x00000170u,0x0004003du,0x00000006u,0x00000172u,0x00000171u,0x0004003du,0x00000006u,0x00000173u,0x00000149u,0x0004003du,0x00000006u,0x00000174u,0x0000016au,0x00050083u,0x00000006u,0x00000175u,0x00000173u,0x00000174u,0x00050085u,0x00000006u,0x00000176u,0x00000172u,0x00000175u,0x0006000cu,0x00000006u,0x00000177u,0x00000001u,0x0000001bu,0x00000176u,0x00050085u,0x00000006u,0x00000178u,0x0000016fu,0x00000177u,0x0003003eu,0x0000016eu,0x00000178u,0x0004003du,0x00000006u,0x0000017au,0x00000167u,0x00050041u,0x00000051u,0x0000017bu,0x0000004fu,0x00000170u,0x0004003du,0x00000006u,0x0000017cu,0x0000017bu,0x0004003du,0x00000006u,0x0000017du,0x00000157u,0x0004003du,0x00000006u,0x0000017eu,0x0000016au,0x00050083u,0x00000006u,0x0000017fu,0x0000017du,0x0000017eu,0x00050085u,0x00000006u,0x00000180u,0x0000017cu,0x0000017fu,0x0006000cu,0x00000006u,0x00000181u,0x00000001u,0x0000001bu,0x00000180u,0x00050085u,0x00000006u,0x00000182u,0x0000017au,0x00000181u,0x0003003eu,0x00000179u,0x00000182u,0x0004003du,0x00000006u,0x00000184u,0x0000016eu,0x0004003du,0x00000006u,0x00000185u,0x00000179u,0x00050081u,0x00000006u,0x00000186u,0x00000184u,0x00000185u,0x0003003eu,0x00000183u,0x00000186u,0x0004003du,0x00000006u,0x00000188u,0x00000183u,0x000500bau,0x00000027u,0x0000018au,0x00000188u,0x00000189u,0x000300f7u,0x0000018du,0x00000000u,0x000400fau,0x0000018au,0x0000018cu,0x00000198u,0x000200f8u,0x0000018cu,0x0004003du,0x00000006u,0x0000018eu,0x0000016eu,0x0004003du,0x00000007u,0x0000018fu,0x000000f0u,0x0005008eu,0x00000007u,0x00000190u,0x0000018fu,0x0000018eu,0x0004003du,0x00000006u,0x00000191u,0x00000179u,0x0004003du,0x00000007u,0x00000192u,0x000000f6u,0x0005008eu,0x00000007u,0x00000193u,0x00000192u,0x00000191u,0x00050081u,0x00000007u,0x00000194u,0x00000190u,0x00000193u,0x0004003du,0x00000006u,0x00000195u,0x00000183u,0x00060050u,0x00000007u,0x00000196u,0x00000195u,0x00000195u,0x00000195u,0x00050088u,0x00000007u,0x00000197u,0x00000194u,0x00000196u,0x0003003eu,0x0000018bu,0x00000197u,0x000200f9u,0x0000018du,0x000200f8u,0x00000198u,0x0004003du,0x00000007u,0x00000199u,0x000000f0u,0x0004003du,0x00000007u,0x0000019au,0x000000f6u,0x00050041u,0x00000051u,0x0000019bu,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x0000019cu,0x0000019bu,0x00060050u,0x00000007u,0x0000019du,0x0000019cu,0x0000019cu,0x0000019cu,0x0008000cu,0x00000007u,0x0000019eu,0x00000001u,0x0000002eu,0x00000199u,0x0000019au,0x0000019du,0x0003003eu,0x0000018bu,0x0000019eu,0x000200f9u,0x0000018du,0x000200f8u,0x0000018du,0x0004003du,0x00000007u,0x0000019fu,0x0000018bu,0x0003003eu,0x00000187u,0x0000019fu,0x0004003du,0x0000008au,0x000001a1u,0x000000f1u,0x0004003du,0x0000003cu,0x000001a2u,0x00000044u,0x00070058u,0x0000004cu,0x000001a3u,0x000001a1u,0x000001a2u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000001a4u,0x000001a3u,0x000001a3u,0x00000000u,0x00000001u,0x00000002u,0x0004003du,0x0000008au,0x000001a5u,0x0000008cu,0x0004003du,0x0000003cu,0x000001a6u,0x00000044u,0x00070058u,0x0000004cu,0x000001a7u,0x000001a5u,0x000001a6u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000001a8u,0x000001a7u,0x000001a7u,0x00000000u,0x00000001u,0x00000002u,0x00050041u,0x00000051u,0x000001a9u,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x000001aau,0x000001a9u,0x00060050u,0x00000007u,0x000001abu,0x000001aau,0x000001aau,0x000001aau,0x0008000cu,0x00000007u,0x000001acu,0x00000001u,0x0000002eu,0x000001a4u,0x000001a8u,0x000001abu,0x0003003eu,0x000001a0u,0x000001acu,0x0004003du,0x00000006u,0x000001aeu,0x000000fbu,0x0004003du,0x00000006u,0x000001afu,0x00000111u,0x0007000cu,0x00000006u,0x000001b0u,0x00000001u,0x00000025u,0x000001aeu,0x000001afu,0x0003003eu,0x000001adu,0x000001b0u,0x0004003du,0x00000006u,0x000001b4u,0x000001adu,0x0008000cu,0x00000006u,0x000001b5u,0x00000001u,0x00000031u,0x000001b2u,0x000001b3u,0x000001b4u,0x00050083u,0x00000006u,0x000001b6u,0x0000003fu,0x000001b5u,0x0003003eu,0x000001b1u,0x000001b6u,0x0004003du,0x00000006u,0x000001b8u,0x00000138u,0x0008000cu,0x00000006u,0x000001b9u,0x00000001u,0x0000002bu,0x000001b8u,0x0000008fu,0x0000003fu,0x0004003du,0x00000006u,0x000001bau,0x000001b1u,0x00050085u,0x00000006u,0x000001bbu,0x000001b9u,0x000001bau,0x0003003eu,0x000001b7u,0x000001bbu,0x00050041u,0x00000051u,0x000001bdu,0x0000004fu,0x000001bcu,0x0004003du,0x00000006u,0x000001beu,0x000001bdu,0x0004003du,0x00000006u,0x000001bfu,0x00000183u,0x0008000cu,0x00000006u,0x000001c0u,0x00000001u,0x00000031u,0x0000008fu,0x000001beu,0x000001bfu,0x0004003du,0x00000006u,0x000001c1u,0x000001b7u,0x00050085u,0x00000006u,0x000001c2u,0x000001c1u,0x000001c0u,0x0003003eu,0x000001b7u,0x000001c2u,0x0004003du,0x0000008au,0x000001c4u,0x000000f1u,0x0004003du,0x0000003cu,0x000001c5u,0x00000044u,0x00070058u,0x0000004cu,0x000001c6u,0x000001c4u,0x000001c5u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000001c7u,0x000001c6u,0x000001c6u,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x000001c3u,0x000001c7u,0x0004003du,0x0000008au,0x000001c9u,0x0000008cu,0x0004003du,0x0000003cu,0x000001cau,0x00000044u,0x00070058u,0x0000004cu,0x000001cbu,0x000001c9u,0x000001cau,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000001ccu,0x000001cbu,0x000001cbu,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x000001c8u,0x000001ccu,0x0004003du,0x00000007u,0x000001ceu,0x000001c8u,0x0004003du,0x00000007u,0x000001cfu,0x000001c3u,0x00050083u,0x00000007u,0x000001d0u,0x000001ceu,0x000001cfu,0x0006000cu,0x00000006u,0x000001d1u,0x00000001u,0x00000042u,0x000001d0u,0x0003003eu,0x000001cdu,0x000001d1u,0x0004003du,0x00000006u,0x000001d4u,0x000001b7u,0x0008000cu,0x00000006u,0x000001d5u,0x00000001u,0x00000031u,0x000000cdu,0x000001d3u,0x000001d4u,0x00050083u,0x00000006u,0x000001d6u,0x0000003fu,0x000001d5u,0x0003003eu,0x000001d2u,0x000001d6u,0x0004003du,0x00000006u,0x000001dau,0x000001cdu,0x0008000cu,0x00000006u,0x000001dbu,0x00000001u,0x00000031u,0x000001d8u,0x000001d9u,0x000001dau,0x0003003eu,0x000001d7u,0x000001dbu,0x0004003du,0x00000006u,0x000001ddu,0x000001d2u,0x0004003du,0x00000006u,0x000001deu,0x000001d7u,0x00050085u,0x00000006u,0x000001dfu,0x000001ddu,0x000001deu,0x0003003eu,0x000001dcu,0x000001dfu,0x0004003du,0x00000007u,0x000001e0u,0x000001a0u,0x0004003du,0x00000007u,0x000001e1u,0x000001c8u,0x0004003du,0x00000006u,0x000001e2u,0x000001dcu,0x00060050u,0x00000007u,0x000001e3u,0x000001e2u,0x000001e2u,0x000001e2u,0x0008000cu,0x00000007u,0x000001e4u,0x00000001u,0x0000002eu,0x000001e0u,0x000001e1u,0x000001e3u,0x0003003eu,0x000001a0u,0x000001e4u,0x0004003du,0x00000007u,0x000001e6u,0x000001a0u,0x0004003du,0x00000007u,0x000001e7u,0x00000187u,0x0004003du,0x00000006u,0x000001e8u,0x000001b7u,0x00060050u,0x00000007u,0x000001e9u,0x000001e8u,0x000001e8u,0x000001e8u,0x0008000cu,0x00000007u,0x000001eau,0x00000001u,0x0000002eu,0x000001e6u,0x000001e7u,0x000001e9u,0x0003003eu,0x000001e5u,0x000001eau,0x0004003du,0x00000027u,0x000001ebu,0x00000098u,0x000300f7u,0x000001edu,0x00000000u,0x000400fau,0x000001ebu,0x000001ecu,0x000001edu,0x000200f8u,0x000001ecu,0x0004003du,0x00000006u,0x000001efu,0x000000c9u,0x0004003du,0x00000006u,0x000001f0u,0x000000d5u,0x0007000cu,0x00000006u,0x000001f1u,0x00000001u,0x00000028u,0x000001efu,0x000001f0u,0x0003003eu,0x000001eeu,0x000001f1u,0x0004003du,0x00000006u,0x000001f3u,0x000001eeu,0x00050088u,0x00000006u,0x000001f4u,0x000001f3u,0x000000cdu,0x0008000cu,0x00000006u,0x000001f5u,0x00000001u,0x0000002bu,0x000001f4u,0x0000008fu,0x0000003fu,0x0003003eu,0x000001f2u,0x000001f5u,0x0004003du,0x00000006u,0x000001f7u,0x000001eeu,0x0007000cu,0x00000006u,0x000001f8u,0x00000001u,0x00000030u,0x000000cdu,0x000001f7u,0x0003003eu,0x000001f6u,0x000001f8u,0x0004003du,0x00000022u,0x000001f9u,0x00000024u,0x0004003du,0x00000016u,0x000001fau,0x00000018u,0x0004003du,0x00000006u,0x000001fbu,0x000001f6u,0x0004003du,0x00000006u,0x000001fcu,0x000001f2u,0x00070050u,0x0000004cu,0x000001fdu,0x000001fbu,0x000001fcu,0x0000008fu,0x0000003fu,0x00040063u,0x000001f9u,0x000001fau,0x000001fdu,0x000100fdu,0x000200f8u,0x000001edu,0x0004003du,0x00000022u,0x000001ffu,0x00000024u,0x0004003du,0x00000016u,0x00000200u,0x00000018u,0x0004003du,0x00000007u,0x00000201u,0x000001e5u,0x00050051u,0x00000006u,0x00000202u,0x00000201u,0x00000000u,0x00050051u,0x00000006u,0x00000203u,0x00000201u,0x00000001u,0x00050051u,0x00000006u,0x00000204u,0x00000201u,0x00000002u,0x00070050u,0x0000004cu,0x00000205u,0x00000202u,0x00000203u,0x00000204u,0x0000003fu,0x00040063u,0x000001ffu,0x00000200u,0x00000205u,0x000100fdu,0x00010038u,0x00050036u,0x00000006u,0x0000000bu,0x00000000u,0x00000009u,0x00030037u,0x00000008u,0x0000000au,0x000200f8u,0x0000000cu,0x0004003du,0x00000007u,0x0000000du,0x0000000au,0x00050094u,0x00000006u,0x00000012u,0x0000000du,0x00000011u,0x000200feu,0x00000012u,0x00010038u}; static const size_t DDFG_SYNTH_LEN = 3082; struct Blob { const uint32_t* code; size_t words; }; diff --git a/app/src/main/cpp/framegen/ddfg/framegen.cpp b/app/src/main/cpp/framegen/ddfg/framegen.cpp index 5200f6b094..20cc5e2d4a 100644 --- a/app/src/main/cpp/framegen/ddfg/framegen.cpp +++ b/app/src/main/cpp/framegen/ddfg/framegen.cpp @@ -3,9 +3,35 @@ #include "log.hpp" #include #include +#include namespace ddfg { +struct ScratchState { + VkDevice ownerDevice = VK_NULL_HANDLE; + VkBuffer synthUbo[ddfg::FrameGen::kSynthSlots]{}; + VkDeviceMemory synthUboMem[ddfg::FrameGen::kSynthSlots]{}; + void* synthUboPtr[ddfg::FrameGen::kSynthSlots]{}; + std::vector flowUbo; std::vector flowUboMem; std::vector flowUboPtr; + VkBuffer expandUbo = VK_NULL_HANDLE; VkDeviceMemory expandUboMem = VK_NULL_HANDLE; void* expandUboPtr = nullptr; + VkBuffer flowRegUbo = VK_NULL_HANDLE; VkDeviceMemory flowRegUboMem = VK_NULL_HANDLE; void* flowRegUboPtr = nullptr; + VkBuffer gmUbo[ddfg::FrameGen::kGmSlots]{}; + VkDeviceMemory gmUboMem[ddfg::FrameGen::kGmSlots]{}; + void* gmUboPtr[ddfg::FrameGen::kGmSlots]{}; + VkDescriptorSet sLumaCurr = VK_NULL_HANDLE, sLumaPrev = VK_NULL_HANDLE; + std::vector sDownA, sDownB, sFlow; + VkDescriptorSet sExpand[ddfg::FrameGen::kGmSlots]{}; + VkDescriptorSet sFlowReg0 = VK_NULL_HANDLE, sFlowRegAB = VK_NULL_HANDLE, sFlowRegBA = VK_NULL_HANDLE; + VkDescriptorSet sSynth[ddfg::FrameGen::kSynthSlots]{}; + VkDescriptorSet sGmReduce[ddfg::FrameGen::kGmSlots]{}; + std::vector sGmPrewarp[ddfg::FrameGen::kGmSlots]; + VkExtent2D builtFor{0,0}; + uint64_t builtGeneration = 0; + bool built = false; + bool flowInited = false; + bool flowReady = false; +}; + #define VKOK(x) do { if ((x) != VK_SUCCESS) { DDFG_LOGE("vk fail: %s", #x); return false; } } while (0) uint32_t FrameGen::findMemType(uint32_t bits, VkMemoryPropertyFlags props) const { @@ -107,6 +133,10 @@ static bool buildSetLayout(const DeviceDispatch* dd, VkDevice dev, bool FrameGen::init(const DeviceDispatch* dd, const InstanceDispatch* id, VkPhysicalDevice phys, VkDevice dev, uint32_t queueFamily, VkQueue queue) { + if (device_ || completionUnknown_ || deviceLost_) { + DDFG_LOGE("framegen: refusing to initialize an instance that still owns device resources"); + return false; + } dd_ = dd; id_ = id; phys_ = phys; device_ = dev; queueFamily_ = queueFamily; queue_ = queue; id_->GetPhysicalDeviceMemoryProperties(phys_, &memProps_); @@ -165,16 +195,37 @@ static VkExtent2D levelExtent(VkExtent2D e, int l) { } bool FrameGen::onResize(VkExtent2D extent, VkFormat , bool force) { - - + if (completionUnknown_ || deviceLost_) return false; + if (!device_) { + DDFG_LOGE("framegen: cannot resize before device initialization"); + return false; + } if (!force && ready_ && extent.width == extent_.width && extent.height == extent_.height) return true; + if (ready_ && !waitIdle("resize")) return false; + if (scratch_ && scratch_->ownerDevice != VK_NULL_HANDLE && !destroyScratchResources()) { + DDFG_LOGE("framegen resize: scratch cleanup failed; retaining the previous image set"); + return false; + } + + ready_ = false; + ++imageGeneration_; for (auto& i : pyrA_) destroyImage(i); pyrA_.clear(); for (auto& i : pyrB_) destroyImage(i); pyrB_.clear(); for (auto& i : pyrAs_) destroyImage(i); pyrAs_.clear(); for (auto& i : flowLvl_) destroyImage(i); flowLvl_.clear(); destroyImage(flowExpA_); destroyImage(flowExpB_); destroyImage(flowRegA_); destroyImage(flowRegB_); - extent_ = extent; ready_ = false; + extent_ = extent; + + for (int i = 0; i < 6; ++i) gmRun_[i] = 0.0; + for (int s = 0; s < kGmSlots; ++s) { + gmSlotValid_[s] = false; + for (int i = 0; i < 6; ++i) gmLinAt_[s][i] = 0.0; + } + gmHaveEst_ = false; + gmEngaged_ = false; + gmStableCount_ = 0; + gmLastTransPx_ = 0.0f; const VkImageUsageFlags lumaUsage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT; const VkImageUsageFlags flowUsage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; @@ -211,10 +262,51 @@ void FrameGen::barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkI VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); } +void FrameGen::initializeImage(VkCommandBuffer cmd, VkImage img, VkImageLayout to) { + VkImageMemoryBarrier b{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; + b.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; + b.newLayout = to; + b.srcAccessMask = 0; + b.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + b.image = img; + b.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + b.srcQueueFamilyIndex = b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + dd_->CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); +} -void FrameGen::destroy() { - if (!device_) return; - dd_->DeviceWaitIdle(device_); + +bool FrameGen::destroy() { + if (!device_) return true; + if (!deviceLost_) { + // A previous wait failure leaves completion unknown, but a later + // teardown attempt may safely retry the wait before releasing resources. + if (!dd_ || !dd_->DeviceWaitIdle) { + ready_ = false; + completionUnknown_ = true; + DDFG_LOGE("framegen destroy: vkDeviceWaitIdle is unavailable; preserving GPU resources"); + return false; + } + const VkResult idleResult = dd_->DeviceWaitIdle(device_); + if (idleResult == VK_SUCCESS) completionUnknown_ = false; + if (idleResult != VK_SUCCESS) { + ready_ = false; + if (idleResult == VK_ERROR_DEVICE_LOST) { + deviceLost_ = true; + DDFG_LOGE("framegen destroy: device lost; releasing owned resources without waiting"); + } else { + completionUnknown_ = true; + DDFG_LOGE("framegen destroy: DeviceWaitIdle failed (%d); preserving resources because GPU completion is unknown", + (int)idleResult); + return false; + } + } + } + + ready_ = false; + if (descPool_) dd_->DestroyDescriptorPool(device_, descPool_, nullptr); + descPool_ = VK_NULL_HANDLE; + releaseScratch(); for (auto& i : pyrA_) destroyImage(i); pyrA_.clear(); for (auto& i : pyrB_) destroyImage(i); pyrB_.clear(); for (auto& i : pyrAs_) destroyImage(i); pyrAs_.clear(); @@ -226,15 +318,45 @@ void FrameGen::destroy() { destroyPipe(pGmReduce_); destroyPipe(pGmPrewarp_); destroyPipe(pFlowReg_); for (int s = 0; s < kGmSlots; ++s) { - if (gmSsboMem_[s]) dd_->UnmapMemory(device_, gmSsboMem_[s]); + if (gmSsboPtr_[s] && gmSsboMem_[s]) dd_->UnmapMemory(device_, gmSsboMem_[s]); if (gmSsbo_[s]) dd_->DestroyBuffer(device_, gmSsbo_[s], nullptr); if (gmSsboMem_[s]) dd_->FreeMemory(device_, gmSsboMem_[s], nullptr); gmSsbo_[s] = VK_NULL_HANDLE; gmSsboMem_[s] = VK_NULL_HANDLE; gmSsboPtr_[s] = nullptr; } gmBuffersReady_ = false; - if (descPool_) dd_->DestroyDescriptorPool(device_, descPool_, nullptr); if (linear_) dd_->DestroySampler(device_, linear_, nullptr); - descPool_ = VK_NULL_HANDLE; linear_ = VK_NULL_HANDLE; device_ = VK_NULL_HANDLE; ready_ = false; + linear_ = VK_NULL_HANDLE; + device_ = VK_NULL_HANDLE; + ready_ = false; + deviceLost_ = false; + return true; +} + +void FrameGen::abandon() { + device_ = VK_NULL_HANDLE; + dd_ = nullptr; + id_ = nullptr; + phys_ = VK_NULL_HANDLE; + queue_ = VK_NULL_HANDLE; + linear_ = VK_NULL_HANDLE; + descPool_ = VK_NULL_HANDLE; + scratch_.reset(); + pyrA_.clear(); pyrB_.clear(); pyrAs_.clear(); flowLvl_.clear(); + flowExpA_ = Img{}; flowExpB_ = Img{}; + flowRegA_ = Img{}; flowRegB_ = Img{}; + pLuma_ = Pipe{}; pDown_ = Pipe{}; pFlow_ = Pipe{}; pFlowM4_ = Pipe{}; + pExpand_ = Pipe{}; pExpandM4_ = Pipe{}; pSynth_ = Pipe{}; + pGmReduce_ = Pipe{}; pGmPrewarp_ = Pipe{}; pFlowReg_ = Pipe{}; + for (int s = 0; s < kGmSlots; ++s) { + gmSsbo_[s] = VK_NULL_HANDLE; + gmSsboMem_[s] = VK_NULL_HANDLE; + gmSsboPtr_[s] = nullptr; + gmSlotValid_[s] = false; + } + gmBuffersReady_ = false; + ready_ = false; + completionUnknown_ = false; + deviceLost_ = false; } } diff --git a/app/src/main/cpp/framegen/ddfg/framegen.hpp b/app/src/main/cpp/framegen/ddfg/framegen.hpp index 70719e7963..bba77480c7 100644 --- a/app/src/main/cpp/framegen/ddfg/framegen.hpp +++ b/app/src/main/cpp/framegen/ddfg/framegen.hpp @@ -1,12 +1,20 @@ #pragma once #include "vk_dispatch.hpp" #include "config.hpp" +#include #include namespace ddfg { +struct ScratchState; + class FrameGen { public: + FrameGen(); + ~FrameGen(); + FrameGen(const FrameGen&) = delete; + FrameGen& operator=(const FrameGen&) = delete; + bool init(const DeviceDispatch* dd, const InstanceDispatch* id, VkPhysicalDevice phys, VkDevice dev, uint32_t queueFamily, VkQueue queue); void configure(const Config& c); @@ -14,7 +22,8 @@ public: void record(VkCommandBuffer cmd, VkImageView prevView, VkImageView currView, VkImageView outView, float alpha, uint32_t gmSlot = 0, uint32_t synthSlot = 0, bool reuseFlow = false); - void destroy(); + bool destroy(); + void abandon(); bool valid() const { return device_ != VK_NULL_HANDLE && ready_; } const Config& config() const { return cfg_; } @@ -63,6 +72,10 @@ private: const std::vector& bindings); void destroyPipe(Pipe& p); void barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkImageLayout to); + void initializeImage(VkCommandBuffer cmd, VkImage img, VkImageLayout to); + bool waitIdle(const char* operation); + bool destroyScratchResources(bool resetPool = true); + void releaseScratch(); const DeviceDispatch* dd_ = nullptr; const InstanceDispatch* id_ = nullptr; @@ -76,8 +89,12 @@ private: Config cfg_; VkExtent2D extent_{}; + uint64_t imageGeneration_ = 0; bool ready_ = false; + bool completionUnknown_ = false; + bool deviceLost_ = false; int flowFinest_ = kFlowFinestDefault; + std::unique_ptr scratch_; Pipe pLuma_, pDown_, pFlow_, pFlowM4_, pExpand_, pExpandM4_, pSynth_; Pipe pGmReduce_, pGmPrewarp_; diff --git a/app/src/main/cpp/framegen/ddfg/record_impl.inc b/app/src/main/cpp/framegen/ddfg/record_impl.inc index f366d9a9c4..3922db391b 100644 --- a/app/src/main/cpp/framegen/ddfg/record_impl.inc +++ b/app/src/main/cpp/framegen/ddfg/record_impl.inc @@ -1,31 +1,7 @@ -namespace { -struct ScratchState { - VkBuffer synthUbo[ddfg::FrameGen::kSynthSlots]{}; - VkDeviceMemory synthUboMem[ddfg::FrameGen::kSynthSlots]{}; - void* synthUboPtr[ddfg::FrameGen::kSynthSlots]{}; - std::vector flowUbo; std::vector flowUboMem; std::vector flowUboPtr; - VkBuffer expandUbo = VK_NULL_HANDLE; VkDeviceMemory expandUboMem = VK_NULL_HANDLE; void* expandUboPtr = nullptr; - VkBuffer flowRegUbo = VK_NULL_HANDLE; VkDeviceMemory flowRegUboMem = VK_NULL_HANDLE; void* flowRegUboPtr = nullptr; - VkBuffer gmUbo[ddfg::FrameGen::kGmSlots]{}; - VkDeviceMemory gmUboMem[ddfg::FrameGen::kGmSlots]{}; - void* gmUboPtr[ddfg::FrameGen::kGmSlots]{}; - VkDescriptorSet sLumaCurr = VK_NULL_HANDLE, sLumaPrev = VK_NULL_HANDLE; - std::vector sDownA, sDownB, sFlow; - VkDescriptorSet sExpand[ddfg::FrameGen::kGmSlots]{}; - - - - VkDescriptorSet sFlowReg0 = VK_NULL_HANDLE, sFlowRegAB = VK_NULL_HANDLE, sFlowRegBA = VK_NULL_HANDLE; - VkDescriptorSet sSynth[ddfg::FrameGen::kSynthSlots]{}; - VkDescriptorSet sGmReduce[ddfg::FrameGen::kGmSlots]{}; - std::vector sGmPrewarp[ddfg::FrameGen::kGmSlots]; - VkExtent2D builtFor{0,0}; - bool built = false; - bool flowInited = false; - bool flowReady = false; -}; -ScratchState g_scratch; +namespace ddfg { +FrameGen::FrameGen() : scratch_(std::make_unique()) {} +FrameGen::~FrameGen() { (void)destroy(); } } static bool makeUbo(const ddfg::DeviceDispatch* dd, VkDevice dev, @@ -58,6 +34,26 @@ static void wImg(const ddfg::DeviceDispatch* dd, VkDevice dev, VkDescriptorSet s w.dstSet = set; w.dstBinding = binding; w.descriptorCount = 1; w.descriptorType = type; w.pImageInfo = ⅈ dd->UpdateDescriptorSets(dev, 1, &w, 0, nullptr); } +static void wImgBatch(const ddfg::DeviceDispatch* dd, VkDevice dev, + const VkDescriptorSet* sets, const uint32_t* bindings, + const VkDescriptorType* types, const VkImageView* views, + const VkSampler* samplers, const VkImageLayout* layouts, + uint32_t count) { + VkDescriptorImageInfo infos[3]{}; + VkWriteDescriptorSet writes[3]{}; + for (uint32_t i = 0; i < count; ++i) { + infos[i].imageView = views[i]; + infos[i].sampler = samplers[i]; + infos[i].imageLayout = layouts[i]; + writes[i] = {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}; + writes[i].dstSet = sets[i]; + writes[i].dstBinding = bindings[i]; + writes[i].descriptorCount = 1; + writes[i].descriptorType = types[i]; + writes[i].pImageInfo = &infos[i]; + } + dd->UpdateDescriptorSets(dev, count, writes, 0, nullptr); +} static void wUbo(const ddfg::DeviceDispatch* dd, VkDevice dev, VkDescriptorSet set, uint32_t binding, VkBuffer buf, VkDeviceSize range) { VkDescriptorBufferInfo bi{}; bi.buffer = buf; bi.range = range; @@ -122,7 +118,7 @@ static void mulAff(const double A[3][3], const double B[3][3], double out[3][3]) namespace ddfg { -static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, +static bool ensureScratch(ScratchState& S, FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, const VkPhysicalDeviceMemoryProperties& mp, VkDescriptorPool pool, VkSampler samp, VkExtent2D ext, std::vector& pyrA, std::vector& pyrB, @@ -133,58 +129,123 @@ static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, const FrameGen::Pipe& pSynth, const FrameGen::Pipe& pGmReduce, const FrameGen::Pipe& pGmPrewarp, const FrameGen::Pipe& pFlowReg, FrameGen::Img& flowRegA, FrameGen::Img& flowRegB, VkBuffer* gmSsbo, - int kLevels, const Config& cfg); + int kLevels, const Config& cfg, uint64_t imageGeneration); -static void destroyScratch(const DeviceDispatch* dd, VkDevice dev, VkDescriptorPool pool) { +bool FrameGen::waitIdle(const char* operation) { + if (completionUnknown_ || deviceLost_ || !device_) return false; + if (!dd_ || !dd_->DeviceWaitIdle) { + completionUnknown_ = true; + ready_ = false; + DDFG_LOGE("framegen: %s cannot confirm GPU completion; this instance is stopped and its resources are retained", + operation); + return false; + } + const VkResult result = dd_->DeviceWaitIdle(device_); + if (result == VK_SUCCESS) return true; + ready_ = false; + if (result == VK_ERROR_DEVICE_LOST) { + deviceLost_ = true; + DDFG_LOGE("framegen: %s reported device loss; cleanup will skip further waits", operation); + } else { + completionUnknown_ = true; + DDFG_LOGE("framegen: %s vkDeviceWaitIdle failed (%d); this instance is stopped and its GPU resources retained", + operation, (int)result); + } + return false; +} + +bool FrameGen::destroyScratchResources(bool resetPool) { + if (!scratch_) return true; + if (resetPool && descPool_ && !deviceLost_) { + if (!dd_ || !dd_->ResetDescriptorPool) { + ready_ = false; + DDFG_LOGE("framegen: descriptor-pool reset is unavailable; retaining scratch resources"); + return false; + } + const VkResult result = dd_->ResetDescriptorPool(device_, descPool_, 0); + if (result != VK_SUCCESS) { + ready_ = false; + if (result == VK_ERROR_DEVICE_LOST) deviceLost_ = true; + DDFG_LOGE("framegen: descriptor-pool reset failed (%d); retaining scratch resources", + (int)result); + return false; + } + } + releaseScratch(); + return true; +} + +void FrameGen::releaseScratch() { + if (!scratch_) return; + auto& S = *scratch_; auto freeUbo = [&](VkBuffer& b, VkDeviceMemory& m, void*& p) { - if (m) dd->UnmapMemory(dev, m); - if (b) dd->DestroyBuffer(dev, b, nullptr); - if (m) dd->FreeMemory(dev, m, nullptr); - b = VK_NULL_HANDLE; m = VK_NULL_HANDLE; p = nullptr; + if (p && m) dd_->UnmapMemory(device_, m); + if (b) dd_->DestroyBuffer(device_, b, nullptr); + if (m) dd_->FreeMemory(device_, m, nullptr); + b = VK_NULL_HANDLE; + m = VK_NULL_HANDLE; + p = nullptr; }; - auto& S = g_scratch; for (int s = 0; s < FrameGen::kSynthSlots; ++s) freeUbo(S.synthUbo[s], S.synthUboMem[s], S.synthUboPtr[s]); - freeUbo(S.expandUbo, S.expandUboMem, S.expandUboPtr); + freeUbo(S.expandUbo, S.expandUboMem, S.expandUboPtr); freeUbo(S.flowRegUbo, S.flowRegUboMem, S.flowRegUboPtr); for (size_t i = 0; i < S.flowUbo.size(); ++i) freeUbo(S.flowUbo[i], S.flowUboMem[i], S.flowUboPtr[i]); for (int s = 0; s < FrameGen::kGmSlots; ++s) freeUbo(S.gmUbo[s], S.gmUboMem[s], S.gmUboPtr[s]); - if (pool && dd->ResetDescriptorPool) dd->ResetDescriptorPool(dev, pool, 0); S = ScratchState{}; } + void FrameGen::configure(const Config& c) { - cfg_ = c; cfg_.sanitize(); - int want = flowFinestForPreset(cfg_.perfPreset); + if (completionUnknown_ || deviceLost_) return; + Config nextCfg = c; + nextCfg.sanitize(); + int want = flowFinestForPreset(nextCfg.perfPreset); const int maxFinest = kLevels - 2; if (want > maxFinest) { DDFG_LOGE("perf-preset=%d wants kFlowFinest=%d but only %d pyramid levels exist " - "(need >=2 solved) - clamping to %d", cfg_.perfPreset, want, kLevels, maxFinest); + "(need >=2 solved) - clamping to %d", nextCfg.perfPreset, want, kLevels, maxFinest); want = maxFinest; } if (want < 1) want = 1; const int prevFinest = flowFinest_; - flowFinest_ = want; - const bool live = (flowFinest_ != prevFinest) && ready_; + const bool live = (want != prevFinest) && ready_; DDFG_LOGI("perf-preset=%d -> kFlowFinest=%d (was %d) live-rebuild=%d ready=%d", - cfg_.perfPreset, flowFinest_, prevFinest, live ? 1 : 0, ready_ ? 1 : 0); + nextCfg.perfPreset, want, prevFinest, live ? 1 : 0, ready_ ? 1 : 0); - if (!live) return; + if (!live) { + cfg_ = nextCfg; + flowFinest_ = want; + return; + } + if (!waitIdle("live preset rebuild")) return; + if (scratch_ && scratch_->ownerDevice != VK_NULL_HANDLE && !destroyScratchResources()) { + DDFG_LOGE("perf-preset live rebuild: scratch cleanup failed; keeping the previous configuration"); + return; + } - - - dd_->DeviceWaitIdle(device_); - destroyScratch(dd_, device_, descPool_); - if (!onResize(extent_, VK_FORMAT_UNDEFINED, true)) - DDFG_LOGE("perf-preset live rebuild: onResize FAILED at %ux%u - FG disabled until next resize", - extent_.width, extent_.height); for (int i = 0; i < 6; ++i) gmRun_[i] = 0.0; - for (int s = 0; s < kGmSlots; ++s) { gmSlotValid_[s] = false; for (int i = 0; i < 6; ++i) gmLinAt_[s][i] = 0.0; } - gmHaveEst_ = false; gmEngaged_ = false; gmStableCount_ = 0; gmLastTransPx_ = 0.0f; + for (int s = 0; s < kGmSlots; ++s) { + gmSlotValid_[s] = false; + for (int i = 0; i < 6; ++i) gmLinAt_[s][i] = 0.0; + } + gmHaveEst_ = false; + gmEngaged_ = false; + gmStableCount_ = 0; + gmLastTransPx_ = 0.0f; + + cfg_ = nextCfg; + flowFinest_ = want; + ready_ = false; + if (!onResize(extent_, VK_FORMAT_UNDEFINED, true)) { + ready_ = false; + DDFG_LOGE("perf-preset live rebuild: onResize FAILED at %ux%u - frame generation unavailable", + extent_.width, extent_.height); + return; + } DDFG_LOGI("perf-preset live rebuild DONE (kFlowFinest=%d, flow predictor reset)", flowFinest_); } - bool FrameGen::updateGlobalMotion(uint32_t gmSlot, VkExtent2D fullExtent) { ++gmFrames_; if (!gmBuffersReady_ || cfg_.gmMode == 2 ) { @@ -199,10 +260,10 @@ bool FrameGen::updateGlobalMotion(uint32_t gmSlot, VkExtent2D fullExtent) { bool good = false; if (gmSlotValid_[gmSlot]) { const float* pt = (const float*)gmSsboPtr_[gmSlot]; - double sums[32]; for (int k = 0; k < 32; ++k) sums[k] = 0.0; + double sums[28]{}; for (int t = 0; t < kGmThreads; ++t) { const float* row = pt + (size_t)t * kGmStride; - for (int k = 0; k < kGmStride; ++k) sums[k] += (double)row[k]; + for (int k = 0; k < 28; ++k) sums[k] += (double)row[k]; } double coverage = sums[27]; double lvlpx = double((fullExtent.width >> kGmLevel) * (fullExtent.height >> kGmLevel)); @@ -254,23 +315,33 @@ bool FrameGen::updateGlobalMotion(uint32_t gmSlot, VkExtent2D fullExtent) { void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView currView, VkImageView outView, float alpha, uint32_t gmSlot, uint32_t synthSlot, bool reuseFlow) { if (!valid()) return; + auto& S = *scratch_; if (gmSlot >= (uint32_t)kGmSlots) gmSlot = 0; if (synthSlot >= (uint32_t)kSynthSlots) synthSlot = 0; const bool m4 = (cfg_.model == 4); const Pipe& flowP = m4 ? pFlowM4_ : pFlow_; const Pipe& expandP = m4 ? pExpandM4_ : pExpand_; - if (!g_scratch.built || g_scratch.builtFor.width != extent_.width || g_scratch.builtFor.height != extent_.height) { - ensureScratch(this, dd_, device_, memProps_, descPool_, linear_, extent_, - pyrA_, pyrB_, pyrAs_, flowLvl_, flowExpA_, flowExpB_, - pLuma_, pDown_, flowP, expandP, pSynth_, pGmReduce_, pGmPrewarp_, - pFlowReg_, flowRegA_, flowRegB_, gmSsbo_, kLevels, cfg_); + if (!S.built || S.builtFor.width != extent_.width || + S.builtFor.height != extent_.height || + S.builtGeneration != imageGeneration_) { + if (S.built && !waitIdle("scratch rebuild")) return; + if (S.ownerDevice != VK_NULL_HANDLE && !destroyScratchResources()) { + DDFG_LOGE("framegen record: scratch cleanup failed; skipping this frame"); + return; + } + if (!ensureScratch(S, this, dd_, device_, memProps_, descPool_, linear_, extent_, + pyrA_, pyrB_, pyrAs_, flowLvl_, flowExpA_, flowExpB_, + pLuma_, pDown_, flowP, expandP, pSynth_, pGmReduce_, pGmPrewarp_, + pFlowReg_, flowRegA_, flowRegB_, gmSsbo_, kLevels, cfg_, imageGeneration_)) + return; } - if (reuseFlow && !g_scratch.flowReady) return; + if (S.ownerDevice != device_) return; + if (reuseFlow && !S.flowReady) return; if (!reuseFlow) { bool gmEngaged = updateGlobalMotion(gmSlot, extent_); - if (g_scratch.gmUboPtr[gmSlot]) { + if (S.gmUboPtr[gmSlot]) { GMUBO g{}; g.lin[0]=(float)gmRun_[0]; g.lin[1]=(float)gmRun_[1]; g.lin[2]=(float)gmRun_[2]; g.lin[3]=(float)gmRun_[3]; g.linT[0]=(float)gmRun_[4]; g.linT[1]=(float)gmRun_[5]; g.linT[2]=gmEngaged?1.0f:0.0f; g.linT[3]=0.0f; @@ -278,7 +349,7 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur g.app[0]=(float)gmRun_[0]; g.app[1]=(float)gmRun_[1]; g.app[2]=(float)gmRun_[2]; g.app[3]=(float)gmRun_[3]; g.appT[0]=(float)gmRun_[4]; g.appT[1]=(float)gmRun_[5]; } - std::memcpy(g_scratch.gmUboPtr[gmSlot], &g, sizeof(g)); + std::memcpy(S.gmUboPtr[gmSlot], &g, sizeof(g)); } { static int lastEng = -1; @@ -289,18 +360,37 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur } } - wImg(dd_, device_, g_scratch.sLumaCurr, 32, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, currView, linear_, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - wImg(dd_, device_, g_scratch.sLumaPrev, 32, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, prevView, linear_, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + const VkDescriptorSet lumaSets[] = {S.sLumaCurr, S.sLumaPrev}; + const uint32_t lumaBindings[] = {32, 32}; + const VkDescriptorType lumaTypes[] = { + VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER}; + const VkImageView lumaViews[] = {currView, prevView}; + const VkSampler lumaSamplers[] = {linear_, linear_}; + const VkImageLayout lumaLayouts[] = { + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL}; + wImgBatch(dd_, device_, lumaSets, lumaBindings, lumaTypes, lumaViews, + lumaSamplers, lumaLayouts, 2); } SynthUBO su{cfg_.flowScale, alpha, cfg_.beta, cfg_.lambda, cfg_.epsilon, cfg_.photoScale, 0, 0, cfg_.hudX0, cfg_.hudY0, cfg_.hudX1, cfg_.hudY1}; - if (g_scratch.synthUboPtr[synthSlot]) std::memcpy(g_scratch.synthUboPtr[synthSlot], &su, sizeof(su)); + if (S.synthUboPtr[synthSlot]) std::memcpy(S.synthUboPtr[synthSlot], &su, sizeof(su)); - const VkDescriptorSet synthSet = g_scratch.sSynth[synthSlot]; - wImg(dd_, device_, synthSet, 32, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, prevView, linear_, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - wImg(dd_, device_, synthSet, 33, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, currView, linear_, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - wImg(dd_, device_, synthSet, 48, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, outView, VK_NULL_HANDLE, VK_IMAGE_LAYOUT_GENERAL); + const VkDescriptorSet synthSet = S.sSynth[synthSlot]; + const VkDescriptorSet synthSets[] = {synthSet, synthSet, synthSet}; + const uint32_t synthBindings[] = {32, 33, 48}; + const VkDescriptorType synthTypes[] = { + VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, + VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, + VK_DESCRIPTOR_TYPE_STORAGE_IMAGE}; + const VkImageView synthViews[] = {prevView, currView, outView}; + const VkSampler synthSamplers[] = {linear_, linear_, VK_NULL_HANDLE}; + const VkImageLayout synthLayouts[] = { + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_GENERAL}; + wImgBatch(dd_, device_, synthSets, synthBindings, synthTypes, synthViews, + synthSamplers, synthLayouts, 3); auto disp = [&](const Pipe& p, VkDescriptorSet set, VkExtent2D e) { dd_->CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, p.pipeline); @@ -308,43 +398,94 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur dd_->CmdDispatch(cmd, (e.width + 15) / 16, (e.height + 15) / 16, 1); }; auto bar = [&](FrameGen::Img& i){ barrier(cmd, i.image, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_GENERAL); }; + auto barPair = [&](FrameGen::Img& a, FrameGen::Img& b) { + VkImageMemoryBarrier barriers[2]{}; + FrameGen::Img* images[] = {&a, &b}; + for (uint32_t i = 0; i < 2; ++i) { + barriers[i].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + barriers[i].srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + barriers[i].dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; + barriers[i].oldLayout = VK_IMAGE_LAYOUT_GENERAL; + barriers[i].newLayout = VK_IMAGE_LAYOUT_GENERAL; + barriers[i].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barriers[i].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barriers[i].image = images[i]->image; + barriers[i].subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + } + dd_->CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, + 0, nullptr, 2, barriers); + }; + const bool frEngaged = (cfg_.frMode != 2) && (cfg_.frIters > 0); if (!reuseFlow) { - for (auto& i : pyrA_) barrier(cmd, i.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - for (auto& i : pyrB_) barrier(cmd, i.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - for (int l = flowFinest_; l < kLevels; ++l) barrier(cmd, pyrAs_[l].image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - barrier(cmd, flowExpA_.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - barrier(cmd, flowExpB_.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - barrier(cmd, flowRegA_.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - barrier(cmd, flowRegB_.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); + // Batch fresh-image transitions that share the same stage and access masks. + std::array initBarriers{}; + size_t initBarrierCount = 0; + auto addInitBarrier = [&](VkImage image) { + VkImageMemoryBarrier b{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; + b.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; + b.newLayout = VK_IMAGE_LAYOUT_GENERAL; + b.srcAccessMask = 0; + b.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + b.image = image; + b.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + b.srcQueueFamilyIndex = b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + initBarriers[initBarrierCount++] = b; + }; + for (auto& i : pyrA_) addInitBarrier(i.image); + for (auto& i : pyrB_) addInitBarrier(i.image); + for (int l = flowFinest_; l < kLevels; ++l) addInitBarrier(pyrAs_[l].image); + addInitBarrier(flowExpA_.image); + addInitBarrier(flowExpB_.image); + if (frEngaged) { + addInitBarrier(flowRegA_.image); + addInitBarrier(flowRegB_.image); + } + // The final flow level is cleared through TRANSFER_DST_OPTIMAL below; + // the other levels can use the common initialization barrier. + for (int l = flowFinest_; l < kLevels - 1; ++l) addInitBarrier(flowLvl_[l].image); + if (initBarrierCount != 0) { + dd_->CmdPipelineBarrier(cmd, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, + 0, nullptr, static_cast(initBarrierCount), initBarriers.data()); + } { VkClearColorValue zero{}; VkImageSubresourceRange rng{VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; - for (int l = flowFinest_; l < kLevels; ++l) { - VkImageMemoryBarrier b{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; - b.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; b.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - b.srcAccessMask = 0; b.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - b.image = flowLvl_[l].image; b.subresourceRange = rng; - b.srcQueueFamilyIndex = b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - dd_->CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); - dd_->CmdClearColorImage(cmd, flowLvl_[l].image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &zero, 1, &rng); - b.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; b.newLayout = VK_IMAGE_LAYOUT_GENERAL; - b.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; b.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; - dd_->CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); - } + VkImageMemoryBarrier b{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; + b.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; + b.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + b.srcAccessMask = 0; + b.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + b.image = flowLvl_[kLevels - 1].image; + b.subresourceRange = rng; + b.srcQueueFamilyIndex = b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + dd_->CmdPipelineBarrier(cmd, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); + dd_->CmdClearColorImage(cmd, flowLvl_[kLevels - 1].image, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &zero, 1, &rng); + b.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + b.newLayout = VK_IMAGE_LAYOUT_GENERAL; + b.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + b.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; + dd_->CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); } - disp(pLuma_, g_scratch.sLumaCurr, levelExtent(extent_, 0)); - disp(pLuma_, g_scratch.sLumaPrev, levelExtent(extent_, 0)); - bar(pyrA_[0]); bar(pyrB_[0]); + disp(pLuma_, S.sLumaCurr, levelExtent(extent_, 0)); + disp(pLuma_, S.sLumaPrev, levelExtent(extent_, 0)); + barPair(pyrA_[0], pyrB_[0]); for (int l = 1; l < kLevels; ++l) { - disp(pDown_, g_scratch.sDownA[l - 1], levelExtent(extent_, l)); - disp(pDown_, g_scratch.sDownB[l - 1], levelExtent(extent_, l)); - bar(pyrA_[l]); bar(pyrB_[l]); + disp(pDown_, S.sDownA[l - 1], levelExtent(extent_, l)); + disp(pDown_, S.sDownB[l - 1], levelExtent(extent_, l)); + barPair(pyrA_[l], pyrB_[l]); } - if (gmBuffersReady_ && g_scratch.sGmReduce[gmSlot]) { + if (gmBuffersReady_ && S.sGmReduce[gmSlot]) { dd_->CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pGmReduce_.pipeline); - dd_->CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pGmReduce_.layout, 0, 1, &g_scratch.sGmReduce[gmSlot], 0, nullptr); + dd_->CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pGmReduce_.layout, 0, 1, &S.sGmReduce[gmSlot], 0, nullptr); dd_->CmdDispatch(cmd, (uint32_t)(kGmThreads / 64), 1, 1); VkMemoryBarrier mb{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; mb.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; mb.dstAccessMask = VK_ACCESS_HOST_READ_BIT; @@ -352,32 +493,31 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur 0, 1, &mb, 0, nullptr, 0, nullptr); } for (int l = flowFinest_; l < kLevels; ++l) { - disp(pGmPrewarp_, g_scratch.sGmPrewarp[gmSlot][l], levelExtent(extent_, l)); + disp(pGmPrewarp_, S.sGmPrewarp[gmSlot][l], levelExtent(extent_, l)); bar(pyrAs_[l]); } for (int l = kLevels - 1; l >= flowFinest_; --l) { - disp(flowP, g_scratch.sFlow[l], levelExtent(extent_, l)); + disp(flowP, S.sFlow[l], levelExtent(extent_, l)); bar(flowLvl_[l]); } - const bool frEngaged = (cfg_.frMode != 2) && (cfg_.frIters > 0); if (frEngaged) { const int F = flowFinest_; const VkExtent2D fe = levelExtent(extent_, F); - if (g_scratch.flowRegUboPtr) { + if (S.flowRegUboPtr) { FlowRegUBO fu{cfg_.frDt, cfg_.frLambda, cfg_.frEdge, cfg_.frEps}; - std::memcpy(g_scratch.flowRegUboPtr, &fu, sizeof(fu)); + std::memcpy(S.flowRegUboPtr, &fu, sizeof(fu)); } FrameGen::Img* last = nullptr; for (int it = 0; it < cfg_.frIters; ++it) { VkDescriptorSet set; FrameGen::Img* outImg; - if (it == 0) { set = g_scratch.sFlowReg0; outImg = &flowRegA_; } - else if (it % 2 == 1) { set = g_scratch.sFlowRegAB; outImg = &flowRegB_; } - else { set = g_scratch.sFlowRegBA; outImg = &flowRegA_; } + if (it == 0) { set = S.sFlowReg0; outImg = &flowRegA_; } + else if (it % 2 == 1) { set = S.sFlowRegAB; outImg = &flowRegB_; } + else { set = S.sFlowRegBA; outImg = &flowRegA_; } dd_->CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pFlowReg_.pipeline); dd_->CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pFlowReg_.layout, 0, 1, &set, 0, nullptr); dd_->CmdDispatch(cmd, (fe.width + 15) / 16, (fe.height + 15) / 16, 1); - bar(*outImg); + if (it + 1 < cfg_.frIters) bar(*outImg); last = outImg; } VkMemoryBarrier mb{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; @@ -407,14 +547,14 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur } } - disp(expandP, g_scratch.sExpand[gmSlot], levelExtent(extent_, 0)); - bar(flowExpA_); bar(flowExpB_); - g_scratch.flowReady = true; + disp(expandP, S.sExpand[gmSlot], levelExtent(extent_, 0)); + barPair(flowExpA_, flowExpB_); + S.flowReady = true; } disp(pSynth_, synthSet, levelExtent(extent_, 0)); } -static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, +static bool ensureScratch(ScratchState& S, FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, const VkPhysicalDeviceMemoryProperties& mp, VkDescriptorPool pool, VkSampler samp, VkExtent2D ext, std::vector& pyrA, std::vector& pyrB, @@ -425,9 +565,10 @@ static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, const FrameGen::Pipe& pSynth, const FrameGen::Pipe& pGmReduce, const FrameGen::Pipe& pGmPrewarp, const FrameGen::Pipe& pFlowReg, FrameGen::Img& flowRegA, FrameGen::Img& flowRegB, VkBuffer* gmSsbo, - int kLevels, const Config& cfg) { - auto& S = g_scratch; + int kLevels, const Config& cfg, uint64_t imageGeneration) { + if (S.ownerDevice != VK_NULL_HANDLE && S.ownerDevice != dev) return false; S = ScratchState{}; + S.ownerDevice = dev; const auto GEN = VK_IMAGE_LAYOUT_GENERAL; for (int s = 0; s < FrameGen::kSynthSlots; ++s) @@ -528,7 +669,7 @@ static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, wImg(dd, dev, S.sSynth[s], 35, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, expB.view, samp, GEN); } - S.builtFor = ext; S.built = true; + S.builtFor = ext; S.builtGeneration = imageGeneration; S.ownerDevice = dev; S.built = true; return true; } diff --git a/app/src/main/cpp/questxr/quest_xr.cpp b/app/src/main/cpp/questxr/quest_xr.cpp index 09423c7d1a..8646bd501c 100644 --- a/app/src/main/cpp/questxr/quest_xr.cpp +++ b/app/src/main/cpp/questxr/quest_xr.cpp @@ -614,10 +614,13 @@ private: XrSessionBeginInfo begin{XR_TYPE_SESSION_BEGIN_INFO}; begin.primaryViewConfigurationType = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO; check(xrBeginSession(session_, &begin), "xrBeginSession"); running_ = true; + // Meta's clock governor scales clocks by the DroidDeck process's overall load and cannot see + // SteamVR missing refreshes inside the guest; holding the top level kept it at 72 Hz. if (setPerformance_) { for (auto domain : {XR_PERF_SETTINGS_DOMAIN_CPU_EXT, XR_PERF_SETTINGS_DOMAIN_GPU_EXT}) { - XrResult request = setPerformance_(session_, domain, XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT); - __android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "sustained performance domain=%d result=%d", domain, request); + XrResult request = setPerformance_(session_, domain, XR_PERF_SETTINGS_LEVEL_BOOST_EXT); + if (XR_FAILED(request)) request = setPerformance_(session_, domain, XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT); + __android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "performance domain=%d result=%d", domain, request); } } } else if (state_ == XR_SESSION_STATE_STOPPING) { diff --git a/app/src/main/cpp/sdnative/sdnative.c b/app/src/main/cpp/sdnative/sdnative.c index 85e0793b10..3e4ef71b41 100644 --- a/app/src/main/cpp/sdnative/sdnative.c +++ b/app/src/main/cpp/sdnative/sdnative.c @@ -1,6 +1,9 @@ #include #include +#include +#include #include +#include #include #include @@ -11,6 +14,13 @@ Java_com_droiddeck_launcher_input_FakeInputWriter_nativeStoreFence(JNIEnv *env, atomic_thread_fence(memory_order_release); } +JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_input_FakeInputWriter_nativeWake(JNIEnv *env, jclass clazz, jobject buffer, jint offset) { + (void)clazz; + uint8_t *base = (*env)->GetDirectBufferAddress(env, buffer); + if (base) syscall(SYS_futex, base + offset, FUTEX_WAKE, INT_MAX, NULL, NULL, 0); +} + JNIEXPORT jint JNICALL Java_com_droiddeck_launcher_session_ThreadSignals_tgkill(JNIEnv *env, jclass clazz, jint tgid, jint tid, jint signal) { (void)env; diff --git a/app/src/main/cpp/shaders/THIRD_PARTY_NOTICES.txt b/app/src/main/cpp/shaders/THIRD_PARTY_NOTICES.txt new file mode 100644 index 0000000000..761743c464 --- /dev/null +++ b/app/src/main/cpp/shaders/THIRD_PARTY_NOTICES.txt @@ -0,0 +1,126 @@ +Third-Party Notices — Graphics Shaders +====================================== + +AMD FidelityFX Super Resolution 1.0 (FSR 1.0) +---------------------------------------------- +The EASU (Edge-Adaptive Spatial Upsampling) and RCAS +(Robust Contrast-Adaptive Sharpening) shader implementations +are adapted from AMD's FidelityFX FSR 1.0 reference code. + +Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. + +SPDX-License-Identifier: MIT + +MIT License +----------- + +Permission is hereby granted, free of charge, to any person obtaining a copy +of 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. + +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. + +NVIDIA Image Scaling (NIS) +-------------------------- +The NIS fragment shader is adapted from NVIDIA's NVIDIA Image Scaling +reference implementation, including NVScaler and NIS configuration code. + +Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +SPDX-License-Identifier: MIT + +The NIS luma prepass (nis_luma.frag), the gather-based NIS pass (nis3.frag) and its +coefficient banks (nis_coef.h) are from the same NVIDIA reference. + +AMD FidelityFX CAS (Contrast Adaptive Sharpening) +------------------------------------------------- +The CAS fragment shader (cas_ffx.frag) is ported from AMD's reference header +GPUOpen-Effects/FidelityFX-CAS ffx-cas/ffx_cas.h (v1.0.2). + +Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved. + +SPDX-License-Identifier: MIT + +The MIT License text above applies to AMD FidelityFX FSR 1.0, AMD FidelityFX CAS and +NVIDIA Image Scaling (NIS). + +Snapdragon Game Super Resolution 1 (SGSR1) +------------------------------------------ +The SGSR fragment shaders are adapted from Qualcomm's reference GLSL +shaders, including the mobile and edge-direction variants. + +Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved. + +SPDX-License-Identifier: BSD-3-Clause + +BSD 3-Clause License (SGSR1) +---------------------------- +Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +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 +POSSIBILITY OF SUCH DAMAGE. + +Upstream SGSR1 BSD 3-Clause License (2023) +---------------------------- +Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +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 +POSSIBILITY OF SUCH DAMAGE. diff --git a/app/src/main/cpp/shaders/cas.frag b/app/src/main/cpp/shaders/cas.frag new file mode 100644 index 0000000000..26c3adee9c --- /dev/null +++ b/app/src/main/cpp/shaders/cas.frag @@ -0,0 +1,68 @@ +#version 450 + +// ============================================================================= +// AMD FidelityFX CAS (Contrast-Adaptive Sharpening) - pure-CAS path. +// +// Ported from the OpenGL FSREffect.java MODE_SUPER_RESOLUTION shader so the +// Vulkan compositor's post-process pipeline applies the SAME sharpen the GL +// renderer's "Sharpen (CAS)" toggle does. Composable: layers on top of any +// scaling mode and runs even at native resolution (no upscale). +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// +// Slider -> SHARPNESS mapping is done CPU-side (planUpscaleFrame): +// SHARPNESS = slider / 100 (clamped 0..1, default slider 60 -> 0.60) +// Higher slider = stronger sharpen. This is the genuine AMD CAS sharpness term +// (peak = lerp(8,5,SHARPNESS)); note the GL source's level->value comments were +// inverted, so we map directly to the AMD term instead of copying that table. +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in pixels + float sharpness; // CAS SHARPNESS term [0..1] +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +void main() { + vec2 uv = fragTexCoord; + vec2 px = 1.0 / pc.resolution; + float SHARPNESS = pc.sharpness; + + // 3x3 neighbourhood + vec3 a = texture(InputTexture, uv + vec2(-px.x, -px.y)).rgb; + vec3 b = texture(InputTexture, uv + vec2( 0.0, -px.y)).rgb; + vec3 c = texture(InputTexture, uv + vec2( px.x, -px.y)).rgb; + vec3 d = texture(InputTexture, uv + vec2(-px.x, 0.0)).rgb; + vec3 e = texture(InputTexture, uv).rgb; + vec3 f = texture(InputTexture, uv + vec2( px.x, 0.0)).rgb; + vec3 g = texture(InputTexture, uv + vec2(-px.x, px.y)).rgb; + vec3 h = texture(InputTexture, uv + vec2( 0.0, px.y)).rgb; + vec3 i = texture(InputTexture, uv + vec2( px.x, px.y)).rgb; + + // CAS + vec3 mnRGB = min(min(min(d, e), min(f, b)), h); + vec3 mnRGB2 = min(min(min(mnRGB, a), min(g, c)), i); + mnRGB += mnRGB2; + + vec3 mxRGB = max(max(max(d, e), max(f, b)), h); + vec3 mxRGB2 = max(max(max(mxRGB, a), max(g, c)), i); + mxRGB += mxRGB2; + + vec3 rcpMxRGB = vec3(1.0) / max(mxRGB, vec3(1e-6)); + vec3 ampRGB = clamp(min(mnRGB, 2.0 - mxRGB) * rcpMxRGB, 0.0, 1.0); + + float peak = 8.0 - 3.0 * SHARPNESS; + vec3 wRGB = -sqrt(ampRGB) / peak; + vec3 rcpWeightRGB = vec3(1.0) / (1.0 + 4.0 * wRGB); + + vec3 window = (b + d) + (f + h); + vec3 col = clamp((window * wRGB + e) * rcpWeightRGB, 0.0, 1.0); + + outColor = vec4(col, 1.0); +} diff --git a/app/src/main/cpp/shaders/cas_ffx.frag b/app/src/main/cpp/shaders/cas_ffx.frag new file mode 100644 index 0000000000..9e0b68a1f4 --- /dev/null +++ b/app/src/main/cpp/shaders/cas_ffx.frag @@ -0,0 +1,108 @@ +#version 450 + +// ============================================================================= +// AMD FidelityFX CAS (Contrast Adaptive Sharpening) - sharpen-only path. +// +// Ported from AMD's reference header: +// GPUOpen-Effects/FidelityFX-CAS ffx-cas/ffx_cas.h (v1.0.2, CAS 1.20190610) +// CasSetup() sharpness term + CasFilter() with noScaling == true. +// +// Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved. +// SPDX-License-Identifier: MIT +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of 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. +// +// 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. +// +// Adapted in Bannerlator (The412Banner/Bannerlator) for its compositors; here +// in the Wayland effects chain, built half only (cas_ffx_half_frag.h): +// - AMD's default build: CAS_BETTER_DIAGONALS, CAS_SLOW and CAS_GO_SLOWER not +// defined -> the 5-tap "circle" (b d e f h) and the green channel's weight +// for all channels. cas.frag (the previous shader) is the BETTER_DIAGONALS +// + CAS_SLOW maths with 9 taps. +// - APrxLoRcp / APrxLoSqrt / APrxMedRcp (bit-trick approximations for AMD +// ALUs) are plain 1/x and sqrt here. +// - Same push constants as cas.frag: ndc, input size, sharpness [0..1]. +// 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 +// 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 +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as in AMD's +// CasFilterH; positions stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + highp vec2 resolution; // input (= output) size in pixels + float sharpness; // CAS sharpness [0..1] +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +vec3 CasLoad(ivec2 p) { + ivec2 sz = textureSize(InputTexture, 0); + 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 AMax3F1(float x, float y, float z) { return max(x, max(y, z)); } + +void main() { + ivec2 sp = ivec2(fragTexCoord * pc.resolution); + + // CasSetup: sharp = -1 / lerp(8.0, 5.0, saturate(sharpness)). + float peak = -1.0 / mix(8.0, 5.0, clamp(pc.sharpness, 0.0, 1.0)); + + // b + // d e f + // h + vec3 b = CasLoad(sp + ivec2( 0, -1)); + vec3 d = CasLoad(sp + ivec2(-1, 0)); + vec3 e = CasLoad(sp); + vec3 f = CasLoad(sp + ivec2( 1, 0)); + vec3 h = CasLoad(sp + ivec2( 0, 1)); + + // Soft min and max of the circle (green only: the weight below uses green). + float mnG = AMin3F1(AMin3F1(d.g, e.g, f.g), b.g, h.g); + float mxG = AMax3F1(AMax3F1(d.g, e.g, f.g), b.g, h.g); + + // Smooth minimum distance to signal limit divided by smooth max. + // AMD's bit-trick reciprocal stays finite at 0; 1/0 here would give 0 * inf + // on black, so the max is floored (below one 8-bit step; mn = 0 there anyway). + float rcpMG = 1.0 / max(mxG, 1.0 / 1024.0); + float ampG = clamp(min(mnG, 1.0 - mxG) * rcpMG, 0.0, 1.0); + + // Shaping amount of sharpening. + ampG = sqrt(ampG); + + // Filter shape: 0 w 0 / w 1 w / 0 w 0 + float wG = ampG * peak; + float rcpWeight = 1.0 / (1.0 + 4.0 * wG); + vec3 pix = clamp((b * wG + d * wG + f * wG + h * wG + e) * rcpWeight, 0.0, 1.0); + + outColor = vec4(pix, 1.0); +} diff --git a/app/src/main/cpp/shaders/cas_ffx_half_frag.h b/app/src/main/cpp/shaders/cas_ffx_half_frag.h new file mode 100644 index 0000000000..22fbf6119b --- /dev/null +++ b/app/src/main/cpp/shaders/cas_ffx_half_frag.h @@ -0,0 +1,214 @@ + // 1116.2.0 + #pragma once +const uint32_t cas_ffx_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x000000d7,0x00000000,0x00020011,0x00000001,0x00020011, + 0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e, + 0x00000000,0x00000001,0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000043, + 0x000000d1,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x00060005,0x0000000d,0x4c736143,0x2864616f,0x3b326976, + 0x00000000,0x00030005,0x0000000c,0x00000070,0x00070005,0x00000014,0x6e694d41,0x28314633, + 0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000011,0x00000078,0x00030005,0x00000012, + 0x00000079,0x00030005,0x00000013,0x0000007a,0x00070005,0x00000019,0x78614d41,0x28314633, + 0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000016,0x00000078,0x00030005,0x00000017, + 0x00000079,0x00030005,0x00000018,0x0000007a,0x00030005,0x0000001b,0x00007a73,0x00060005, + 0x0000001f,0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x00000040,0x00007073, + 0x00060005,0x00000043,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00030005,0x00000045, + 0x00004350,0x00040006,0x00000045,0x00000000,0x0063646e,0x00060006,0x00000045,0x00000001, + 0x6f736572,0x6974756c,0x00006e6f,0x00060006,0x00000045,0x00000002,0x72616873,0x73656e70, + 0x00000073,0x00030005,0x00000047,0x00006370,0x00040005,0x0000004d,0x6b616570,0x00000000, + 0x00030005,0x0000005b,0x00000062,0x00040005,0x00000060,0x61726170,0x0000006d,0x00030005, + 0x00000062,0x00000064,0x00040005,0x00000066,0x61726170,0x0000006d,0x00030005,0x00000068, + 0x00000065,0x00040005,0x00000069,0x61726170,0x0000006d,0x00030005,0x0000006c,0x00000066, + 0x00040005,0x00000070,0x61726170,0x0000006d,0x00030005,0x00000072,0x00000068,0x00040005, + 0x00000076,0x61726170,0x0000006d,0x00030005,0x00000078,0x00476e6d,0x00040005,0x00000079, + 0x61726170,0x0000006d,0x00040005,0x0000007e,0x61726170,0x0000006d,0x00040005,0x00000081, + 0x61726170,0x0000006d,0x00040005,0x00000085,0x61726170,0x0000006d,0x00040005,0x00000086, + 0x61726170,0x0000006d,0x00040005,0x00000089,0x61726170,0x0000006d,0x00030005,0x0000008d, + 0x0047786d,0x00040005,0x0000008e,0x61726170,0x0000006d,0x00040005,0x00000091,0x61726170, + 0x0000006d,0x00040005,0x00000094,0x61726170,0x0000006d,0x00040005,0x00000098,0x61726170, + 0x0000006d,0x00040005,0x00000099,0x61726170,0x0000006d,0x00040005,0x0000009c,0x61726170, + 0x0000006d,0x00040005,0x000000a0,0x4d706372,0x00000047,0x00040005,0x000000a5,0x47706d61, + 0x00000000,0x00030005,0x000000af,0x00004777,0x00050005,0x000000b3,0x57706372,0x68676965, + 0x00000074,0x00030005,0x000000b9,0x00786970,0x00050005,0x000000d1,0x4374756f,0x726f6c6f, + 0x00000000,0x00030047,0x0000000d,0x00000000,0x00030047,0x00000011,0x00000000,0x00030047, + 0x00000012,0x00000000,0x00030047,0x00000013,0x00000000,0x00030047,0x00000014,0x00000000, + 0x00030047,0x00000016,0x00000000,0x00030047,0x00000017,0x00000000,0x00030047,0x00000018, + 0x00000000,0x00030047,0x00000019,0x00000000,0x00030047,0x0000001f,0x00000000,0x00040047, + 0x0000001f,0x00000021,0x00000000,0x00040047,0x0000001f,0x00000022,0x00000000,0x00030047, + 0x00000020,0x00000000,0x00030047,0x00000024,0x00000000,0x00030047,0x0000002e,0x00000000, + 0x00030047,0x0000002f,0x00000000,0x00030047,0x00000032,0x00000000,0x00030047,0x00000033, + 0x00000000,0x00030047,0x00000034,0x00000000,0x00030047,0x00000035,0x00000000,0x00030047, + 0x00000036,0x00000000,0x00030047,0x00000039,0x00000000,0x00030047,0x0000003a,0x00000000, + 0x00030047,0x0000003b,0x00000000,0x00030047,0x0000003c,0x00000000,0x00030047,0x0000003d, + 0x00000000,0x00040047,0x00000043,0x0000001e,0x00000000,0x00030047,0x00000045,0x00000002, + 0x00050048,0x00000045,0x00000000,0x00000023,0x00000000,0x00050048,0x00000045,0x00000001, + 0x00000023,0x00000010,0x00040048,0x00000045,0x00000002,0x00000000,0x00050048,0x00000045, + 0x00000002,0x00000023,0x00000018,0x00030047,0x0000004d,0x00000000,0x00030047,0x00000054, + 0x00000000,0x00030047,0x00000057,0x00000000,0x00030047,0x00000058,0x00000000,0x00030047, + 0x00000059,0x00000000,0x00030047,0x0000005b,0x00000000,0x00030047,0x00000061,0x00000000, + 0x00030047,0x00000062,0x00000000,0x00030047,0x00000067,0x00000000,0x00030047,0x00000068, + 0x00000000,0x00030047,0x0000006b,0x00000000,0x00030047,0x0000006c,0x00000000,0x00030047, + 0x00000071,0x00000000,0x00030047,0x00000072,0x00000000,0x00030047,0x00000077,0x00000000, + 0x00030047,0x00000078,0x00000000,0x00030047,0x00000079,0x00000000,0x00030047,0x0000007d, + 0x00000000,0x00030047,0x0000007e,0x00000000,0x00030047,0x00000080,0x00000000,0x00030047, + 0x00000081,0x00000000,0x00030047,0x00000083,0x00000000,0x00030047,0x00000084,0x00000000, + 0x00030047,0x00000085,0x00000000,0x00030047,0x00000086,0x00000000,0x00030047,0x00000088, + 0x00000000,0x00030047,0x00000089,0x00000000,0x00030047,0x0000008b,0x00000000,0x00030047, + 0x0000008c,0x00000000,0x00030047,0x0000008d,0x00000000,0x00030047,0x0000008e,0x00000000, + 0x00030047,0x00000090,0x00000000,0x00030047,0x00000091,0x00000000,0x00030047,0x00000093, + 0x00000000,0x00030047,0x00000094,0x00000000,0x00030047,0x00000096,0x00000000,0x00030047, + 0x00000097,0x00000000,0x00030047,0x00000098,0x00000000,0x00030047,0x00000099,0x00000000, + 0x00030047,0x0000009b,0x00000000,0x00030047,0x0000009c,0x00000000,0x00030047,0x0000009e, + 0x00000000,0x00030047,0x0000009f,0x00000000,0x00030047,0x000000a0,0x00000000,0x00030047, + 0x000000a1,0x00000000,0x00030047,0x000000a3,0x00000000,0x00030047,0x000000a4,0x00000000, + 0x00030047,0x000000a5,0x00000000,0x00030047,0x000000a6,0x00000000,0x00030047,0x000000a7, + 0x00000000,0x00030047,0x000000a8,0x00000000,0x00030047,0x000000a9,0x00000000,0x00030047, + 0x000000aa,0x00000000,0x00030047,0x000000ab,0x00000000,0x00030047,0x000000ac,0x00000000, + 0x00030047,0x000000ad,0x00000000,0x00030047,0x000000ae,0x00000000,0x00030047,0x000000af, + 0x00000000,0x00030047,0x000000b0,0x00000000,0x00030047,0x000000b1,0x00000000,0x00030047, + 0x000000b2,0x00000000,0x00030047,0x000000b3,0x00000000,0x00030047,0x000000b5,0x00000000, + 0x00030047,0x000000b6,0x00000000,0x00030047,0x000000b7,0x00000000,0x00030047,0x000000b8, + 0x00000000,0x00030047,0x000000b9,0x00000000,0x00030047,0x000000ba,0x00000000,0x00030047, + 0x000000bb,0x00000000,0x00030047,0x000000bc,0x00000000,0x00030047,0x000000bd,0x00000000, + 0x00030047,0x000000be,0x00000000,0x00030047,0x000000bf,0x00000000,0x00030047,0x000000c0, + 0x00000000,0x00030047,0x000000c1,0x00000000,0x00030047,0x000000c2,0x00000000,0x00030047, + 0x000000c3,0x00000000,0x00030047,0x000000c4,0x00000000,0x00030047,0x000000c5,0x00000000, + 0x00030047,0x000000c6,0x00000000,0x00030047,0x000000c7,0x00000000,0x00030047,0x000000c8, + 0x00000000,0x00030047,0x000000c9,0x00000000,0x00030047,0x000000ca,0x00000000,0x00030047, + 0x000000cb,0x00000000,0x00030047,0x000000cc,0x00000000,0x00030047,0x000000cd,0x00000000, + 0x00030047,0x000000ce,0x00000000,0x00030047,0x000000cf,0x00000000,0x00030047,0x000000d1, + 0x00000000,0x00040047,0x000000d1,0x0000001e,0x00000000,0x00030047,0x000000d2,0x00000000, + 0x00030047,0x000000d3,0x00000000,0x00030047,0x000000d4,0x00000000,0x00030047,0x000000d5, + 0x00000000,0x00030047,0x000000d6,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003, + 0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040017,0x00000007,0x00000006, + 0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00030016,0x00000009,0x00000020, + 0x00040017,0x0000000a,0x00000009,0x00000003,0x00040021,0x0000000b,0x0000000a,0x00000008, + 0x00040020,0x0000000f,0x00000007,0x00000009,0x00060021,0x00000010,0x00000009,0x0000000f, + 0x0000000f,0x0000000f,0x00090019,0x0000001c,0x00000009,0x00000001,0x00000000,0x00000000, + 0x00000000,0x00000001,0x00000000,0x0003001b,0x0000001d,0x0000001c,0x00040020,0x0000001e, + 0x00000000,0x0000001d,0x0004003b,0x0000001e,0x0000001f,0x00000000,0x0004002b,0x00000006, + 0x00000021,0x00000000,0x0005002c,0x00000007,0x00000026,0x00000021,0x00000021,0x0004002b, + 0x00000006,0x00000028,0x00000001,0x0005002c,0x00000007,0x00000029,0x00000028,0x00000028, + 0x00040017,0x0000002d,0x00000009,0x00000004,0x00040017,0x00000041,0x00000009,0x00000002, + 0x00040020,0x00000042,0x00000001,0x00000041,0x0004003b,0x00000042,0x00000043,0x00000001, + 0x0005001e,0x00000045,0x0000002d,0x00000041,0x00000009,0x00040020,0x00000046,0x00000009, + 0x00000045,0x0004003b,0x00000046,0x00000047,0x00000009,0x00040020,0x00000048,0x00000009, + 0x00000041,0x0004002b,0x00000009,0x0000004e,0xbf800000,0x0004002b,0x00000009,0x0000004f, + 0x41000000,0x0004002b,0x00000009,0x00000050,0x40a00000,0x0004002b,0x00000006,0x00000051, + 0x00000002,0x00040020,0x00000052,0x00000009,0x00000009,0x0004002b,0x00000009,0x00000055, + 0x00000000,0x0004002b,0x00000009,0x00000056,0x3f800000,0x00040020,0x0000005a,0x00000007, + 0x0000000a,0x0004002b,0x00000006,0x0000005d,0xffffffff,0x0005002c,0x00000007,0x0000005e, + 0x00000021,0x0000005d,0x0005002c,0x00000007,0x00000064,0x0000005d,0x00000021,0x0005002c, + 0x00000007,0x0000006e,0x00000028,0x00000021,0x0005002c,0x00000007,0x00000074,0x00000021, + 0x00000028,0x00040015,0x0000007a,0x00000020,0x00000000,0x0004002b,0x0000007a,0x0000007b, + 0x00000001,0x0004002b,0x00000009,0x000000a2,0x3a800000,0x0004002b,0x00000009,0x000000b4, + 0x40800000,0x00040020,0x000000d0,0x00000003,0x0000002d,0x0004003b,0x000000d0,0x000000d1, + 0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, + 0x0004003b,0x00000008,0x00000040,0x00000007,0x0004003b,0x0000000f,0x0000004d,0x00000007, + 0x0004003b,0x0000005a,0x0000005b,0x00000007,0x0004003b,0x00000008,0x00000060,0x00000007, + 0x0004003b,0x0000005a,0x00000062,0x00000007,0x0004003b,0x00000008,0x00000066,0x00000007, + 0x0004003b,0x0000005a,0x00000068,0x00000007,0x0004003b,0x00000008,0x00000069,0x00000007, + 0x0004003b,0x0000005a,0x0000006c,0x00000007,0x0004003b,0x00000008,0x00000070,0x00000007, + 0x0004003b,0x0000005a,0x00000072,0x00000007,0x0004003b,0x00000008,0x00000076,0x00000007, + 0x0004003b,0x0000000f,0x00000078,0x00000007,0x0004003b,0x0000000f,0x00000079,0x00000007, + 0x0004003b,0x0000000f,0x0000007e,0x00000007,0x0004003b,0x0000000f,0x00000081,0x00000007, + 0x0004003b,0x0000000f,0x00000085,0x00000007,0x0004003b,0x0000000f,0x00000086,0x00000007, + 0x0004003b,0x0000000f,0x00000089,0x00000007,0x0004003b,0x0000000f,0x0000008d,0x00000007, + 0x0004003b,0x0000000f,0x0000008e,0x00000007,0x0004003b,0x0000000f,0x00000091,0x00000007, + 0x0004003b,0x0000000f,0x00000094,0x00000007,0x0004003b,0x0000000f,0x00000098,0x00000007, + 0x0004003b,0x0000000f,0x00000099,0x00000007,0x0004003b,0x0000000f,0x0000009c,0x00000007, + 0x0004003b,0x0000000f,0x000000a0,0x00000007,0x0004003b,0x0000000f,0x000000a5,0x00000007, + 0x0004003b,0x0000000f,0x000000af,0x00000007,0x0004003b,0x0000000f,0x000000b3,0x00000007, + 0x0004003b,0x0000005a,0x000000b9,0x00000007,0x0004003d,0x00000041,0x00000044,0x00000043, + 0x00050041,0x00000048,0x00000049,0x00000047,0x00000028,0x0004003d,0x00000041,0x0000004a, + 0x00000049,0x00050085,0x00000041,0x0000004b,0x00000044,0x0000004a,0x0004006e,0x00000007, + 0x0000004c,0x0000004b,0x0003003e,0x00000040,0x0000004c,0x00050041,0x00000052,0x00000053, + 0x00000047,0x00000051,0x0004003d,0x00000009,0x00000054,0x00000053,0x0008000c,0x00000009, + 0x00000057,0x00000001,0x0000002b,0x00000054,0x00000055,0x00000056,0x0008000c,0x00000009, + 0x00000058,0x00000001,0x0000002e,0x0000004f,0x00000050,0x00000057,0x00050088,0x00000009, + 0x00000059,0x0000004e,0x00000058,0x0003003e,0x0000004d,0x00000059,0x0004003d,0x00000007, + 0x0000005c,0x00000040,0x00050080,0x00000007,0x0000005f,0x0000005c,0x0000005e,0x0003003e, + 0x00000060,0x0000005f,0x00050039,0x0000000a,0x00000061,0x0000000d,0x00000060,0x0003003e, + 0x0000005b,0x00000061,0x0004003d,0x00000007,0x00000063,0x00000040,0x00050080,0x00000007, + 0x00000065,0x00000063,0x00000064,0x0003003e,0x00000066,0x00000065,0x00050039,0x0000000a, + 0x00000067,0x0000000d,0x00000066,0x0003003e,0x00000062,0x00000067,0x0004003d,0x00000007, + 0x0000006a,0x00000040,0x0003003e,0x00000069,0x0000006a,0x00050039,0x0000000a,0x0000006b, + 0x0000000d,0x00000069,0x0003003e,0x00000068,0x0000006b,0x0004003d,0x00000007,0x0000006d, + 0x00000040,0x00050080,0x00000007,0x0000006f,0x0000006d,0x0000006e,0x0003003e,0x00000070, + 0x0000006f,0x00050039,0x0000000a,0x00000071,0x0000000d,0x00000070,0x0003003e,0x0000006c, + 0x00000071,0x0004003d,0x00000007,0x00000073,0x00000040,0x00050080,0x00000007,0x00000075, + 0x00000073,0x00000074,0x0003003e,0x00000076,0x00000075,0x00050039,0x0000000a,0x00000077, + 0x0000000d,0x00000076,0x0003003e,0x00000072,0x00000077,0x00050041,0x0000000f,0x0000007c, + 0x00000062,0x0000007b,0x0004003d,0x00000009,0x0000007d,0x0000007c,0x0003003e,0x00000079, + 0x0000007d,0x00050041,0x0000000f,0x0000007f,0x00000068,0x0000007b,0x0004003d,0x00000009, + 0x00000080,0x0000007f,0x0003003e,0x0000007e,0x00000080,0x00050041,0x0000000f,0x00000082, + 0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000083,0x00000082,0x0003003e,0x00000081, + 0x00000083,0x00070039,0x00000009,0x00000084,0x00000014,0x00000079,0x0000007e,0x00000081, + 0x0003003e,0x00000085,0x00000084,0x00050041,0x0000000f,0x00000087,0x0000005b,0x0000007b, + 0x0004003d,0x00000009,0x00000088,0x00000087,0x0003003e,0x00000086,0x00000088,0x00050041, + 0x0000000f,0x0000008a,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000008b,0x0000008a, + 0x0003003e,0x00000089,0x0000008b,0x00070039,0x00000009,0x0000008c,0x00000014,0x00000085, + 0x00000086,0x00000089,0x0003003e,0x00000078,0x0000008c,0x00050041,0x0000000f,0x0000008f, + 0x00000062,0x0000007b,0x0004003d,0x00000009,0x00000090,0x0000008f,0x0003003e,0x0000008e, + 0x00000090,0x00050041,0x0000000f,0x00000092,0x00000068,0x0000007b,0x0004003d,0x00000009, + 0x00000093,0x00000092,0x0003003e,0x00000091,0x00000093,0x00050041,0x0000000f,0x00000095, + 0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000096,0x00000095,0x0003003e,0x00000094, + 0x00000096,0x00070039,0x00000009,0x00000097,0x00000019,0x0000008e,0x00000091,0x00000094, + 0x0003003e,0x00000098,0x00000097,0x00050041,0x0000000f,0x0000009a,0x0000005b,0x0000007b, + 0x0004003d,0x00000009,0x0000009b,0x0000009a,0x0003003e,0x00000099,0x0000009b,0x00050041, + 0x0000000f,0x0000009d,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000009e,0x0000009d, + 0x0003003e,0x0000009c,0x0000009e,0x00070039,0x00000009,0x0000009f,0x00000019,0x00000098, + 0x00000099,0x0000009c,0x0003003e,0x0000008d,0x0000009f,0x0004003d,0x00000009,0x000000a1, + 0x0000008d,0x0007000c,0x00000009,0x000000a3,0x00000001,0x00000028,0x000000a1,0x000000a2, + 0x00050088,0x00000009,0x000000a4,0x00000056,0x000000a3,0x0003003e,0x000000a0,0x000000a4, + 0x0004003d,0x00000009,0x000000a6,0x00000078,0x0004003d,0x00000009,0x000000a7,0x0000008d, + 0x00050083,0x00000009,0x000000a8,0x00000056,0x000000a7,0x0007000c,0x00000009,0x000000a9, + 0x00000001,0x00000025,0x000000a6,0x000000a8,0x0004003d,0x00000009,0x000000aa,0x000000a0, + 0x00050085,0x00000009,0x000000ab,0x000000a9,0x000000aa,0x0008000c,0x00000009,0x000000ac, + 0x00000001,0x0000002b,0x000000ab,0x00000055,0x00000056,0x0003003e,0x000000a5,0x000000ac, + 0x0004003d,0x00000009,0x000000ad,0x000000a5,0x0006000c,0x00000009,0x000000ae,0x00000001, + 0x0000001f,0x000000ad,0x0003003e,0x000000a5,0x000000ae,0x0004003d,0x00000009,0x000000b0, + 0x000000a5,0x0004003d,0x00000009,0x000000b1,0x0000004d,0x00050085,0x00000009,0x000000b2, + 0x000000b0,0x000000b1,0x0003003e,0x000000af,0x000000b2,0x0004003d,0x00000009,0x000000b5, + 0x000000af,0x00050085,0x00000009,0x000000b6,0x000000b4,0x000000b5,0x00050081,0x00000009, + 0x000000b7,0x00000056,0x000000b6,0x00050088,0x00000009,0x000000b8,0x00000056,0x000000b7, + 0x0003003e,0x000000b3,0x000000b8,0x0004003d,0x0000000a,0x000000ba,0x0000005b,0x0004003d, + 0x00000009,0x000000bb,0x000000af,0x0005008e,0x0000000a,0x000000bc,0x000000ba,0x000000bb, + 0x0004003d,0x0000000a,0x000000bd,0x00000062,0x0004003d,0x00000009,0x000000be,0x000000af, + 0x0005008e,0x0000000a,0x000000bf,0x000000bd,0x000000be,0x00050081,0x0000000a,0x000000c0, + 0x000000bc,0x000000bf,0x0004003d,0x0000000a,0x000000c1,0x0000006c,0x0004003d,0x00000009, + 0x000000c2,0x000000af,0x0005008e,0x0000000a,0x000000c3,0x000000c1,0x000000c2,0x00050081, + 0x0000000a,0x000000c4,0x000000c0,0x000000c3,0x0004003d,0x0000000a,0x000000c5,0x00000072, + 0x0004003d,0x00000009,0x000000c6,0x000000af,0x0005008e,0x0000000a,0x000000c7,0x000000c5, + 0x000000c6,0x00050081,0x0000000a,0x000000c8,0x000000c4,0x000000c7,0x0004003d,0x0000000a, + 0x000000c9,0x00000068,0x00050081,0x0000000a,0x000000ca,0x000000c8,0x000000c9,0x0004003d, + 0x00000009,0x000000cb,0x000000b3,0x0005008e,0x0000000a,0x000000cc,0x000000ca,0x000000cb, + 0x00060050,0x0000000a,0x000000cd,0x00000055,0x00000055,0x00000055,0x00060050,0x0000000a, + 0x000000ce,0x00000056,0x00000056,0x00000056,0x0008000c,0x0000000a,0x000000cf,0x00000001, + 0x0000002b,0x000000cc,0x000000cd,0x000000ce,0x0003003e,0x000000b9,0x000000cf,0x0004003d, + 0x0000000a,0x000000d2,0x000000b9,0x00050051,0x00000009,0x000000d3,0x000000d2,0x00000000, + 0x00050051,0x00000009,0x000000d4,0x000000d2,0x00000001,0x00050051,0x00000009,0x000000d5, + 0x000000d2,0x00000002,0x00070050,0x0000002d,0x000000d6,0x000000d3,0x000000d4,0x000000d5, + 0x00000056,0x0003003e,0x000000d1,0x000000d6,0x000100fd,0x00010038,0x00050036,0x0000000a, + 0x0000000d,0x00000000,0x0000000b,0x00030037,0x00000008,0x0000000c,0x000200f8,0x0000000e, + 0x0004003b,0x00000008,0x0000001b,0x00000007,0x0004003d,0x0000001d,0x00000020,0x0000001f, + 0x00040064,0x0000001c,0x00000022,0x00000020,0x00050067,0x00000007,0x00000023,0x00000022, + 0x00000021,0x0003003e,0x0000001b,0x00000023,0x0004003d,0x0000001d,0x00000024,0x0000001f, + 0x0004003d,0x00000007,0x00000025,0x0000000c,0x0004003d,0x00000007,0x00000027,0x0000001b, + 0x00050082,0x00000007,0x0000002a,0x00000027,0x00000029,0x0008000c,0x00000007,0x0000002b, + 0x00000001,0x0000002d,0x00000025,0x00000026,0x0000002a,0x00040064,0x0000001c,0x0000002c, + 0x00000024,0x0007005f,0x0000002d,0x0000002e,0x0000002c,0x0000002b,0x00000002,0x00000021, + 0x0008004f,0x0000000a,0x0000002f,0x0000002e,0x0000002e,0x00000000,0x00000001,0x00000002, + 0x000200fe,0x0000002f,0x00010038,0x00050036,0x00000009,0x00000014,0x00000000,0x00000010, + 0x00030037,0x0000000f,0x00000011,0x00030037,0x0000000f,0x00000012,0x00030037,0x0000000f, + 0x00000013,0x000200f8,0x00000015,0x0004003d,0x00000009,0x00000032,0x00000011,0x0004003d, + 0x00000009,0x00000033,0x00000012,0x0004003d,0x00000009,0x00000034,0x00000013,0x0007000c, + 0x00000009,0x00000035,0x00000001,0x00000025,0x00000033,0x00000034,0x0007000c,0x00000009, + 0x00000036,0x00000001,0x00000025,0x00000032,0x00000035,0x000200fe,0x00000036,0x00010038, + 0x00050036,0x00000009,0x00000019,0x00000000,0x00000010,0x00030037,0x0000000f,0x00000016, + 0x00030037,0x0000000f,0x00000017,0x00030037,0x0000000f,0x00000018,0x000200f8,0x0000001a, + 0x0004003d,0x00000009,0x00000039,0x00000016,0x0004003d,0x00000009,0x0000003a,0x00000017, + 0x0004003d,0x00000009,0x0000003b,0x00000018,0x0007000c,0x00000009,0x0000003c,0x00000001, + 0x00000028,0x0000003a,0x0000003b,0x0007000c,0x00000009,0x0000003d,0x00000001,0x00000028, + 0x00000039,0x0000003c,0x000200fe,0x0000003d,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/cas_frag.h b/app/src/main/cpp/shaders/cas_frag.h index 103c2cce42..e21737d61a 100644 --- a/app/src/main/cpp/shaders/cas_frag.h +++ b/app/src/main/cpp/shaders/cas_frag.h @@ -1,8 +1,9 @@ + // 1116.3.0 #pragma once const uint32_t cas_code[] = { - 0x07230203,0x00010000,0x0008000b,0x000000f3,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x07230203,0x00010000,0x0008000b,0x000000f4,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x000000ed,0x00030010, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x000000ee,0x00030010, 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00030005,0x00000009,0x00007675,0x00060005,0x0000000b,0x67617266,0x43786554, 0x64726f6f,0x00000000,0x00030005,0x0000000d,0x00007870,0x00030005,0x00000010,0x00004350, @@ -15,15 +16,15 @@ const uint32_t cas_code[] = { 0x00030005,0x00000065,0x00000067,0x00030005,0x00000071,0x00000068,0x00030005,0x0000007a, 0x00000069,0x00040005,0x00000085,0x47526e6d,0x00000042,0x00040005,0x0000008f,0x47526e6d, 0x00003242,0x00040005,0x0000009c,0x4752786d,0x00000042,0x00040005,0x000000a6,0x4752786d, - 0x00003242,0x00050005,0x000000b3,0x4d706372,0x42475278,0x00000000,0x00040005,0x000000b7, - 0x52706d61,0x00004247,0x00040005,0x000000c5,0x6b616570,0x00000000,0x00040005,0x000000cb, - 0x42475277,0x00000000,0x00060005,0x000000d2,0x57706372,0x68676965,0x42475274,0x00000000, - 0x00040005,0x000000d9,0x646e6977,0x0000776f,0x00030005,0x000000e1,0x006c6f63,0x00050005, - 0x000000ed,0x4374756f,0x726f6c6f,0x00000000,0x00040047,0x0000000b,0x0000001e,0x00000000, + 0x00003242,0x00050005,0x000000b3,0x4d706372,0x42475278,0x00000000,0x00040005,0x000000ba, + 0x52706d61,0x00004247,0x00040005,0x000000c6,0x6b616570,0x00000000,0x00040005,0x000000cc, + 0x42475277,0x00000000,0x00060005,0x000000d3,0x57706372,0x68676965,0x42475274,0x00000000, + 0x00040005,0x000000da,0x646e6977,0x0000776f,0x00030005,0x000000e2,0x006c6f63,0x00050005, + 0x000000ee,0x4374756f,0x726f6c6f,0x00000000,0x00040047,0x0000000b,0x0000001e,0x00000000, 0x00030047,0x00000010,0x00000002,0x00050048,0x00000010,0x00000000,0x00000023,0x00000000, 0x00050048,0x00000010,0x00000001,0x00000023,0x00000010,0x00050048,0x00000010,0x00000002, 0x00000023,0x00000018,0x00040047,0x00000026,0x00000021,0x00000000,0x00040047,0x00000026, - 0x00000022,0x00000000,0x00040047,0x000000ed,0x0000001e,0x00000000,0x00020013,0x00000002, + 0x00000022,0x00000000,0x00040047,0x000000ee,0x0000001e,0x00000000,0x00020013,0x00000002, 0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007, 0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00040020,0x0000000a, 0x00000001,0x00000007,0x0004003b,0x0000000a,0x0000000b,0x00000001,0x0004002b,0x00000006, @@ -38,11 +39,11 @@ const uint32_t cas_code[] = { 0x00000025,0x00000000,0x00000024,0x0004003b,0x00000025,0x00000026,0x00000000,0x00040015, 0x00000029,0x00000020,0x00000000,0x0004002b,0x00000029,0x0000002a,0x00000000,0x0004002b, 0x00000029,0x0000002e,0x00000001,0x0004002b,0x00000006,0x00000039,0x00000000,0x0006002c, - 0x00000020,0x000000b4,0x0000000e,0x0000000e,0x0000000e,0x0004002b,0x00000006,0x000000b9, - 0x40000000,0x0004002b,0x00000006,0x000000c6,0x41000000,0x0004002b,0x00000006,0x000000c7, - 0x40400000,0x0004002b,0x00000006,0x000000cc,0xbf800000,0x0006002c,0x00000020,0x000000cd, - 0x000000cc,0x000000cc,0x000000cc,0x0004002b,0x00000006,0x000000d3,0x40800000,0x00040020, - 0x000000ec,0x00000003,0x0000000f,0x0004003b,0x000000ec,0x000000ed,0x00000003,0x00050036, + 0x00000020,0x000000b4,0x0000000e,0x0000000e,0x0000000e,0x0004002b,0x00000006,0x000000b6, + 0x358637bd,0x0006002c,0x00000020,0x000000b7,0x000000b6,0x000000b6,0x000000b6,0x0004002b, + 0x00000006,0x000000bc,0x40000000,0x0004002b,0x00000006,0x000000c7,0x41000000,0x0004002b, + 0x00000006,0x000000c8,0x40400000,0x0004002b,0x00000006,0x000000d4,0x40800000,0x00040020, + 0x000000ed,0x00000003,0x0000000f,0x0004003b,0x000000ed,0x000000ee,0x00000003,0x00050036, 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008, 0x00000009,0x00000007,0x0004003b,0x00000008,0x0000000d,0x00000007,0x0004003b,0x0000001a, 0x0000001b,0x00000007,0x0004003b,0x00000021,0x00000022,0x00000007,0x0004003b,0x00000021, @@ -52,10 +53,10 @@ const uint32_t cas_code[] = { 0x00000071,0x00000007,0x0004003b,0x00000021,0x0000007a,0x00000007,0x0004003b,0x00000021, 0x00000085,0x00000007,0x0004003b,0x00000021,0x0000008f,0x00000007,0x0004003b,0x00000021, 0x0000009c,0x00000007,0x0004003b,0x00000021,0x000000a6,0x00000007,0x0004003b,0x00000021, - 0x000000b3,0x00000007,0x0004003b,0x00000021,0x000000b7,0x00000007,0x0004003b,0x0000001a, - 0x000000c5,0x00000007,0x0004003b,0x00000021,0x000000cb,0x00000007,0x0004003b,0x00000021, - 0x000000d2,0x00000007,0x0004003b,0x00000021,0x000000d9,0x00000007,0x0004003b,0x00000021, - 0x000000e1,0x00000007,0x0004003d,0x00000007,0x0000000c,0x0000000b,0x0003003e,0x00000009, + 0x000000b3,0x00000007,0x0004003b,0x00000021,0x000000ba,0x00000007,0x0004003b,0x0000001a, + 0x000000c6,0x00000007,0x0004003b,0x00000021,0x000000cc,0x00000007,0x0004003b,0x00000021, + 0x000000d3,0x00000007,0x0004003b,0x00000021,0x000000da,0x00000007,0x0004003b,0x00000021, + 0x000000e2,0x00000007,0x0004003d,0x00000007,0x0000000c,0x0000000b,0x0003003e,0x00000009, 0x0000000c,0x00050041,0x00000015,0x00000016,0x00000012,0x00000014,0x0004003d,0x00000007, 0x00000017,0x00000016,0x00050050,0x00000007,0x00000018,0x0000000e,0x0000000e,0x00050088, 0x00000007,0x00000019,0x00000018,0x00000017,0x0003003e,0x0000000d,0x00000019,0x00050041, @@ -143,38 +144,39 @@ const uint32_t cas_code[] = { 0x0000007a,0x0007000c,0x00000020,0x000000af,0x00000001,0x00000028,0x000000ad,0x000000ae, 0x0003003e,0x000000a6,0x000000af,0x0004003d,0x00000020,0x000000b0,0x000000a6,0x0004003d, 0x00000020,0x000000b1,0x0000009c,0x00050081,0x00000020,0x000000b2,0x000000b1,0x000000b0, - 0x0003003e,0x0000009c,0x000000b2,0x0004003d,0x00000020,0x000000b5,0x0000009c,0x00050088, - 0x00000020,0x000000b6,0x000000b4,0x000000b5,0x0003003e,0x000000b3,0x000000b6,0x0004003d, - 0x00000020,0x000000b8,0x00000085,0x0004003d,0x00000020,0x000000ba,0x0000009c,0x00060050, - 0x00000020,0x000000bb,0x000000b9,0x000000b9,0x000000b9,0x00050083,0x00000020,0x000000bc, - 0x000000bb,0x000000ba,0x0007000c,0x00000020,0x000000bd,0x00000001,0x00000025,0x000000b8, - 0x000000bc,0x0004003d,0x00000020,0x000000be,0x000000b3,0x00050085,0x00000020,0x000000bf, - 0x000000bd,0x000000be,0x00060050,0x00000020,0x000000c0,0x00000039,0x00000039,0x00000039, - 0x00060050,0x00000020,0x000000c1,0x0000000e,0x0000000e,0x0000000e,0x0008000c,0x00000020, - 0x000000c2,0x00000001,0x0000002b,0x000000bf,0x000000c0,0x000000c1,0x0003003e,0x000000b7, - 0x000000c2,0x0004003d,0x00000020,0x000000c3,0x000000b7,0x0006000c,0x00000020,0x000000c4, - 0x00000001,0x00000020,0x000000c3,0x0003003e,0x000000b7,0x000000c4,0x0004003d,0x00000006, - 0x000000c8,0x0000001b,0x00050085,0x00000006,0x000000c9,0x000000c7,0x000000c8,0x00050083, - 0x00000006,0x000000ca,0x000000c6,0x000000c9,0x0003003e,0x000000c5,0x000000ca,0x0004003d, - 0x00000020,0x000000ce,0x000000b7,0x0004003d,0x00000006,0x000000cf,0x000000c5,0x0005008e, - 0x00000020,0x000000d0,0x000000ce,0x000000cf,0x00050088,0x00000020,0x000000d1,0x000000cd, - 0x000000d0,0x0003003e,0x000000cb,0x000000d1,0x0004003d,0x00000020,0x000000d4,0x000000cb, - 0x0005008e,0x00000020,0x000000d5,0x000000d4,0x000000d3,0x00060050,0x00000020,0x000000d6, - 0x0000000e,0x0000000e,0x0000000e,0x00050081,0x00000020,0x000000d7,0x000000d6,0x000000d5, - 0x00050088,0x00000020,0x000000d8,0x000000b4,0x000000d7,0x0003003e,0x000000d2,0x000000d8, - 0x0004003d,0x00000020,0x000000da,0x00000036,0x0004003d,0x00000020,0x000000db,0x0000004d, - 0x00050081,0x00000020,0x000000dc,0x000000da,0x000000db,0x0004003d,0x00000020,0x000000dd, - 0x0000005c,0x0004003d,0x00000020,0x000000de,0x00000071,0x00050081,0x00000020,0x000000df, - 0x000000dd,0x000000de,0x00050081,0x00000020,0x000000e0,0x000000dc,0x000000df,0x0003003e, - 0x000000d9,0x000000e0,0x0004003d,0x00000020,0x000000e2,0x000000d9,0x0004003d,0x00000020, - 0x000000e3,0x000000cb,0x00050085,0x00000020,0x000000e4,0x000000e2,0x000000e3,0x0004003d, - 0x00000020,0x000000e5,0x00000057,0x00050081,0x00000020,0x000000e6,0x000000e4,0x000000e5, - 0x0004003d,0x00000020,0x000000e7,0x000000d2,0x00050085,0x00000020,0x000000e8,0x000000e6, - 0x000000e7,0x00060050,0x00000020,0x000000e9,0x00000039,0x00000039,0x00000039,0x00060050, - 0x00000020,0x000000ea,0x0000000e,0x0000000e,0x0000000e,0x0008000c,0x00000020,0x000000eb, - 0x00000001,0x0000002b,0x000000e8,0x000000e9,0x000000ea,0x0003003e,0x000000e1,0x000000eb, - 0x0004003d,0x00000020,0x000000ee,0x000000e1,0x00050051,0x00000006,0x000000ef,0x000000ee, - 0x00000000,0x00050051,0x00000006,0x000000f0,0x000000ee,0x00000001,0x00050051,0x00000006, - 0x000000f1,0x000000ee,0x00000002,0x00070050,0x0000000f,0x000000f2,0x000000ef,0x000000f0, - 0x000000f1,0x0000000e,0x0003003e,0x000000ed,0x000000f2,0x000100fd,0x00010038 + 0x0003003e,0x0000009c,0x000000b2,0x0004003d,0x00000020,0x000000b5,0x0000009c,0x0007000c, + 0x00000020,0x000000b8,0x00000001,0x00000028,0x000000b5,0x000000b7,0x00050088,0x00000020, + 0x000000b9,0x000000b4,0x000000b8,0x0003003e,0x000000b3,0x000000b9,0x0004003d,0x00000020, + 0x000000bb,0x00000085,0x0004003d,0x00000020,0x000000bd,0x0000009c,0x00060050,0x00000020, + 0x000000be,0x000000bc,0x000000bc,0x000000bc,0x00050083,0x00000020,0x000000bf,0x000000be, + 0x000000bd,0x0007000c,0x00000020,0x000000c0,0x00000001,0x00000025,0x000000bb,0x000000bf, + 0x0004003d,0x00000020,0x000000c1,0x000000b3,0x00050085,0x00000020,0x000000c2,0x000000c0, + 0x000000c1,0x00060050,0x00000020,0x000000c3,0x00000039,0x00000039,0x00000039,0x00060050, + 0x00000020,0x000000c4,0x0000000e,0x0000000e,0x0000000e,0x0008000c,0x00000020,0x000000c5, + 0x00000001,0x0000002b,0x000000c2,0x000000c3,0x000000c4,0x0003003e,0x000000ba,0x000000c5, + 0x0004003d,0x00000006,0x000000c9,0x0000001b,0x00050085,0x00000006,0x000000ca,0x000000c8, + 0x000000c9,0x00050083,0x00000006,0x000000cb,0x000000c7,0x000000ca,0x0003003e,0x000000c6, + 0x000000cb,0x0004003d,0x00000020,0x000000cd,0x000000ba,0x0006000c,0x00000020,0x000000ce, + 0x00000001,0x0000001f,0x000000cd,0x0004007f,0x00000020,0x000000cf,0x000000ce,0x0004003d, + 0x00000006,0x000000d0,0x000000c6,0x00060050,0x00000020,0x000000d1,0x000000d0,0x000000d0, + 0x000000d0,0x00050088,0x00000020,0x000000d2,0x000000cf,0x000000d1,0x0003003e,0x000000cc, + 0x000000d2,0x0004003d,0x00000020,0x000000d5,0x000000cc,0x0005008e,0x00000020,0x000000d6, + 0x000000d5,0x000000d4,0x00060050,0x00000020,0x000000d7,0x0000000e,0x0000000e,0x0000000e, + 0x00050081,0x00000020,0x000000d8,0x000000d7,0x000000d6,0x00050088,0x00000020,0x000000d9, + 0x000000b4,0x000000d8,0x0003003e,0x000000d3,0x000000d9,0x0004003d,0x00000020,0x000000db, + 0x00000036,0x0004003d,0x00000020,0x000000dc,0x0000004d,0x00050081,0x00000020,0x000000dd, + 0x000000db,0x000000dc,0x0004003d,0x00000020,0x000000de,0x0000005c,0x0004003d,0x00000020, + 0x000000df,0x00000071,0x00050081,0x00000020,0x000000e0,0x000000de,0x000000df,0x00050081, + 0x00000020,0x000000e1,0x000000dd,0x000000e0,0x0003003e,0x000000da,0x000000e1,0x0004003d, + 0x00000020,0x000000e3,0x000000da,0x0004003d,0x00000020,0x000000e4,0x000000cc,0x00050085, + 0x00000020,0x000000e5,0x000000e3,0x000000e4,0x0004003d,0x00000020,0x000000e6,0x00000057, + 0x00050081,0x00000020,0x000000e7,0x000000e5,0x000000e6,0x0004003d,0x00000020,0x000000e8, + 0x000000d3,0x00050085,0x00000020,0x000000e9,0x000000e7,0x000000e8,0x00060050,0x00000020, + 0x000000ea,0x00000039,0x00000039,0x00000039,0x00060050,0x00000020,0x000000eb,0x0000000e, + 0x0000000e,0x0000000e,0x0008000c,0x00000020,0x000000ec,0x00000001,0x0000002b,0x000000e9, + 0x000000ea,0x000000eb,0x0003003e,0x000000e2,0x000000ec,0x0004003d,0x00000020,0x000000ef, + 0x000000e2,0x00050051,0x00000006,0x000000f0,0x000000ef,0x00000000,0x00050051,0x00000006, + 0x000000f1,0x000000ef,0x00000001,0x00050051,0x00000006,0x000000f2,0x000000ef,0x00000002, + 0x00070050,0x0000000f,0x000000f3,0x000000f0,0x000000f1,0x000000f2,0x0000000e,0x0003003e, + 0x000000ee,0x000000f3,0x000100fd,0x00010038 }; diff --git a/app/src/main/cpp/shaders/color.frag b/app/src/main/cpp/shaders/color.frag new file mode 100644 index 0000000000..8629453f71 --- /dev/null +++ b/app/src/main/cpp/shaders/color.frag @@ -0,0 +1,52 @@ +#version 450 + +// ============================================================================= +// Color grade (brightness / contrast / saturation / gamma) post effect. +// +// Ported verbatim from the OpenGL ColorEffect.java shader. The four terms are +// prepared CPU-side (planUpscaleFrame) exactly as the GL path does: +// brightness = brightnessSlider / 100 clamped to [-1, 1] +// contrast = contrastSlider / 100 clamped to [ 0, 2] +// saturation = saturationSlider / 100 clamped to [ 0, 2] +// gamma = gammaSlider clamped to [0.1, 5] +// (the clamps replicate ColorEffectMaterial.use()). Neutral = (0,0,1,1) -> no-op, +// matching the GL "remove the effect" check; the chain skips Color when neutral. +// +// Term ORDER inside this shader is brightness -> contrast -> saturation -> gamma. +// Saturation sits after contrast and before gamma deliberately: it mixes towards +// Rec.709 luma of the already-graded linear-ish signal, so the greyscale it blends +// against is the one the viewer sees, and the gamma curve is still applied last to +// the finished colour. ColorEffect.java applies its terms in the same order, so a +// Screen Effect "Look" grades identically on the OpenGL and Vulkan renderers. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// `saturation` is APPENDED at the end of the block so the offsets of the three +// original terms are unchanged. +// Runs after Toon, before CAS in the canonical chain (grade the clean image). +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + float brightness; // additive, [-1, 1] + float contrast; // [0, 2]; effective multiplier = clamp(contrast+1, 0.5, 2) + float gamma; // [0.1, 5] + float saturation; // [0, 2]; 1 = unchanged, 0 = greyscale +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +void main() { + vec4 texelColor = texture(InputTexture, fragTexCoord); + vec3 color = texelColor.rgb; + color = clamp(color + pc.brightness, 0.0, 1.0); + color = (color - 0.5) * clamp(pc.contrast + 1.0, 0.5, 2.0) + 0.5; + vec3 grey = vec3(dot(color, vec3(0.2126, 0.7152, 0.0722))); + color = mix(grey, color, clamp(pc.saturation, 0.0, 2.0)); + color = max(color, vec3(0.0)); + color = pow(color, vec3(1.0 / pc.gamma)); + outColor = vec4(color, texelColor.a); +} diff --git a/app/src/main/cpp/shaders/color_frag.h b/app/src/main/cpp/shaders/color_frag.h index 7026c7c880..f8237dc27d 100644 --- a/app/src/main/cpp/shaders/color_frag.h +++ b/app/src/main/cpp/shaders/color_frag.h @@ -1,8 +1,9 @@ + // 1116.3.0 #pragma once const uint32_t color_code[] = { - 0x07230203,0x00010000,0x0008000b,0x00000059,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x07230203,0x00010000,0x0008000b,0x0000005c,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000011,0x0000004e,0x00030010, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000011,0x00000051,0x00030010, 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00050005,0x00000009,0x65786574,0x6c6f436c,0x0000726f,0x00060005,0x0000000d, 0x75706e49,0x78655474,0x65727574,0x00000000,0x00060005,0x00000011,0x67617266,0x43786554, @@ -11,13 +12,13 @@ const uint32_t color_code[] = { 0x67697262,0x656e7468,0x00007373,0x00060006,0x0000001a,0x00000002,0x746e6f63,0x74736172, 0x00000000,0x00050006,0x0000001a,0x00000003,0x6d6d6167,0x00000061,0x00060006,0x0000001a, 0x00000004,0x75746173,0x69746172,0x00006e6f,0x00030005,0x0000001c,0x00006370,0x00040005, - 0x00000036,0x79657267,0x00000000,0x00050005,0x0000004e,0x4374756f,0x726f6c6f,0x00000000, + 0x00000036,0x79657267,0x00000000,0x00050005,0x00000051,0x4374756f,0x726f6c6f,0x00000000, 0x00040047,0x0000000d,0x00000021,0x00000000,0x00040047,0x0000000d,0x00000022,0x00000000, 0x00040047,0x00000011,0x0000001e,0x00000000,0x00030047,0x0000001a,0x00000002,0x00050048, 0x0000001a,0x00000000,0x00000023,0x00000000,0x00050048,0x0000001a,0x00000001,0x00000023, 0x00000010,0x00050048,0x0000001a,0x00000002,0x00000023,0x00000014,0x00050048,0x0000001a, 0x00000003,0x00000023,0x00000018,0x00050048,0x0000001a,0x00000004,0x00000023,0x0000001c, - 0x00040047,0x0000004e,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003, + 0x00040047,0x00000051,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003, 0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004, 0x00040020,0x00000008,0x00000007,0x00000007,0x00090019,0x0000000a,0x00000006,0x00000001, 0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000000b,0x0000000a, @@ -33,43 +34,46 @@ const uint32_t color_code[] = { 0x00000006,0x00000031,0x40000000,0x0004002b,0x00000006,0x00000038,0x3e59b3d0,0x0004002b, 0x00000006,0x00000039,0x3f371759,0x0004002b,0x00000006,0x0000003a,0x3d93dd98,0x0006002c, 0x00000014,0x0000003b,0x00000038,0x00000039,0x0000003a,0x0004002b,0x0000001d,0x00000040, - 0x00000004,0x0004002b,0x0000001d,0x00000047,0x00000003,0x00040020,0x0000004d,0x00000003, - 0x00000007,0x0004003b,0x0000004d,0x0000004e,0x00000003,0x00040015,0x00000050,0x00000020, - 0x00000000,0x0004002b,0x00000050,0x00000051,0x00000003,0x00040020,0x00000052,0x00000007, - 0x00000006,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, - 0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000015,0x00000016,0x00000007, - 0x0004003b,0x00000015,0x00000036,0x00000007,0x0004003d,0x0000000b,0x0000000e,0x0000000d, - 0x0004003d,0x0000000f,0x00000012,0x00000011,0x00050057,0x00000007,0x00000013,0x0000000e, - 0x00000012,0x0003003e,0x00000009,0x00000013,0x0004003d,0x00000007,0x00000017,0x00000009, - 0x0008004f,0x00000014,0x00000018,0x00000017,0x00000017,0x00000000,0x00000001,0x00000002, - 0x0003003e,0x00000016,0x00000018,0x0004003d,0x00000014,0x00000019,0x00000016,0x00050041, - 0x0000001f,0x00000020,0x0000001c,0x0000001e,0x0004003d,0x00000006,0x00000021,0x00000020, - 0x00060050,0x00000014,0x00000022,0x00000021,0x00000021,0x00000021,0x00050081,0x00000014, - 0x00000023,0x00000019,0x00000022,0x00060050,0x00000014,0x00000026,0x00000024,0x00000024, - 0x00000024,0x00060050,0x00000014,0x00000027,0x00000025,0x00000025,0x00000025,0x0008000c, - 0x00000014,0x00000028,0x00000001,0x0000002b,0x00000023,0x00000026,0x00000027,0x0003003e, - 0x00000016,0x00000028,0x0004003d,0x00000014,0x00000029,0x00000016,0x00060050,0x00000014, - 0x0000002b,0x0000002a,0x0000002a,0x0000002a,0x00050083,0x00000014,0x0000002c,0x00000029, - 0x0000002b,0x00050041,0x0000001f,0x0000002e,0x0000001c,0x0000002d,0x0004003d,0x00000006, - 0x0000002f,0x0000002e,0x00050081,0x00000006,0x00000030,0x0000002f,0x00000025,0x0008000c, - 0x00000006,0x00000032,0x00000001,0x0000002b,0x00000030,0x0000002a,0x00000031,0x0005008e, - 0x00000014,0x00000033,0x0000002c,0x00000032,0x00060050,0x00000014,0x00000034,0x0000002a, - 0x0000002a,0x0000002a,0x00050081,0x00000014,0x00000035,0x00000033,0x00000034,0x0003003e, - 0x00000016,0x00000035,0x0004003d,0x00000014,0x00000037,0x00000016,0x00050094,0x00000006, - 0x0000003c,0x00000037,0x0000003b,0x00060050,0x00000014,0x0000003d,0x0000003c,0x0000003c, - 0x0000003c,0x0003003e,0x00000036,0x0000003d,0x0004003d,0x00000014,0x0000003e,0x00000036, - 0x0004003d,0x00000014,0x0000003f,0x00000016,0x00050041,0x0000001f,0x00000041,0x0000001c, - 0x00000040,0x0004003d,0x00000006,0x00000042,0x00000041,0x0008000c,0x00000006,0x00000043, - 0x00000001,0x0000002b,0x00000042,0x00000024,0x00000031,0x00060050,0x00000014,0x00000044, - 0x00000043,0x00000043,0x00000043,0x0008000c,0x00000014,0x00000045,0x00000001,0x0000002e, - 0x0000003e,0x0000003f,0x00000044,0x0003003e,0x00000016,0x00000045,0x0004003d,0x00000014, - 0x00000046,0x00000016,0x00050041,0x0000001f,0x00000048,0x0000001c,0x00000047,0x0004003d, - 0x00000006,0x00000049,0x00000048,0x00050088,0x00000006,0x0000004a,0x00000025,0x00000049, - 0x00060050,0x00000014,0x0000004b,0x0000004a,0x0000004a,0x0000004a,0x0007000c,0x00000014, - 0x0000004c,0x00000001,0x0000001a,0x00000046,0x0000004b,0x0003003e,0x00000016,0x0000004c, - 0x0004003d,0x00000014,0x0000004f,0x00000016,0x00050041,0x00000052,0x00000053,0x00000009, - 0x00000051,0x0004003d,0x00000006,0x00000054,0x00000053,0x00050051,0x00000006,0x00000055, - 0x0000004f,0x00000000,0x00050051,0x00000006,0x00000056,0x0000004f,0x00000001,0x00050051, - 0x00000006,0x00000057,0x0000004f,0x00000002,0x00070050,0x00000007,0x00000058,0x00000055, - 0x00000056,0x00000057,0x00000054,0x0003003e,0x0000004e,0x00000058,0x000100fd,0x00010038 + 0x00000004,0x0006002c,0x00000014,0x00000047,0x00000024,0x00000024,0x00000024,0x0004002b, + 0x0000001d,0x0000004a,0x00000003,0x00040020,0x00000050,0x00000003,0x00000007,0x0004003b, + 0x00000050,0x00000051,0x00000003,0x00040015,0x00000053,0x00000020,0x00000000,0x0004002b, + 0x00000053,0x00000054,0x00000003,0x00040020,0x00000055,0x00000007,0x00000006,0x00050036, + 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008, + 0x00000009,0x00000007,0x0004003b,0x00000015,0x00000016,0x00000007,0x0004003b,0x00000015, + 0x00000036,0x00000007,0x0004003d,0x0000000b,0x0000000e,0x0000000d,0x0004003d,0x0000000f, + 0x00000012,0x00000011,0x00050057,0x00000007,0x00000013,0x0000000e,0x00000012,0x0003003e, + 0x00000009,0x00000013,0x0004003d,0x00000007,0x00000017,0x00000009,0x0008004f,0x00000014, + 0x00000018,0x00000017,0x00000017,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000016, + 0x00000018,0x0004003d,0x00000014,0x00000019,0x00000016,0x00050041,0x0000001f,0x00000020, + 0x0000001c,0x0000001e,0x0004003d,0x00000006,0x00000021,0x00000020,0x00060050,0x00000014, + 0x00000022,0x00000021,0x00000021,0x00000021,0x00050081,0x00000014,0x00000023,0x00000019, + 0x00000022,0x00060050,0x00000014,0x00000026,0x00000024,0x00000024,0x00000024,0x00060050, + 0x00000014,0x00000027,0x00000025,0x00000025,0x00000025,0x0008000c,0x00000014,0x00000028, + 0x00000001,0x0000002b,0x00000023,0x00000026,0x00000027,0x0003003e,0x00000016,0x00000028, + 0x0004003d,0x00000014,0x00000029,0x00000016,0x00060050,0x00000014,0x0000002b,0x0000002a, + 0x0000002a,0x0000002a,0x00050083,0x00000014,0x0000002c,0x00000029,0x0000002b,0x00050041, + 0x0000001f,0x0000002e,0x0000001c,0x0000002d,0x0004003d,0x00000006,0x0000002f,0x0000002e, + 0x00050081,0x00000006,0x00000030,0x0000002f,0x00000025,0x0008000c,0x00000006,0x00000032, + 0x00000001,0x0000002b,0x00000030,0x0000002a,0x00000031,0x0005008e,0x00000014,0x00000033, + 0x0000002c,0x00000032,0x00060050,0x00000014,0x00000034,0x0000002a,0x0000002a,0x0000002a, + 0x00050081,0x00000014,0x00000035,0x00000033,0x00000034,0x0003003e,0x00000016,0x00000035, + 0x0004003d,0x00000014,0x00000037,0x00000016,0x00050094,0x00000006,0x0000003c,0x00000037, + 0x0000003b,0x00060050,0x00000014,0x0000003d,0x0000003c,0x0000003c,0x0000003c,0x0003003e, + 0x00000036,0x0000003d,0x0004003d,0x00000014,0x0000003e,0x00000036,0x0004003d,0x00000014, + 0x0000003f,0x00000016,0x00050041,0x0000001f,0x00000041,0x0000001c,0x00000040,0x0004003d, + 0x00000006,0x00000042,0x00000041,0x0008000c,0x00000006,0x00000043,0x00000001,0x0000002b, + 0x00000042,0x00000024,0x00000031,0x00060050,0x00000014,0x00000044,0x00000043,0x00000043, + 0x00000043,0x0008000c,0x00000014,0x00000045,0x00000001,0x0000002e,0x0000003e,0x0000003f, + 0x00000044,0x0003003e,0x00000016,0x00000045,0x0004003d,0x00000014,0x00000046,0x00000016, + 0x0007000c,0x00000014,0x00000048,0x00000001,0x00000028,0x00000046,0x00000047,0x0003003e, + 0x00000016,0x00000048,0x0004003d,0x00000014,0x00000049,0x00000016,0x00050041,0x0000001f, + 0x0000004b,0x0000001c,0x0000004a,0x0004003d,0x00000006,0x0000004c,0x0000004b,0x00050088, + 0x00000006,0x0000004d,0x00000025,0x0000004c,0x00060050,0x00000014,0x0000004e,0x0000004d, + 0x0000004d,0x0000004d,0x0007000c,0x00000014,0x0000004f,0x00000001,0x0000001a,0x00000049, + 0x0000004e,0x0003003e,0x00000016,0x0000004f,0x0004003d,0x00000014,0x00000052,0x00000016, + 0x00050041,0x00000055,0x00000056,0x00000009,0x00000054,0x0004003d,0x00000006,0x00000057, + 0x00000056,0x00050051,0x00000006,0x00000058,0x00000052,0x00000000,0x00050051,0x00000006, + 0x00000059,0x00000052,0x00000001,0x00050051,0x00000006,0x0000005a,0x00000052,0x00000002, + 0x00070050,0x00000007,0x0000005b,0x00000058,0x00000059,0x0000005a,0x00000057,0x0003003e, + 0x00000051,0x0000005b,0x000100fd,0x00010038 }; diff --git a/app/src/main/cpp/shaders/crt.frag b/app/src/main/cpp/shaders/crt.frag new file mode 100644 index 0000000000..1903549e95 --- /dev/null +++ b/app/src/main/cpp/shaders/crt.frag @@ -0,0 +1,42 @@ +#version 450 + +// ============================================================================= +// CRT (chromatic aberration + scanlines) post effect. +// +// Ported verbatim from the OpenGL CRTEffect.java shader. GL sampled with the +// varying vUV; here fragTexCoord IS that uv. All constants unchanged. Runs LAST +// in the canonical chain (the physical tube emulation, after NTSC's analog +// signal). Does not need the resolution, but the PC carries it for a uniform +// effect-PC layout. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in px (unused; layout uniformity) +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +#define CA_AMOUNT 1.0025 +#define SCANLINE_INTENSITY_X 0.125 +#define SCANLINE_INTENSITY_Y 0.375 +#define SCANLINE_SIZE 1024.0 + +void main() { + vec2 vUV = fragTexCoord; + vec4 finalColor = texture(InputTexture, vUV); + finalColor.rgb = vec3( + texture(InputTexture, (vUV - 0.5) * CA_AMOUNT + 0.5).r, + finalColor.g, + texture(InputTexture, (vUV - 0.5) / CA_AMOUNT + 0.5).b + ); + float scanlineX = abs(sin(vUV.x * SCANLINE_SIZE) * 0.5 * SCANLINE_INTENSITY_X); + float scanlineY = abs(sin(vUV.y * SCANLINE_SIZE) * 0.5 * SCANLINE_INTENSITY_Y); + outColor = vec4(mix(finalColor.rgb, vec3(0.0), scanlineX + scanlineY), finalColor.a); +} diff --git a/app/src/main/cpp/shaders/deband.frag b/app/src/main/cpp/shaders/deband.frag new file mode 100644 index 0000000000..025012608e --- /dev/null +++ b/app/src/main/cpp/shaders/deband.frag @@ -0,0 +1,56 @@ +#version 450 + +// ============================================================================= +// Debanding / dither - terminal post pass. +// +// Adds sub-LSB triangular-PDF (TPDF) noise just before the final 8-bit +// swapchain quantization, so smooth gradients (dark skies, fog, bloom +// falloff, vignettes) stop showing 8-bit "stair-step" banding. Especially +// visible on AMOLED panels in dark scenes. +// +// This is the LAST pass in the effect chain and always writes the swapchain, +// so the dither matches the display quantizer. The whole compositor chain is +// R8G8B8A8_UNORM and the swapchain has no _SRGB view, i.e. values are already +// display(gamma)-encoded here - so we dither in display space, ~1 LSB = 1/255, +// which is where AMOLED banding is worst (the darks). +// +// Noise = interleaved gradient noise (Jimenez 2014, public technique), two +// screen-locked samples summed for a triangular PDF (flat noise spectrum, no +// DC bias). Screen-locked (gl_FragCoord) so the pattern is static = no shimmer. +// Float-only hash (no floatBitsToInt / bvec / bitwise) = Adreno-compile-safe. +// +// Conventions match upscale.vert / cas.frag: combined-image-sampler at binding +// 0, push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// +// CPU side (planUpscaleFrame) maps the UI strength slider to LSB units: +// strength = slider / 100 (slider 100 -> 1.0 LSB, the default) +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in pixels (unused here, kept for layout parity) + float strength; // dither amplitude in LSBs (1.0 = +/-1/255 triangular) +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +// Interleaved gradient noise - returns [0,1), float-only, Adreno-safe. +float ign(vec2 p) { + return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); +} + +void main() { + vec3 col = texture(InputTexture, fragTexCoord).rgb; + + // Two decorrelated samples -> triangular PDF in (-1, 1). + float n1 = ign(gl_FragCoord.xy); + float n2 = ign(gl_FragCoord.xy + vec2(11.0, 17.0)); + float tri = (n1 + n2) - 1.0; + + col += vec3(tri * (pc.strength / 255.0)); + + outColor = vec4(col, 1.0); +} diff --git a/app/src/main/cpp/shaders/fsr_easu.frag b/app/src/main/cpp/shaders/fsr_easu.frag new file mode 100644 index 0000000000..dbc66824eb --- /dev/null +++ b/app/src/main/cpp/shaders/fsr_easu.frag @@ -0,0 +1,221 @@ +#version 450 + +// ============================================================================= +// AMD FidelityFX Super Resolution 1.0 - EASU (Edge-Adaptive Spatial Upsampling). +// +// Algorithm (FsrEasuF / FsrEasuTapF / FsrEasuSetF) ported verbatim from AMD's +// reference header: GPUOpen-Effects/FidelityFX-FSR ffx-fsr/ffx_fsr1.h +// +// Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// SPDX-License-Identifier: MIT +// +// Full license text is included in THIRD_PARTY_NOTICES.txt and packaged +// in the APK at assets/licenses/graphics/THIRD_PARTY_NOTICES.txt. +// +// Adapted for the Winlator native Vulkan compositor: +// - fp32-only path (the AF1/AU1 portability macros below replace ffx_a.h) +// - con0..con3 are computed CPU-side (FsrEasuCon) and delivered via push const +// - output pixel position comes from window.vert's fragTexCoord * outputSize +// - input sampled via textureGather on a CLAMP_TO_EDGE / linear sampler +// ============================================================================= + +// ---- minimal ffx_a.h fp32 portability layer ------------------------------- +#define AF1 float +#define AF2 vec2 +#define AF3 vec3 +#define AF4 vec4 +#define AU1 uint +#define AU2 uvec2 +#define AU4 uvec4 +#define ASU2 ivec2 +#define AP1 bool +#define AF1_(a) float(a) +#define AF2_(a) vec2(AF1_(a)) +#define AF3_(a) vec3(AF1_(a)) +#define AF4_(a) vec4(AF1_(a)) +#define AF2_AU2(x) uintBitsToFloat(uvec2(x)) +#define AF1_AU1(x) uintBitsToFloat(uint(x)) +float ARcpF1(float x) { return 1.0 / x; } +float APrxLoRcpF1(float x) { return 1.0 / x; } +float APrxMedRcpF1(float x){ return 1.0 / x; } +float APrxLoRsqF1(float x) { return inversesqrt(x); } +float ASatF1(float x) { return clamp(x, 0.0, 1.0); } +vec3 AMin3F3(vec3 a, vec3 b, vec3 c) { return min(a, min(b, c)); } +vec3 AMax3F3(vec3 a, vec3 b, vec3 c) { return max(a, max(b, c)); } +// --------------------------------------------------------------------------- + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as in AMD's +// FSR_EASU_H / FSR_RCAS_H paths; positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif +#ifdef DD_HALF +// 1/32768 is a 16-bit subnormal (flushed to 0 where denormals are not kept); +// 1/16384 is the smallest normal one. +#define BL_EASU_DIR_ZERO (1.0/16384.0) +#else +#define BL_EASU_DIR_ZERO (1.0/32768.0) +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by window.vert (offset 0) + uvec4 con0; + uvec4 con1; + uvec4 con2; + uvec4 con3; + highp vec2 outputSize; // EASU output (this pass's render-target) size in pixels +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +AF4 FsrEasuRF(highp AF2 p) { return textureGather(InputTexture, p, 0); } +AF4 FsrEasuGF(highp AF2 p) { return textureGather(InputTexture, p, 1); } +AF4 FsrEasuBF(highp AF2 p) { return textureGather(InputTexture, p, 2); } + +void FsrEasuTapF( + inout AF3 aC, + inout AF1 aW, + AF2 off, + AF2 dir, + AF2 len, + AF1 lob, + AF1 clp, + AF3 c){ + AF2 v; + v.x=(off.x*( dir.x))+(off.y*dir.y); + v.y=(off.x*(-dir.y))+(off.y*dir.x); + v*=len; + AF1 d2=v.x*v.x+v.y*v.y; + d2=min(d2,clp); + AF1 wB=AF1_(2.0/5.0)*d2+AF1_(-1.0); + AF1 wA=lob*d2+AF1_(-1.0); + wB*=wB; + wA*=wA; + wB=AF1_(25.0/16.0)*wB+AF1_(-(25.0/16.0-1.0)); + AF1 w=wB*wA; + aC+=c*w;aW+=w;} + +void FsrEasuSetF( + inout AF2 dir, + inout AF1 len, + AF2 pp, + AP1 biS,AP1 biT,AP1 biU,AP1 biV, + AF1 lA,AF1 lB,AF1 lC,AF1 lD,AF1 lE){ + AF1 w = AF1_(0.0); + if(biS)w=(AF1_(1.0)-pp.x)*(AF1_(1.0)-pp.y); + if(biT)w= pp.x *(AF1_(1.0)-pp.y); + if(biU)w=(AF1_(1.0)-pp.x)* pp.y ; + if(biV)w= pp.x * pp.y ; + AF1 dc=lD-lC; + AF1 cb=lC-lB; + AF1 lenX=max(abs(dc),abs(cb)); + lenX=lenX>0.0?APrxLoRcpF1(lenX):AF1_(0.0); + AF1 dirX=lD-lB; + dir.x+=dirX*w; + lenX=ASatF1(abs(dirX)*lenX); + lenX*=lenX; + len+=lenX*w; + AF1 ec=lE-lC; + AF1 ca=lC-lA; + AF1 lenY=max(abs(ec),abs(ca)); + lenY=lenY>0.0?APrxLoRcpF1(lenY):AF1_(0.0); + AF1 dirY=lE-lA; + dir.y+=dirY*w; + lenY=ASatF1(abs(dirY)*lenY); + lenY*=lenY; + len+=lenY*w;} + +void FsrEasuF( + out AF3 pix, + AU2 ip, + AU4 con0, + AU4 con1, + AU4 con2, + AU4 con3){ + highp AF2 pp=AF2(ip)*AF2_AU2(con0.xy)+AF2_AU2(con0.zw); + highp AF2 fp=floor(pp); + pp-=fp; + highp AF2 p0=fp*AF2_AU2(con1.xy)+AF2_AU2(con1.zw); + highp AF2 p1=p0+AF2_AU2(con2.xy); + highp AF2 p2=p0+AF2_AU2(con2.zw); + highp AF2 p3=p0+AF2_AU2(con3.xy); + AF4 bczzR=FsrEasuRF(p0); + AF4 bczzG=FsrEasuGF(p0); + AF4 bczzB=FsrEasuBF(p0); + AF4 ijfeR=FsrEasuRF(p1); + AF4 ijfeG=FsrEasuGF(p1); + AF4 ijfeB=FsrEasuBF(p1); + AF4 klhgR=FsrEasuRF(p2); + AF4 klhgG=FsrEasuGF(p2); + AF4 klhgB=FsrEasuBF(p2); + AF4 zzonR=FsrEasuRF(p3); + AF4 zzonG=FsrEasuGF(p3); + AF4 zzonB=FsrEasuBF(p3); + AF4 bczzL=bczzB*AF4_(0.5)+(bczzR*AF4_(0.5)+bczzG); + AF4 ijfeL=ijfeB*AF4_(0.5)+(ijfeR*AF4_(0.5)+ijfeG); + AF4 klhgL=klhgB*AF4_(0.5)+(klhgR*AF4_(0.5)+klhgG); + AF4 zzonL=zzonB*AF4_(0.5)+(zzonR*AF4_(0.5)+zzonG); + AF1 bL=bczzL.x; + AF1 cL=bczzL.y; + AF1 iL=ijfeL.x; + AF1 jL=ijfeL.y; + AF1 fL=ijfeL.z; + AF1 eL=ijfeL.w; + AF1 kL=klhgL.x; + AF1 lL=klhgL.y; + AF1 hL=klhgL.z; + AF1 gL=klhgL.w; + AF1 oL=zzonL.z; + AF1 nL=zzonL.w; + AF2 dir=AF2_(0.0); + AF1 len=AF1_(0.0); + FsrEasuSetF(dir,len,pp,true, false,false,false,bL,eL,fL,gL,jL); + FsrEasuSetF(dir,len,pp,false,true ,false,false,cL,fL,gL,hL,kL); + FsrEasuSetF(dir,len,pp,false,false,true ,false,fL,iL,jL,kL,nL); + FsrEasuSetF(dir,len,pp,false,false,false,true ,gL,jL,kL,lL,oL); + AF2 dir2=dir*dir; + AF1 dirR=dir2.x+dir2.y; + AP1 zro=dirR push const con +// - input is the EASU output (already at output resolution), read 1:1 via +// texelFetch with edge clamping for robustness +// ============================================================================= + +// ---- minimal ffx_a.h fp32 portability layer ------------------------------- +#define AF1 float +#define AF2 vec2 +#define AF3 vec3 +#define AF4 vec4 +#define AU2 uvec2 +#define AU4 uvec4 +#define ASU2 ivec2 +#define AF1_(a) float(a) +#define AF1_AU1(x) uintBitsToFloat(uint(x)) +float ARcpF1(float x) { return 1.0 / x; } +float APrxMedRcpF1(float x){ return 1.0 / x; } +float ASatF1(float x) { return clamp(x, 0.0, 1.0); } +float AMin3F1(float a, float b, float c) { return min(a, min(b, c)); } +float AMax3F1(float a, float b, float c) { return max(a, max(b, c)); } +#define FSR_RCAS_LIMIT (0.25 - (1.0 / 16.0)) +// --------------------------------------------------------------------------- + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as in AMD's +// FSR_EASU_H / FSR_RCAS_H paths; positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; // EASU output, output res + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by window.vert (offset 0) + uvec4 con; // con.x = bit-packed sharpness (FsrRcasCon) + highp vec2 outputSize; // pass output size in pixels +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +AF4 FsrRcasLoadF(ASU2 p) { + ivec2 sz = textureSize(InputTexture, 0); + return texelFetch(InputTexture, clamp(p, ivec2(0), sz - ivec2(1)), 0); +} +void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {} + +void FsrRcasF( + out AF1 pixR, + out AF1 pixG, + out AF1 pixB, + AU2 ip, + AU4 con){ + ASU2 sp=ASU2(ip); + AF3 b=FsrRcasLoadF(sp+ASU2( 0,-1)).rgb; + AF3 d=FsrRcasLoadF(sp+ASU2(-1, 0)).rgb; + AF3 e=FsrRcasLoadF(sp).rgb; + AF3 f=FsrRcasLoadF(sp+ASU2( 1, 0)).rgb; + AF3 h=FsrRcasLoadF(sp+ASU2( 0, 1)).rgb; + AF1 bR=b.r; + AF1 bG=b.g; + AF1 bB=b.b; + AF1 dR=d.r; + AF1 dG=d.g; + AF1 dB=d.b; + AF1 eR=e.r; + AF1 eG=e.g; + AF1 eB=e.b; + AF1 fR=f.r; + AF1 fG=f.g; + AF1 fB=f.b; + AF1 hR=h.r; + AF1 hG=h.g; + AF1 hB=h.b; + FsrRcasInputF(bR,bG,bB); + FsrRcasInputF(dR,dG,dB); + FsrRcasInputF(eR,eG,eB); + FsrRcasInputF(fR,fG,fB); + FsrRcasInputF(hR,hG,hB); + AF1 bL=bB*AF1_(0.5)+(bR*AF1_(0.5)+bG); + AF1 dL=dB*AF1_(0.5)+(dR*AF1_(0.5)+dG); + AF1 eL=eB*AF1_(0.5)+(eR*AF1_(0.5)+eG); + AF1 fL=fB*AF1_(0.5)+(fR*AF1_(0.5)+fG); + AF1 hL=hB*AF1_(0.5)+(hR*AF1_(0.5)+hG); + AF1 nz=AF1_(0.25)*bL+AF1_(0.25)*dL+AF1_(0.25)*fL+AF1_(0.25)*hL-eL; + nz=ASatF1(abs(nz)*APrxMedRcpF1(AMax3F1(AMax3F1(bL,dL,eL),fL,hL)-AMin3F1(AMin3F1(bL,dL,eL),fL,hL))); + nz=AF1_(-0.5)*nz+AF1_(1.0); + AF1 mn4R=min(AMin3F1(bR,dR,fR),hR); + AF1 mn4G=min(AMin3F1(bG,dG,fG),hG); + AF1 mn4B=min(AMin3F1(bB,dB,fB),hB); + AF1 mx4R=max(AMax3F1(bR,dR,fR),hR); + AF1 mx4G=max(AMax3F1(bG,dG,fG),hG); + AF1 mx4B=max(AMax3F1(bB,dB,fB),hB); + AF2 peakC=AF2(1.0,-1.0*4.0); + AF1 denMinR=AF1_(4.0)*mx4R; + AF1 denMinG=AF1_(4.0)*mx4G; + AF1 denMinB=AF1_(4.0)*mx4B; + AF1 denMaxR=AF1_(4.0)*mn4R+peakC.y; + AF1 denMaxG=AF1_(4.0)*mn4G+peakC.y; + AF1 denMaxB=AF1_(4.0)*mn4B+peakC.y; + AF1 hitMinR=denMinR>0.0?min(mn4R,eR)/denMinR:AF1_(0.0); + AF1 hitMinG=denMinG>0.0?min(mn4G,eG)/denMinG:AF1_(0.0); + AF1 hitMinB=denMinB>0.0?min(mn4B,eB)/denMinB:AF1_(0.0); + AF1 numMaxR=peakC.x-max(mx4R,eR); + AF1 numMaxG=peakC.x-max(mx4G,eG); + AF1 numMaxB=peakC.x-max(mx4B,eB); + AF1 hitMaxR=abs(denMaxR)>1e-6?numMaxR/denMaxR:AF1_(0.0); + AF1 hitMaxG=abs(denMaxG)>1e-6?numMaxG/denMaxG:AF1_(0.0); + AF1 hitMaxB=abs(denMaxB)>1e-6?numMaxB/denMaxB:AF1_(0.0); + AF1 lobeR=max(-hitMinR,hitMaxR); + AF1 lobeG=max(-hitMinG,hitMaxG); + AF1 lobeB=max(-hitMinB,hitMaxB); + AF1 lobe=max(AF1_(-FSR_RCAS_LIMIT),min(AMax3F1(lobeR,lobeG,lobeB),AF1_(0.0)))*AF1_AU1(con.x); + AF1 rcpL=APrxMedRcpF1(AF1_(4.0)*lobe+AF1_(1.0)); + pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL; + pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL; + pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL; + return;} + +void main() { + uvec2 ip = uvec2(fragTexCoord * pc.outputSize); + vec3 c; + FsrRcasF(c.r, c.g, c.b, ip, pc.con); + outColor = vec4(c, 1.0); +} diff --git a/app/src/main/cpp/shaders/fsr_rcas_frag.h b/app/src/main/cpp/shaders/fsr_rcas_frag.h index f241d7590c..e011659ba6 100644 --- a/app/src/main/cpp/shaders/fsr_rcas_frag.h +++ b/app/src/main/cpp/shaders/fsr_rcas_frag.h @@ -1,468 +1,503 @@ + // 1116.3.0 #pragma once const uint32_t fsr_rcas_code[] = { - 0x07230203,0x00010000,0x0008000b,0x0000025e,0x00000000,0x00020011,0x00000001,0x00020011, + 0x07230203,0x00010000,0x0008000b,0x0000028c,0x00000000,0x00020011,0x00000001,0x00020011, 0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e, - 0x00000000,0x00000001,0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000023b, - 0x00000258,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005, - 0x00000004,0x6e69616d,0x00000000,0x00050005,0x0000000a,0x70635241,0x66283146,0x00003b31, - 0x00030005,0x00000009,0x00000078,0x00070005,0x0000000d,0x78725041,0x5264654d,0x31467063, - 0x3b316628,0x00000000,0x00030005,0x0000000c,0x00000078,0x00050005,0x00000010,0x74615341, - 0x66283146,0x00003b31,0x00030005,0x0000000f,0x00000078,0x00070005,0x00000016,0x6e694d41, - 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000013,0x00000061,0x00030005, - 0x00000014,0x00000062,0x00030005,0x00000015,0x00000063,0x00070005,0x0000001b,0x78614d41, - 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000018,0x00000061,0x00030005, - 0x00000019,0x00000062,0x00030005,0x0000001a,0x00000063,0x00070005,0x00000023,0x52727346, - 0x4c736163,0x4664616f,0x32697628,0x0000003b,0x00030005,0x00000022,0x00000070,0x00080005, - 0x00000029,0x52727346,0x49736163,0x7475706e,0x31662846,0x3b31663b,0x003b3166,0x00030005, - 0x00000026,0x00000072,0x00030005,0x00000027,0x00000067,0x00030005,0x00000028,0x00000062, - 0x00090005,0x00000036,0x52727346,0x46736163,0x3b316628,0x663b3166,0x75763b31,0x75763b32, - 0x00003b34,0x00040005,0x00000031,0x52786970,0x00000000,0x00040005,0x00000032,0x47786970, - 0x00000000,0x00040005,0x00000033,0x42786970,0x00000000,0x00030005,0x00000034,0x00007069, - 0x00030005,0x00000035,0x006e6f63,0x00030005,0x00000054,0x00007a73,0x00060005,0x00000058, - 0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x00000069,0x00007073,0x00030005, - 0x0000006e,0x00000062,0x00040005,0x00000073,0x61726170,0x0000006d,0x00030005,0x00000076, - 0x00000064,0x00040005,0x0000007a,0x61726170,0x0000006d,0x00030005,0x0000007d,0x00000065, - 0x00040005,0x0000007e,0x61726170,0x0000006d,0x00030005,0x00000082,0x00000066,0x00040005, - 0x00000086,0x61726170,0x0000006d,0x00030005,0x00000089,0x00000068,0x00040005,0x0000008d, - 0x61726170,0x0000006d,0x00030005,0x00000090,0x00005262,0x00030005,0x00000094,0x00004762, - 0x00030005,0x00000098,0x00004262,0x00030005,0x0000009c,0x00005264,0x00030005,0x0000009f, - 0x00004764,0x00030005,0x000000a2,0x00004264,0x00030005,0x000000a5,0x00005265,0x00030005, - 0x000000a8,0x00004765,0x00030005,0x000000ab,0x00004265,0x00030005,0x000000ae,0x00005266, - 0x00030005,0x000000b1,0x00004766,0x00030005,0x000000b4,0x00004266,0x00030005,0x000000b7, - 0x00005268,0x00030005,0x000000ba,0x00004768,0x00030005,0x000000bd,0x00004268,0x00040005, - 0x000000c0,0x61726170,0x0000006d,0x00040005,0x000000c2,0x61726170,0x0000006d,0x00040005, - 0x000000c4,0x61726170,0x0000006d,0x00040005,0x000000ca,0x61726170,0x0000006d,0x00040005, - 0x000000cc,0x61726170,0x0000006d,0x00040005,0x000000ce,0x61726170,0x0000006d,0x00040005, - 0x000000d4,0x61726170,0x0000006d,0x00040005,0x000000d6,0x61726170,0x0000006d,0x00040005, - 0x000000d8,0x61726170,0x0000006d,0x00040005,0x000000de,0x61726170,0x0000006d,0x00040005, - 0x000000e0,0x61726170,0x0000006d,0x00040005,0x000000e2,0x61726170,0x0000006d,0x00040005, - 0x000000e8,0x61726170,0x0000006d,0x00040005,0x000000ea,0x61726170,0x0000006d,0x00040005, - 0x000000ec,0x61726170,0x0000006d,0x00030005,0x000000f2,0x00004c62,0x00030005,0x000000fb, - 0x00004c64,0x00030005,0x00000103,0x00004c65,0x00030005,0x0000010b,0x00004c66,0x00030005, - 0x00000113,0x00004c68,0x00030005,0x0000011b,0x00007a6e,0x00040005,0x0000012c,0x61726170, - 0x0000006d,0x00040005,0x0000012e,0x61726170,0x0000006d,0x00040005,0x00000130,0x61726170, - 0x0000006d,0x00040005,0x00000133,0x61726170,0x0000006d,0x00040005,0x00000134,0x61726170, - 0x0000006d,0x00040005,0x00000136,0x61726170,0x0000006d,0x00040005,0x00000139,0x61726170, - 0x0000006d,0x00040005,0x0000013b,0x61726170,0x0000006d,0x00040005,0x0000013d,0x61726170, - 0x0000006d,0x00040005,0x00000140,0x61726170,0x0000006d,0x00040005,0x00000141,0x61726170, - 0x0000006d,0x00040005,0x00000143,0x61726170,0x0000006d,0x00040005,0x00000147,0x61726170, - 0x0000006d,0x00040005,0x0000014a,0x61726170,0x0000006d,0x00040005,0x00000150,0x52346e6d, - 0x00000000,0x00040005,0x00000151,0x61726170,0x0000006d,0x00040005,0x00000153,0x61726170, - 0x0000006d,0x00040005,0x00000155,0x61726170,0x0000006d,0x00040005,0x0000015a,0x47346e6d, - 0x00000000,0x00040005,0x0000015b,0x61726170,0x0000006d,0x00040005,0x0000015d,0x61726170, - 0x0000006d,0x00040005,0x0000015f,0x61726170,0x0000006d,0x00040005,0x00000164,0x42346e6d, - 0x00000000,0x00040005,0x00000165,0x61726170,0x0000006d,0x00040005,0x00000167,0x61726170, - 0x0000006d,0x00040005,0x00000169,0x61726170,0x0000006d,0x00040005,0x0000016e,0x5234786d, - 0x00000000,0x00040005,0x0000016f,0x61726170,0x0000006d,0x00040005,0x00000171,0x61726170, - 0x0000006d,0x00040005,0x00000173,0x61726170,0x0000006d,0x00040005,0x00000178,0x4734786d, - 0x00000000,0x00040005,0x00000179,0x61726170,0x0000006d,0x00040005,0x0000017b,0x61726170, - 0x0000006d,0x00040005,0x0000017d,0x61726170,0x0000006d,0x00040005,0x00000182,0x4234786d, - 0x00000000,0x00040005,0x00000183,0x61726170,0x0000006d,0x00040005,0x00000185,0x61726170, - 0x0000006d,0x00040005,0x00000187,0x61726170,0x0000006d,0x00040005,0x0000018e,0x6b616570, - 0x00000043,0x00040005,0x00000191,0x4d746968,0x00526e69,0x00040005,0x00000198,0x61726170, - 0x0000006d,0x00040005,0x0000019b,0x4d746968,0x00476e69,0x00040005,0x000001a1,0x61726170, - 0x0000006d,0x00040005,0x000001a4,0x4d746968,0x00426e69,0x00040005,0x000001aa,0x61726170, - 0x0000006d,0x00040005,0x000001ad,0x4d746968,0x00527861,0x00040005,0x000001b9,0x61726170, - 0x0000006d,0x00040005,0x000001bc,0x4d746968,0x00477861,0x00040005,0x000001c8,0x61726170, - 0x0000006d,0x00040005,0x000001cb,0x4d746968,0x00427861,0x00040005,0x000001d7,0x61726170, - 0x0000006d,0x00040005,0x000001da,0x65626f6c,0x00000052,0x00040005,0x000001df,0x65626f6c, - 0x00000047,0x00040005,0x000001e4,0x65626f6c,0x00000042,0x00040005,0x000001e9,0x65626f6c, - 0x00000000,0x00040005,0x000001eb,0x61726170,0x0000006d,0x00040005,0x000001ed,0x61726170, - 0x0000006d,0x00040005,0x000001ef,0x61726170,0x0000006d,0x00040005,0x000001f9,0x4c706372, - 0x00000000,0x00040005,0x000001fd,0x61726170,0x0000006d,0x00030005,0x00000239,0x00007069, - 0x00060005,0x0000023b,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00030005,0x0000023d, - 0x00004350,0x00040006,0x0000023d,0x00000000,0x0063646e,0x00040006,0x0000023d,0x00000001, - 0x006e6f63,0x00060006,0x0000023d,0x00000002,0x7074756f,0x69537475,0x0000657a,0x00030005, - 0x0000023f,0x00006370,0x00030005,0x00000246,0x00000063,0x00040005,0x00000247,0x61726170, - 0x0000006d,0x00040005,0x00000248,0x61726170,0x0000006d,0x00040005,0x00000249,0x61726170, - 0x0000006d,0x00040005,0x0000024a,0x61726170,0x0000006d,0x00040005,0x0000024c,0x61726170, - 0x0000006d,0x00050005,0x00000258,0x4374756f,0x726f6c6f,0x00000000,0x00040047,0x00000058, - 0x00000021,0x00000000,0x00040047,0x00000058,0x00000022,0x00000000,0x00040047,0x0000023b, - 0x0000001e,0x00000000,0x00030047,0x0000023d,0x00000002,0x00050048,0x0000023d,0x00000000, - 0x00000023,0x00000000,0x00050048,0x0000023d,0x00000001,0x00000023,0x00000010,0x00050048, - 0x0000023d,0x00000002,0x00000023,0x00000020,0x00040047,0x00000258,0x0000001e,0x00000000, - 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, - 0x00040020,0x00000007,0x00000007,0x00000006,0x00040021,0x00000008,0x00000006,0x00000007, - 0x00060021,0x00000012,0x00000006,0x00000007,0x00000007,0x00000007,0x00040015,0x0000001d, - 0x00000020,0x00000001,0x00040017,0x0000001e,0x0000001d,0x00000002,0x00040020,0x0000001f, - 0x00000007,0x0000001e,0x00040017,0x00000020,0x00000006,0x00000004,0x00040021,0x00000021, - 0x00000020,0x0000001f,0x00060021,0x00000025,0x00000002,0x00000007,0x00000007,0x00000007, - 0x00040015,0x0000002b,0x00000020,0x00000000,0x00040017,0x0000002c,0x0000002b,0x00000002, - 0x00040020,0x0000002d,0x00000007,0x0000002c,0x00040017,0x0000002e,0x0000002b,0x00000004, - 0x00040020,0x0000002f,0x00000007,0x0000002e,0x00080021,0x00000030,0x00000002,0x00000007, - 0x00000007,0x00000007,0x0000002d,0x0000002f,0x0004002b,0x00000006,0x00000038,0x3f800000, - 0x0004002b,0x00000006,0x00000042,0x00000000,0x00090019,0x00000055,0x00000006,0x00000001, - 0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000056,0x00000055, - 0x00040020,0x00000057,0x00000000,0x00000056,0x0004003b,0x00000057,0x00000058,0x00000000, - 0x0004002b,0x0000001d,0x0000005a,0x00000000,0x0005002c,0x0000001e,0x0000005f,0x0000005a, - 0x0000005a,0x0004002b,0x0000001d,0x00000061,0x00000001,0x0005002c,0x0000001e,0x00000062, - 0x00000061,0x00000061,0x00040017,0x0000006c,0x00000006,0x00000003,0x00040020,0x0000006d, - 0x00000007,0x0000006c,0x0004002b,0x0000001d,0x00000070,0xffffffff,0x0005002c,0x0000001e, - 0x00000071,0x0000005a,0x00000070,0x0005002c,0x0000001e,0x00000078,0x00000070,0x0000005a, - 0x0005002c,0x0000001e,0x00000084,0x00000061,0x0000005a,0x0005002c,0x0000001e,0x0000008b, - 0x0000005a,0x00000061,0x0004002b,0x0000002b,0x00000091,0x00000000,0x0004002b,0x0000002b, - 0x00000095,0x00000001,0x0004002b,0x0000002b,0x00000099,0x00000002,0x0004002b,0x00000006, - 0x000000f4,0x3f000000,0x0004002b,0x00000006,0x0000011c,0x3e800000,0x0004002b,0x00000006, - 0x0000014c,0xbf000000,0x00040017,0x0000018c,0x00000006,0x00000002,0x00040020,0x0000018d, - 0x00000007,0x0000018c,0x0004002b,0x00000006,0x0000018f,0xc0800000,0x0005002c,0x0000018c, - 0x00000190,0x00000038,0x0000018f,0x0004002b,0x00000006,0x00000195,0x40800000,0x0004002b, - 0x00000006,0x000001ea,0xbe400000,0x00040020,0x000001f4,0x00000007,0x0000002b,0x00040020, - 0x0000023a,0x00000001,0x0000018c,0x0004003b,0x0000023a,0x0000023b,0x00000001,0x0005001e, - 0x0000023d,0x00000020,0x0000002e,0x0000018c,0x00040020,0x0000023e,0x00000009,0x0000023d, - 0x0004003b,0x0000023e,0x0000023f,0x00000009,0x0004002b,0x0000001d,0x00000240,0x00000002, - 0x00040020,0x00000241,0x00000009,0x0000018c,0x00040020,0x0000024d,0x00000009,0x0000002e, - 0x00040020,0x00000257,0x00000003,0x00000020,0x0004003b,0x00000257,0x00000258,0x00000003, - 0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b, - 0x0000002d,0x00000239,0x00000007,0x0004003b,0x0000006d,0x00000246,0x00000007,0x0004003b, - 0x00000007,0x00000247,0x00000007,0x0004003b,0x00000007,0x00000248,0x00000007,0x0004003b, - 0x00000007,0x00000249,0x00000007,0x0004003b,0x0000002d,0x0000024a,0x00000007,0x0004003b, - 0x0000002f,0x0000024c,0x00000007,0x0004003d,0x0000018c,0x0000023c,0x0000023b,0x00050041, - 0x00000241,0x00000242,0x0000023f,0x00000240,0x0004003d,0x0000018c,0x00000243,0x00000242, - 0x00050085,0x0000018c,0x00000244,0x0000023c,0x00000243,0x0004006d,0x0000002c,0x00000245, - 0x00000244,0x0003003e,0x00000239,0x00000245,0x0004003d,0x0000002c,0x0000024b,0x00000239, - 0x0003003e,0x0000024a,0x0000024b,0x00050041,0x0000024d,0x0000024e,0x0000023f,0x00000061, - 0x0004003d,0x0000002e,0x0000024f,0x0000024e,0x0003003e,0x0000024c,0x0000024f,0x00090039, - 0x00000002,0x00000250,0x00000036,0x00000247,0x00000248,0x00000249,0x0000024a,0x0000024c, - 0x0004003d,0x00000006,0x00000251,0x00000247,0x00050041,0x00000007,0x00000252,0x00000246, - 0x00000091,0x0003003e,0x00000252,0x00000251,0x0004003d,0x00000006,0x00000253,0x00000248, - 0x00050041,0x00000007,0x00000254,0x00000246,0x00000095,0x0003003e,0x00000254,0x00000253, - 0x0004003d,0x00000006,0x00000255,0x00000249,0x00050041,0x00000007,0x00000256,0x00000246, - 0x00000099,0x0003003e,0x00000256,0x00000255,0x0004003d,0x0000006c,0x00000259,0x00000246, - 0x00050051,0x00000006,0x0000025a,0x00000259,0x00000000,0x00050051,0x00000006,0x0000025b, - 0x00000259,0x00000001,0x00050051,0x00000006,0x0000025c,0x00000259,0x00000002,0x00070050, - 0x00000020,0x0000025d,0x0000025a,0x0000025b,0x0000025c,0x00000038,0x0003003e,0x00000258, - 0x0000025d,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000a,0x00000000,0x00000008, - 0x00030037,0x00000007,0x00000009,0x000200f8,0x0000000b,0x0004003d,0x00000006,0x00000039, - 0x00000009,0x00050088,0x00000006,0x0000003a,0x00000038,0x00000039,0x000200fe,0x0000003a, - 0x00010038,0x00050036,0x00000006,0x0000000d,0x00000000,0x00000008,0x00030037,0x00000007, - 0x0000000c,0x000200f8,0x0000000e,0x0004003d,0x00000006,0x0000003d,0x0000000c,0x00050088, - 0x00000006,0x0000003e,0x00000038,0x0000003d,0x000200fe,0x0000003e,0x00010038,0x00050036, - 0x00000006,0x00000010,0x00000000,0x00000008,0x00030037,0x00000007,0x0000000f,0x000200f8, - 0x00000011,0x0004003d,0x00000006,0x00000041,0x0000000f,0x0008000c,0x00000006,0x00000043, - 0x00000001,0x0000002b,0x00000041,0x00000042,0x00000038,0x000200fe,0x00000043,0x00010038, - 0x00050036,0x00000006,0x00000016,0x00000000,0x00000012,0x00030037,0x00000007,0x00000013, - 0x00030037,0x00000007,0x00000014,0x00030037,0x00000007,0x00000015,0x000200f8,0x00000017, - 0x0004003d,0x00000006,0x00000046,0x00000013,0x0004003d,0x00000006,0x00000047,0x00000014, - 0x0004003d,0x00000006,0x00000048,0x00000015,0x0007000c,0x00000006,0x00000049,0x00000001, - 0x00000025,0x00000047,0x00000048,0x0007000c,0x00000006,0x0000004a,0x00000001,0x00000025, - 0x00000046,0x00000049,0x000200fe,0x0000004a,0x00010038,0x00050036,0x00000006,0x0000001b, - 0x00000000,0x00000012,0x00030037,0x00000007,0x00000018,0x00030037,0x00000007,0x00000019, - 0x00030037,0x00000007,0x0000001a,0x000200f8,0x0000001c,0x0004003d,0x00000006,0x0000004d, - 0x00000018,0x0004003d,0x00000006,0x0000004e,0x00000019,0x0004003d,0x00000006,0x0000004f, - 0x0000001a,0x0007000c,0x00000006,0x00000050,0x00000001,0x00000028,0x0000004e,0x0000004f, - 0x0007000c,0x00000006,0x00000051,0x00000001,0x00000028,0x0000004d,0x00000050,0x000200fe, - 0x00000051,0x00010038,0x00050036,0x00000020,0x00000023,0x00000000,0x00000021,0x00030037, - 0x0000001f,0x00000022,0x000200f8,0x00000024,0x0004003b,0x0000001f,0x00000054,0x00000007, - 0x0004003d,0x00000056,0x00000059,0x00000058,0x00040064,0x00000055,0x0000005b,0x00000059, - 0x00050067,0x0000001e,0x0000005c,0x0000005b,0x0000005a,0x0003003e,0x00000054,0x0000005c, - 0x0004003d,0x00000056,0x0000005d,0x00000058,0x0004003d,0x0000001e,0x0000005e,0x00000022, - 0x0004003d,0x0000001e,0x00000060,0x00000054,0x00050082,0x0000001e,0x00000063,0x00000060, - 0x00000062,0x0008000c,0x0000001e,0x00000064,0x00000001,0x0000002d,0x0000005e,0x0000005f, - 0x00000063,0x00040064,0x00000055,0x00000065,0x0000005d,0x0007005f,0x00000020,0x00000066, - 0x00000065,0x00000064,0x00000002,0x0000005a,0x000200fe,0x00000066,0x00010038,0x00050036, - 0x00000002,0x00000029,0x00000000,0x00000025,0x00030037,0x00000007,0x00000026,0x00030037, - 0x00000007,0x00000027,0x00030037,0x00000007,0x00000028,0x000200f8,0x0000002a,0x000100fd, - 0x00010038,0x00050036,0x00000002,0x00000036,0x00000000,0x00000030,0x00030037,0x00000007, - 0x00000031,0x00030037,0x00000007,0x00000032,0x00030037,0x00000007,0x00000033,0x00030037, - 0x0000002d,0x00000034,0x00030037,0x0000002f,0x00000035,0x000200f8,0x00000037,0x0004003b, - 0x0000001f,0x00000069,0x00000007,0x0004003b,0x0000006d,0x0000006e,0x00000007,0x0004003b, - 0x0000001f,0x00000073,0x00000007,0x0004003b,0x0000006d,0x00000076,0x00000007,0x0004003b, - 0x0000001f,0x0000007a,0x00000007,0x0004003b,0x0000006d,0x0000007d,0x00000007,0x0004003b, - 0x0000001f,0x0000007e,0x00000007,0x0004003b,0x0000006d,0x00000082,0x00000007,0x0004003b, - 0x0000001f,0x00000086,0x00000007,0x0004003b,0x0000006d,0x00000089,0x00000007,0x0004003b, - 0x0000001f,0x0000008d,0x00000007,0x0004003b,0x00000007,0x00000090,0x00000007,0x0004003b, - 0x00000007,0x00000094,0x00000007,0x0004003b,0x00000007,0x00000098,0x00000007,0x0004003b, - 0x00000007,0x0000009c,0x00000007,0x0004003b,0x00000007,0x0000009f,0x00000007,0x0004003b, - 0x00000007,0x000000a2,0x00000007,0x0004003b,0x00000007,0x000000a5,0x00000007,0x0004003b, - 0x00000007,0x000000a8,0x00000007,0x0004003b,0x00000007,0x000000ab,0x00000007,0x0004003b, - 0x00000007,0x000000ae,0x00000007,0x0004003b,0x00000007,0x000000b1,0x00000007,0x0004003b, - 0x00000007,0x000000b4,0x00000007,0x0004003b,0x00000007,0x000000b7,0x00000007,0x0004003b, - 0x00000007,0x000000ba,0x00000007,0x0004003b,0x00000007,0x000000bd,0x00000007,0x0004003b, - 0x00000007,0x000000c0,0x00000007,0x0004003b,0x00000007,0x000000c2,0x00000007,0x0004003b, - 0x00000007,0x000000c4,0x00000007,0x0004003b,0x00000007,0x000000ca,0x00000007,0x0004003b, - 0x00000007,0x000000cc,0x00000007,0x0004003b,0x00000007,0x000000ce,0x00000007,0x0004003b, - 0x00000007,0x000000d4,0x00000007,0x0004003b,0x00000007,0x000000d6,0x00000007,0x0004003b, - 0x00000007,0x000000d8,0x00000007,0x0004003b,0x00000007,0x000000de,0x00000007,0x0004003b, - 0x00000007,0x000000e0,0x00000007,0x0004003b,0x00000007,0x000000e2,0x00000007,0x0004003b, - 0x00000007,0x000000e8,0x00000007,0x0004003b,0x00000007,0x000000ea,0x00000007,0x0004003b, - 0x00000007,0x000000ec,0x00000007,0x0004003b,0x00000007,0x000000f2,0x00000007,0x0004003b, - 0x00000007,0x000000fb,0x00000007,0x0004003b,0x00000007,0x00000103,0x00000007,0x0004003b, - 0x00000007,0x0000010b,0x00000007,0x0004003b,0x00000007,0x00000113,0x00000007,0x0004003b, - 0x00000007,0x0000011b,0x00000007,0x0004003b,0x00000007,0x0000012c,0x00000007,0x0004003b, - 0x00000007,0x0000012e,0x00000007,0x0004003b,0x00000007,0x00000130,0x00000007,0x0004003b, - 0x00000007,0x00000133,0x00000007,0x0004003b,0x00000007,0x00000134,0x00000007,0x0004003b, + 0x00000000,0x00000001,0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000269, + 0x00000286,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x00070005,0x0000000a,0x78725041,0x5264654d,0x31467063, + 0x3b316628,0x00000000,0x00030005,0x00000009,0x00000078,0x00050005,0x0000000d,0x74615341, + 0x66283146,0x00003b31,0x00030005,0x0000000c,0x00000078,0x00070005,0x00000013,0x6e694d41, + 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000010,0x00000061,0x00030005, + 0x00000011,0x00000062,0x00030005,0x00000012,0x00000063,0x00070005,0x00000018,0x78614d41, + 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000015,0x00000061,0x00030005, + 0x00000016,0x00000062,0x00030005,0x00000017,0x00000063,0x00070005,0x00000020,0x52727346, + 0x4c736163,0x4664616f,0x32697628,0x0000003b,0x00030005,0x0000001f,0x00000070,0x00080005, + 0x00000026,0x52727346,0x49736163,0x7475706e,0x31662846,0x3b31663b,0x003b3166,0x00030005, + 0x00000023,0x00000072,0x00030005,0x00000024,0x00000067,0x00030005,0x00000025,0x00000062, + 0x00090005,0x00000033,0x52727346,0x46736163,0x3b316628,0x663b3166,0x75763b31,0x75763b32, + 0x00003b34,0x00040005,0x0000002e,0x52786970,0x00000000,0x00040005,0x0000002f,0x47786970, + 0x00000000,0x00040005,0x00000030,0x42786970,0x00000000,0x00030005,0x00000031,0x00007069, + 0x00030005,0x00000032,0x006e6f63,0x00030005,0x0000004d,0x00007a73,0x00060005,0x00000051, + 0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x00000062,0x00007073,0x00030005, + 0x00000067,0x00000062,0x00040005,0x0000006c,0x61726170,0x0000006d,0x00030005,0x0000006f, + 0x00000064,0x00040005,0x00000073,0x61726170,0x0000006d,0x00030005,0x00000076,0x00000065, + 0x00040005,0x00000077,0x61726170,0x0000006d,0x00030005,0x0000007b,0x00000066,0x00040005, + 0x0000007f,0x61726170,0x0000006d,0x00030005,0x00000082,0x00000068,0x00040005,0x00000086, + 0x61726170,0x0000006d,0x00030005,0x00000089,0x00005262,0x00030005,0x0000008d,0x00004762, + 0x00030005,0x00000091,0x00004262,0x00030005,0x00000095,0x00005264,0x00030005,0x00000098, + 0x00004764,0x00030005,0x0000009b,0x00004264,0x00030005,0x0000009e,0x00005265,0x00030005, + 0x000000a1,0x00004765,0x00030005,0x000000a4,0x00004265,0x00030005,0x000000a7,0x00005266, + 0x00030005,0x000000aa,0x00004766,0x00030005,0x000000ad,0x00004266,0x00030005,0x000000b0, + 0x00005268,0x00030005,0x000000b3,0x00004768,0x00030005,0x000000b6,0x00004268,0x00040005, + 0x000000b9,0x61726170,0x0000006d,0x00040005,0x000000bb,0x61726170,0x0000006d,0x00040005, + 0x000000bd,0x61726170,0x0000006d,0x00040005,0x000000c3,0x61726170,0x0000006d,0x00040005, + 0x000000c5,0x61726170,0x0000006d,0x00040005,0x000000c7,0x61726170,0x0000006d,0x00040005, + 0x000000cd,0x61726170,0x0000006d,0x00040005,0x000000cf,0x61726170,0x0000006d,0x00040005, + 0x000000d1,0x61726170,0x0000006d,0x00040005,0x000000d7,0x61726170,0x0000006d,0x00040005, + 0x000000d9,0x61726170,0x0000006d,0x00040005,0x000000db,0x61726170,0x0000006d,0x00040005, + 0x000000e1,0x61726170,0x0000006d,0x00040005,0x000000e3,0x61726170,0x0000006d,0x00040005, + 0x000000e5,0x61726170,0x0000006d,0x00030005,0x000000eb,0x00004c62,0x00030005,0x000000f4, + 0x00004c64,0x00030005,0x000000fc,0x00004c65,0x00030005,0x00000104,0x00004c66,0x00030005, + 0x0000010c,0x00004c68,0x00030005,0x00000114,0x00007a6e,0x00040005,0x00000125,0x61726170, + 0x0000006d,0x00040005,0x00000127,0x61726170,0x0000006d,0x00040005,0x00000129,0x61726170, + 0x0000006d,0x00040005,0x0000012c,0x61726170,0x0000006d,0x00040005,0x0000012d,0x61726170, + 0x0000006d,0x00040005,0x0000012f,0x61726170,0x0000006d,0x00040005,0x00000132,0x61726170, + 0x0000006d,0x00040005,0x00000134,0x61726170,0x0000006d,0x00040005,0x00000136,0x61726170, + 0x0000006d,0x00040005,0x00000139,0x61726170,0x0000006d,0x00040005,0x0000013a,0x61726170, + 0x0000006d,0x00040005,0x0000013c,0x61726170,0x0000006d,0x00040005,0x00000140,0x61726170, + 0x0000006d,0x00040005,0x00000143,0x61726170,0x0000006d,0x00040005,0x00000149,0x52346e6d, + 0x00000000,0x00040005,0x0000014a,0x61726170,0x0000006d,0x00040005,0x0000014c,0x61726170, + 0x0000006d,0x00040005,0x0000014e,0x61726170,0x0000006d,0x00040005,0x00000153,0x47346e6d, + 0x00000000,0x00040005,0x00000154,0x61726170,0x0000006d,0x00040005,0x00000156,0x61726170, + 0x0000006d,0x00040005,0x00000158,0x61726170,0x0000006d,0x00040005,0x0000015d,0x42346e6d, + 0x00000000,0x00040005,0x0000015e,0x61726170,0x0000006d,0x00040005,0x00000160,0x61726170, + 0x0000006d,0x00040005,0x00000162,0x61726170,0x0000006d,0x00040005,0x00000167,0x5234786d, + 0x00000000,0x00040005,0x00000168,0x61726170,0x0000006d,0x00040005,0x0000016a,0x61726170, + 0x0000006d,0x00040005,0x0000016c,0x61726170,0x0000006d,0x00040005,0x00000171,0x4734786d, + 0x00000000,0x00040005,0x00000172,0x61726170,0x0000006d,0x00040005,0x00000174,0x61726170, + 0x0000006d,0x00040005,0x00000176,0x61726170,0x0000006d,0x00040005,0x0000017b,0x4234786d, + 0x00000000,0x00040005,0x0000017c,0x61726170,0x0000006d,0x00040005,0x0000017e,0x61726170, + 0x0000006d,0x00040005,0x00000180,0x61726170,0x0000006d,0x00040005,0x00000187,0x6b616570, + 0x00000043,0x00040005,0x0000018a,0x4d6e6564,0x00526e69,0x00040005,0x0000018e,0x4d6e6564, + 0x00476e69,0x00040005,0x00000191,0x4d6e6564,0x00426e69,0x00040005,0x00000194,0x4d6e6564, + 0x00527861,0x00040005,0x0000019a,0x4d6e6564,0x00477861,0x00040005,0x000001a0,0x4d6e6564, + 0x00427861,0x00040005,0x000001a6,0x4d746968,0x00526e69,0x00040005,0x000001b4,0x4d746968, + 0x00476e69,0x00040005,0x000001c1,0x4d746968,0x00426e69,0x00040005,0x000001ce,0x4d6d756e, + 0x00527861,0x00040005,0x000001d5,0x4d6d756e,0x00477861,0x00040005,0x000001dc,0x4d6d756e, + 0x00427861,0x00040005,0x000001e3,0x4d746968,0x00527861,0x00040005,0x000001f0,0x4d746968, + 0x00477861,0x00040005,0x000001fc,0x4d746968,0x00427861,0x00040005,0x00000208,0x65626f6c, + 0x00000052,0x00040005,0x0000020d,0x65626f6c,0x00000047,0x00040005,0x00000212,0x65626f6c, + 0x00000042,0x00040005,0x00000217,0x65626f6c,0x00000000,0x00040005,0x00000219,0x61726170, + 0x0000006d,0x00040005,0x0000021b,0x61726170,0x0000006d,0x00040005,0x0000021d,0x61726170, + 0x0000006d,0x00040005,0x00000227,0x4c706372,0x00000000,0x00040005,0x0000022b,0x61726170, + 0x0000006d,0x00030005,0x00000267,0x00007069,0x00060005,0x00000269,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00030005,0x0000026b,0x00004350,0x00040006,0x0000026b,0x00000000, + 0x0063646e,0x00040006,0x0000026b,0x00000001,0x006e6f63,0x00060006,0x0000026b,0x00000002, + 0x7074756f,0x69537475,0x0000657a,0x00030005,0x0000026d,0x00006370,0x00030005,0x00000274, + 0x00000063,0x00040005,0x00000275,0x61726170,0x0000006d,0x00040005,0x00000276,0x61726170, + 0x0000006d,0x00040005,0x00000277,0x61726170,0x0000006d,0x00040005,0x00000278,0x61726170, + 0x0000006d,0x00040005,0x0000027a,0x61726170,0x0000006d,0x00050005,0x00000286,0x4374756f, + 0x726f6c6f,0x00000000,0x00040047,0x00000051,0x00000021,0x00000000,0x00040047,0x00000051, + 0x00000022,0x00000000,0x00040047,0x00000269,0x0000001e,0x00000000,0x00030047,0x0000026b, + 0x00000002,0x00050048,0x0000026b,0x00000000,0x00000023,0x00000000,0x00050048,0x0000026b, + 0x00000001,0x00000023,0x00000010,0x00050048,0x0000026b,0x00000002,0x00000023,0x00000020, + 0x00040047,0x00000286,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003, + 0x00000002,0x00030016,0x00000006,0x00000020,0x00040020,0x00000007,0x00000007,0x00000006, + 0x00040021,0x00000008,0x00000006,0x00000007,0x00060021,0x0000000f,0x00000006,0x00000007, + 0x00000007,0x00000007,0x00040015,0x0000001a,0x00000020,0x00000001,0x00040017,0x0000001b, + 0x0000001a,0x00000002,0x00040020,0x0000001c,0x00000007,0x0000001b,0x00040017,0x0000001d, + 0x00000006,0x00000004,0x00040021,0x0000001e,0x0000001d,0x0000001c,0x00060021,0x00000022, + 0x00000002,0x00000007,0x00000007,0x00000007,0x00040015,0x00000028,0x00000020,0x00000000, + 0x00040017,0x00000029,0x00000028,0x00000002,0x00040020,0x0000002a,0x00000007,0x00000029, + 0x00040017,0x0000002b,0x00000028,0x00000004,0x00040020,0x0000002c,0x00000007,0x0000002b, + 0x00080021,0x0000002d,0x00000002,0x00000007,0x00000007,0x00000007,0x0000002a,0x0000002c, + 0x0004002b,0x00000006,0x00000035,0x3f800000,0x0004002b,0x00000006,0x0000003b,0x00000000, + 0x00090019,0x0000004e,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001, + 0x00000000,0x0003001b,0x0000004f,0x0000004e,0x00040020,0x00000050,0x00000000,0x0000004f, + 0x0004003b,0x00000050,0x00000051,0x00000000,0x0004002b,0x0000001a,0x00000053,0x00000000, + 0x0005002c,0x0000001b,0x00000058,0x00000053,0x00000053,0x0004002b,0x0000001a,0x0000005a, + 0x00000001,0x0005002c,0x0000001b,0x0000005b,0x0000005a,0x0000005a,0x00040017,0x00000065, + 0x00000006,0x00000003,0x00040020,0x00000066,0x00000007,0x00000065,0x0004002b,0x0000001a, + 0x00000069,0xffffffff,0x0005002c,0x0000001b,0x0000006a,0x00000053,0x00000069,0x0005002c, + 0x0000001b,0x00000071,0x00000069,0x00000053,0x0005002c,0x0000001b,0x0000007d,0x0000005a, + 0x00000053,0x0005002c,0x0000001b,0x00000084,0x00000053,0x0000005a,0x0004002b,0x00000028, + 0x0000008a,0x00000000,0x0004002b,0x00000028,0x0000008e,0x00000001,0x0004002b,0x00000028, + 0x00000092,0x00000002,0x0004002b,0x00000006,0x000000ed,0x3f000000,0x0004002b,0x00000006, + 0x00000115,0x3e800000,0x0004002b,0x00000006,0x00000145,0xbf000000,0x00040017,0x00000185, + 0x00000006,0x00000002,0x00040020,0x00000186,0x00000007,0x00000185,0x0004002b,0x00000006, + 0x00000188,0xc0800000,0x0005002c,0x00000185,0x00000189,0x00000035,0x00000188,0x0004002b, + 0x00000006,0x0000018b,0x40800000,0x00020014,0x000001a8,0x0004002b,0x00000006,0x000001e6, + 0x358637bd,0x0004002b,0x00000006,0x00000218,0xbe400000,0x00040020,0x00000222,0x00000007, + 0x00000028,0x00040020,0x00000268,0x00000001,0x00000185,0x0004003b,0x00000268,0x00000269, + 0x00000001,0x0005001e,0x0000026b,0x0000001d,0x0000002b,0x00000185,0x00040020,0x0000026c, + 0x00000009,0x0000026b,0x0004003b,0x0000026c,0x0000026d,0x00000009,0x0004002b,0x0000001a, + 0x0000026e,0x00000002,0x00040020,0x0000026f,0x00000009,0x00000185,0x00040020,0x0000027b, + 0x00000009,0x0000002b,0x00040020,0x00000285,0x00000003,0x0000001d,0x0004003b,0x00000285, + 0x00000286,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, + 0x00000005,0x0004003b,0x0000002a,0x00000267,0x00000007,0x0004003b,0x00000066,0x00000274, + 0x00000007,0x0004003b,0x00000007,0x00000275,0x00000007,0x0004003b,0x00000007,0x00000276, + 0x00000007,0x0004003b,0x00000007,0x00000277,0x00000007,0x0004003b,0x0000002a,0x00000278, + 0x00000007,0x0004003b,0x0000002c,0x0000027a,0x00000007,0x0004003d,0x00000185,0x0000026a, + 0x00000269,0x00050041,0x0000026f,0x00000270,0x0000026d,0x0000026e,0x0004003d,0x00000185, + 0x00000271,0x00000270,0x00050085,0x00000185,0x00000272,0x0000026a,0x00000271,0x0004006d, + 0x00000029,0x00000273,0x00000272,0x0003003e,0x00000267,0x00000273,0x0004003d,0x00000029, + 0x00000279,0x00000267,0x0003003e,0x00000278,0x00000279,0x00050041,0x0000027b,0x0000027c, + 0x0000026d,0x0000005a,0x0004003d,0x0000002b,0x0000027d,0x0000027c,0x0003003e,0x0000027a, + 0x0000027d,0x00090039,0x00000002,0x0000027e,0x00000033,0x00000275,0x00000276,0x00000277, + 0x00000278,0x0000027a,0x0004003d,0x00000006,0x0000027f,0x00000275,0x00050041,0x00000007, + 0x00000280,0x00000274,0x0000008a,0x0003003e,0x00000280,0x0000027f,0x0004003d,0x00000006, + 0x00000281,0x00000276,0x00050041,0x00000007,0x00000282,0x00000274,0x0000008e,0x0003003e, + 0x00000282,0x00000281,0x0004003d,0x00000006,0x00000283,0x00000277,0x00050041,0x00000007, + 0x00000284,0x00000274,0x00000092,0x0003003e,0x00000284,0x00000283,0x0004003d,0x00000065, + 0x00000287,0x00000274,0x00050051,0x00000006,0x00000288,0x00000287,0x00000000,0x00050051, + 0x00000006,0x00000289,0x00000287,0x00000001,0x00050051,0x00000006,0x0000028a,0x00000287, + 0x00000002,0x00070050,0x0000001d,0x0000028b,0x00000288,0x00000289,0x0000028a,0x00000035, + 0x0003003e,0x00000286,0x0000028b,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000a, + 0x00000000,0x00000008,0x00030037,0x00000007,0x00000009,0x000200f8,0x0000000b,0x0004003d, + 0x00000006,0x00000036,0x00000009,0x00050088,0x00000006,0x00000037,0x00000035,0x00000036, + 0x000200fe,0x00000037,0x00010038,0x00050036,0x00000006,0x0000000d,0x00000000,0x00000008, + 0x00030037,0x00000007,0x0000000c,0x000200f8,0x0000000e,0x0004003d,0x00000006,0x0000003a, + 0x0000000c,0x0008000c,0x00000006,0x0000003c,0x00000001,0x0000002b,0x0000003a,0x0000003b, + 0x00000035,0x000200fe,0x0000003c,0x00010038,0x00050036,0x00000006,0x00000013,0x00000000, + 0x0000000f,0x00030037,0x00000007,0x00000010,0x00030037,0x00000007,0x00000011,0x00030037, + 0x00000007,0x00000012,0x000200f8,0x00000014,0x0004003d,0x00000006,0x0000003f,0x00000010, + 0x0004003d,0x00000006,0x00000040,0x00000011,0x0004003d,0x00000006,0x00000041,0x00000012, + 0x0007000c,0x00000006,0x00000042,0x00000001,0x00000025,0x00000040,0x00000041,0x0007000c, + 0x00000006,0x00000043,0x00000001,0x00000025,0x0000003f,0x00000042,0x000200fe,0x00000043, + 0x00010038,0x00050036,0x00000006,0x00000018,0x00000000,0x0000000f,0x00030037,0x00000007, + 0x00000015,0x00030037,0x00000007,0x00000016,0x00030037,0x00000007,0x00000017,0x000200f8, + 0x00000019,0x0004003d,0x00000006,0x00000046,0x00000015,0x0004003d,0x00000006,0x00000047, + 0x00000016,0x0004003d,0x00000006,0x00000048,0x00000017,0x0007000c,0x00000006,0x00000049, + 0x00000001,0x00000028,0x00000047,0x00000048,0x0007000c,0x00000006,0x0000004a,0x00000001, + 0x00000028,0x00000046,0x00000049,0x000200fe,0x0000004a,0x00010038,0x00050036,0x0000001d, + 0x00000020,0x00000000,0x0000001e,0x00030037,0x0000001c,0x0000001f,0x000200f8,0x00000021, + 0x0004003b,0x0000001c,0x0000004d,0x00000007,0x0004003d,0x0000004f,0x00000052,0x00000051, + 0x00040064,0x0000004e,0x00000054,0x00000052,0x00050067,0x0000001b,0x00000055,0x00000054, + 0x00000053,0x0003003e,0x0000004d,0x00000055,0x0004003d,0x0000004f,0x00000056,0x00000051, + 0x0004003d,0x0000001b,0x00000057,0x0000001f,0x0004003d,0x0000001b,0x00000059,0x0000004d, + 0x00050082,0x0000001b,0x0000005c,0x00000059,0x0000005b,0x0008000c,0x0000001b,0x0000005d, + 0x00000001,0x0000002d,0x00000057,0x00000058,0x0000005c,0x00040064,0x0000004e,0x0000005e, + 0x00000056,0x0007005f,0x0000001d,0x0000005f,0x0000005e,0x0000005d,0x00000002,0x00000053, + 0x000200fe,0x0000005f,0x00010038,0x00050036,0x00000002,0x00000026,0x00000000,0x00000022, + 0x00030037,0x00000007,0x00000023,0x00030037,0x00000007,0x00000024,0x00030037,0x00000007, + 0x00000025,0x000200f8,0x00000027,0x000100fd,0x00010038,0x00050036,0x00000002,0x00000033, + 0x00000000,0x0000002d,0x00030037,0x00000007,0x0000002e,0x00030037,0x00000007,0x0000002f, + 0x00030037,0x00000007,0x00000030,0x00030037,0x0000002a,0x00000031,0x00030037,0x0000002c, + 0x00000032,0x000200f8,0x00000034,0x0004003b,0x0000001c,0x00000062,0x00000007,0x0004003b, + 0x00000066,0x00000067,0x00000007,0x0004003b,0x0000001c,0x0000006c,0x00000007,0x0004003b, + 0x00000066,0x0000006f,0x00000007,0x0004003b,0x0000001c,0x00000073,0x00000007,0x0004003b, + 0x00000066,0x00000076,0x00000007,0x0004003b,0x0000001c,0x00000077,0x00000007,0x0004003b, + 0x00000066,0x0000007b,0x00000007,0x0004003b,0x0000001c,0x0000007f,0x00000007,0x0004003b, + 0x00000066,0x00000082,0x00000007,0x0004003b,0x0000001c,0x00000086,0x00000007,0x0004003b, + 0x00000007,0x00000089,0x00000007,0x0004003b,0x00000007,0x0000008d,0x00000007,0x0004003b, + 0x00000007,0x00000091,0x00000007,0x0004003b,0x00000007,0x00000095,0x00000007,0x0004003b, + 0x00000007,0x00000098,0x00000007,0x0004003b,0x00000007,0x0000009b,0x00000007,0x0004003b, + 0x00000007,0x0000009e,0x00000007,0x0004003b,0x00000007,0x000000a1,0x00000007,0x0004003b, + 0x00000007,0x000000a4,0x00000007,0x0004003b,0x00000007,0x000000a7,0x00000007,0x0004003b, + 0x00000007,0x000000aa,0x00000007,0x0004003b,0x00000007,0x000000ad,0x00000007,0x0004003b, + 0x00000007,0x000000b0,0x00000007,0x0004003b,0x00000007,0x000000b3,0x00000007,0x0004003b, + 0x00000007,0x000000b6,0x00000007,0x0004003b,0x00000007,0x000000b9,0x00000007,0x0004003b, + 0x00000007,0x000000bb,0x00000007,0x0004003b,0x00000007,0x000000bd,0x00000007,0x0004003b, + 0x00000007,0x000000c3,0x00000007,0x0004003b,0x00000007,0x000000c5,0x00000007,0x0004003b, + 0x00000007,0x000000c7,0x00000007,0x0004003b,0x00000007,0x000000cd,0x00000007,0x0004003b, + 0x00000007,0x000000cf,0x00000007,0x0004003b,0x00000007,0x000000d1,0x00000007,0x0004003b, + 0x00000007,0x000000d7,0x00000007,0x0004003b,0x00000007,0x000000d9,0x00000007,0x0004003b, + 0x00000007,0x000000db,0x00000007,0x0004003b,0x00000007,0x000000e1,0x00000007,0x0004003b, + 0x00000007,0x000000e3,0x00000007,0x0004003b,0x00000007,0x000000e5,0x00000007,0x0004003b, + 0x00000007,0x000000eb,0x00000007,0x0004003b,0x00000007,0x000000f4,0x00000007,0x0004003b, + 0x00000007,0x000000fc,0x00000007,0x0004003b,0x00000007,0x00000104,0x00000007,0x0004003b, + 0x00000007,0x0000010c,0x00000007,0x0004003b,0x00000007,0x00000114,0x00000007,0x0004003b, + 0x00000007,0x00000125,0x00000007,0x0004003b,0x00000007,0x00000127,0x00000007,0x0004003b, + 0x00000007,0x00000129,0x00000007,0x0004003b,0x00000007,0x0000012c,0x00000007,0x0004003b, + 0x00000007,0x0000012d,0x00000007,0x0004003b,0x00000007,0x0000012f,0x00000007,0x0004003b, + 0x00000007,0x00000132,0x00000007,0x0004003b,0x00000007,0x00000134,0x00000007,0x0004003b, 0x00000007,0x00000136,0x00000007,0x0004003b,0x00000007,0x00000139,0x00000007,0x0004003b, - 0x00000007,0x0000013b,0x00000007,0x0004003b,0x00000007,0x0000013d,0x00000007,0x0004003b, - 0x00000007,0x00000140,0x00000007,0x0004003b,0x00000007,0x00000141,0x00000007,0x0004003b, - 0x00000007,0x00000143,0x00000007,0x0004003b,0x00000007,0x00000147,0x00000007,0x0004003b, - 0x00000007,0x0000014a,0x00000007,0x0004003b,0x00000007,0x00000150,0x00000007,0x0004003b, - 0x00000007,0x00000151,0x00000007,0x0004003b,0x00000007,0x00000153,0x00000007,0x0004003b, - 0x00000007,0x00000155,0x00000007,0x0004003b,0x00000007,0x0000015a,0x00000007,0x0004003b, - 0x00000007,0x0000015b,0x00000007,0x0004003b,0x00000007,0x0000015d,0x00000007,0x0004003b, - 0x00000007,0x0000015f,0x00000007,0x0004003b,0x00000007,0x00000164,0x00000007,0x0004003b, - 0x00000007,0x00000165,0x00000007,0x0004003b,0x00000007,0x00000167,0x00000007,0x0004003b, - 0x00000007,0x00000169,0x00000007,0x0004003b,0x00000007,0x0000016e,0x00000007,0x0004003b, - 0x00000007,0x0000016f,0x00000007,0x0004003b,0x00000007,0x00000171,0x00000007,0x0004003b, - 0x00000007,0x00000173,0x00000007,0x0004003b,0x00000007,0x00000178,0x00000007,0x0004003b, - 0x00000007,0x00000179,0x00000007,0x0004003b,0x00000007,0x0000017b,0x00000007,0x0004003b, - 0x00000007,0x0000017d,0x00000007,0x0004003b,0x00000007,0x00000182,0x00000007,0x0004003b, - 0x00000007,0x00000183,0x00000007,0x0004003b,0x00000007,0x00000185,0x00000007,0x0004003b, - 0x00000007,0x00000187,0x00000007,0x0004003b,0x0000018d,0x0000018e,0x00000007,0x0004003b, - 0x00000007,0x00000191,0x00000007,0x0004003b,0x00000007,0x00000198,0x00000007,0x0004003b, - 0x00000007,0x0000019b,0x00000007,0x0004003b,0x00000007,0x000001a1,0x00000007,0x0004003b, - 0x00000007,0x000001a4,0x00000007,0x0004003b,0x00000007,0x000001aa,0x00000007,0x0004003b, - 0x00000007,0x000001ad,0x00000007,0x0004003b,0x00000007,0x000001b9,0x00000007,0x0004003b, - 0x00000007,0x000001bc,0x00000007,0x0004003b,0x00000007,0x000001c8,0x00000007,0x0004003b, - 0x00000007,0x000001cb,0x00000007,0x0004003b,0x00000007,0x000001d7,0x00000007,0x0004003b, - 0x00000007,0x000001da,0x00000007,0x0004003b,0x00000007,0x000001df,0x00000007,0x0004003b, - 0x00000007,0x000001e4,0x00000007,0x0004003b,0x00000007,0x000001e9,0x00000007,0x0004003b, - 0x00000007,0x000001eb,0x00000007,0x0004003b,0x00000007,0x000001ed,0x00000007,0x0004003b, - 0x00000007,0x000001ef,0x00000007,0x0004003b,0x00000007,0x000001f9,0x00000007,0x0004003b, - 0x00000007,0x000001fd,0x00000007,0x0004003d,0x0000002c,0x0000006a,0x00000034,0x0004007c, - 0x0000001e,0x0000006b,0x0000006a,0x0003003e,0x00000069,0x0000006b,0x0004003d,0x0000001e, - 0x0000006f,0x00000069,0x00050080,0x0000001e,0x00000072,0x0000006f,0x00000071,0x0003003e, - 0x00000073,0x00000072,0x00050039,0x00000020,0x00000074,0x00000023,0x00000073,0x0008004f, - 0x0000006c,0x00000075,0x00000074,0x00000074,0x00000000,0x00000001,0x00000002,0x0003003e, - 0x0000006e,0x00000075,0x0004003d,0x0000001e,0x00000077,0x00000069,0x00050080,0x0000001e, - 0x00000079,0x00000077,0x00000078,0x0003003e,0x0000007a,0x00000079,0x00050039,0x00000020, - 0x0000007b,0x00000023,0x0000007a,0x0008004f,0x0000006c,0x0000007c,0x0000007b,0x0000007b, - 0x00000000,0x00000001,0x00000002,0x0003003e,0x00000076,0x0000007c,0x0004003d,0x0000001e, - 0x0000007f,0x00000069,0x0003003e,0x0000007e,0x0000007f,0x00050039,0x00000020,0x00000080, - 0x00000023,0x0000007e,0x0008004f,0x0000006c,0x00000081,0x00000080,0x00000080,0x00000000, - 0x00000001,0x00000002,0x0003003e,0x0000007d,0x00000081,0x0004003d,0x0000001e,0x00000083, - 0x00000069,0x00050080,0x0000001e,0x00000085,0x00000083,0x00000084,0x0003003e,0x00000086, - 0x00000085,0x00050039,0x00000020,0x00000087,0x00000023,0x00000086,0x0008004f,0x0000006c, - 0x00000088,0x00000087,0x00000087,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000082, - 0x00000088,0x0004003d,0x0000001e,0x0000008a,0x00000069,0x00050080,0x0000001e,0x0000008c, - 0x0000008a,0x0000008b,0x0003003e,0x0000008d,0x0000008c,0x00050039,0x00000020,0x0000008e, - 0x00000023,0x0000008d,0x0008004f,0x0000006c,0x0000008f,0x0000008e,0x0000008e,0x00000000, - 0x00000001,0x00000002,0x0003003e,0x00000089,0x0000008f,0x00050041,0x00000007,0x00000092, - 0x0000006e,0x00000091,0x0004003d,0x00000006,0x00000093,0x00000092,0x0003003e,0x00000090, - 0x00000093,0x00050041,0x00000007,0x00000096,0x0000006e,0x00000095,0x0004003d,0x00000006, - 0x00000097,0x00000096,0x0003003e,0x00000094,0x00000097,0x00050041,0x00000007,0x0000009a, - 0x0000006e,0x00000099,0x0004003d,0x00000006,0x0000009b,0x0000009a,0x0003003e,0x00000098, - 0x0000009b,0x00050041,0x00000007,0x0000009d,0x00000076,0x00000091,0x0004003d,0x00000006, - 0x0000009e,0x0000009d,0x0003003e,0x0000009c,0x0000009e,0x00050041,0x00000007,0x000000a0, - 0x00000076,0x00000095,0x0004003d,0x00000006,0x000000a1,0x000000a0,0x0003003e,0x0000009f, - 0x000000a1,0x00050041,0x00000007,0x000000a3,0x00000076,0x00000099,0x0004003d,0x00000006, - 0x000000a4,0x000000a3,0x0003003e,0x000000a2,0x000000a4,0x00050041,0x00000007,0x000000a6, - 0x0000007d,0x00000091,0x0004003d,0x00000006,0x000000a7,0x000000a6,0x0003003e,0x000000a5, - 0x000000a7,0x00050041,0x00000007,0x000000a9,0x0000007d,0x00000095,0x0004003d,0x00000006, - 0x000000aa,0x000000a9,0x0003003e,0x000000a8,0x000000aa,0x00050041,0x00000007,0x000000ac, - 0x0000007d,0x00000099,0x0004003d,0x00000006,0x000000ad,0x000000ac,0x0003003e,0x000000ab, - 0x000000ad,0x00050041,0x00000007,0x000000af,0x00000082,0x00000091,0x0004003d,0x00000006, - 0x000000b0,0x000000af,0x0003003e,0x000000ae,0x000000b0,0x00050041,0x00000007,0x000000b2, - 0x00000082,0x00000095,0x0004003d,0x00000006,0x000000b3,0x000000b2,0x0003003e,0x000000b1, - 0x000000b3,0x00050041,0x00000007,0x000000b5,0x00000082,0x00000099,0x0004003d,0x00000006, - 0x000000b6,0x000000b5,0x0003003e,0x000000b4,0x000000b6,0x00050041,0x00000007,0x000000b8, - 0x00000089,0x00000091,0x0004003d,0x00000006,0x000000b9,0x000000b8,0x0003003e,0x000000b7, - 0x000000b9,0x00050041,0x00000007,0x000000bb,0x00000089,0x00000095,0x0004003d,0x00000006, - 0x000000bc,0x000000bb,0x0003003e,0x000000ba,0x000000bc,0x00050041,0x00000007,0x000000be, - 0x00000089,0x00000099,0x0004003d,0x00000006,0x000000bf,0x000000be,0x0003003e,0x000000bd, - 0x000000bf,0x0004003d,0x00000006,0x000000c1,0x00000090,0x0003003e,0x000000c0,0x000000c1, - 0x0004003d,0x00000006,0x000000c3,0x00000094,0x0003003e,0x000000c2,0x000000c3,0x0004003d, - 0x00000006,0x000000c5,0x00000098,0x0003003e,0x000000c4,0x000000c5,0x00070039,0x00000002, - 0x000000c6,0x00000029,0x000000c0,0x000000c2,0x000000c4,0x0004003d,0x00000006,0x000000c7, - 0x000000c0,0x0003003e,0x00000090,0x000000c7,0x0004003d,0x00000006,0x000000c8,0x000000c2, - 0x0003003e,0x00000094,0x000000c8,0x0004003d,0x00000006,0x000000c9,0x000000c4,0x0003003e, - 0x00000098,0x000000c9,0x0004003d,0x00000006,0x000000cb,0x0000009c,0x0003003e,0x000000ca, - 0x000000cb,0x0004003d,0x00000006,0x000000cd,0x0000009f,0x0003003e,0x000000cc,0x000000cd, - 0x0004003d,0x00000006,0x000000cf,0x000000a2,0x0003003e,0x000000ce,0x000000cf,0x00070039, - 0x00000002,0x000000d0,0x00000029,0x000000ca,0x000000cc,0x000000ce,0x0004003d,0x00000006, - 0x000000d1,0x000000ca,0x0003003e,0x0000009c,0x000000d1,0x0004003d,0x00000006,0x000000d2, - 0x000000cc,0x0003003e,0x0000009f,0x000000d2,0x0004003d,0x00000006,0x000000d3,0x000000ce, - 0x0003003e,0x000000a2,0x000000d3,0x0004003d,0x00000006,0x000000d5,0x000000a5,0x0003003e, - 0x000000d4,0x000000d5,0x0004003d,0x00000006,0x000000d7,0x000000a8,0x0003003e,0x000000d6, - 0x000000d7,0x0004003d,0x00000006,0x000000d9,0x000000ab,0x0003003e,0x000000d8,0x000000d9, - 0x00070039,0x00000002,0x000000da,0x00000029,0x000000d4,0x000000d6,0x000000d8,0x0004003d, - 0x00000006,0x000000db,0x000000d4,0x0003003e,0x000000a5,0x000000db,0x0004003d,0x00000006, - 0x000000dc,0x000000d6,0x0003003e,0x000000a8,0x000000dc,0x0004003d,0x00000006,0x000000dd, - 0x000000d8,0x0003003e,0x000000ab,0x000000dd,0x0004003d,0x00000006,0x000000df,0x000000ae, - 0x0003003e,0x000000de,0x000000df,0x0004003d,0x00000006,0x000000e1,0x000000b1,0x0003003e, - 0x000000e0,0x000000e1,0x0004003d,0x00000006,0x000000e3,0x000000b4,0x0003003e,0x000000e2, - 0x000000e3,0x00070039,0x00000002,0x000000e4,0x00000029,0x000000de,0x000000e0,0x000000e2, - 0x0004003d,0x00000006,0x000000e5,0x000000de,0x0003003e,0x000000ae,0x000000e5,0x0004003d, - 0x00000006,0x000000e6,0x000000e0,0x0003003e,0x000000b1,0x000000e6,0x0004003d,0x00000006, - 0x000000e7,0x000000e2,0x0003003e,0x000000b4,0x000000e7,0x0004003d,0x00000006,0x000000e9, - 0x000000b7,0x0003003e,0x000000e8,0x000000e9,0x0004003d,0x00000006,0x000000eb,0x000000ba, - 0x0003003e,0x000000ea,0x000000eb,0x0004003d,0x00000006,0x000000ed,0x000000bd,0x0003003e, - 0x000000ec,0x000000ed,0x00070039,0x00000002,0x000000ee,0x00000029,0x000000e8,0x000000ea, - 0x000000ec,0x0004003d,0x00000006,0x000000ef,0x000000e8,0x0003003e,0x000000b7,0x000000ef, - 0x0004003d,0x00000006,0x000000f0,0x000000ea,0x0003003e,0x000000ba,0x000000f0,0x0004003d, - 0x00000006,0x000000f1,0x000000ec,0x0003003e,0x000000bd,0x000000f1,0x0004003d,0x00000006, - 0x000000f3,0x00000098,0x00050085,0x00000006,0x000000f5,0x000000f3,0x000000f4,0x0004003d, - 0x00000006,0x000000f6,0x00000090,0x00050085,0x00000006,0x000000f7,0x000000f6,0x000000f4, - 0x0004003d,0x00000006,0x000000f8,0x00000094,0x00050081,0x00000006,0x000000f9,0x000000f7, - 0x000000f8,0x00050081,0x00000006,0x000000fa,0x000000f5,0x000000f9,0x0003003e,0x000000f2, - 0x000000fa,0x0004003d,0x00000006,0x000000fc,0x000000a2,0x00050085,0x00000006,0x000000fd, - 0x000000fc,0x000000f4,0x0004003d,0x00000006,0x000000fe,0x0000009c,0x00050085,0x00000006, - 0x000000ff,0x000000fe,0x000000f4,0x0004003d,0x00000006,0x00000100,0x0000009f,0x00050081, - 0x00000006,0x00000101,0x000000ff,0x00000100,0x00050081,0x00000006,0x00000102,0x000000fd, - 0x00000101,0x0003003e,0x000000fb,0x00000102,0x0004003d,0x00000006,0x00000104,0x000000ab, - 0x00050085,0x00000006,0x00000105,0x00000104,0x000000f4,0x0004003d,0x00000006,0x00000106, - 0x000000a5,0x00050085,0x00000006,0x00000107,0x00000106,0x000000f4,0x0004003d,0x00000006, - 0x00000108,0x000000a8,0x00050081,0x00000006,0x00000109,0x00000107,0x00000108,0x00050081, - 0x00000006,0x0000010a,0x00000105,0x00000109,0x0003003e,0x00000103,0x0000010a,0x0004003d, - 0x00000006,0x0000010c,0x000000b4,0x00050085,0x00000006,0x0000010d,0x0000010c,0x000000f4, - 0x0004003d,0x00000006,0x0000010e,0x000000ae,0x00050085,0x00000006,0x0000010f,0x0000010e, - 0x000000f4,0x0004003d,0x00000006,0x00000110,0x000000b1,0x00050081,0x00000006,0x00000111, - 0x0000010f,0x00000110,0x00050081,0x00000006,0x00000112,0x0000010d,0x00000111,0x0003003e, - 0x0000010b,0x00000112,0x0004003d,0x00000006,0x00000114,0x000000bd,0x00050085,0x00000006, - 0x00000115,0x00000114,0x000000f4,0x0004003d,0x00000006,0x00000116,0x000000b7,0x00050085, - 0x00000006,0x00000117,0x00000116,0x000000f4,0x0004003d,0x00000006,0x00000118,0x000000ba, - 0x00050081,0x00000006,0x00000119,0x00000117,0x00000118,0x00050081,0x00000006,0x0000011a, - 0x00000115,0x00000119,0x0003003e,0x00000113,0x0000011a,0x0004003d,0x00000006,0x0000011d, - 0x000000f2,0x00050085,0x00000006,0x0000011e,0x0000011c,0x0000011d,0x0004003d,0x00000006, - 0x0000011f,0x000000fb,0x00050085,0x00000006,0x00000120,0x0000011c,0x0000011f,0x00050081, - 0x00000006,0x00000121,0x0000011e,0x00000120,0x0004003d,0x00000006,0x00000122,0x0000010b, - 0x00050085,0x00000006,0x00000123,0x0000011c,0x00000122,0x00050081,0x00000006,0x00000124, - 0x00000121,0x00000123,0x0004003d,0x00000006,0x00000125,0x00000113,0x00050085,0x00000006, - 0x00000126,0x0000011c,0x00000125,0x00050081,0x00000006,0x00000127,0x00000124,0x00000126, - 0x0004003d,0x00000006,0x00000128,0x00000103,0x00050083,0x00000006,0x00000129,0x00000127, - 0x00000128,0x0003003e,0x0000011b,0x00000129,0x0004003d,0x00000006,0x0000012a,0x0000011b, - 0x0006000c,0x00000006,0x0000012b,0x00000001,0x00000004,0x0000012a,0x0004003d,0x00000006, - 0x0000012d,0x000000f2,0x0003003e,0x0000012c,0x0000012d,0x0004003d,0x00000006,0x0000012f, - 0x000000fb,0x0003003e,0x0000012e,0x0000012f,0x0004003d,0x00000006,0x00000131,0x00000103, - 0x0003003e,0x00000130,0x00000131,0x00070039,0x00000006,0x00000132,0x0000001b,0x0000012c, - 0x0000012e,0x00000130,0x0003003e,0x00000133,0x00000132,0x0004003d,0x00000006,0x00000135, - 0x0000010b,0x0003003e,0x00000134,0x00000135,0x0004003d,0x00000006,0x00000137,0x00000113, - 0x0003003e,0x00000136,0x00000137,0x00070039,0x00000006,0x00000138,0x0000001b,0x00000133, - 0x00000134,0x00000136,0x0004003d,0x00000006,0x0000013a,0x000000f2,0x0003003e,0x00000139, - 0x0000013a,0x0004003d,0x00000006,0x0000013c,0x000000fb,0x0003003e,0x0000013b,0x0000013c, - 0x0004003d,0x00000006,0x0000013e,0x00000103,0x0003003e,0x0000013d,0x0000013e,0x00070039, - 0x00000006,0x0000013f,0x00000016,0x00000139,0x0000013b,0x0000013d,0x0003003e,0x00000140, - 0x0000013f,0x0004003d,0x00000006,0x00000142,0x0000010b,0x0003003e,0x00000141,0x00000142, - 0x0004003d,0x00000006,0x00000144,0x00000113,0x0003003e,0x00000143,0x00000144,0x00070039, - 0x00000006,0x00000145,0x00000016,0x00000140,0x00000141,0x00000143,0x00050083,0x00000006, - 0x00000146,0x00000138,0x00000145,0x0003003e,0x00000147,0x00000146,0x00050039,0x00000006, - 0x00000148,0x0000000d,0x00000147,0x00050085,0x00000006,0x00000149,0x0000012b,0x00000148, - 0x0003003e,0x0000014a,0x00000149,0x00050039,0x00000006,0x0000014b,0x00000010,0x0000014a, - 0x0003003e,0x0000011b,0x0000014b,0x0004003d,0x00000006,0x0000014d,0x0000011b,0x00050085, - 0x00000006,0x0000014e,0x0000014c,0x0000014d,0x00050081,0x00000006,0x0000014f,0x0000014e, - 0x00000038,0x0003003e,0x0000011b,0x0000014f,0x0004003d,0x00000006,0x00000152,0x00000090, - 0x0003003e,0x00000151,0x00000152,0x0004003d,0x00000006,0x00000154,0x0000009c,0x0003003e, - 0x00000153,0x00000154,0x0004003d,0x00000006,0x00000156,0x000000ae,0x0003003e,0x00000155, - 0x00000156,0x00070039,0x00000006,0x00000157,0x00000016,0x00000151,0x00000153,0x00000155, - 0x0004003d,0x00000006,0x00000158,0x000000b7,0x0007000c,0x00000006,0x00000159,0x00000001, - 0x00000025,0x00000157,0x00000158,0x0003003e,0x00000150,0x00000159,0x0004003d,0x00000006, - 0x0000015c,0x00000094,0x0003003e,0x0000015b,0x0000015c,0x0004003d,0x00000006,0x0000015e, - 0x0000009f,0x0003003e,0x0000015d,0x0000015e,0x0004003d,0x00000006,0x00000160,0x000000b1, - 0x0003003e,0x0000015f,0x00000160,0x00070039,0x00000006,0x00000161,0x00000016,0x0000015b, - 0x0000015d,0x0000015f,0x0004003d,0x00000006,0x00000162,0x000000ba,0x0007000c,0x00000006, - 0x00000163,0x00000001,0x00000025,0x00000161,0x00000162,0x0003003e,0x0000015a,0x00000163, - 0x0004003d,0x00000006,0x00000166,0x00000098,0x0003003e,0x00000165,0x00000166,0x0004003d, - 0x00000006,0x00000168,0x000000a2,0x0003003e,0x00000167,0x00000168,0x0004003d,0x00000006, - 0x0000016a,0x000000b4,0x0003003e,0x00000169,0x0000016a,0x00070039,0x00000006,0x0000016b, - 0x00000016,0x00000165,0x00000167,0x00000169,0x0004003d,0x00000006,0x0000016c,0x000000bd, - 0x0007000c,0x00000006,0x0000016d,0x00000001,0x00000025,0x0000016b,0x0000016c,0x0003003e, - 0x00000164,0x0000016d,0x0004003d,0x00000006,0x00000170,0x00000090,0x0003003e,0x0000016f, - 0x00000170,0x0004003d,0x00000006,0x00000172,0x0000009c,0x0003003e,0x00000171,0x00000172, - 0x0004003d,0x00000006,0x00000174,0x000000ae,0x0003003e,0x00000173,0x00000174,0x00070039, - 0x00000006,0x00000175,0x0000001b,0x0000016f,0x00000171,0x00000173,0x0004003d,0x00000006, - 0x00000176,0x000000b7,0x0007000c,0x00000006,0x00000177,0x00000001,0x00000028,0x00000175, - 0x00000176,0x0003003e,0x0000016e,0x00000177,0x0004003d,0x00000006,0x0000017a,0x00000094, - 0x0003003e,0x00000179,0x0000017a,0x0004003d,0x00000006,0x0000017c,0x0000009f,0x0003003e, - 0x0000017b,0x0000017c,0x0004003d,0x00000006,0x0000017e,0x000000b1,0x0003003e,0x0000017d, - 0x0000017e,0x00070039,0x00000006,0x0000017f,0x0000001b,0x00000179,0x0000017b,0x0000017d, - 0x0004003d,0x00000006,0x00000180,0x000000ba,0x0007000c,0x00000006,0x00000181,0x00000001, - 0x00000028,0x0000017f,0x00000180,0x0003003e,0x00000178,0x00000181,0x0004003d,0x00000006, - 0x00000184,0x00000098,0x0003003e,0x00000183,0x00000184,0x0004003d,0x00000006,0x00000186, - 0x000000a2,0x0003003e,0x00000185,0x00000186,0x0004003d,0x00000006,0x00000188,0x000000b4, - 0x0003003e,0x00000187,0x00000188,0x00070039,0x00000006,0x00000189,0x0000001b,0x00000183, - 0x00000185,0x00000187,0x0004003d,0x00000006,0x0000018a,0x000000bd,0x0007000c,0x00000006, - 0x0000018b,0x00000001,0x00000028,0x00000189,0x0000018a,0x0003003e,0x00000182,0x0000018b, - 0x0003003e,0x0000018e,0x00000190,0x0004003d,0x00000006,0x00000192,0x00000150,0x0004003d, - 0x00000006,0x00000193,0x000000a5,0x0007000c,0x00000006,0x00000194,0x00000001,0x00000025, - 0x00000192,0x00000193,0x0004003d,0x00000006,0x00000196,0x0000016e,0x00050085,0x00000006, - 0x00000197,0x00000195,0x00000196,0x0003003e,0x00000198,0x00000197,0x00050039,0x00000006, - 0x00000199,0x0000000a,0x00000198,0x00050085,0x00000006,0x0000019a,0x00000194,0x00000199, - 0x0003003e,0x00000191,0x0000019a,0x0004003d,0x00000006,0x0000019c,0x0000015a,0x0004003d, - 0x00000006,0x0000019d,0x000000a8,0x0007000c,0x00000006,0x0000019e,0x00000001,0x00000025, - 0x0000019c,0x0000019d,0x0004003d,0x00000006,0x0000019f,0x00000178,0x00050085,0x00000006, - 0x000001a0,0x00000195,0x0000019f,0x0003003e,0x000001a1,0x000001a0,0x00050039,0x00000006, - 0x000001a2,0x0000000a,0x000001a1,0x00050085,0x00000006,0x000001a3,0x0000019e,0x000001a2, - 0x0003003e,0x0000019b,0x000001a3,0x0004003d,0x00000006,0x000001a5,0x00000164,0x0004003d, - 0x00000006,0x000001a6,0x000000ab,0x0007000c,0x00000006,0x000001a7,0x00000001,0x00000025, - 0x000001a5,0x000001a6,0x0004003d,0x00000006,0x000001a8,0x00000182,0x00050085,0x00000006, - 0x000001a9,0x00000195,0x000001a8,0x0003003e,0x000001aa,0x000001a9,0x00050039,0x00000006, - 0x000001ab,0x0000000a,0x000001aa,0x00050085,0x00000006,0x000001ac,0x000001a7,0x000001ab, - 0x0003003e,0x000001a4,0x000001ac,0x00050041,0x00000007,0x000001ae,0x0000018e,0x00000091, - 0x0004003d,0x00000006,0x000001af,0x000001ae,0x0004003d,0x00000006,0x000001b0,0x0000016e, - 0x0004003d,0x00000006,0x000001b1,0x000000a5,0x0007000c,0x00000006,0x000001b2,0x00000001, - 0x00000028,0x000001b0,0x000001b1,0x00050083,0x00000006,0x000001b3,0x000001af,0x000001b2, - 0x0004003d,0x00000006,0x000001b4,0x00000150,0x00050085,0x00000006,0x000001b5,0x00000195, - 0x000001b4,0x00050041,0x00000007,0x000001b6,0x0000018e,0x00000095,0x0004003d,0x00000006, - 0x000001b7,0x000001b6,0x00050081,0x00000006,0x000001b8,0x000001b5,0x000001b7,0x0003003e, - 0x000001b9,0x000001b8,0x00050039,0x00000006,0x000001ba,0x0000000a,0x000001b9,0x00050085, - 0x00000006,0x000001bb,0x000001b3,0x000001ba,0x0003003e,0x000001ad,0x000001bb,0x00050041, - 0x00000007,0x000001bd,0x0000018e,0x00000091,0x0004003d,0x00000006,0x000001be,0x000001bd, - 0x0004003d,0x00000006,0x000001bf,0x00000178,0x0004003d,0x00000006,0x000001c0,0x000000a8, - 0x0007000c,0x00000006,0x000001c1,0x00000001,0x00000028,0x000001bf,0x000001c0,0x00050083, - 0x00000006,0x000001c2,0x000001be,0x000001c1,0x0004003d,0x00000006,0x000001c3,0x0000015a, - 0x00050085,0x00000006,0x000001c4,0x00000195,0x000001c3,0x00050041,0x00000007,0x000001c5, - 0x0000018e,0x00000095,0x0004003d,0x00000006,0x000001c6,0x000001c5,0x00050081,0x00000006, - 0x000001c7,0x000001c4,0x000001c6,0x0003003e,0x000001c8,0x000001c7,0x00050039,0x00000006, - 0x000001c9,0x0000000a,0x000001c8,0x00050085,0x00000006,0x000001ca,0x000001c2,0x000001c9, - 0x0003003e,0x000001bc,0x000001ca,0x00050041,0x00000007,0x000001cc,0x0000018e,0x00000091, - 0x0004003d,0x00000006,0x000001cd,0x000001cc,0x0004003d,0x00000006,0x000001ce,0x00000182, - 0x0004003d,0x00000006,0x000001cf,0x000000ab,0x0007000c,0x00000006,0x000001d0,0x00000001, - 0x00000028,0x000001ce,0x000001cf,0x00050083,0x00000006,0x000001d1,0x000001cd,0x000001d0, - 0x0004003d,0x00000006,0x000001d2,0x00000164,0x00050085,0x00000006,0x000001d3,0x00000195, - 0x000001d2,0x00050041,0x00000007,0x000001d4,0x0000018e,0x00000095,0x0004003d,0x00000006, - 0x000001d5,0x000001d4,0x00050081,0x00000006,0x000001d6,0x000001d3,0x000001d5,0x0003003e, - 0x000001d7,0x000001d6,0x00050039,0x00000006,0x000001d8,0x0000000a,0x000001d7,0x00050085, - 0x00000006,0x000001d9,0x000001d1,0x000001d8,0x0003003e,0x000001cb,0x000001d9,0x0004003d, - 0x00000006,0x000001db,0x00000191,0x0004007f,0x00000006,0x000001dc,0x000001db,0x0004003d, - 0x00000006,0x000001dd,0x000001ad,0x0007000c,0x00000006,0x000001de,0x00000001,0x00000028, - 0x000001dc,0x000001dd,0x0003003e,0x000001da,0x000001de,0x0004003d,0x00000006,0x000001e0, - 0x0000019b,0x0004007f,0x00000006,0x000001e1,0x000001e0,0x0004003d,0x00000006,0x000001e2, - 0x000001bc,0x0007000c,0x00000006,0x000001e3,0x00000001,0x00000028,0x000001e1,0x000001e2, - 0x0003003e,0x000001df,0x000001e3,0x0004003d,0x00000006,0x000001e5,0x000001a4,0x0004007f, - 0x00000006,0x000001e6,0x000001e5,0x0004003d,0x00000006,0x000001e7,0x000001cb,0x0007000c, - 0x00000006,0x000001e8,0x00000001,0x00000028,0x000001e6,0x000001e7,0x0003003e,0x000001e4, - 0x000001e8,0x0004003d,0x00000006,0x000001ec,0x000001da,0x0003003e,0x000001eb,0x000001ec, - 0x0004003d,0x00000006,0x000001ee,0x000001df,0x0003003e,0x000001ed,0x000001ee,0x0004003d, - 0x00000006,0x000001f0,0x000001e4,0x0003003e,0x000001ef,0x000001f0,0x00070039,0x00000006, - 0x000001f1,0x0000001b,0x000001eb,0x000001ed,0x000001ef,0x0007000c,0x00000006,0x000001f2, - 0x00000001,0x00000025,0x000001f1,0x00000042,0x0007000c,0x00000006,0x000001f3,0x00000001, - 0x00000028,0x000001ea,0x000001f2,0x00050041,0x000001f4,0x000001f5,0x00000035,0x00000091, - 0x0004003d,0x0000002b,0x000001f6,0x000001f5,0x0004007c,0x00000006,0x000001f7,0x000001f6, - 0x00050085,0x00000006,0x000001f8,0x000001f3,0x000001f7,0x0003003e,0x000001e9,0x000001f8, - 0x0004003d,0x00000006,0x000001fa,0x000001e9,0x00050085,0x00000006,0x000001fb,0x00000195, - 0x000001fa,0x00050081,0x00000006,0x000001fc,0x000001fb,0x00000038,0x0003003e,0x000001fd, - 0x000001fc,0x00050039,0x00000006,0x000001fe,0x0000000d,0x000001fd,0x0003003e,0x000001f9, - 0x000001fe,0x0004003d,0x00000006,0x000001ff,0x000001e9,0x0004003d,0x00000006,0x00000200, - 0x00000090,0x00050085,0x00000006,0x00000201,0x000001ff,0x00000200,0x0004003d,0x00000006, - 0x00000202,0x000001e9,0x0004003d,0x00000006,0x00000203,0x0000009c,0x00050085,0x00000006, - 0x00000204,0x00000202,0x00000203,0x00050081,0x00000006,0x00000205,0x00000201,0x00000204, - 0x0004003d,0x00000006,0x00000206,0x000001e9,0x0004003d,0x00000006,0x00000207,0x000000b7, - 0x00050085,0x00000006,0x00000208,0x00000206,0x00000207,0x00050081,0x00000006,0x00000209, - 0x00000205,0x00000208,0x0004003d,0x00000006,0x0000020a,0x000001e9,0x0004003d,0x00000006, - 0x0000020b,0x000000ae,0x00050085,0x00000006,0x0000020c,0x0000020a,0x0000020b,0x00050081, - 0x00000006,0x0000020d,0x00000209,0x0000020c,0x0004003d,0x00000006,0x0000020e,0x000000a5, - 0x00050081,0x00000006,0x0000020f,0x0000020d,0x0000020e,0x0004003d,0x00000006,0x00000210, - 0x000001f9,0x00050085,0x00000006,0x00000211,0x0000020f,0x00000210,0x0003003e,0x00000031, - 0x00000211,0x0004003d,0x00000006,0x00000212,0x000001e9,0x0004003d,0x00000006,0x00000213, - 0x00000094,0x00050085,0x00000006,0x00000214,0x00000212,0x00000213,0x0004003d,0x00000006, - 0x00000215,0x000001e9,0x0004003d,0x00000006,0x00000216,0x0000009f,0x00050085,0x00000006, - 0x00000217,0x00000215,0x00000216,0x00050081,0x00000006,0x00000218,0x00000214,0x00000217, - 0x0004003d,0x00000006,0x00000219,0x000001e9,0x0004003d,0x00000006,0x0000021a,0x000000ba, - 0x00050085,0x00000006,0x0000021b,0x00000219,0x0000021a,0x00050081,0x00000006,0x0000021c, - 0x00000218,0x0000021b,0x0004003d,0x00000006,0x0000021d,0x000001e9,0x0004003d,0x00000006, - 0x0000021e,0x000000b1,0x00050085,0x00000006,0x0000021f,0x0000021d,0x0000021e,0x00050081, - 0x00000006,0x00000220,0x0000021c,0x0000021f,0x0004003d,0x00000006,0x00000221,0x000000a8, - 0x00050081,0x00000006,0x00000222,0x00000220,0x00000221,0x0004003d,0x00000006,0x00000223, - 0x000001f9,0x00050085,0x00000006,0x00000224,0x00000222,0x00000223,0x0003003e,0x00000032, - 0x00000224,0x0004003d,0x00000006,0x00000225,0x000001e9,0x0004003d,0x00000006,0x00000226, - 0x00000098,0x00050085,0x00000006,0x00000227,0x00000225,0x00000226,0x0004003d,0x00000006, - 0x00000228,0x000001e9,0x0004003d,0x00000006,0x00000229,0x000000a2,0x00050085,0x00000006, - 0x0000022a,0x00000228,0x00000229,0x00050081,0x00000006,0x0000022b,0x00000227,0x0000022a, - 0x0004003d,0x00000006,0x0000022c,0x000001e9,0x0004003d,0x00000006,0x0000022d,0x000000bd, - 0x00050085,0x00000006,0x0000022e,0x0000022c,0x0000022d,0x00050081,0x00000006,0x0000022f, - 0x0000022b,0x0000022e,0x0004003d,0x00000006,0x00000230,0x000001e9,0x0004003d,0x00000006, - 0x00000231,0x000000b4,0x00050085,0x00000006,0x00000232,0x00000230,0x00000231,0x00050081, - 0x00000006,0x00000233,0x0000022f,0x00000232,0x0004003d,0x00000006,0x00000234,0x000000ab, - 0x00050081,0x00000006,0x00000235,0x00000233,0x00000234,0x0004003d,0x00000006,0x00000236, - 0x000001f9,0x00050085,0x00000006,0x00000237,0x00000235,0x00000236,0x0003003e,0x00000033, - 0x00000237,0x000100fd,0x00010038 + 0x00000007,0x0000013a,0x00000007,0x0004003b,0x00000007,0x0000013c,0x00000007,0x0004003b, + 0x00000007,0x00000140,0x00000007,0x0004003b,0x00000007,0x00000143,0x00000007,0x0004003b, + 0x00000007,0x00000149,0x00000007,0x0004003b,0x00000007,0x0000014a,0x00000007,0x0004003b, + 0x00000007,0x0000014c,0x00000007,0x0004003b,0x00000007,0x0000014e,0x00000007,0x0004003b, + 0x00000007,0x00000153,0x00000007,0x0004003b,0x00000007,0x00000154,0x00000007,0x0004003b, + 0x00000007,0x00000156,0x00000007,0x0004003b,0x00000007,0x00000158,0x00000007,0x0004003b, + 0x00000007,0x0000015d,0x00000007,0x0004003b,0x00000007,0x0000015e,0x00000007,0x0004003b, + 0x00000007,0x00000160,0x00000007,0x0004003b,0x00000007,0x00000162,0x00000007,0x0004003b, + 0x00000007,0x00000167,0x00000007,0x0004003b,0x00000007,0x00000168,0x00000007,0x0004003b, + 0x00000007,0x0000016a,0x00000007,0x0004003b,0x00000007,0x0000016c,0x00000007,0x0004003b, + 0x00000007,0x00000171,0x00000007,0x0004003b,0x00000007,0x00000172,0x00000007,0x0004003b, + 0x00000007,0x00000174,0x00000007,0x0004003b,0x00000007,0x00000176,0x00000007,0x0004003b, + 0x00000007,0x0000017b,0x00000007,0x0004003b,0x00000007,0x0000017c,0x00000007,0x0004003b, + 0x00000007,0x0000017e,0x00000007,0x0004003b,0x00000007,0x00000180,0x00000007,0x0004003b, + 0x00000186,0x00000187,0x00000007,0x0004003b,0x00000007,0x0000018a,0x00000007,0x0004003b, + 0x00000007,0x0000018e,0x00000007,0x0004003b,0x00000007,0x00000191,0x00000007,0x0004003b, + 0x00000007,0x00000194,0x00000007,0x0004003b,0x00000007,0x0000019a,0x00000007,0x0004003b, + 0x00000007,0x000001a0,0x00000007,0x0004003b,0x00000007,0x000001a6,0x00000007,0x0004003b, + 0x00000007,0x000001aa,0x00000007,0x0004003b,0x00000007,0x000001b4,0x00000007,0x0004003b, + 0x00000007,0x000001b7,0x00000007,0x0004003b,0x00000007,0x000001c1,0x00000007,0x0004003b, + 0x00000007,0x000001c4,0x00000007,0x0004003b,0x00000007,0x000001ce,0x00000007,0x0004003b, + 0x00000007,0x000001d5,0x00000007,0x0004003b,0x00000007,0x000001dc,0x00000007,0x0004003b, + 0x00000007,0x000001e3,0x00000007,0x0004003b,0x00000007,0x000001e8,0x00000007,0x0004003b, + 0x00000007,0x000001f0,0x00000007,0x0004003b,0x00000007,0x000001f4,0x00000007,0x0004003b, + 0x00000007,0x000001fc,0x00000007,0x0004003b,0x00000007,0x00000200,0x00000007,0x0004003b, + 0x00000007,0x00000208,0x00000007,0x0004003b,0x00000007,0x0000020d,0x00000007,0x0004003b, + 0x00000007,0x00000212,0x00000007,0x0004003b,0x00000007,0x00000217,0x00000007,0x0004003b, + 0x00000007,0x00000219,0x00000007,0x0004003b,0x00000007,0x0000021b,0x00000007,0x0004003b, + 0x00000007,0x0000021d,0x00000007,0x0004003b,0x00000007,0x00000227,0x00000007,0x0004003b, + 0x00000007,0x0000022b,0x00000007,0x0004003d,0x00000029,0x00000063,0x00000031,0x0004007c, + 0x0000001b,0x00000064,0x00000063,0x0003003e,0x00000062,0x00000064,0x0004003d,0x0000001b, + 0x00000068,0x00000062,0x00050080,0x0000001b,0x0000006b,0x00000068,0x0000006a,0x0003003e, + 0x0000006c,0x0000006b,0x00050039,0x0000001d,0x0000006d,0x00000020,0x0000006c,0x0008004f, + 0x00000065,0x0000006e,0x0000006d,0x0000006d,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x00000067,0x0000006e,0x0004003d,0x0000001b,0x00000070,0x00000062,0x00050080,0x0000001b, + 0x00000072,0x00000070,0x00000071,0x0003003e,0x00000073,0x00000072,0x00050039,0x0000001d, + 0x00000074,0x00000020,0x00000073,0x0008004f,0x00000065,0x00000075,0x00000074,0x00000074, + 0x00000000,0x00000001,0x00000002,0x0003003e,0x0000006f,0x00000075,0x0004003d,0x0000001b, + 0x00000078,0x00000062,0x0003003e,0x00000077,0x00000078,0x00050039,0x0000001d,0x00000079, + 0x00000020,0x00000077,0x0008004f,0x00000065,0x0000007a,0x00000079,0x00000079,0x00000000, + 0x00000001,0x00000002,0x0003003e,0x00000076,0x0000007a,0x0004003d,0x0000001b,0x0000007c, + 0x00000062,0x00050080,0x0000001b,0x0000007e,0x0000007c,0x0000007d,0x0003003e,0x0000007f, + 0x0000007e,0x00050039,0x0000001d,0x00000080,0x00000020,0x0000007f,0x0008004f,0x00000065, + 0x00000081,0x00000080,0x00000080,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000007b, + 0x00000081,0x0004003d,0x0000001b,0x00000083,0x00000062,0x00050080,0x0000001b,0x00000085, + 0x00000083,0x00000084,0x0003003e,0x00000086,0x00000085,0x00050039,0x0000001d,0x00000087, + 0x00000020,0x00000086,0x0008004f,0x00000065,0x00000088,0x00000087,0x00000087,0x00000000, + 0x00000001,0x00000002,0x0003003e,0x00000082,0x00000088,0x00050041,0x00000007,0x0000008b, + 0x00000067,0x0000008a,0x0004003d,0x00000006,0x0000008c,0x0000008b,0x0003003e,0x00000089, + 0x0000008c,0x00050041,0x00000007,0x0000008f,0x00000067,0x0000008e,0x0004003d,0x00000006, + 0x00000090,0x0000008f,0x0003003e,0x0000008d,0x00000090,0x00050041,0x00000007,0x00000093, + 0x00000067,0x00000092,0x0004003d,0x00000006,0x00000094,0x00000093,0x0003003e,0x00000091, + 0x00000094,0x00050041,0x00000007,0x00000096,0x0000006f,0x0000008a,0x0004003d,0x00000006, + 0x00000097,0x00000096,0x0003003e,0x00000095,0x00000097,0x00050041,0x00000007,0x00000099, + 0x0000006f,0x0000008e,0x0004003d,0x00000006,0x0000009a,0x00000099,0x0003003e,0x00000098, + 0x0000009a,0x00050041,0x00000007,0x0000009c,0x0000006f,0x00000092,0x0004003d,0x00000006, + 0x0000009d,0x0000009c,0x0003003e,0x0000009b,0x0000009d,0x00050041,0x00000007,0x0000009f, + 0x00000076,0x0000008a,0x0004003d,0x00000006,0x000000a0,0x0000009f,0x0003003e,0x0000009e, + 0x000000a0,0x00050041,0x00000007,0x000000a2,0x00000076,0x0000008e,0x0004003d,0x00000006, + 0x000000a3,0x000000a2,0x0003003e,0x000000a1,0x000000a3,0x00050041,0x00000007,0x000000a5, + 0x00000076,0x00000092,0x0004003d,0x00000006,0x000000a6,0x000000a5,0x0003003e,0x000000a4, + 0x000000a6,0x00050041,0x00000007,0x000000a8,0x0000007b,0x0000008a,0x0004003d,0x00000006, + 0x000000a9,0x000000a8,0x0003003e,0x000000a7,0x000000a9,0x00050041,0x00000007,0x000000ab, + 0x0000007b,0x0000008e,0x0004003d,0x00000006,0x000000ac,0x000000ab,0x0003003e,0x000000aa, + 0x000000ac,0x00050041,0x00000007,0x000000ae,0x0000007b,0x00000092,0x0004003d,0x00000006, + 0x000000af,0x000000ae,0x0003003e,0x000000ad,0x000000af,0x00050041,0x00000007,0x000000b1, + 0x00000082,0x0000008a,0x0004003d,0x00000006,0x000000b2,0x000000b1,0x0003003e,0x000000b0, + 0x000000b2,0x00050041,0x00000007,0x000000b4,0x00000082,0x0000008e,0x0004003d,0x00000006, + 0x000000b5,0x000000b4,0x0003003e,0x000000b3,0x000000b5,0x00050041,0x00000007,0x000000b7, + 0x00000082,0x00000092,0x0004003d,0x00000006,0x000000b8,0x000000b7,0x0003003e,0x000000b6, + 0x000000b8,0x0004003d,0x00000006,0x000000ba,0x00000089,0x0003003e,0x000000b9,0x000000ba, + 0x0004003d,0x00000006,0x000000bc,0x0000008d,0x0003003e,0x000000bb,0x000000bc,0x0004003d, + 0x00000006,0x000000be,0x00000091,0x0003003e,0x000000bd,0x000000be,0x00070039,0x00000002, + 0x000000bf,0x00000026,0x000000b9,0x000000bb,0x000000bd,0x0004003d,0x00000006,0x000000c0, + 0x000000b9,0x0003003e,0x00000089,0x000000c0,0x0004003d,0x00000006,0x000000c1,0x000000bb, + 0x0003003e,0x0000008d,0x000000c1,0x0004003d,0x00000006,0x000000c2,0x000000bd,0x0003003e, + 0x00000091,0x000000c2,0x0004003d,0x00000006,0x000000c4,0x00000095,0x0003003e,0x000000c3, + 0x000000c4,0x0004003d,0x00000006,0x000000c6,0x00000098,0x0003003e,0x000000c5,0x000000c6, + 0x0004003d,0x00000006,0x000000c8,0x0000009b,0x0003003e,0x000000c7,0x000000c8,0x00070039, + 0x00000002,0x000000c9,0x00000026,0x000000c3,0x000000c5,0x000000c7,0x0004003d,0x00000006, + 0x000000ca,0x000000c3,0x0003003e,0x00000095,0x000000ca,0x0004003d,0x00000006,0x000000cb, + 0x000000c5,0x0003003e,0x00000098,0x000000cb,0x0004003d,0x00000006,0x000000cc,0x000000c7, + 0x0003003e,0x0000009b,0x000000cc,0x0004003d,0x00000006,0x000000ce,0x0000009e,0x0003003e, + 0x000000cd,0x000000ce,0x0004003d,0x00000006,0x000000d0,0x000000a1,0x0003003e,0x000000cf, + 0x000000d0,0x0004003d,0x00000006,0x000000d2,0x000000a4,0x0003003e,0x000000d1,0x000000d2, + 0x00070039,0x00000002,0x000000d3,0x00000026,0x000000cd,0x000000cf,0x000000d1,0x0004003d, + 0x00000006,0x000000d4,0x000000cd,0x0003003e,0x0000009e,0x000000d4,0x0004003d,0x00000006, + 0x000000d5,0x000000cf,0x0003003e,0x000000a1,0x000000d5,0x0004003d,0x00000006,0x000000d6, + 0x000000d1,0x0003003e,0x000000a4,0x000000d6,0x0004003d,0x00000006,0x000000d8,0x000000a7, + 0x0003003e,0x000000d7,0x000000d8,0x0004003d,0x00000006,0x000000da,0x000000aa,0x0003003e, + 0x000000d9,0x000000da,0x0004003d,0x00000006,0x000000dc,0x000000ad,0x0003003e,0x000000db, + 0x000000dc,0x00070039,0x00000002,0x000000dd,0x00000026,0x000000d7,0x000000d9,0x000000db, + 0x0004003d,0x00000006,0x000000de,0x000000d7,0x0003003e,0x000000a7,0x000000de,0x0004003d, + 0x00000006,0x000000df,0x000000d9,0x0003003e,0x000000aa,0x000000df,0x0004003d,0x00000006, + 0x000000e0,0x000000db,0x0003003e,0x000000ad,0x000000e0,0x0004003d,0x00000006,0x000000e2, + 0x000000b0,0x0003003e,0x000000e1,0x000000e2,0x0004003d,0x00000006,0x000000e4,0x000000b3, + 0x0003003e,0x000000e3,0x000000e4,0x0004003d,0x00000006,0x000000e6,0x000000b6,0x0003003e, + 0x000000e5,0x000000e6,0x00070039,0x00000002,0x000000e7,0x00000026,0x000000e1,0x000000e3, + 0x000000e5,0x0004003d,0x00000006,0x000000e8,0x000000e1,0x0003003e,0x000000b0,0x000000e8, + 0x0004003d,0x00000006,0x000000e9,0x000000e3,0x0003003e,0x000000b3,0x000000e9,0x0004003d, + 0x00000006,0x000000ea,0x000000e5,0x0003003e,0x000000b6,0x000000ea,0x0004003d,0x00000006, + 0x000000ec,0x00000091,0x00050085,0x00000006,0x000000ee,0x000000ec,0x000000ed,0x0004003d, + 0x00000006,0x000000ef,0x00000089,0x00050085,0x00000006,0x000000f0,0x000000ef,0x000000ed, + 0x0004003d,0x00000006,0x000000f1,0x0000008d,0x00050081,0x00000006,0x000000f2,0x000000f0, + 0x000000f1,0x00050081,0x00000006,0x000000f3,0x000000ee,0x000000f2,0x0003003e,0x000000eb, + 0x000000f3,0x0004003d,0x00000006,0x000000f5,0x0000009b,0x00050085,0x00000006,0x000000f6, + 0x000000f5,0x000000ed,0x0004003d,0x00000006,0x000000f7,0x00000095,0x00050085,0x00000006, + 0x000000f8,0x000000f7,0x000000ed,0x0004003d,0x00000006,0x000000f9,0x00000098,0x00050081, + 0x00000006,0x000000fa,0x000000f8,0x000000f9,0x00050081,0x00000006,0x000000fb,0x000000f6, + 0x000000fa,0x0003003e,0x000000f4,0x000000fb,0x0004003d,0x00000006,0x000000fd,0x000000a4, + 0x00050085,0x00000006,0x000000fe,0x000000fd,0x000000ed,0x0004003d,0x00000006,0x000000ff, + 0x0000009e,0x00050085,0x00000006,0x00000100,0x000000ff,0x000000ed,0x0004003d,0x00000006, + 0x00000101,0x000000a1,0x00050081,0x00000006,0x00000102,0x00000100,0x00000101,0x00050081, + 0x00000006,0x00000103,0x000000fe,0x00000102,0x0003003e,0x000000fc,0x00000103,0x0004003d, + 0x00000006,0x00000105,0x000000ad,0x00050085,0x00000006,0x00000106,0x00000105,0x000000ed, + 0x0004003d,0x00000006,0x00000107,0x000000a7,0x00050085,0x00000006,0x00000108,0x00000107, + 0x000000ed,0x0004003d,0x00000006,0x00000109,0x000000aa,0x00050081,0x00000006,0x0000010a, + 0x00000108,0x00000109,0x00050081,0x00000006,0x0000010b,0x00000106,0x0000010a,0x0003003e, + 0x00000104,0x0000010b,0x0004003d,0x00000006,0x0000010d,0x000000b6,0x00050085,0x00000006, + 0x0000010e,0x0000010d,0x000000ed,0x0004003d,0x00000006,0x0000010f,0x000000b0,0x00050085, + 0x00000006,0x00000110,0x0000010f,0x000000ed,0x0004003d,0x00000006,0x00000111,0x000000b3, + 0x00050081,0x00000006,0x00000112,0x00000110,0x00000111,0x00050081,0x00000006,0x00000113, + 0x0000010e,0x00000112,0x0003003e,0x0000010c,0x00000113,0x0004003d,0x00000006,0x00000116, + 0x000000eb,0x00050085,0x00000006,0x00000117,0x00000115,0x00000116,0x0004003d,0x00000006, + 0x00000118,0x000000f4,0x00050085,0x00000006,0x00000119,0x00000115,0x00000118,0x00050081, + 0x00000006,0x0000011a,0x00000117,0x00000119,0x0004003d,0x00000006,0x0000011b,0x00000104, + 0x00050085,0x00000006,0x0000011c,0x00000115,0x0000011b,0x00050081,0x00000006,0x0000011d, + 0x0000011a,0x0000011c,0x0004003d,0x00000006,0x0000011e,0x0000010c,0x00050085,0x00000006, + 0x0000011f,0x00000115,0x0000011e,0x00050081,0x00000006,0x00000120,0x0000011d,0x0000011f, + 0x0004003d,0x00000006,0x00000121,0x000000fc,0x00050083,0x00000006,0x00000122,0x00000120, + 0x00000121,0x0003003e,0x00000114,0x00000122,0x0004003d,0x00000006,0x00000123,0x00000114, + 0x0006000c,0x00000006,0x00000124,0x00000001,0x00000004,0x00000123,0x0004003d,0x00000006, + 0x00000126,0x000000eb,0x0003003e,0x00000125,0x00000126,0x0004003d,0x00000006,0x00000128, + 0x000000f4,0x0003003e,0x00000127,0x00000128,0x0004003d,0x00000006,0x0000012a,0x000000fc, + 0x0003003e,0x00000129,0x0000012a,0x00070039,0x00000006,0x0000012b,0x00000018,0x00000125, + 0x00000127,0x00000129,0x0003003e,0x0000012c,0x0000012b,0x0004003d,0x00000006,0x0000012e, + 0x00000104,0x0003003e,0x0000012d,0x0000012e,0x0004003d,0x00000006,0x00000130,0x0000010c, + 0x0003003e,0x0000012f,0x00000130,0x00070039,0x00000006,0x00000131,0x00000018,0x0000012c, + 0x0000012d,0x0000012f,0x0004003d,0x00000006,0x00000133,0x000000eb,0x0003003e,0x00000132, + 0x00000133,0x0004003d,0x00000006,0x00000135,0x000000f4,0x0003003e,0x00000134,0x00000135, + 0x0004003d,0x00000006,0x00000137,0x000000fc,0x0003003e,0x00000136,0x00000137,0x00070039, + 0x00000006,0x00000138,0x00000013,0x00000132,0x00000134,0x00000136,0x0003003e,0x00000139, + 0x00000138,0x0004003d,0x00000006,0x0000013b,0x00000104,0x0003003e,0x0000013a,0x0000013b, + 0x0004003d,0x00000006,0x0000013d,0x0000010c,0x0003003e,0x0000013c,0x0000013d,0x00070039, + 0x00000006,0x0000013e,0x00000013,0x00000139,0x0000013a,0x0000013c,0x00050083,0x00000006, + 0x0000013f,0x00000131,0x0000013e,0x0003003e,0x00000140,0x0000013f,0x00050039,0x00000006, + 0x00000141,0x0000000a,0x00000140,0x00050085,0x00000006,0x00000142,0x00000124,0x00000141, + 0x0003003e,0x00000143,0x00000142,0x00050039,0x00000006,0x00000144,0x0000000d,0x00000143, + 0x0003003e,0x00000114,0x00000144,0x0004003d,0x00000006,0x00000146,0x00000114,0x00050085, + 0x00000006,0x00000147,0x00000145,0x00000146,0x00050081,0x00000006,0x00000148,0x00000147, + 0x00000035,0x0003003e,0x00000114,0x00000148,0x0004003d,0x00000006,0x0000014b,0x00000089, + 0x0003003e,0x0000014a,0x0000014b,0x0004003d,0x00000006,0x0000014d,0x00000095,0x0003003e, + 0x0000014c,0x0000014d,0x0004003d,0x00000006,0x0000014f,0x000000a7,0x0003003e,0x0000014e, + 0x0000014f,0x00070039,0x00000006,0x00000150,0x00000013,0x0000014a,0x0000014c,0x0000014e, + 0x0004003d,0x00000006,0x00000151,0x000000b0,0x0007000c,0x00000006,0x00000152,0x00000001, + 0x00000025,0x00000150,0x00000151,0x0003003e,0x00000149,0x00000152,0x0004003d,0x00000006, + 0x00000155,0x0000008d,0x0003003e,0x00000154,0x00000155,0x0004003d,0x00000006,0x00000157, + 0x00000098,0x0003003e,0x00000156,0x00000157,0x0004003d,0x00000006,0x00000159,0x000000aa, + 0x0003003e,0x00000158,0x00000159,0x00070039,0x00000006,0x0000015a,0x00000013,0x00000154, + 0x00000156,0x00000158,0x0004003d,0x00000006,0x0000015b,0x000000b3,0x0007000c,0x00000006, + 0x0000015c,0x00000001,0x00000025,0x0000015a,0x0000015b,0x0003003e,0x00000153,0x0000015c, + 0x0004003d,0x00000006,0x0000015f,0x00000091,0x0003003e,0x0000015e,0x0000015f,0x0004003d, + 0x00000006,0x00000161,0x0000009b,0x0003003e,0x00000160,0x00000161,0x0004003d,0x00000006, + 0x00000163,0x000000ad,0x0003003e,0x00000162,0x00000163,0x00070039,0x00000006,0x00000164, + 0x00000013,0x0000015e,0x00000160,0x00000162,0x0004003d,0x00000006,0x00000165,0x000000b6, + 0x0007000c,0x00000006,0x00000166,0x00000001,0x00000025,0x00000164,0x00000165,0x0003003e, + 0x0000015d,0x00000166,0x0004003d,0x00000006,0x00000169,0x00000089,0x0003003e,0x00000168, + 0x00000169,0x0004003d,0x00000006,0x0000016b,0x00000095,0x0003003e,0x0000016a,0x0000016b, + 0x0004003d,0x00000006,0x0000016d,0x000000a7,0x0003003e,0x0000016c,0x0000016d,0x00070039, + 0x00000006,0x0000016e,0x00000018,0x00000168,0x0000016a,0x0000016c,0x0004003d,0x00000006, + 0x0000016f,0x000000b0,0x0007000c,0x00000006,0x00000170,0x00000001,0x00000028,0x0000016e, + 0x0000016f,0x0003003e,0x00000167,0x00000170,0x0004003d,0x00000006,0x00000173,0x0000008d, + 0x0003003e,0x00000172,0x00000173,0x0004003d,0x00000006,0x00000175,0x00000098,0x0003003e, + 0x00000174,0x00000175,0x0004003d,0x00000006,0x00000177,0x000000aa,0x0003003e,0x00000176, + 0x00000177,0x00070039,0x00000006,0x00000178,0x00000018,0x00000172,0x00000174,0x00000176, + 0x0004003d,0x00000006,0x00000179,0x000000b3,0x0007000c,0x00000006,0x0000017a,0x00000001, + 0x00000028,0x00000178,0x00000179,0x0003003e,0x00000171,0x0000017a,0x0004003d,0x00000006, + 0x0000017d,0x00000091,0x0003003e,0x0000017c,0x0000017d,0x0004003d,0x00000006,0x0000017f, + 0x0000009b,0x0003003e,0x0000017e,0x0000017f,0x0004003d,0x00000006,0x00000181,0x000000ad, + 0x0003003e,0x00000180,0x00000181,0x00070039,0x00000006,0x00000182,0x00000018,0x0000017c, + 0x0000017e,0x00000180,0x0004003d,0x00000006,0x00000183,0x000000b6,0x0007000c,0x00000006, + 0x00000184,0x00000001,0x00000028,0x00000182,0x00000183,0x0003003e,0x0000017b,0x00000184, + 0x0003003e,0x00000187,0x00000189,0x0004003d,0x00000006,0x0000018c,0x00000167,0x00050085, + 0x00000006,0x0000018d,0x0000018b,0x0000018c,0x0003003e,0x0000018a,0x0000018d,0x0004003d, + 0x00000006,0x0000018f,0x00000171,0x00050085,0x00000006,0x00000190,0x0000018b,0x0000018f, + 0x0003003e,0x0000018e,0x00000190,0x0004003d,0x00000006,0x00000192,0x0000017b,0x00050085, + 0x00000006,0x00000193,0x0000018b,0x00000192,0x0003003e,0x00000191,0x00000193,0x0004003d, + 0x00000006,0x00000195,0x00000149,0x00050085,0x00000006,0x00000196,0x0000018b,0x00000195, + 0x00050041,0x00000007,0x00000197,0x00000187,0x0000008e,0x0004003d,0x00000006,0x00000198, + 0x00000197,0x00050081,0x00000006,0x00000199,0x00000196,0x00000198,0x0003003e,0x00000194, + 0x00000199,0x0004003d,0x00000006,0x0000019b,0x00000153,0x00050085,0x00000006,0x0000019c, + 0x0000018b,0x0000019b,0x00050041,0x00000007,0x0000019d,0x00000187,0x0000008e,0x0004003d, + 0x00000006,0x0000019e,0x0000019d,0x00050081,0x00000006,0x0000019f,0x0000019c,0x0000019e, + 0x0003003e,0x0000019a,0x0000019f,0x0004003d,0x00000006,0x000001a1,0x0000015d,0x00050085, + 0x00000006,0x000001a2,0x0000018b,0x000001a1,0x00050041,0x00000007,0x000001a3,0x00000187, + 0x0000008e,0x0004003d,0x00000006,0x000001a4,0x000001a3,0x00050081,0x00000006,0x000001a5, + 0x000001a2,0x000001a4,0x0003003e,0x000001a0,0x000001a5,0x0004003d,0x00000006,0x000001a7, + 0x0000018a,0x000500ba,0x000001a8,0x000001a9,0x000001a7,0x0000003b,0x000300f7,0x000001ac, + 0x00000000,0x000400fa,0x000001a9,0x000001ab,0x000001b2,0x000200f8,0x000001ab,0x0004003d, + 0x00000006,0x000001ad,0x00000149,0x0004003d,0x00000006,0x000001ae,0x0000009e,0x0007000c, + 0x00000006,0x000001af,0x00000001,0x00000025,0x000001ad,0x000001ae,0x0004003d,0x00000006, + 0x000001b0,0x0000018a,0x00050088,0x00000006,0x000001b1,0x000001af,0x000001b0,0x0003003e, + 0x000001aa,0x000001b1,0x000200f9,0x000001ac,0x000200f8,0x000001b2,0x0003003e,0x000001aa, + 0x0000003b,0x000200f9,0x000001ac,0x000200f8,0x000001ac,0x0004003d,0x00000006,0x000001b3, + 0x000001aa,0x0003003e,0x000001a6,0x000001b3,0x0004003d,0x00000006,0x000001b5,0x0000018e, + 0x000500ba,0x000001a8,0x000001b6,0x000001b5,0x0000003b,0x000300f7,0x000001b9,0x00000000, + 0x000400fa,0x000001b6,0x000001b8,0x000001bf,0x000200f8,0x000001b8,0x0004003d,0x00000006, + 0x000001ba,0x00000153,0x0004003d,0x00000006,0x000001bb,0x000000a1,0x0007000c,0x00000006, + 0x000001bc,0x00000001,0x00000025,0x000001ba,0x000001bb,0x0004003d,0x00000006,0x000001bd, + 0x0000018e,0x00050088,0x00000006,0x000001be,0x000001bc,0x000001bd,0x0003003e,0x000001b7, + 0x000001be,0x000200f9,0x000001b9,0x000200f8,0x000001bf,0x0003003e,0x000001b7,0x0000003b, + 0x000200f9,0x000001b9,0x000200f8,0x000001b9,0x0004003d,0x00000006,0x000001c0,0x000001b7, + 0x0003003e,0x000001b4,0x000001c0,0x0004003d,0x00000006,0x000001c2,0x00000191,0x000500ba, + 0x000001a8,0x000001c3,0x000001c2,0x0000003b,0x000300f7,0x000001c6,0x00000000,0x000400fa, + 0x000001c3,0x000001c5,0x000001cc,0x000200f8,0x000001c5,0x0004003d,0x00000006,0x000001c7, + 0x0000015d,0x0004003d,0x00000006,0x000001c8,0x000000a4,0x0007000c,0x00000006,0x000001c9, + 0x00000001,0x00000025,0x000001c7,0x000001c8,0x0004003d,0x00000006,0x000001ca,0x00000191, + 0x00050088,0x00000006,0x000001cb,0x000001c9,0x000001ca,0x0003003e,0x000001c4,0x000001cb, + 0x000200f9,0x000001c6,0x000200f8,0x000001cc,0x0003003e,0x000001c4,0x0000003b,0x000200f9, + 0x000001c6,0x000200f8,0x000001c6,0x0004003d,0x00000006,0x000001cd,0x000001c4,0x0003003e, + 0x000001c1,0x000001cd,0x00050041,0x00000007,0x000001cf,0x00000187,0x0000008a,0x0004003d, + 0x00000006,0x000001d0,0x000001cf,0x0004003d,0x00000006,0x000001d1,0x00000167,0x0004003d, + 0x00000006,0x000001d2,0x0000009e,0x0007000c,0x00000006,0x000001d3,0x00000001,0x00000028, + 0x000001d1,0x000001d2,0x00050083,0x00000006,0x000001d4,0x000001d0,0x000001d3,0x0003003e, + 0x000001ce,0x000001d4,0x00050041,0x00000007,0x000001d6,0x00000187,0x0000008a,0x0004003d, + 0x00000006,0x000001d7,0x000001d6,0x0004003d,0x00000006,0x000001d8,0x00000171,0x0004003d, + 0x00000006,0x000001d9,0x000000a1,0x0007000c,0x00000006,0x000001da,0x00000001,0x00000028, + 0x000001d8,0x000001d9,0x00050083,0x00000006,0x000001db,0x000001d7,0x000001da,0x0003003e, + 0x000001d5,0x000001db,0x00050041,0x00000007,0x000001dd,0x00000187,0x0000008a,0x0004003d, + 0x00000006,0x000001de,0x000001dd,0x0004003d,0x00000006,0x000001df,0x0000017b,0x0004003d, + 0x00000006,0x000001e0,0x000000a4,0x0007000c,0x00000006,0x000001e1,0x00000001,0x00000028, + 0x000001df,0x000001e0,0x00050083,0x00000006,0x000001e2,0x000001de,0x000001e1,0x0003003e, + 0x000001dc,0x000001e2,0x0004003d,0x00000006,0x000001e4,0x00000194,0x0006000c,0x00000006, + 0x000001e5,0x00000001,0x00000004,0x000001e4,0x000500ba,0x000001a8,0x000001e7,0x000001e5, + 0x000001e6,0x000300f7,0x000001ea,0x00000000,0x000400fa,0x000001e7,0x000001e9,0x000001ee, + 0x000200f8,0x000001e9,0x0004003d,0x00000006,0x000001eb,0x000001ce,0x0004003d,0x00000006, + 0x000001ec,0x00000194,0x00050088,0x00000006,0x000001ed,0x000001eb,0x000001ec,0x0003003e, + 0x000001e8,0x000001ed,0x000200f9,0x000001ea,0x000200f8,0x000001ee,0x0003003e,0x000001e8, + 0x0000003b,0x000200f9,0x000001ea,0x000200f8,0x000001ea,0x0004003d,0x00000006,0x000001ef, + 0x000001e8,0x0003003e,0x000001e3,0x000001ef,0x0004003d,0x00000006,0x000001f1,0x0000019a, + 0x0006000c,0x00000006,0x000001f2,0x00000001,0x00000004,0x000001f1,0x000500ba,0x000001a8, + 0x000001f3,0x000001f2,0x000001e6,0x000300f7,0x000001f6,0x00000000,0x000400fa,0x000001f3, + 0x000001f5,0x000001fa,0x000200f8,0x000001f5,0x0004003d,0x00000006,0x000001f7,0x000001d5, + 0x0004003d,0x00000006,0x000001f8,0x0000019a,0x00050088,0x00000006,0x000001f9,0x000001f7, + 0x000001f8,0x0003003e,0x000001f4,0x000001f9,0x000200f9,0x000001f6,0x000200f8,0x000001fa, + 0x0003003e,0x000001f4,0x0000003b,0x000200f9,0x000001f6,0x000200f8,0x000001f6,0x0004003d, + 0x00000006,0x000001fb,0x000001f4,0x0003003e,0x000001f0,0x000001fb,0x0004003d,0x00000006, + 0x000001fd,0x000001a0,0x0006000c,0x00000006,0x000001fe,0x00000001,0x00000004,0x000001fd, + 0x000500ba,0x000001a8,0x000001ff,0x000001fe,0x000001e6,0x000300f7,0x00000202,0x00000000, + 0x000400fa,0x000001ff,0x00000201,0x00000206,0x000200f8,0x00000201,0x0004003d,0x00000006, + 0x00000203,0x000001dc,0x0004003d,0x00000006,0x00000204,0x000001a0,0x00050088,0x00000006, + 0x00000205,0x00000203,0x00000204,0x0003003e,0x00000200,0x00000205,0x000200f9,0x00000202, + 0x000200f8,0x00000206,0x0003003e,0x00000200,0x0000003b,0x000200f9,0x00000202,0x000200f8, + 0x00000202,0x0004003d,0x00000006,0x00000207,0x00000200,0x0003003e,0x000001fc,0x00000207, + 0x0004003d,0x00000006,0x00000209,0x000001a6,0x0004007f,0x00000006,0x0000020a,0x00000209, + 0x0004003d,0x00000006,0x0000020b,0x000001e3,0x0007000c,0x00000006,0x0000020c,0x00000001, + 0x00000028,0x0000020a,0x0000020b,0x0003003e,0x00000208,0x0000020c,0x0004003d,0x00000006, + 0x0000020e,0x000001b4,0x0004007f,0x00000006,0x0000020f,0x0000020e,0x0004003d,0x00000006, + 0x00000210,0x000001f0,0x0007000c,0x00000006,0x00000211,0x00000001,0x00000028,0x0000020f, + 0x00000210,0x0003003e,0x0000020d,0x00000211,0x0004003d,0x00000006,0x00000213,0x000001c1, + 0x0004007f,0x00000006,0x00000214,0x00000213,0x0004003d,0x00000006,0x00000215,0x000001fc, + 0x0007000c,0x00000006,0x00000216,0x00000001,0x00000028,0x00000214,0x00000215,0x0003003e, + 0x00000212,0x00000216,0x0004003d,0x00000006,0x0000021a,0x00000208,0x0003003e,0x00000219, + 0x0000021a,0x0004003d,0x00000006,0x0000021c,0x0000020d,0x0003003e,0x0000021b,0x0000021c, + 0x0004003d,0x00000006,0x0000021e,0x00000212,0x0003003e,0x0000021d,0x0000021e,0x00070039, + 0x00000006,0x0000021f,0x00000018,0x00000219,0x0000021b,0x0000021d,0x0007000c,0x00000006, + 0x00000220,0x00000001,0x00000025,0x0000021f,0x0000003b,0x0007000c,0x00000006,0x00000221, + 0x00000001,0x00000028,0x00000218,0x00000220,0x00050041,0x00000222,0x00000223,0x00000032, + 0x0000008a,0x0004003d,0x00000028,0x00000224,0x00000223,0x0004007c,0x00000006,0x00000225, + 0x00000224,0x00050085,0x00000006,0x00000226,0x00000221,0x00000225,0x0003003e,0x00000217, + 0x00000226,0x0004003d,0x00000006,0x00000228,0x00000217,0x00050085,0x00000006,0x00000229, + 0x0000018b,0x00000228,0x00050081,0x00000006,0x0000022a,0x00000229,0x00000035,0x0003003e, + 0x0000022b,0x0000022a,0x00050039,0x00000006,0x0000022c,0x0000000a,0x0000022b,0x0003003e, + 0x00000227,0x0000022c,0x0004003d,0x00000006,0x0000022d,0x00000217,0x0004003d,0x00000006, + 0x0000022e,0x00000089,0x00050085,0x00000006,0x0000022f,0x0000022d,0x0000022e,0x0004003d, + 0x00000006,0x00000230,0x00000217,0x0004003d,0x00000006,0x00000231,0x00000095,0x00050085, + 0x00000006,0x00000232,0x00000230,0x00000231,0x00050081,0x00000006,0x00000233,0x0000022f, + 0x00000232,0x0004003d,0x00000006,0x00000234,0x00000217,0x0004003d,0x00000006,0x00000235, + 0x000000b0,0x00050085,0x00000006,0x00000236,0x00000234,0x00000235,0x00050081,0x00000006, + 0x00000237,0x00000233,0x00000236,0x0004003d,0x00000006,0x00000238,0x00000217,0x0004003d, + 0x00000006,0x00000239,0x000000a7,0x00050085,0x00000006,0x0000023a,0x00000238,0x00000239, + 0x00050081,0x00000006,0x0000023b,0x00000237,0x0000023a,0x0004003d,0x00000006,0x0000023c, + 0x0000009e,0x00050081,0x00000006,0x0000023d,0x0000023b,0x0000023c,0x0004003d,0x00000006, + 0x0000023e,0x00000227,0x00050085,0x00000006,0x0000023f,0x0000023d,0x0000023e,0x0003003e, + 0x0000002e,0x0000023f,0x0004003d,0x00000006,0x00000240,0x00000217,0x0004003d,0x00000006, + 0x00000241,0x0000008d,0x00050085,0x00000006,0x00000242,0x00000240,0x00000241,0x0004003d, + 0x00000006,0x00000243,0x00000217,0x0004003d,0x00000006,0x00000244,0x00000098,0x00050085, + 0x00000006,0x00000245,0x00000243,0x00000244,0x00050081,0x00000006,0x00000246,0x00000242, + 0x00000245,0x0004003d,0x00000006,0x00000247,0x00000217,0x0004003d,0x00000006,0x00000248, + 0x000000b3,0x00050085,0x00000006,0x00000249,0x00000247,0x00000248,0x00050081,0x00000006, + 0x0000024a,0x00000246,0x00000249,0x0004003d,0x00000006,0x0000024b,0x00000217,0x0004003d, + 0x00000006,0x0000024c,0x000000aa,0x00050085,0x00000006,0x0000024d,0x0000024b,0x0000024c, + 0x00050081,0x00000006,0x0000024e,0x0000024a,0x0000024d,0x0004003d,0x00000006,0x0000024f, + 0x000000a1,0x00050081,0x00000006,0x00000250,0x0000024e,0x0000024f,0x0004003d,0x00000006, + 0x00000251,0x00000227,0x00050085,0x00000006,0x00000252,0x00000250,0x00000251,0x0003003e, + 0x0000002f,0x00000252,0x0004003d,0x00000006,0x00000253,0x00000217,0x0004003d,0x00000006, + 0x00000254,0x00000091,0x00050085,0x00000006,0x00000255,0x00000253,0x00000254,0x0004003d, + 0x00000006,0x00000256,0x00000217,0x0004003d,0x00000006,0x00000257,0x0000009b,0x00050085, + 0x00000006,0x00000258,0x00000256,0x00000257,0x00050081,0x00000006,0x00000259,0x00000255, + 0x00000258,0x0004003d,0x00000006,0x0000025a,0x00000217,0x0004003d,0x00000006,0x0000025b, + 0x000000b6,0x00050085,0x00000006,0x0000025c,0x0000025a,0x0000025b,0x00050081,0x00000006, + 0x0000025d,0x00000259,0x0000025c,0x0004003d,0x00000006,0x0000025e,0x00000217,0x0004003d, + 0x00000006,0x0000025f,0x000000ad,0x00050085,0x00000006,0x00000260,0x0000025e,0x0000025f, + 0x00050081,0x00000006,0x00000261,0x0000025d,0x00000260,0x0004003d,0x00000006,0x00000262, + 0x000000a4,0x00050081,0x00000006,0x00000263,0x00000261,0x00000262,0x0004003d,0x00000006, + 0x00000264,0x00000227,0x00050085,0x00000006,0x00000265,0x00000263,0x00000264,0x0003003e, + 0x00000030,0x00000265,0x000100fd,0x00010038 }; diff --git a/app/src/main/cpp/shaders/fsr_rcas_half_frag.h b/app/src/main/cpp/shaders/fsr_rcas_half_frag.h new file mode 100644 index 0000000000..c3d43fde32 --- /dev/null +++ b/app/src/main/cpp/shaders/fsr_rcas_half_frag.h @@ -0,0 +1,641 @@ + // 1116.2.0 + #pragma once +const uint32_t fsr_rcas_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x0000028c,0x00000000,0x00020011,0x00000001,0x00020011, + 0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e, + 0x00000000,0x00000001,0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000269, + 0x00000286,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x00070005,0x0000000a,0x78725041,0x5264654d,0x31467063, + 0x3b316628,0x00000000,0x00030005,0x00000009,0x00000078,0x00050005,0x0000000d,0x74615341, + 0x66283146,0x00003b31,0x00030005,0x0000000c,0x00000078,0x00070005,0x00000013,0x6e694d41, + 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000010,0x00000061,0x00030005, + 0x00000011,0x00000062,0x00030005,0x00000012,0x00000063,0x00070005,0x00000018,0x78614d41, + 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000015,0x00000061,0x00030005, + 0x00000016,0x00000062,0x00030005,0x00000017,0x00000063,0x00070005,0x00000020,0x52727346, + 0x4c736163,0x4664616f,0x32697628,0x0000003b,0x00030005,0x0000001f,0x00000070,0x00080005, + 0x00000026,0x52727346,0x49736163,0x7475706e,0x31662846,0x3b31663b,0x003b3166,0x00030005, + 0x00000023,0x00000072,0x00030005,0x00000024,0x00000067,0x00030005,0x00000025,0x00000062, + 0x00090005,0x00000033,0x52727346,0x46736163,0x3b316628,0x663b3166,0x75763b31,0x75763b32, + 0x00003b34,0x00040005,0x0000002e,0x52786970,0x00000000,0x00040005,0x0000002f,0x47786970, + 0x00000000,0x00040005,0x00000030,0x42786970,0x00000000,0x00030005,0x00000031,0x00007069, + 0x00030005,0x00000032,0x006e6f63,0x00030005,0x0000004d,0x00007a73,0x00060005,0x00000051, + 0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x00000062,0x00007073,0x00030005, + 0x00000067,0x00000062,0x00040005,0x0000006c,0x61726170,0x0000006d,0x00030005,0x0000006f, + 0x00000064,0x00040005,0x00000073,0x61726170,0x0000006d,0x00030005,0x00000076,0x00000065, + 0x00040005,0x00000077,0x61726170,0x0000006d,0x00030005,0x0000007b,0x00000066,0x00040005, + 0x0000007f,0x61726170,0x0000006d,0x00030005,0x00000082,0x00000068,0x00040005,0x00000086, + 0x61726170,0x0000006d,0x00030005,0x00000089,0x00005262,0x00030005,0x0000008d,0x00004762, + 0x00030005,0x00000091,0x00004262,0x00030005,0x00000095,0x00005264,0x00030005,0x00000098, + 0x00004764,0x00030005,0x0000009b,0x00004264,0x00030005,0x0000009e,0x00005265,0x00030005, + 0x000000a1,0x00004765,0x00030005,0x000000a4,0x00004265,0x00030005,0x000000a7,0x00005266, + 0x00030005,0x000000aa,0x00004766,0x00030005,0x000000ad,0x00004266,0x00030005,0x000000b0, + 0x00005268,0x00030005,0x000000b3,0x00004768,0x00030005,0x000000b6,0x00004268,0x00040005, + 0x000000b9,0x61726170,0x0000006d,0x00040005,0x000000bb,0x61726170,0x0000006d,0x00040005, + 0x000000bd,0x61726170,0x0000006d,0x00040005,0x000000c3,0x61726170,0x0000006d,0x00040005, + 0x000000c5,0x61726170,0x0000006d,0x00040005,0x000000c7,0x61726170,0x0000006d,0x00040005, + 0x000000cd,0x61726170,0x0000006d,0x00040005,0x000000cf,0x61726170,0x0000006d,0x00040005, + 0x000000d1,0x61726170,0x0000006d,0x00040005,0x000000d7,0x61726170,0x0000006d,0x00040005, + 0x000000d9,0x61726170,0x0000006d,0x00040005,0x000000db,0x61726170,0x0000006d,0x00040005, + 0x000000e1,0x61726170,0x0000006d,0x00040005,0x000000e3,0x61726170,0x0000006d,0x00040005, + 0x000000e5,0x61726170,0x0000006d,0x00030005,0x000000eb,0x00004c62,0x00030005,0x000000f4, + 0x00004c64,0x00030005,0x000000fc,0x00004c65,0x00030005,0x00000104,0x00004c66,0x00030005, + 0x0000010c,0x00004c68,0x00030005,0x00000114,0x00007a6e,0x00040005,0x00000125,0x61726170, + 0x0000006d,0x00040005,0x00000127,0x61726170,0x0000006d,0x00040005,0x00000129,0x61726170, + 0x0000006d,0x00040005,0x0000012c,0x61726170,0x0000006d,0x00040005,0x0000012d,0x61726170, + 0x0000006d,0x00040005,0x0000012f,0x61726170,0x0000006d,0x00040005,0x00000132,0x61726170, + 0x0000006d,0x00040005,0x00000134,0x61726170,0x0000006d,0x00040005,0x00000136,0x61726170, + 0x0000006d,0x00040005,0x00000139,0x61726170,0x0000006d,0x00040005,0x0000013a,0x61726170, + 0x0000006d,0x00040005,0x0000013c,0x61726170,0x0000006d,0x00040005,0x00000140,0x61726170, + 0x0000006d,0x00040005,0x00000143,0x61726170,0x0000006d,0x00040005,0x00000149,0x52346e6d, + 0x00000000,0x00040005,0x0000014a,0x61726170,0x0000006d,0x00040005,0x0000014c,0x61726170, + 0x0000006d,0x00040005,0x0000014e,0x61726170,0x0000006d,0x00040005,0x00000153,0x47346e6d, + 0x00000000,0x00040005,0x00000154,0x61726170,0x0000006d,0x00040005,0x00000156,0x61726170, + 0x0000006d,0x00040005,0x00000158,0x61726170,0x0000006d,0x00040005,0x0000015d,0x42346e6d, + 0x00000000,0x00040005,0x0000015e,0x61726170,0x0000006d,0x00040005,0x00000160,0x61726170, + 0x0000006d,0x00040005,0x00000162,0x61726170,0x0000006d,0x00040005,0x00000167,0x5234786d, + 0x00000000,0x00040005,0x00000168,0x61726170,0x0000006d,0x00040005,0x0000016a,0x61726170, + 0x0000006d,0x00040005,0x0000016c,0x61726170,0x0000006d,0x00040005,0x00000171,0x4734786d, + 0x00000000,0x00040005,0x00000172,0x61726170,0x0000006d,0x00040005,0x00000174,0x61726170, + 0x0000006d,0x00040005,0x00000176,0x61726170,0x0000006d,0x00040005,0x0000017b,0x4234786d, + 0x00000000,0x00040005,0x0000017c,0x61726170,0x0000006d,0x00040005,0x0000017e,0x61726170, + 0x0000006d,0x00040005,0x00000180,0x61726170,0x0000006d,0x00040005,0x00000187,0x6b616570, + 0x00000043,0x00040005,0x0000018a,0x4d6e6564,0x00526e69,0x00040005,0x0000018e,0x4d6e6564, + 0x00476e69,0x00040005,0x00000191,0x4d6e6564,0x00426e69,0x00040005,0x00000194,0x4d6e6564, + 0x00527861,0x00040005,0x0000019a,0x4d6e6564,0x00477861,0x00040005,0x000001a0,0x4d6e6564, + 0x00427861,0x00040005,0x000001a6,0x4d746968,0x00526e69,0x00040005,0x000001b4,0x4d746968, + 0x00476e69,0x00040005,0x000001c1,0x4d746968,0x00426e69,0x00040005,0x000001ce,0x4d6d756e, + 0x00527861,0x00040005,0x000001d5,0x4d6d756e,0x00477861,0x00040005,0x000001dc,0x4d6d756e, + 0x00427861,0x00040005,0x000001e3,0x4d746968,0x00527861,0x00040005,0x000001f0,0x4d746968, + 0x00477861,0x00040005,0x000001fc,0x4d746968,0x00427861,0x00040005,0x00000208,0x65626f6c, + 0x00000052,0x00040005,0x0000020d,0x65626f6c,0x00000047,0x00040005,0x00000212,0x65626f6c, + 0x00000042,0x00040005,0x00000217,0x65626f6c,0x00000000,0x00040005,0x00000219,0x61726170, + 0x0000006d,0x00040005,0x0000021b,0x61726170,0x0000006d,0x00040005,0x0000021d,0x61726170, + 0x0000006d,0x00040005,0x00000227,0x4c706372,0x00000000,0x00040005,0x0000022b,0x61726170, + 0x0000006d,0x00030005,0x00000267,0x00007069,0x00060005,0x00000269,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00030005,0x0000026b,0x00004350,0x00040006,0x0000026b,0x00000000, + 0x0063646e,0x00040006,0x0000026b,0x00000001,0x006e6f63,0x00060006,0x0000026b,0x00000002, + 0x7074756f,0x69537475,0x0000657a,0x00030005,0x0000026d,0x00006370,0x00030005,0x00000274, + 0x00000063,0x00040005,0x00000275,0x61726170,0x0000006d,0x00040005,0x00000276,0x61726170, + 0x0000006d,0x00040005,0x00000277,0x61726170,0x0000006d,0x00040005,0x00000278,0x61726170, + 0x0000006d,0x00040005,0x0000027a,0x61726170,0x0000006d,0x00050005,0x00000286,0x4374756f, + 0x726f6c6f,0x00000000,0x00030047,0x00000020,0x00000000,0x00030047,0x00000023,0x00000000, + 0x00030047,0x00000024,0x00000000,0x00030047,0x00000025,0x00000000,0x00030047,0x0000002e, + 0x00000000,0x00030047,0x0000002f,0x00000000,0x00030047,0x00000030,0x00000000,0x00030047, + 0x00000051,0x00000000,0x00040047,0x00000051,0x00000021,0x00000000,0x00040047,0x00000051, + 0x00000022,0x00000000,0x00030047,0x00000052,0x00000000,0x00030047,0x00000056,0x00000000, + 0x00030047,0x0000005f,0x00000000,0x00030047,0x00000067,0x00000000,0x00030047,0x0000006d, + 0x00000000,0x00030047,0x0000006e,0x00000000,0x00030047,0x0000006f,0x00000000,0x00030047, + 0x00000074,0x00000000,0x00030047,0x00000075,0x00000000,0x00030047,0x00000076,0x00000000, + 0x00030047,0x00000079,0x00000000,0x00030047,0x0000007a,0x00000000,0x00030047,0x0000007b, + 0x00000000,0x00030047,0x00000080,0x00000000,0x00030047,0x00000081,0x00000000,0x00030047, + 0x00000082,0x00000000,0x00030047,0x00000087,0x00000000,0x00030047,0x00000088,0x00000000, + 0x00030047,0x00000089,0x00000000,0x00030047,0x0000008c,0x00000000,0x00030047,0x0000008d, + 0x00000000,0x00030047,0x00000090,0x00000000,0x00030047,0x00000091,0x00000000,0x00030047, + 0x00000094,0x00000000,0x00030047,0x00000095,0x00000000,0x00030047,0x00000097,0x00000000, + 0x00030047,0x00000098,0x00000000,0x00030047,0x0000009a,0x00000000,0x00030047,0x0000009b, + 0x00000000,0x00030047,0x0000009d,0x00000000,0x00030047,0x0000009e,0x00000000,0x00030047, + 0x000000a0,0x00000000,0x00030047,0x000000a1,0x00000000,0x00030047,0x000000a3,0x00000000, + 0x00030047,0x000000a4,0x00000000,0x00030047,0x000000a6,0x00000000,0x00030047,0x000000a7, + 0x00000000,0x00030047,0x000000a9,0x00000000,0x00030047,0x000000aa,0x00000000,0x00030047, + 0x000000ac,0x00000000,0x00030047,0x000000ad,0x00000000,0x00030047,0x000000af,0x00000000, + 0x00030047,0x000000b0,0x00000000,0x00030047,0x000000b2,0x00000000,0x00030047,0x000000b3, + 0x00000000,0x00030047,0x000000b5,0x00000000,0x00030047,0x000000b6,0x00000000,0x00030047, + 0x000000b8,0x00000000,0x00030047,0x000000b9,0x00000000,0x00030047,0x000000ba,0x00000000, + 0x00030047,0x000000bb,0x00000000,0x00030047,0x000000bc,0x00000000,0x00030047,0x000000bd, + 0x00000000,0x00030047,0x000000be,0x00000000,0x00030047,0x000000c3,0x00000000,0x00030047, + 0x000000c4,0x00000000,0x00030047,0x000000c5,0x00000000,0x00030047,0x000000c6,0x00000000, + 0x00030047,0x000000c7,0x00000000,0x00030047,0x000000c8,0x00000000,0x00030047,0x000000cd, + 0x00000000,0x00030047,0x000000ce,0x00000000,0x00030047,0x000000cf,0x00000000,0x00030047, + 0x000000d0,0x00000000,0x00030047,0x000000d1,0x00000000,0x00030047,0x000000d2,0x00000000, + 0x00030047,0x000000d7,0x00000000,0x00030047,0x000000d8,0x00000000,0x00030047,0x000000d9, + 0x00000000,0x00030047,0x000000da,0x00000000,0x00030047,0x000000db,0x00000000,0x00030047, + 0x000000dc,0x00000000,0x00030047,0x000000e1,0x00000000,0x00030047,0x000000e2,0x00000000, + 0x00030047,0x000000e3,0x00000000,0x00030047,0x000000e4,0x00000000,0x00030047,0x000000e5, + 0x00000000,0x00030047,0x000000e6,0x00000000,0x00030047,0x000000eb,0x00000000,0x00030047, + 0x000000ec,0x00000000,0x00030047,0x000000ee,0x00000000,0x00030047,0x000000ef,0x00000000, + 0x00030047,0x000000f0,0x00000000,0x00030047,0x000000f1,0x00000000,0x00030047,0x000000f2, + 0x00000000,0x00030047,0x000000f3,0x00000000,0x00030047,0x000000f4,0x00000000,0x00030047, + 0x000000f5,0x00000000,0x00030047,0x000000f6,0x00000000,0x00030047,0x000000f7,0x00000000, + 0x00030047,0x000000f8,0x00000000,0x00030047,0x000000f9,0x00000000,0x00030047,0x000000fa, + 0x00000000,0x00030047,0x000000fb,0x00000000,0x00030047,0x000000fc,0x00000000,0x00030047, + 0x000000fd,0x00000000,0x00030047,0x000000fe,0x00000000,0x00030047,0x000000ff,0x00000000, + 0x00030047,0x00000100,0x00000000,0x00030047,0x00000101,0x00000000,0x00030047,0x00000102, + 0x00000000,0x00030047,0x00000103,0x00000000,0x00030047,0x00000104,0x00000000,0x00030047, + 0x00000105,0x00000000,0x00030047,0x00000106,0x00000000,0x00030047,0x00000107,0x00000000, + 0x00030047,0x00000108,0x00000000,0x00030047,0x00000109,0x00000000,0x00030047,0x0000010a, + 0x00000000,0x00030047,0x0000010b,0x00000000,0x00030047,0x0000010c,0x00000000,0x00030047, + 0x0000010d,0x00000000,0x00030047,0x0000010e,0x00000000,0x00030047,0x0000010f,0x00000000, + 0x00030047,0x00000110,0x00000000,0x00030047,0x00000111,0x00000000,0x00030047,0x00000112, + 0x00000000,0x00030047,0x00000113,0x00000000,0x00030047,0x00000114,0x00000000,0x00030047, + 0x00000116,0x00000000,0x00030047,0x00000117,0x00000000,0x00030047,0x00000118,0x00000000, + 0x00030047,0x00000119,0x00000000,0x00030047,0x0000011a,0x00000000,0x00030047,0x0000011b, + 0x00000000,0x00030047,0x0000011c,0x00000000,0x00030047,0x0000011d,0x00000000,0x00030047, + 0x0000011e,0x00000000,0x00030047,0x0000011f,0x00000000,0x00030047,0x00000120,0x00000000, + 0x00030047,0x00000121,0x00000000,0x00030047,0x00000122,0x00000000,0x00030047,0x00000123, + 0x00000000,0x00030047,0x00000124,0x00000000,0x00030047,0x00000126,0x00000000,0x00030047, + 0x00000128,0x00000000,0x00030047,0x0000012a,0x00000000,0x00030047,0x0000012e,0x00000000, + 0x00030047,0x00000130,0x00000000,0x00030047,0x00000133,0x00000000,0x00030047,0x00000135, + 0x00000000,0x00030047,0x00000137,0x00000000,0x00030047,0x0000013b,0x00000000,0x00030047, + 0x0000013d,0x00000000,0x00030047,0x00000146,0x00000000,0x00030047,0x00000147,0x00000000, + 0x00030047,0x00000148,0x00000000,0x00030047,0x00000149,0x00000000,0x00030047,0x0000014b, + 0x00000000,0x00030047,0x0000014d,0x00000000,0x00030047,0x0000014f,0x00000000,0x00030047, + 0x00000151,0x00000000,0x00030047,0x00000153,0x00000000,0x00030047,0x00000155,0x00000000, + 0x00030047,0x00000157,0x00000000,0x00030047,0x00000159,0x00000000,0x00030047,0x0000015b, + 0x00000000,0x00030047,0x0000015d,0x00000000,0x00030047,0x0000015f,0x00000000,0x00030047, + 0x00000161,0x00000000,0x00030047,0x00000163,0x00000000,0x00030047,0x00000165,0x00000000, + 0x00030047,0x00000167,0x00000000,0x00030047,0x00000169,0x00000000,0x00030047,0x0000016b, + 0x00000000,0x00030047,0x0000016d,0x00000000,0x00030047,0x0000016f,0x00000000,0x00030047, + 0x00000171,0x00000000,0x00030047,0x00000173,0x00000000,0x00030047,0x00000175,0x00000000, + 0x00030047,0x00000177,0x00000000,0x00030047,0x00000179,0x00000000,0x00030047,0x0000017b, + 0x00000000,0x00030047,0x0000017d,0x00000000,0x00030047,0x0000017f,0x00000000,0x00030047, + 0x00000181,0x00000000,0x00030047,0x00000183,0x00000000,0x00030047,0x00000187,0x00000000, + 0x00030047,0x0000018a,0x00000000,0x00030047,0x0000018c,0x00000000,0x00030047,0x0000018d, + 0x00000000,0x00030047,0x0000018e,0x00000000,0x00030047,0x0000018f,0x00000000,0x00030047, + 0x00000190,0x00000000,0x00030047,0x00000191,0x00000000,0x00030047,0x00000192,0x00000000, + 0x00030047,0x00000193,0x00000000,0x00030047,0x00000194,0x00000000,0x00030047,0x00000195, + 0x00000000,0x00030047,0x00000196,0x00000000,0x00030047,0x00000198,0x00000000,0x00030047, + 0x00000199,0x00000000,0x00030047,0x0000019a,0x00000000,0x00030047,0x0000019b,0x00000000, + 0x00030047,0x0000019c,0x00000000,0x00030047,0x0000019e,0x00000000,0x00030047,0x0000019f, + 0x00000000,0x00030047,0x000001a0,0x00000000,0x00030047,0x000001a1,0x00000000,0x00030047, + 0x000001a2,0x00000000,0x00030047,0x000001a4,0x00000000,0x00030047,0x000001a5,0x00000000, + 0x00030047,0x000001a6,0x00000000,0x00030047,0x000001a7,0x00000000,0x00030047,0x000001aa, + 0x00000000,0x00030047,0x000001ad,0x00000000,0x00030047,0x000001ae,0x00000000,0x00030047, + 0x000001af,0x00000000,0x00030047,0x000001b0,0x00000000,0x00030047,0x000001b1,0x00000000, + 0x00030047,0x000001b3,0x00000000,0x00030047,0x000001b4,0x00000000,0x00030047,0x000001b5, + 0x00000000,0x00030047,0x000001b7,0x00000000,0x00030047,0x000001ba,0x00000000,0x00030047, + 0x000001bb,0x00000000,0x00030047,0x000001bc,0x00000000,0x00030047,0x000001bd,0x00000000, + 0x00030047,0x000001be,0x00000000,0x00030047,0x000001c0,0x00000000,0x00030047,0x000001c1, + 0x00000000,0x00030047,0x000001c2,0x00000000,0x00030047,0x000001c4,0x00000000,0x00030047, + 0x000001c7,0x00000000,0x00030047,0x000001c8,0x00000000,0x00030047,0x000001c9,0x00000000, + 0x00030047,0x000001ca,0x00000000,0x00030047,0x000001cb,0x00000000,0x00030047,0x000001cd, + 0x00000000,0x00030047,0x000001ce,0x00000000,0x00030047,0x000001d0,0x00000000,0x00030047, + 0x000001d1,0x00000000,0x00030047,0x000001d2,0x00000000,0x00030047,0x000001d3,0x00000000, + 0x00030047,0x000001d4,0x00000000,0x00030047,0x000001d5,0x00000000,0x00030047,0x000001d7, + 0x00000000,0x00030047,0x000001d8,0x00000000,0x00030047,0x000001d9,0x00000000,0x00030047, + 0x000001da,0x00000000,0x00030047,0x000001db,0x00000000,0x00030047,0x000001dc,0x00000000, + 0x00030047,0x000001de,0x00000000,0x00030047,0x000001df,0x00000000,0x00030047,0x000001e0, + 0x00000000,0x00030047,0x000001e1,0x00000000,0x00030047,0x000001e2,0x00000000,0x00030047, + 0x000001e3,0x00000000,0x00030047,0x000001e4,0x00000000,0x00030047,0x000001e5,0x00000000, + 0x00030047,0x000001e8,0x00000000,0x00030047,0x000001eb,0x00000000,0x00030047,0x000001ec, + 0x00000000,0x00030047,0x000001ed,0x00000000,0x00030047,0x000001ef,0x00000000,0x00030047, + 0x000001f0,0x00000000,0x00030047,0x000001f1,0x00000000,0x00030047,0x000001f2,0x00000000, + 0x00030047,0x000001f4,0x00000000,0x00030047,0x000001f7,0x00000000,0x00030047,0x000001f8, + 0x00000000,0x00030047,0x000001f9,0x00000000,0x00030047,0x000001fb,0x00000000,0x00030047, + 0x000001fc,0x00000000,0x00030047,0x000001fd,0x00000000,0x00030047,0x000001fe,0x00000000, + 0x00030047,0x00000200,0x00000000,0x00030047,0x00000203,0x00000000,0x00030047,0x00000204, + 0x00000000,0x00030047,0x00000205,0x00000000,0x00030047,0x00000207,0x00000000,0x00030047, + 0x00000208,0x00000000,0x00030047,0x00000209,0x00000000,0x00030047,0x0000020a,0x00000000, + 0x00030047,0x0000020b,0x00000000,0x00030047,0x0000020c,0x00000000,0x00030047,0x0000020d, + 0x00000000,0x00030047,0x0000020e,0x00000000,0x00030047,0x0000020f,0x00000000,0x00030047, + 0x00000210,0x00000000,0x00030047,0x00000211,0x00000000,0x00030047,0x00000212,0x00000000, + 0x00030047,0x00000213,0x00000000,0x00030047,0x00000214,0x00000000,0x00030047,0x00000215, + 0x00000000,0x00030047,0x00000216,0x00000000,0x00030047,0x00000217,0x00000000,0x00030047, + 0x0000021a,0x00000000,0x00030047,0x0000021c,0x00000000,0x00030047,0x0000021e,0x00000000, + 0x00030047,0x00000227,0x00000000,0x00030047,0x00000228,0x00000000,0x00030047,0x00000229, + 0x00000000,0x00030047,0x0000022a,0x00000000,0x00030047,0x0000022d,0x00000000,0x00030047, + 0x0000022e,0x00000000,0x00030047,0x0000022f,0x00000000,0x00030047,0x00000230,0x00000000, + 0x00030047,0x00000231,0x00000000,0x00030047,0x00000232,0x00000000,0x00030047,0x00000233, + 0x00000000,0x00030047,0x00000234,0x00000000,0x00030047,0x00000235,0x00000000,0x00030047, + 0x00000236,0x00000000,0x00030047,0x00000237,0x00000000,0x00030047,0x00000238,0x00000000, + 0x00030047,0x00000239,0x00000000,0x00030047,0x0000023a,0x00000000,0x00030047,0x0000023b, + 0x00000000,0x00030047,0x0000023c,0x00000000,0x00030047,0x0000023d,0x00000000,0x00030047, + 0x0000023e,0x00000000,0x00030047,0x0000023f,0x00000000,0x00030047,0x00000240,0x00000000, + 0x00030047,0x00000241,0x00000000,0x00030047,0x00000242,0x00000000,0x00030047,0x00000243, + 0x00000000,0x00030047,0x00000244,0x00000000,0x00030047,0x00000245,0x00000000,0x00030047, + 0x00000246,0x00000000,0x00030047,0x00000247,0x00000000,0x00030047,0x00000248,0x00000000, + 0x00030047,0x00000249,0x00000000,0x00030047,0x0000024a,0x00000000,0x00030047,0x0000024b, + 0x00000000,0x00030047,0x0000024c,0x00000000,0x00030047,0x0000024d,0x00000000,0x00030047, + 0x0000024e,0x00000000,0x00030047,0x0000024f,0x00000000,0x00030047,0x00000250,0x00000000, + 0x00030047,0x00000251,0x00000000,0x00030047,0x00000252,0x00000000,0x00030047,0x00000253, + 0x00000000,0x00030047,0x00000254,0x00000000,0x00030047,0x00000255,0x00000000,0x00030047, + 0x00000256,0x00000000,0x00030047,0x00000257,0x00000000,0x00030047,0x00000258,0x00000000, + 0x00030047,0x00000259,0x00000000,0x00030047,0x0000025a,0x00000000,0x00030047,0x0000025b, + 0x00000000,0x00030047,0x0000025c,0x00000000,0x00030047,0x0000025d,0x00000000,0x00030047, + 0x0000025e,0x00000000,0x00030047,0x0000025f,0x00000000,0x00030047,0x00000260,0x00000000, + 0x00030047,0x00000261,0x00000000,0x00030047,0x00000262,0x00000000,0x00030047,0x00000263, + 0x00000000,0x00030047,0x00000264,0x00000000,0x00030047,0x00000265,0x00000000,0x00040047, + 0x00000269,0x0000001e,0x00000000,0x00030047,0x0000026b,0x00000002,0x00050048,0x0000026b, + 0x00000000,0x00000023,0x00000000,0x00050048,0x0000026b,0x00000001,0x00000023,0x00000010, + 0x00050048,0x0000026b,0x00000002,0x00000023,0x00000020,0x00030047,0x00000274,0x00000000, + 0x00030047,0x00000275,0x00000000,0x00030047,0x00000276,0x00000000,0x00030047,0x00000277, + 0x00000000,0x00030047,0x00000286,0x00000000,0x00040047,0x00000286,0x0000001e,0x00000000, + 0x00030047,0x00000287,0x00000000,0x00030047,0x00000288,0x00000000,0x00030047,0x00000289, + 0x00000000,0x00030047,0x0000028a,0x00000000,0x00030047,0x0000028b,0x00000000,0x00020013, + 0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040020, + 0x00000007,0x00000007,0x00000006,0x00040021,0x00000008,0x00000006,0x00000007,0x00060021, + 0x0000000f,0x00000006,0x00000007,0x00000007,0x00000007,0x00040015,0x0000001a,0x00000020, + 0x00000001,0x00040017,0x0000001b,0x0000001a,0x00000002,0x00040020,0x0000001c,0x00000007, + 0x0000001b,0x00040017,0x0000001d,0x00000006,0x00000004,0x00040021,0x0000001e,0x0000001d, + 0x0000001c,0x00060021,0x00000022,0x00000002,0x00000007,0x00000007,0x00000007,0x00040015, + 0x00000028,0x00000020,0x00000000,0x00040017,0x00000029,0x00000028,0x00000002,0x00040020, + 0x0000002a,0x00000007,0x00000029,0x00040017,0x0000002b,0x00000028,0x00000004,0x00040020, + 0x0000002c,0x00000007,0x0000002b,0x00080021,0x0000002d,0x00000002,0x00000007,0x00000007, + 0x00000007,0x0000002a,0x0000002c,0x0004002b,0x00000006,0x00000035,0x3f800000,0x0004002b, + 0x00000006,0x0000003b,0x00000000,0x00090019,0x0000004e,0x00000006,0x00000001,0x00000000, + 0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000004f,0x0000004e,0x00040020, + 0x00000050,0x00000000,0x0000004f,0x0004003b,0x00000050,0x00000051,0x00000000,0x0004002b, + 0x0000001a,0x00000053,0x00000000,0x0005002c,0x0000001b,0x00000058,0x00000053,0x00000053, + 0x0004002b,0x0000001a,0x0000005a,0x00000001,0x0005002c,0x0000001b,0x0000005b,0x0000005a, + 0x0000005a,0x00040017,0x00000065,0x00000006,0x00000003,0x00040020,0x00000066,0x00000007, + 0x00000065,0x0004002b,0x0000001a,0x00000069,0xffffffff,0x0005002c,0x0000001b,0x0000006a, + 0x00000053,0x00000069,0x0005002c,0x0000001b,0x00000071,0x00000069,0x00000053,0x0005002c, + 0x0000001b,0x0000007d,0x0000005a,0x00000053,0x0005002c,0x0000001b,0x00000084,0x00000053, + 0x0000005a,0x0004002b,0x00000028,0x0000008a,0x00000000,0x0004002b,0x00000028,0x0000008e, + 0x00000001,0x0004002b,0x00000028,0x00000092,0x00000002,0x0004002b,0x00000006,0x000000ed, + 0x3f000000,0x0004002b,0x00000006,0x00000115,0x3e800000,0x0004002b,0x00000006,0x00000145, + 0xbf000000,0x00040017,0x00000185,0x00000006,0x00000002,0x00040020,0x00000186,0x00000007, + 0x00000185,0x0004002b,0x00000006,0x00000188,0xc0800000,0x0005002c,0x00000185,0x00000189, + 0x00000035,0x00000188,0x0004002b,0x00000006,0x0000018b,0x40800000,0x00020014,0x000001a8, + 0x0004002b,0x00000006,0x000001e6,0x358637bd,0x0004002b,0x00000006,0x00000218,0xbe400000, + 0x00040020,0x00000222,0x00000007,0x00000028,0x00040020,0x00000268,0x00000001,0x00000185, + 0x0004003b,0x00000268,0x00000269,0x00000001,0x0005001e,0x0000026b,0x0000001d,0x0000002b, + 0x00000185,0x00040020,0x0000026c,0x00000009,0x0000026b,0x0004003b,0x0000026c,0x0000026d, + 0x00000009,0x0004002b,0x0000001a,0x0000026e,0x00000002,0x00040020,0x0000026f,0x00000009, + 0x00000185,0x00040020,0x0000027b,0x00000009,0x0000002b,0x00040020,0x00000285,0x00000003, + 0x0000001d,0x0004003b,0x00000285,0x00000286,0x00000003,0x00050036,0x00000002,0x00000004, + 0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x0000002a,0x00000267,0x00000007, + 0x0004003b,0x00000066,0x00000274,0x00000007,0x0004003b,0x00000007,0x00000275,0x00000007, + 0x0004003b,0x00000007,0x00000276,0x00000007,0x0004003b,0x00000007,0x00000277,0x00000007, + 0x0004003b,0x0000002a,0x00000278,0x00000007,0x0004003b,0x0000002c,0x0000027a,0x00000007, + 0x0004003d,0x00000185,0x0000026a,0x00000269,0x00050041,0x0000026f,0x00000270,0x0000026d, + 0x0000026e,0x0004003d,0x00000185,0x00000271,0x00000270,0x00050085,0x00000185,0x00000272, + 0x0000026a,0x00000271,0x0004006d,0x00000029,0x00000273,0x00000272,0x0003003e,0x00000267, + 0x00000273,0x0004003d,0x00000029,0x00000279,0x00000267,0x0003003e,0x00000278,0x00000279, + 0x00050041,0x0000027b,0x0000027c,0x0000026d,0x0000005a,0x0004003d,0x0000002b,0x0000027d, + 0x0000027c,0x0003003e,0x0000027a,0x0000027d,0x00090039,0x00000002,0x0000027e,0x00000033, + 0x00000275,0x00000276,0x00000277,0x00000278,0x0000027a,0x0004003d,0x00000006,0x0000027f, + 0x00000275,0x00050041,0x00000007,0x00000280,0x00000274,0x0000008a,0x0003003e,0x00000280, + 0x0000027f,0x0004003d,0x00000006,0x00000281,0x00000276,0x00050041,0x00000007,0x00000282, + 0x00000274,0x0000008e,0x0003003e,0x00000282,0x00000281,0x0004003d,0x00000006,0x00000283, + 0x00000277,0x00050041,0x00000007,0x00000284,0x00000274,0x00000092,0x0003003e,0x00000284, + 0x00000283,0x0004003d,0x00000065,0x00000287,0x00000274,0x00050051,0x00000006,0x00000288, + 0x00000287,0x00000000,0x00050051,0x00000006,0x00000289,0x00000287,0x00000001,0x00050051, + 0x00000006,0x0000028a,0x00000287,0x00000002,0x00070050,0x0000001d,0x0000028b,0x00000288, + 0x00000289,0x0000028a,0x00000035,0x0003003e,0x00000286,0x0000028b,0x000100fd,0x00010038, + 0x00050036,0x00000006,0x0000000a,0x00000000,0x00000008,0x00030037,0x00000007,0x00000009, + 0x000200f8,0x0000000b,0x0004003d,0x00000006,0x00000036,0x00000009,0x00050088,0x00000006, + 0x00000037,0x00000035,0x00000036,0x000200fe,0x00000037,0x00010038,0x00050036,0x00000006, + 0x0000000d,0x00000000,0x00000008,0x00030037,0x00000007,0x0000000c,0x000200f8,0x0000000e, + 0x0004003d,0x00000006,0x0000003a,0x0000000c,0x0008000c,0x00000006,0x0000003c,0x00000001, + 0x0000002b,0x0000003a,0x0000003b,0x00000035,0x000200fe,0x0000003c,0x00010038,0x00050036, + 0x00000006,0x00000013,0x00000000,0x0000000f,0x00030037,0x00000007,0x00000010,0x00030037, + 0x00000007,0x00000011,0x00030037,0x00000007,0x00000012,0x000200f8,0x00000014,0x0004003d, + 0x00000006,0x0000003f,0x00000010,0x0004003d,0x00000006,0x00000040,0x00000011,0x0004003d, + 0x00000006,0x00000041,0x00000012,0x0007000c,0x00000006,0x00000042,0x00000001,0x00000025, + 0x00000040,0x00000041,0x0007000c,0x00000006,0x00000043,0x00000001,0x00000025,0x0000003f, + 0x00000042,0x000200fe,0x00000043,0x00010038,0x00050036,0x00000006,0x00000018,0x00000000, + 0x0000000f,0x00030037,0x00000007,0x00000015,0x00030037,0x00000007,0x00000016,0x00030037, + 0x00000007,0x00000017,0x000200f8,0x00000019,0x0004003d,0x00000006,0x00000046,0x00000015, + 0x0004003d,0x00000006,0x00000047,0x00000016,0x0004003d,0x00000006,0x00000048,0x00000017, + 0x0007000c,0x00000006,0x00000049,0x00000001,0x00000028,0x00000047,0x00000048,0x0007000c, + 0x00000006,0x0000004a,0x00000001,0x00000028,0x00000046,0x00000049,0x000200fe,0x0000004a, + 0x00010038,0x00050036,0x0000001d,0x00000020,0x00000000,0x0000001e,0x00030037,0x0000001c, + 0x0000001f,0x000200f8,0x00000021,0x0004003b,0x0000001c,0x0000004d,0x00000007,0x0004003d, + 0x0000004f,0x00000052,0x00000051,0x00040064,0x0000004e,0x00000054,0x00000052,0x00050067, + 0x0000001b,0x00000055,0x00000054,0x00000053,0x0003003e,0x0000004d,0x00000055,0x0004003d, + 0x0000004f,0x00000056,0x00000051,0x0004003d,0x0000001b,0x00000057,0x0000001f,0x0004003d, + 0x0000001b,0x00000059,0x0000004d,0x00050082,0x0000001b,0x0000005c,0x00000059,0x0000005b, + 0x0008000c,0x0000001b,0x0000005d,0x00000001,0x0000002d,0x00000057,0x00000058,0x0000005c, + 0x00040064,0x0000004e,0x0000005e,0x00000056,0x0007005f,0x0000001d,0x0000005f,0x0000005e, + 0x0000005d,0x00000002,0x00000053,0x000200fe,0x0000005f,0x00010038,0x00050036,0x00000002, + 0x00000026,0x00000000,0x00000022,0x00030037,0x00000007,0x00000023,0x00030037,0x00000007, + 0x00000024,0x00030037,0x00000007,0x00000025,0x000200f8,0x00000027,0x000100fd,0x00010038, + 0x00050036,0x00000002,0x00000033,0x00000000,0x0000002d,0x00030037,0x00000007,0x0000002e, + 0x00030037,0x00000007,0x0000002f,0x00030037,0x00000007,0x00000030,0x00030037,0x0000002a, + 0x00000031,0x00030037,0x0000002c,0x00000032,0x000200f8,0x00000034,0x0004003b,0x0000001c, + 0x00000062,0x00000007,0x0004003b,0x00000066,0x00000067,0x00000007,0x0004003b,0x0000001c, + 0x0000006c,0x00000007,0x0004003b,0x00000066,0x0000006f,0x00000007,0x0004003b,0x0000001c, + 0x00000073,0x00000007,0x0004003b,0x00000066,0x00000076,0x00000007,0x0004003b,0x0000001c, + 0x00000077,0x00000007,0x0004003b,0x00000066,0x0000007b,0x00000007,0x0004003b,0x0000001c, + 0x0000007f,0x00000007,0x0004003b,0x00000066,0x00000082,0x00000007,0x0004003b,0x0000001c, + 0x00000086,0x00000007,0x0004003b,0x00000007,0x00000089,0x00000007,0x0004003b,0x00000007, + 0x0000008d,0x00000007,0x0004003b,0x00000007,0x00000091,0x00000007,0x0004003b,0x00000007, + 0x00000095,0x00000007,0x0004003b,0x00000007,0x00000098,0x00000007,0x0004003b,0x00000007, + 0x0000009b,0x00000007,0x0004003b,0x00000007,0x0000009e,0x00000007,0x0004003b,0x00000007, + 0x000000a1,0x00000007,0x0004003b,0x00000007,0x000000a4,0x00000007,0x0004003b,0x00000007, + 0x000000a7,0x00000007,0x0004003b,0x00000007,0x000000aa,0x00000007,0x0004003b,0x00000007, + 0x000000ad,0x00000007,0x0004003b,0x00000007,0x000000b0,0x00000007,0x0004003b,0x00000007, + 0x000000b3,0x00000007,0x0004003b,0x00000007,0x000000b6,0x00000007,0x0004003b,0x00000007, + 0x000000b9,0x00000007,0x0004003b,0x00000007,0x000000bb,0x00000007,0x0004003b,0x00000007, + 0x000000bd,0x00000007,0x0004003b,0x00000007,0x000000c3,0x00000007,0x0004003b,0x00000007, + 0x000000c5,0x00000007,0x0004003b,0x00000007,0x000000c7,0x00000007,0x0004003b,0x00000007, + 0x000000cd,0x00000007,0x0004003b,0x00000007,0x000000cf,0x00000007,0x0004003b,0x00000007, + 0x000000d1,0x00000007,0x0004003b,0x00000007,0x000000d7,0x00000007,0x0004003b,0x00000007, + 0x000000d9,0x00000007,0x0004003b,0x00000007,0x000000db,0x00000007,0x0004003b,0x00000007, + 0x000000e1,0x00000007,0x0004003b,0x00000007,0x000000e3,0x00000007,0x0004003b,0x00000007, + 0x000000e5,0x00000007,0x0004003b,0x00000007,0x000000eb,0x00000007,0x0004003b,0x00000007, + 0x000000f4,0x00000007,0x0004003b,0x00000007,0x000000fc,0x00000007,0x0004003b,0x00000007, + 0x00000104,0x00000007,0x0004003b,0x00000007,0x0000010c,0x00000007,0x0004003b,0x00000007, + 0x00000114,0x00000007,0x0004003b,0x00000007,0x00000125,0x00000007,0x0004003b,0x00000007, + 0x00000127,0x00000007,0x0004003b,0x00000007,0x00000129,0x00000007,0x0004003b,0x00000007, + 0x0000012c,0x00000007,0x0004003b,0x00000007,0x0000012d,0x00000007,0x0004003b,0x00000007, + 0x0000012f,0x00000007,0x0004003b,0x00000007,0x00000132,0x00000007,0x0004003b,0x00000007, + 0x00000134,0x00000007,0x0004003b,0x00000007,0x00000136,0x00000007,0x0004003b,0x00000007, + 0x00000139,0x00000007,0x0004003b,0x00000007,0x0000013a,0x00000007,0x0004003b,0x00000007, + 0x0000013c,0x00000007,0x0004003b,0x00000007,0x00000140,0x00000007,0x0004003b,0x00000007, + 0x00000143,0x00000007,0x0004003b,0x00000007,0x00000149,0x00000007,0x0004003b,0x00000007, + 0x0000014a,0x00000007,0x0004003b,0x00000007,0x0000014c,0x00000007,0x0004003b,0x00000007, + 0x0000014e,0x00000007,0x0004003b,0x00000007,0x00000153,0x00000007,0x0004003b,0x00000007, + 0x00000154,0x00000007,0x0004003b,0x00000007,0x00000156,0x00000007,0x0004003b,0x00000007, + 0x00000158,0x00000007,0x0004003b,0x00000007,0x0000015d,0x00000007,0x0004003b,0x00000007, + 0x0000015e,0x00000007,0x0004003b,0x00000007,0x00000160,0x00000007,0x0004003b,0x00000007, + 0x00000162,0x00000007,0x0004003b,0x00000007,0x00000167,0x00000007,0x0004003b,0x00000007, + 0x00000168,0x00000007,0x0004003b,0x00000007,0x0000016a,0x00000007,0x0004003b,0x00000007, + 0x0000016c,0x00000007,0x0004003b,0x00000007,0x00000171,0x00000007,0x0004003b,0x00000007, + 0x00000172,0x00000007,0x0004003b,0x00000007,0x00000174,0x00000007,0x0004003b,0x00000007, + 0x00000176,0x00000007,0x0004003b,0x00000007,0x0000017b,0x00000007,0x0004003b,0x00000007, + 0x0000017c,0x00000007,0x0004003b,0x00000007,0x0000017e,0x00000007,0x0004003b,0x00000007, + 0x00000180,0x00000007,0x0004003b,0x00000186,0x00000187,0x00000007,0x0004003b,0x00000007, + 0x0000018a,0x00000007,0x0004003b,0x00000007,0x0000018e,0x00000007,0x0004003b,0x00000007, + 0x00000191,0x00000007,0x0004003b,0x00000007,0x00000194,0x00000007,0x0004003b,0x00000007, + 0x0000019a,0x00000007,0x0004003b,0x00000007,0x000001a0,0x00000007,0x0004003b,0x00000007, + 0x000001a6,0x00000007,0x0004003b,0x00000007,0x000001aa,0x00000007,0x0004003b,0x00000007, + 0x000001b4,0x00000007,0x0004003b,0x00000007,0x000001b7,0x00000007,0x0004003b,0x00000007, + 0x000001c1,0x00000007,0x0004003b,0x00000007,0x000001c4,0x00000007,0x0004003b,0x00000007, + 0x000001ce,0x00000007,0x0004003b,0x00000007,0x000001d5,0x00000007,0x0004003b,0x00000007, + 0x000001dc,0x00000007,0x0004003b,0x00000007,0x000001e3,0x00000007,0x0004003b,0x00000007, + 0x000001e8,0x00000007,0x0004003b,0x00000007,0x000001f0,0x00000007,0x0004003b,0x00000007, + 0x000001f4,0x00000007,0x0004003b,0x00000007,0x000001fc,0x00000007,0x0004003b,0x00000007, + 0x00000200,0x00000007,0x0004003b,0x00000007,0x00000208,0x00000007,0x0004003b,0x00000007, + 0x0000020d,0x00000007,0x0004003b,0x00000007,0x00000212,0x00000007,0x0004003b,0x00000007, + 0x00000217,0x00000007,0x0004003b,0x00000007,0x00000219,0x00000007,0x0004003b,0x00000007, + 0x0000021b,0x00000007,0x0004003b,0x00000007,0x0000021d,0x00000007,0x0004003b,0x00000007, + 0x00000227,0x00000007,0x0004003b,0x00000007,0x0000022b,0x00000007,0x0004003d,0x00000029, + 0x00000063,0x00000031,0x0004007c,0x0000001b,0x00000064,0x00000063,0x0003003e,0x00000062, + 0x00000064,0x0004003d,0x0000001b,0x00000068,0x00000062,0x00050080,0x0000001b,0x0000006b, + 0x00000068,0x0000006a,0x0003003e,0x0000006c,0x0000006b,0x00050039,0x0000001d,0x0000006d, + 0x00000020,0x0000006c,0x0008004f,0x00000065,0x0000006e,0x0000006d,0x0000006d,0x00000000, + 0x00000001,0x00000002,0x0003003e,0x00000067,0x0000006e,0x0004003d,0x0000001b,0x00000070, + 0x00000062,0x00050080,0x0000001b,0x00000072,0x00000070,0x00000071,0x0003003e,0x00000073, + 0x00000072,0x00050039,0x0000001d,0x00000074,0x00000020,0x00000073,0x0008004f,0x00000065, + 0x00000075,0x00000074,0x00000074,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000006f, + 0x00000075,0x0004003d,0x0000001b,0x00000078,0x00000062,0x0003003e,0x00000077,0x00000078, + 0x00050039,0x0000001d,0x00000079,0x00000020,0x00000077,0x0008004f,0x00000065,0x0000007a, + 0x00000079,0x00000079,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000076,0x0000007a, + 0x0004003d,0x0000001b,0x0000007c,0x00000062,0x00050080,0x0000001b,0x0000007e,0x0000007c, + 0x0000007d,0x0003003e,0x0000007f,0x0000007e,0x00050039,0x0000001d,0x00000080,0x00000020, + 0x0000007f,0x0008004f,0x00000065,0x00000081,0x00000080,0x00000080,0x00000000,0x00000001, + 0x00000002,0x0003003e,0x0000007b,0x00000081,0x0004003d,0x0000001b,0x00000083,0x00000062, + 0x00050080,0x0000001b,0x00000085,0x00000083,0x00000084,0x0003003e,0x00000086,0x00000085, + 0x00050039,0x0000001d,0x00000087,0x00000020,0x00000086,0x0008004f,0x00000065,0x00000088, + 0x00000087,0x00000087,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000082,0x00000088, + 0x00050041,0x00000007,0x0000008b,0x00000067,0x0000008a,0x0004003d,0x00000006,0x0000008c, + 0x0000008b,0x0003003e,0x00000089,0x0000008c,0x00050041,0x00000007,0x0000008f,0x00000067, + 0x0000008e,0x0004003d,0x00000006,0x00000090,0x0000008f,0x0003003e,0x0000008d,0x00000090, + 0x00050041,0x00000007,0x00000093,0x00000067,0x00000092,0x0004003d,0x00000006,0x00000094, + 0x00000093,0x0003003e,0x00000091,0x00000094,0x00050041,0x00000007,0x00000096,0x0000006f, + 0x0000008a,0x0004003d,0x00000006,0x00000097,0x00000096,0x0003003e,0x00000095,0x00000097, + 0x00050041,0x00000007,0x00000099,0x0000006f,0x0000008e,0x0004003d,0x00000006,0x0000009a, + 0x00000099,0x0003003e,0x00000098,0x0000009a,0x00050041,0x00000007,0x0000009c,0x0000006f, + 0x00000092,0x0004003d,0x00000006,0x0000009d,0x0000009c,0x0003003e,0x0000009b,0x0000009d, + 0x00050041,0x00000007,0x0000009f,0x00000076,0x0000008a,0x0004003d,0x00000006,0x000000a0, + 0x0000009f,0x0003003e,0x0000009e,0x000000a0,0x00050041,0x00000007,0x000000a2,0x00000076, + 0x0000008e,0x0004003d,0x00000006,0x000000a3,0x000000a2,0x0003003e,0x000000a1,0x000000a3, + 0x00050041,0x00000007,0x000000a5,0x00000076,0x00000092,0x0004003d,0x00000006,0x000000a6, + 0x000000a5,0x0003003e,0x000000a4,0x000000a6,0x00050041,0x00000007,0x000000a8,0x0000007b, + 0x0000008a,0x0004003d,0x00000006,0x000000a9,0x000000a8,0x0003003e,0x000000a7,0x000000a9, + 0x00050041,0x00000007,0x000000ab,0x0000007b,0x0000008e,0x0004003d,0x00000006,0x000000ac, + 0x000000ab,0x0003003e,0x000000aa,0x000000ac,0x00050041,0x00000007,0x000000ae,0x0000007b, + 0x00000092,0x0004003d,0x00000006,0x000000af,0x000000ae,0x0003003e,0x000000ad,0x000000af, + 0x00050041,0x00000007,0x000000b1,0x00000082,0x0000008a,0x0004003d,0x00000006,0x000000b2, + 0x000000b1,0x0003003e,0x000000b0,0x000000b2,0x00050041,0x00000007,0x000000b4,0x00000082, + 0x0000008e,0x0004003d,0x00000006,0x000000b5,0x000000b4,0x0003003e,0x000000b3,0x000000b5, + 0x00050041,0x00000007,0x000000b7,0x00000082,0x00000092,0x0004003d,0x00000006,0x000000b8, + 0x000000b7,0x0003003e,0x000000b6,0x000000b8,0x0004003d,0x00000006,0x000000ba,0x00000089, + 0x0003003e,0x000000b9,0x000000ba,0x0004003d,0x00000006,0x000000bc,0x0000008d,0x0003003e, + 0x000000bb,0x000000bc,0x0004003d,0x00000006,0x000000be,0x00000091,0x0003003e,0x000000bd, + 0x000000be,0x00070039,0x00000002,0x000000bf,0x00000026,0x000000b9,0x000000bb,0x000000bd, + 0x0004003d,0x00000006,0x000000c0,0x000000b9,0x0003003e,0x00000089,0x000000c0,0x0004003d, + 0x00000006,0x000000c1,0x000000bb,0x0003003e,0x0000008d,0x000000c1,0x0004003d,0x00000006, + 0x000000c2,0x000000bd,0x0003003e,0x00000091,0x000000c2,0x0004003d,0x00000006,0x000000c4, + 0x00000095,0x0003003e,0x000000c3,0x000000c4,0x0004003d,0x00000006,0x000000c6,0x00000098, + 0x0003003e,0x000000c5,0x000000c6,0x0004003d,0x00000006,0x000000c8,0x0000009b,0x0003003e, + 0x000000c7,0x000000c8,0x00070039,0x00000002,0x000000c9,0x00000026,0x000000c3,0x000000c5, + 0x000000c7,0x0004003d,0x00000006,0x000000ca,0x000000c3,0x0003003e,0x00000095,0x000000ca, + 0x0004003d,0x00000006,0x000000cb,0x000000c5,0x0003003e,0x00000098,0x000000cb,0x0004003d, + 0x00000006,0x000000cc,0x000000c7,0x0003003e,0x0000009b,0x000000cc,0x0004003d,0x00000006, + 0x000000ce,0x0000009e,0x0003003e,0x000000cd,0x000000ce,0x0004003d,0x00000006,0x000000d0, + 0x000000a1,0x0003003e,0x000000cf,0x000000d0,0x0004003d,0x00000006,0x000000d2,0x000000a4, + 0x0003003e,0x000000d1,0x000000d2,0x00070039,0x00000002,0x000000d3,0x00000026,0x000000cd, + 0x000000cf,0x000000d1,0x0004003d,0x00000006,0x000000d4,0x000000cd,0x0003003e,0x0000009e, + 0x000000d4,0x0004003d,0x00000006,0x000000d5,0x000000cf,0x0003003e,0x000000a1,0x000000d5, + 0x0004003d,0x00000006,0x000000d6,0x000000d1,0x0003003e,0x000000a4,0x000000d6,0x0004003d, + 0x00000006,0x000000d8,0x000000a7,0x0003003e,0x000000d7,0x000000d8,0x0004003d,0x00000006, + 0x000000da,0x000000aa,0x0003003e,0x000000d9,0x000000da,0x0004003d,0x00000006,0x000000dc, + 0x000000ad,0x0003003e,0x000000db,0x000000dc,0x00070039,0x00000002,0x000000dd,0x00000026, + 0x000000d7,0x000000d9,0x000000db,0x0004003d,0x00000006,0x000000de,0x000000d7,0x0003003e, + 0x000000a7,0x000000de,0x0004003d,0x00000006,0x000000df,0x000000d9,0x0003003e,0x000000aa, + 0x000000df,0x0004003d,0x00000006,0x000000e0,0x000000db,0x0003003e,0x000000ad,0x000000e0, + 0x0004003d,0x00000006,0x000000e2,0x000000b0,0x0003003e,0x000000e1,0x000000e2,0x0004003d, + 0x00000006,0x000000e4,0x000000b3,0x0003003e,0x000000e3,0x000000e4,0x0004003d,0x00000006, + 0x000000e6,0x000000b6,0x0003003e,0x000000e5,0x000000e6,0x00070039,0x00000002,0x000000e7, + 0x00000026,0x000000e1,0x000000e3,0x000000e5,0x0004003d,0x00000006,0x000000e8,0x000000e1, + 0x0003003e,0x000000b0,0x000000e8,0x0004003d,0x00000006,0x000000e9,0x000000e3,0x0003003e, + 0x000000b3,0x000000e9,0x0004003d,0x00000006,0x000000ea,0x000000e5,0x0003003e,0x000000b6, + 0x000000ea,0x0004003d,0x00000006,0x000000ec,0x00000091,0x00050085,0x00000006,0x000000ee, + 0x000000ec,0x000000ed,0x0004003d,0x00000006,0x000000ef,0x00000089,0x00050085,0x00000006, + 0x000000f0,0x000000ef,0x000000ed,0x0004003d,0x00000006,0x000000f1,0x0000008d,0x00050081, + 0x00000006,0x000000f2,0x000000f0,0x000000f1,0x00050081,0x00000006,0x000000f3,0x000000ee, + 0x000000f2,0x0003003e,0x000000eb,0x000000f3,0x0004003d,0x00000006,0x000000f5,0x0000009b, + 0x00050085,0x00000006,0x000000f6,0x000000f5,0x000000ed,0x0004003d,0x00000006,0x000000f7, + 0x00000095,0x00050085,0x00000006,0x000000f8,0x000000f7,0x000000ed,0x0004003d,0x00000006, + 0x000000f9,0x00000098,0x00050081,0x00000006,0x000000fa,0x000000f8,0x000000f9,0x00050081, + 0x00000006,0x000000fb,0x000000f6,0x000000fa,0x0003003e,0x000000f4,0x000000fb,0x0004003d, + 0x00000006,0x000000fd,0x000000a4,0x00050085,0x00000006,0x000000fe,0x000000fd,0x000000ed, + 0x0004003d,0x00000006,0x000000ff,0x0000009e,0x00050085,0x00000006,0x00000100,0x000000ff, + 0x000000ed,0x0004003d,0x00000006,0x00000101,0x000000a1,0x00050081,0x00000006,0x00000102, + 0x00000100,0x00000101,0x00050081,0x00000006,0x00000103,0x000000fe,0x00000102,0x0003003e, + 0x000000fc,0x00000103,0x0004003d,0x00000006,0x00000105,0x000000ad,0x00050085,0x00000006, + 0x00000106,0x00000105,0x000000ed,0x0004003d,0x00000006,0x00000107,0x000000a7,0x00050085, + 0x00000006,0x00000108,0x00000107,0x000000ed,0x0004003d,0x00000006,0x00000109,0x000000aa, + 0x00050081,0x00000006,0x0000010a,0x00000108,0x00000109,0x00050081,0x00000006,0x0000010b, + 0x00000106,0x0000010a,0x0003003e,0x00000104,0x0000010b,0x0004003d,0x00000006,0x0000010d, + 0x000000b6,0x00050085,0x00000006,0x0000010e,0x0000010d,0x000000ed,0x0004003d,0x00000006, + 0x0000010f,0x000000b0,0x00050085,0x00000006,0x00000110,0x0000010f,0x000000ed,0x0004003d, + 0x00000006,0x00000111,0x000000b3,0x00050081,0x00000006,0x00000112,0x00000110,0x00000111, + 0x00050081,0x00000006,0x00000113,0x0000010e,0x00000112,0x0003003e,0x0000010c,0x00000113, + 0x0004003d,0x00000006,0x00000116,0x000000eb,0x00050085,0x00000006,0x00000117,0x00000115, + 0x00000116,0x0004003d,0x00000006,0x00000118,0x000000f4,0x00050085,0x00000006,0x00000119, + 0x00000115,0x00000118,0x00050081,0x00000006,0x0000011a,0x00000117,0x00000119,0x0004003d, + 0x00000006,0x0000011b,0x00000104,0x00050085,0x00000006,0x0000011c,0x00000115,0x0000011b, + 0x00050081,0x00000006,0x0000011d,0x0000011a,0x0000011c,0x0004003d,0x00000006,0x0000011e, + 0x0000010c,0x00050085,0x00000006,0x0000011f,0x00000115,0x0000011e,0x00050081,0x00000006, + 0x00000120,0x0000011d,0x0000011f,0x0004003d,0x00000006,0x00000121,0x000000fc,0x00050083, + 0x00000006,0x00000122,0x00000120,0x00000121,0x0003003e,0x00000114,0x00000122,0x0004003d, + 0x00000006,0x00000123,0x00000114,0x0006000c,0x00000006,0x00000124,0x00000001,0x00000004, + 0x00000123,0x0004003d,0x00000006,0x00000126,0x000000eb,0x0003003e,0x00000125,0x00000126, + 0x0004003d,0x00000006,0x00000128,0x000000f4,0x0003003e,0x00000127,0x00000128,0x0004003d, + 0x00000006,0x0000012a,0x000000fc,0x0003003e,0x00000129,0x0000012a,0x00070039,0x00000006, + 0x0000012b,0x00000018,0x00000125,0x00000127,0x00000129,0x0003003e,0x0000012c,0x0000012b, + 0x0004003d,0x00000006,0x0000012e,0x00000104,0x0003003e,0x0000012d,0x0000012e,0x0004003d, + 0x00000006,0x00000130,0x0000010c,0x0003003e,0x0000012f,0x00000130,0x00070039,0x00000006, + 0x00000131,0x00000018,0x0000012c,0x0000012d,0x0000012f,0x0004003d,0x00000006,0x00000133, + 0x000000eb,0x0003003e,0x00000132,0x00000133,0x0004003d,0x00000006,0x00000135,0x000000f4, + 0x0003003e,0x00000134,0x00000135,0x0004003d,0x00000006,0x00000137,0x000000fc,0x0003003e, + 0x00000136,0x00000137,0x00070039,0x00000006,0x00000138,0x00000013,0x00000132,0x00000134, + 0x00000136,0x0003003e,0x00000139,0x00000138,0x0004003d,0x00000006,0x0000013b,0x00000104, + 0x0003003e,0x0000013a,0x0000013b,0x0004003d,0x00000006,0x0000013d,0x0000010c,0x0003003e, + 0x0000013c,0x0000013d,0x00070039,0x00000006,0x0000013e,0x00000013,0x00000139,0x0000013a, + 0x0000013c,0x00050083,0x00000006,0x0000013f,0x00000131,0x0000013e,0x0003003e,0x00000140, + 0x0000013f,0x00050039,0x00000006,0x00000141,0x0000000a,0x00000140,0x00050085,0x00000006, + 0x00000142,0x00000124,0x00000141,0x0003003e,0x00000143,0x00000142,0x00050039,0x00000006, + 0x00000144,0x0000000d,0x00000143,0x0003003e,0x00000114,0x00000144,0x0004003d,0x00000006, + 0x00000146,0x00000114,0x00050085,0x00000006,0x00000147,0x00000145,0x00000146,0x00050081, + 0x00000006,0x00000148,0x00000147,0x00000035,0x0003003e,0x00000114,0x00000148,0x0004003d, + 0x00000006,0x0000014b,0x00000089,0x0003003e,0x0000014a,0x0000014b,0x0004003d,0x00000006, + 0x0000014d,0x00000095,0x0003003e,0x0000014c,0x0000014d,0x0004003d,0x00000006,0x0000014f, + 0x000000a7,0x0003003e,0x0000014e,0x0000014f,0x00070039,0x00000006,0x00000150,0x00000013, + 0x0000014a,0x0000014c,0x0000014e,0x0004003d,0x00000006,0x00000151,0x000000b0,0x0007000c, + 0x00000006,0x00000152,0x00000001,0x00000025,0x00000150,0x00000151,0x0003003e,0x00000149, + 0x00000152,0x0004003d,0x00000006,0x00000155,0x0000008d,0x0003003e,0x00000154,0x00000155, + 0x0004003d,0x00000006,0x00000157,0x00000098,0x0003003e,0x00000156,0x00000157,0x0004003d, + 0x00000006,0x00000159,0x000000aa,0x0003003e,0x00000158,0x00000159,0x00070039,0x00000006, + 0x0000015a,0x00000013,0x00000154,0x00000156,0x00000158,0x0004003d,0x00000006,0x0000015b, + 0x000000b3,0x0007000c,0x00000006,0x0000015c,0x00000001,0x00000025,0x0000015a,0x0000015b, + 0x0003003e,0x00000153,0x0000015c,0x0004003d,0x00000006,0x0000015f,0x00000091,0x0003003e, + 0x0000015e,0x0000015f,0x0004003d,0x00000006,0x00000161,0x0000009b,0x0003003e,0x00000160, + 0x00000161,0x0004003d,0x00000006,0x00000163,0x000000ad,0x0003003e,0x00000162,0x00000163, + 0x00070039,0x00000006,0x00000164,0x00000013,0x0000015e,0x00000160,0x00000162,0x0004003d, + 0x00000006,0x00000165,0x000000b6,0x0007000c,0x00000006,0x00000166,0x00000001,0x00000025, + 0x00000164,0x00000165,0x0003003e,0x0000015d,0x00000166,0x0004003d,0x00000006,0x00000169, + 0x00000089,0x0003003e,0x00000168,0x00000169,0x0004003d,0x00000006,0x0000016b,0x00000095, + 0x0003003e,0x0000016a,0x0000016b,0x0004003d,0x00000006,0x0000016d,0x000000a7,0x0003003e, + 0x0000016c,0x0000016d,0x00070039,0x00000006,0x0000016e,0x00000018,0x00000168,0x0000016a, + 0x0000016c,0x0004003d,0x00000006,0x0000016f,0x000000b0,0x0007000c,0x00000006,0x00000170, + 0x00000001,0x00000028,0x0000016e,0x0000016f,0x0003003e,0x00000167,0x00000170,0x0004003d, + 0x00000006,0x00000173,0x0000008d,0x0003003e,0x00000172,0x00000173,0x0004003d,0x00000006, + 0x00000175,0x00000098,0x0003003e,0x00000174,0x00000175,0x0004003d,0x00000006,0x00000177, + 0x000000aa,0x0003003e,0x00000176,0x00000177,0x00070039,0x00000006,0x00000178,0x00000018, + 0x00000172,0x00000174,0x00000176,0x0004003d,0x00000006,0x00000179,0x000000b3,0x0007000c, + 0x00000006,0x0000017a,0x00000001,0x00000028,0x00000178,0x00000179,0x0003003e,0x00000171, + 0x0000017a,0x0004003d,0x00000006,0x0000017d,0x00000091,0x0003003e,0x0000017c,0x0000017d, + 0x0004003d,0x00000006,0x0000017f,0x0000009b,0x0003003e,0x0000017e,0x0000017f,0x0004003d, + 0x00000006,0x00000181,0x000000ad,0x0003003e,0x00000180,0x00000181,0x00070039,0x00000006, + 0x00000182,0x00000018,0x0000017c,0x0000017e,0x00000180,0x0004003d,0x00000006,0x00000183, + 0x000000b6,0x0007000c,0x00000006,0x00000184,0x00000001,0x00000028,0x00000182,0x00000183, + 0x0003003e,0x0000017b,0x00000184,0x0003003e,0x00000187,0x00000189,0x0004003d,0x00000006, + 0x0000018c,0x00000167,0x00050085,0x00000006,0x0000018d,0x0000018b,0x0000018c,0x0003003e, + 0x0000018a,0x0000018d,0x0004003d,0x00000006,0x0000018f,0x00000171,0x00050085,0x00000006, + 0x00000190,0x0000018b,0x0000018f,0x0003003e,0x0000018e,0x00000190,0x0004003d,0x00000006, + 0x00000192,0x0000017b,0x00050085,0x00000006,0x00000193,0x0000018b,0x00000192,0x0003003e, + 0x00000191,0x00000193,0x0004003d,0x00000006,0x00000195,0x00000149,0x00050085,0x00000006, + 0x00000196,0x0000018b,0x00000195,0x00050041,0x00000007,0x00000197,0x00000187,0x0000008e, + 0x0004003d,0x00000006,0x00000198,0x00000197,0x00050081,0x00000006,0x00000199,0x00000196, + 0x00000198,0x0003003e,0x00000194,0x00000199,0x0004003d,0x00000006,0x0000019b,0x00000153, + 0x00050085,0x00000006,0x0000019c,0x0000018b,0x0000019b,0x00050041,0x00000007,0x0000019d, + 0x00000187,0x0000008e,0x0004003d,0x00000006,0x0000019e,0x0000019d,0x00050081,0x00000006, + 0x0000019f,0x0000019c,0x0000019e,0x0003003e,0x0000019a,0x0000019f,0x0004003d,0x00000006, + 0x000001a1,0x0000015d,0x00050085,0x00000006,0x000001a2,0x0000018b,0x000001a1,0x00050041, + 0x00000007,0x000001a3,0x00000187,0x0000008e,0x0004003d,0x00000006,0x000001a4,0x000001a3, + 0x00050081,0x00000006,0x000001a5,0x000001a2,0x000001a4,0x0003003e,0x000001a0,0x000001a5, + 0x0004003d,0x00000006,0x000001a7,0x0000018a,0x000500ba,0x000001a8,0x000001a9,0x000001a7, + 0x0000003b,0x000300f7,0x000001ac,0x00000000,0x000400fa,0x000001a9,0x000001ab,0x000001b2, + 0x000200f8,0x000001ab,0x0004003d,0x00000006,0x000001ad,0x00000149,0x0004003d,0x00000006, + 0x000001ae,0x0000009e,0x0007000c,0x00000006,0x000001af,0x00000001,0x00000025,0x000001ad, + 0x000001ae,0x0004003d,0x00000006,0x000001b0,0x0000018a,0x00050088,0x00000006,0x000001b1, + 0x000001af,0x000001b0,0x0003003e,0x000001aa,0x000001b1,0x000200f9,0x000001ac,0x000200f8, + 0x000001b2,0x0003003e,0x000001aa,0x0000003b,0x000200f9,0x000001ac,0x000200f8,0x000001ac, + 0x0004003d,0x00000006,0x000001b3,0x000001aa,0x0003003e,0x000001a6,0x000001b3,0x0004003d, + 0x00000006,0x000001b5,0x0000018e,0x000500ba,0x000001a8,0x000001b6,0x000001b5,0x0000003b, + 0x000300f7,0x000001b9,0x00000000,0x000400fa,0x000001b6,0x000001b8,0x000001bf,0x000200f8, + 0x000001b8,0x0004003d,0x00000006,0x000001ba,0x00000153,0x0004003d,0x00000006,0x000001bb, + 0x000000a1,0x0007000c,0x00000006,0x000001bc,0x00000001,0x00000025,0x000001ba,0x000001bb, + 0x0004003d,0x00000006,0x000001bd,0x0000018e,0x00050088,0x00000006,0x000001be,0x000001bc, + 0x000001bd,0x0003003e,0x000001b7,0x000001be,0x000200f9,0x000001b9,0x000200f8,0x000001bf, + 0x0003003e,0x000001b7,0x0000003b,0x000200f9,0x000001b9,0x000200f8,0x000001b9,0x0004003d, + 0x00000006,0x000001c0,0x000001b7,0x0003003e,0x000001b4,0x000001c0,0x0004003d,0x00000006, + 0x000001c2,0x00000191,0x000500ba,0x000001a8,0x000001c3,0x000001c2,0x0000003b,0x000300f7, + 0x000001c6,0x00000000,0x000400fa,0x000001c3,0x000001c5,0x000001cc,0x000200f8,0x000001c5, + 0x0004003d,0x00000006,0x000001c7,0x0000015d,0x0004003d,0x00000006,0x000001c8,0x000000a4, + 0x0007000c,0x00000006,0x000001c9,0x00000001,0x00000025,0x000001c7,0x000001c8,0x0004003d, + 0x00000006,0x000001ca,0x00000191,0x00050088,0x00000006,0x000001cb,0x000001c9,0x000001ca, + 0x0003003e,0x000001c4,0x000001cb,0x000200f9,0x000001c6,0x000200f8,0x000001cc,0x0003003e, + 0x000001c4,0x0000003b,0x000200f9,0x000001c6,0x000200f8,0x000001c6,0x0004003d,0x00000006, + 0x000001cd,0x000001c4,0x0003003e,0x000001c1,0x000001cd,0x00050041,0x00000007,0x000001cf, + 0x00000187,0x0000008a,0x0004003d,0x00000006,0x000001d0,0x000001cf,0x0004003d,0x00000006, + 0x000001d1,0x00000167,0x0004003d,0x00000006,0x000001d2,0x0000009e,0x0007000c,0x00000006, + 0x000001d3,0x00000001,0x00000028,0x000001d1,0x000001d2,0x00050083,0x00000006,0x000001d4, + 0x000001d0,0x000001d3,0x0003003e,0x000001ce,0x000001d4,0x00050041,0x00000007,0x000001d6, + 0x00000187,0x0000008a,0x0004003d,0x00000006,0x000001d7,0x000001d6,0x0004003d,0x00000006, + 0x000001d8,0x00000171,0x0004003d,0x00000006,0x000001d9,0x000000a1,0x0007000c,0x00000006, + 0x000001da,0x00000001,0x00000028,0x000001d8,0x000001d9,0x00050083,0x00000006,0x000001db, + 0x000001d7,0x000001da,0x0003003e,0x000001d5,0x000001db,0x00050041,0x00000007,0x000001dd, + 0x00000187,0x0000008a,0x0004003d,0x00000006,0x000001de,0x000001dd,0x0004003d,0x00000006, + 0x000001df,0x0000017b,0x0004003d,0x00000006,0x000001e0,0x000000a4,0x0007000c,0x00000006, + 0x000001e1,0x00000001,0x00000028,0x000001df,0x000001e0,0x00050083,0x00000006,0x000001e2, + 0x000001de,0x000001e1,0x0003003e,0x000001dc,0x000001e2,0x0004003d,0x00000006,0x000001e4, + 0x00000194,0x0006000c,0x00000006,0x000001e5,0x00000001,0x00000004,0x000001e4,0x000500ba, + 0x000001a8,0x000001e7,0x000001e5,0x000001e6,0x000300f7,0x000001ea,0x00000000,0x000400fa, + 0x000001e7,0x000001e9,0x000001ee,0x000200f8,0x000001e9,0x0004003d,0x00000006,0x000001eb, + 0x000001ce,0x0004003d,0x00000006,0x000001ec,0x00000194,0x00050088,0x00000006,0x000001ed, + 0x000001eb,0x000001ec,0x0003003e,0x000001e8,0x000001ed,0x000200f9,0x000001ea,0x000200f8, + 0x000001ee,0x0003003e,0x000001e8,0x0000003b,0x000200f9,0x000001ea,0x000200f8,0x000001ea, + 0x0004003d,0x00000006,0x000001ef,0x000001e8,0x0003003e,0x000001e3,0x000001ef,0x0004003d, + 0x00000006,0x000001f1,0x0000019a,0x0006000c,0x00000006,0x000001f2,0x00000001,0x00000004, + 0x000001f1,0x000500ba,0x000001a8,0x000001f3,0x000001f2,0x000001e6,0x000300f7,0x000001f6, + 0x00000000,0x000400fa,0x000001f3,0x000001f5,0x000001fa,0x000200f8,0x000001f5,0x0004003d, + 0x00000006,0x000001f7,0x000001d5,0x0004003d,0x00000006,0x000001f8,0x0000019a,0x00050088, + 0x00000006,0x000001f9,0x000001f7,0x000001f8,0x0003003e,0x000001f4,0x000001f9,0x000200f9, + 0x000001f6,0x000200f8,0x000001fa,0x0003003e,0x000001f4,0x0000003b,0x000200f9,0x000001f6, + 0x000200f8,0x000001f6,0x0004003d,0x00000006,0x000001fb,0x000001f4,0x0003003e,0x000001f0, + 0x000001fb,0x0004003d,0x00000006,0x000001fd,0x000001a0,0x0006000c,0x00000006,0x000001fe, + 0x00000001,0x00000004,0x000001fd,0x000500ba,0x000001a8,0x000001ff,0x000001fe,0x000001e6, + 0x000300f7,0x00000202,0x00000000,0x000400fa,0x000001ff,0x00000201,0x00000206,0x000200f8, + 0x00000201,0x0004003d,0x00000006,0x00000203,0x000001dc,0x0004003d,0x00000006,0x00000204, + 0x000001a0,0x00050088,0x00000006,0x00000205,0x00000203,0x00000204,0x0003003e,0x00000200, + 0x00000205,0x000200f9,0x00000202,0x000200f8,0x00000206,0x0003003e,0x00000200,0x0000003b, + 0x000200f9,0x00000202,0x000200f8,0x00000202,0x0004003d,0x00000006,0x00000207,0x00000200, + 0x0003003e,0x000001fc,0x00000207,0x0004003d,0x00000006,0x00000209,0x000001a6,0x0004007f, + 0x00000006,0x0000020a,0x00000209,0x0004003d,0x00000006,0x0000020b,0x000001e3,0x0007000c, + 0x00000006,0x0000020c,0x00000001,0x00000028,0x0000020a,0x0000020b,0x0003003e,0x00000208, + 0x0000020c,0x0004003d,0x00000006,0x0000020e,0x000001b4,0x0004007f,0x00000006,0x0000020f, + 0x0000020e,0x0004003d,0x00000006,0x00000210,0x000001f0,0x0007000c,0x00000006,0x00000211, + 0x00000001,0x00000028,0x0000020f,0x00000210,0x0003003e,0x0000020d,0x00000211,0x0004003d, + 0x00000006,0x00000213,0x000001c1,0x0004007f,0x00000006,0x00000214,0x00000213,0x0004003d, + 0x00000006,0x00000215,0x000001fc,0x0007000c,0x00000006,0x00000216,0x00000001,0x00000028, + 0x00000214,0x00000215,0x0003003e,0x00000212,0x00000216,0x0004003d,0x00000006,0x0000021a, + 0x00000208,0x0003003e,0x00000219,0x0000021a,0x0004003d,0x00000006,0x0000021c,0x0000020d, + 0x0003003e,0x0000021b,0x0000021c,0x0004003d,0x00000006,0x0000021e,0x00000212,0x0003003e, + 0x0000021d,0x0000021e,0x00070039,0x00000006,0x0000021f,0x00000018,0x00000219,0x0000021b, + 0x0000021d,0x0007000c,0x00000006,0x00000220,0x00000001,0x00000025,0x0000021f,0x0000003b, + 0x0007000c,0x00000006,0x00000221,0x00000001,0x00000028,0x00000218,0x00000220,0x00050041, + 0x00000222,0x00000223,0x00000032,0x0000008a,0x0004003d,0x00000028,0x00000224,0x00000223, + 0x0004007c,0x00000006,0x00000225,0x00000224,0x00050085,0x00000006,0x00000226,0x00000221, + 0x00000225,0x0003003e,0x00000217,0x00000226,0x0004003d,0x00000006,0x00000228,0x00000217, + 0x00050085,0x00000006,0x00000229,0x0000018b,0x00000228,0x00050081,0x00000006,0x0000022a, + 0x00000229,0x00000035,0x0003003e,0x0000022b,0x0000022a,0x00050039,0x00000006,0x0000022c, + 0x0000000a,0x0000022b,0x0003003e,0x00000227,0x0000022c,0x0004003d,0x00000006,0x0000022d, + 0x00000217,0x0004003d,0x00000006,0x0000022e,0x00000089,0x00050085,0x00000006,0x0000022f, + 0x0000022d,0x0000022e,0x0004003d,0x00000006,0x00000230,0x00000217,0x0004003d,0x00000006, + 0x00000231,0x00000095,0x00050085,0x00000006,0x00000232,0x00000230,0x00000231,0x00050081, + 0x00000006,0x00000233,0x0000022f,0x00000232,0x0004003d,0x00000006,0x00000234,0x00000217, + 0x0004003d,0x00000006,0x00000235,0x000000b0,0x00050085,0x00000006,0x00000236,0x00000234, + 0x00000235,0x00050081,0x00000006,0x00000237,0x00000233,0x00000236,0x0004003d,0x00000006, + 0x00000238,0x00000217,0x0004003d,0x00000006,0x00000239,0x000000a7,0x00050085,0x00000006, + 0x0000023a,0x00000238,0x00000239,0x00050081,0x00000006,0x0000023b,0x00000237,0x0000023a, + 0x0004003d,0x00000006,0x0000023c,0x0000009e,0x00050081,0x00000006,0x0000023d,0x0000023b, + 0x0000023c,0x0004003d,0x00000006,0x0000023e,0x00000227,0x00050085,0x00000006,0x0000023f, + 0x0000023d,0x0000023e,0x0003003e,0x0000002e,0x0000023f,0x0004003d,0x00000006,0x00000240, + 0x00000217,0x0004003d,0x00000006,0x00000241,0x0000008d,0x00050085,0x00000006,0x00000242, + 0x00000240,0x00000241,0x0004003d,0x00000006,0x00000243,0x00000217,0x0004003d,0x00000006, + 0x00000244,0x00000098,0x00050085,0x00000006,0x00000245,0x00000243,0x00000244,0x00050081, + 0x00000006,0x00000246,0x00000242,0x00000245,0x0004003d,0x00000006,0x00000247,0x00000217, + 0x0004003d,0x00000006,0x00000248,0x000000b3,0x00050085,0x00000006,0x00000249,0x00000247, + 0x00000248,0x00050081,0x00000006,0x0000024a,0x00000246,0x00000249,0x0004003d,0x00000006, + 0x0000024b,0x00000217,0x0004003d,0x00000006,0x0000024c,0x000000aa,0x00050085,0x00000006, + 0x0000024d,0x0000024b,0x0000024c,0x00050081,0x00000006,0x0000024e,0x0000024a,0x0000024d, + 0x0004003d,0x00000006,0x0000024f,0x000000a1,0x00050081,0x00000006,0x00000250,0x0000024e, + 0x0000024f,0x0004003d,0x00000006,0x00000251,0x00000227,0x00050085,0x00000006,0x00000252, + 0x00000250,0x00000251,0x0003003e,0x0000002f,0x00000252,0x0004003d,0x00000006,0x00000253, + 0x00000217,0x0004003d,0x00000006,0x00000254,0x00000091,0x00050085,0x00000006,0x00000255, + 0x00000253,0x00000254,0x0004003d,0x00000006,0x00000256,0x00000217,0x0004003d,0x00000006, + 0x00000257,0x0000009b,0x00050085,0x00000006,0x00000258,0x00000256,0x00000257,0x00050081, + 0x00000006,0x00000259,0x00000255,0x00000258,0x0004003d,0x00000006,0x0000025a,0x00000217, + 0x0004003d,0x00000006,0x0000025b,0x000000b6,0x00050085,0x00000006,0x0000025c,0x0000025a, + 0x0000025b,0x00050081,0x00000006,0x0000025d,0x00000259,0x0000025c,0x0004003d,0x00000006, + 0x0000025e,0x00000217,0x0004003d,0x00000006,0x0000025f,0x000000ad,0x00050085,0x00000006, + 0x00000260,0x0000025e,0x0000025f,0x00050081,0x00000006,0x00000261,0x0000025d,0x00000260, + 0x0004003d,0x00000006,0x00000262,0x000000a4,0x00050081,0x00000006,0x00000263,0x00000261, + 0x00000262,0x0004003d,0x00000006,0x00000264,0x00000227,0x00050085,0x00000006,0x00000265, + 0x00000263,0x00000264,0x0003003e,0x00000030,0x00000265,0x000100fd,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/fxaa.frag b/app/src/main/cpp/shaders/fxaa.frag new file mode 100644 index 0000000000..9476117722 --- /dev/null +++ b/app/src/main/cpp/shaders/fxaa.frag @@ -0,0 +1,67 @@ +#version 450 + +// ============================================================================= +// FXAA (Fast Approximate Anti-Aliasing) post effect. +// +// Ported verbatim from the OpenGL FXAAEffect.java shader so the Vulkan +// compositor's post-process pipeline applies the SAME anti-aliasing the GL +// renderer's "FXAA" toggle does. GL sampled with gl_FragCoord.xy*invResolution; +// here fragTexCoord already spans [0,1] across the output, so it IS that uv. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// Runs FIRST in the canonical post chain (AA on the clean composited image). +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in px +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +#define FXAA_MIN_REDUCE (1.0 / 128.0) +#define FXAA_MUL_REDUCE (1.0 / 8.0) +#define MAX_SPAN 8.0 +const vec3 luma = vec3(0.299, 0.587, 0.114); + +void main() { + vec2 invResolution = 1.0 / pc.resolution; + vec2 uv = fragTexCoord; + + vec3 rgbNW = texture(InputTexture, uv + vec2(-1.0, -1.0) * invResolution).rgb; + vec3 rgbNE = texture(InputTexture, uv + vec2( 1.0, -1.0) * invResolution).rgb; + vec3 rgbSW = texture(InputTexture, uv + vec2(-1.0, 1.0) * invResolution).rgb; + vec3 rgbSE = texture(InputTexture, uv + vec2( 1.0, 1.0) * invResolution).rgb; + vec3 rgbM = texture(InputTexture, uv).rgb; + + float lumaNW = dot(rgbNW, luma); + float lumaNE = dot(rgbNE, luma); + float lumaSW = dot(rgbSW, luma); + float lumaSE = dot(rgbSE, luma); + float lumaM = dot(rgbM, luma); + + float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); + float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); + + vec2 dir; + dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); + dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); + + float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * 0.25 * FXAA_MUL_REDUCE, FXAA_MIN_REDUCE); + float minDirFactor = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); + dir = clamp(dir * minDirFactor, vec2(-MAX_SPAN), vec2(MAX_SPAN)) * invResolution; + + vec4 rgbA = 0.5 * ( + texture(InputTexture, uv + dir * (1.0 / 3.0 - 0.5)) + + texture(InputTexture, uv + dir * (2.0 / 3.0 - 0.5))); + vec4 rgbB = rgbA * 0.5 + 0.25 * ( + texture(InputTexture, uv + dir * -0.5) + + texture(InputTexture, uv + dir * 0.5)); + + float lumaB = dot(rgbB, vec4(luma, 0.0)); + outColor = (lumaB < lumaMin || lumaB > lumaMax) ? rgbA : rgbB; +} diff --git a/app/src/main/cpp/shaders/fxaa_toon.frag b/app/src/main/cpp/shaders/fxaa_toon.frag new file mode 100644 index 0000000000..ee75bba04f --- /dev/null +++ b/app/src/main/cpp/shaders/fxaa_toon.frag @@ -0,0 +1,69 @@ +#version 450 + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; + vec2 resolution; +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +#define FXAA_MIN_REDUCE (1.0 / 128.0) +#define FXAA_MUL_REDUCE (1.0 / 8.0) +#define MAX_SPAN 8.0 + +const vec3 luma = vec3(0.299, 0.587, 0.114); + +void main() { + vec2 invResolution = 1.0 / pc.resolution; + vec2 uv = fragTexCoord; + + vec3 rgbNW = texture(InputTexture, uv + vec2(-1.0, -1.0) * invResolution).rgb; + vec3 rgbNE = texture(InputTexture, uv + vec2( 1.0, -1.0) * invResolution).rgb; + vec3 rgbSW = texture(InputTexture, uv + vec2(-1.0, 1.0) * invResolution).rgb; + vec3 rgbSE = texture(InputTexture, uv + vec2( 1.0, 1.0) * invResolution).rgb; + vec3 rgbM = texture(InputTexture, uv).rgb; + + float lumaNW = dot(rgbNW, luma); + float lumaNE = dot(rgbNE, luma); + float lumaSW = dot(rgbSW, luma); + float lumaSE = dot(rgbSE, luma); + float lumaM = dot(rgbM, luma); + + float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); + float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); + + vec2 dir; + dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); + dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); + + float dirReduce = max( + (lumaNW + lumaNE + lumaSW + lumaSE) * 0.25 * FXAA_MUL_REDUCE, + FXAA_MIN_REDUCE); + float minDirFactor = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); + dir = clamp(dir * minDirFactor, vec2(-MAX_SPAN), vec2(MAX_SPAN)) * invResolution; + + vec4 rgbA = 0.5 * ( + texture(InputTexture, uv + dir * (1.0 / 3.0 - 0.5)) + + texture(InputTexture, uv + dir * (2.0 / 3.0 - 0.5))); + vec4 rgbB = rgbA * 0.5 + 0.25 * ( + texture(InputTexture, uv + dir * -0.5) + + texture(InputTexture, uv + dir * 0.5)); + + vec4 fxaaColor = dot(rgbB, vec4(luma, 0.0)) < lumaMin || + dot(rgbB, vec4(luma, 0.0)) > lumaMax ? rgbA : rgbB; + + // Approximate Toon edges using only FXAA's existing five samples. + vec3 colorLeft = 0.5 * (rgbNW + rgbSW); + vec3 colorRight = 0.5 * (rgbNE + rgbSE); + vec3 colorUp = 0.5 * (rgbNW + rgbNE); + vec3 colorDown = 0.5 * (rgbSW + rgbSE); + + float diffHorizontal = length(colorRight - colorLeft); + float diffVertical = length(colorUp - colorDown); + float edgeFactor = step(0.2, diffHorizontal + diffVertical); + + outColor = vec4(mix(fxaaColor.rgb, vec3(0.0), edgeFactor), 1.0); +} diff --git a/app/src/main/cpp/shaders/fxaa_toon_frag.h b/app/src/main/cpp/shaders/fxaa_toon_frag.h new file mode 100644 index 0000000000..3c8e221743 --- /dev/null +++ b/app/src/main/cpp/shaders/fxaa_toon_frag.h @@ -0,0 +1,202 @@ + // 1116.3.0 + #pragma once +const uint32_t fxaa_toon_code[] = { + 0x07230203,0x00010000,0x0008000b,0x00000115,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000018,0x0000010a,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00060005,0x00000009,0x52766e69,0x6c6f7365,0x6f697475,0x0000006e,0x00030005, + 0x0000000c,0x00004350,0x00040006,0x0000000c,0x00000000,0x0063646e,0x00060006,0x0000000c, + 0x00000001,0x6f736572,0x6974756c,0x00006e6f,0x00030005,0x0000000e,0x00006370,0x00030005, + 0x00000016,0x00007675,0x00060005,0x00000018,0x67617266,0x43786554,0x64726f6f,0x00000000, + 0x00040005,0x0000001c,0x4e626772,0x00000057,0x00060005,0x00000020,0x75706e49,0x78655474, + 0x65727574,0x00000000,0x00040005,0x0000002a,0x4e626772,0x00000045,0x00040005,0x00000033, + 0x53626772,0x00000057,0x00040005,0x0000003c,0x53626772,0x00000045,0x00040005,0x00000045, + 0x4d626772,0x00000000,0x00040005,0x0000004b,0x616d756c,0x0000574e,0x00040005,0x00000052, + 0x616d756c,0x0000454e,0x00040005,0x00000055,0x616d756c,0x00005753,0x00040005,0x00000058, + 0x616d756c,0x00004553,0x00040005,0x0000005b,0x616d756c,0x0000004d,0x00040005,0x0000005e, + 0x616d756c,0x006e694d,0x00040005,0x00000068,0x616d756c,0x0078614d,0x00030005,0x00000072, + 0x00726964,0x00050005,0x00000087,0x52726964,0x63756465,0x00000065,0x00060005,0x00000095, + 0x446e696d,0x61467269,0x726f7463,0x00000000,0x00040005,0x000000ab,0x41626772,0x00000000, + 0x00040005,0x000000bd,0x42626772,0x00000000,0x00050005,0x000000d0,0x61617866,0x6f6c6f43, + 0x00000072,0x00050005,0x000000e5,0x6f6c6f63,0x66654c72,0x00000074,0x00050005,0x000000ea, + 0x6f6c6f63,0x67695272,0x00007468,0x00040005,0x000000ef,0x6f6c6f63,0x00705572,0x00050005, + 0x000000f4,0x6f6c6f63,0x776f4472,0x0000006e,0x00060005,0x000000f9,0x66666964,0x69726f48, + 0x746e6f7a,0x00006c61,0x00060005,0x000000fe,0x66666964,0x74726556,0x6c616369,0x00000000, + 0x00050005,0x00000103,0x65676465,0x74636146,0x0000726f,0x00050005,0x0000010a,0x4374756f, + 0x726f6c6f,0x00000000,0x00030047,0x0000000c,0x00000002,0x00050048,0x0000000c,0x00000000, + 0x00000023,0x00000000,0x00050048,0x0000000c,0x00000001,0x00000023,0x00000010,0x00040047, + 0x00000018,0x0000001e,0x00000000,0x00040047,0x00000020,0x00000021,0x00000000,0x00040047, + 0x00000020,0x00000022,0x00000000,0x00040047,0x0000010a,0x0000001e,0x00000000,0x00020013, + 0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017, + 0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x0004002b, + 0x00000006,0x0000000a,0x3f800000,0x00040017,0x0000000b,0x00000006,0x00000004,0x0004001e, + 0x0000000c,0x0000000b,0x00000007,0x00040020,0x0000000d,0x00000009,0x0000000c,0x0004003b, + 0x0000000d,0x0000000e,0x00000009,0x00040015,0x0000000f,0x00000020,0x00000001,0x0004002b, + 0x0000000f,0x00000010,0x00000001,0x00040020,0x00000011,0x00000009,0x00000007,0x00040020, + 0x00000017,0x00000001,0x00000007,0x0004003b,0x00000017,0x00000018,0x00000001,0x00040017, + 0x0000001a,0x00000006,0x00000003,0x00040020,0x0000001b,0x00000007,0x0000001a,0x00090019, + 0x0000001d,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000, + 0x0003001b,0x0000001e,0x0000001d,0x00040020,0x0000001f,0x00000000,0x0000001e,0x0004003b, + 0x0000001f,0x00000020,0x00000000,0x0004002b,0x00000006,0x00000023,0xbf800000,0x0005002c, + 0x00000007,0x00000024,0x00000023,0x00000023,0x0005002c,0x00000007,0x0000002d,0x0000000a, + 0x00000023,0x0005002c,0x00000007,0x00000036,0x00000023,0x0000000a,0x0005002c,0x00000007, + 0x0000003f,0x0000000a,0x0000000a,0x00040020,0x0000004a,0x00000007,0x00000006,0x0004002b, + 0x00000006,0x0000004d,0x3e991687,0x0004002b,0x00000006,0x0000004e,0x3f1645a2,0x0004002b, + 0x00000006,0x0000004f,0x3de978d5,0x0006002c,0x0000001a,0x00000050,0x0000004d,0x0000004e, + 0x0000004f,0x00040015,0x0000007b,0x00000020,0x00000000,0x0004002b,0x0000007b,0x0000007c, + 0x00000000,0x0004002b,0x0000007b,0x00000085,0x00000001,0x0004002b,0x00000006,0x0000008f, + 0x3e800000,0x0004002b,0x00000006,0x00000091,0x3e000000,0x0004002b,0x00000006,0x00000093, + 0x3c000000,0x0004002b,0x00000006,0x000000a3,0xc1000000,0x0005002c,0x00000007,0x000000a4, + 0x000000a3,0x000000a3,0x0004002b,0x00000006,0x000000a5,0x41000000,0x0005002c,0x00000007, + 0x000000a6,0x000000a5,0x000000a5,0x00040020,0x000000aa,0x00000007,0x0000000b,0x0004002b, + 0x00000006,0x000000ac,0x3f000000,0x0004002b,0x00000006,0x000000b0,0xbe2aaaab,0x0004002b, + 0x00000006,0x000000b7,0x3e2aaaab,0x0004002b,0x00000006,0x000000c3,0xbf000000,0x00020014, + 0x000000d1,0x0004002b,0x00000006,0x000000d3,0x00000000,0x0007002c,0x0000000b,0x000000d4, + 0x0000004d,0x0000004e,0x0000004f,0x000000d3,0x00040017,0x000000e2,0x000000d1,0x00000004, + 0x0004002b,0x00000006,0x00000104,0x3e4ccccd,0x00040020,0x00000109,0x00000003,0x0000000b, + 0x0004003b,0x00000109,0x0000010a,0x00000003,0x0006002c,0x0000001a,0x0000010d,0x000000d3, + 0x000000d3,0x000000d3,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, + 0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000008,0x00000016, + 0x00000007,0x0004003b,0x0000001b,0x0000001c,0x00000007,0x0004003b,0x0000001b,0x0000002a, + 0x00000007,0x0004003b,0x0000001b,0x00000033,0x00000007,0x0004003b,0x0000001b,0x0000003c, + 0x00000007,0x0004003b,0x0000001b,0x00000045,0x00000007,0x0004003b,0x0000004a,0x0000004b, + 0x00000007,0x0004003b,0x0000004a,0x00000052,0x00000007,0x0004003b,0x0000004a,0x00000055, + 0x00000007,0x0004003b,0x0000004a,0x00000058,0x00000007,0x0004003b,0x0000004a,0x0000005b, + 0x00000007,0x0004003b,0x0000004a,0x0000005e,0x00000007,0x0004003b,0x0000004a,0x00000068, + 0x00000007,0x0004003b,0x00000008,0x00000072,0x00000007,0x0004003b,0x0000004a,0x00000087, + 0x00000007,0x0004003b,0x0000004a,0x00000095,0x00000007,0x0004003b,0x000000aa,0x000000ab, + 0x00000007,0x0004003b,0x000000aa,0x000000bd,0x00000007,0x0004003b,0x000000aa,0x000000d0, + 0x00000007,0x0004003b,0x0000001b,0x000000e5,0x00000007,0x0004003b,0x0000001b,0x000000ea, + 0x00000007,0x0004003b,0x0000001b,0x000000ef,0x00000007,0x0004003b,0x0000001b,0x000000f4, + 0x00000007,0x0004003b,0x0000004a,0x000000f9,0x00000007,0x0004003b,0x0000004a,0x000000fe, + 0x00000007,0x0004003b,0x0000004a,0x00000103,0x00000007,0x00050041,0x00000011,0x00000012, + 0x0000000e,0x00000010,0x0004003d,0x00000007,0x00000013,0x00000012,0x00050050,0x00000007, + 0x00000014,0x0000000a,0x0000000a,0x00050088,0x00000007,0x00000015,0x00000014,0x00000013, + 0x0003003e,0x00000009,0x00000015,0x0004003d,0x00000007,0x00000019,0x00000018,0x0003003e, + 0x00000016,0x00000019,0x0004003d,0x0000001e,0x00000021,0x00000020,0x0004003d,0x00000007, + 0x00000022,0x00000016,0x0004003d,0x00000007,0x00000025,0x00000009,0x00050085,0x00000007, + 0x00000026,0x00000024,0x00000025,0x00050081,0x00000007,0x00000027,0x00000022,0x00000026, + 0x00050057,0x0000000b,0x00000028,0x00000021,0x00000027,0x0008004f,0x0000001a,0x00000029, + 0x00000028,0x00000028,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000001c,0x00000029, + 0x0004003d,0x0000001e,0x0000002b,0x00000020,0x0004003d,0x00000007,0x0000002c,0x00000016, + 0x0004003d,0x00000007,0x0000002e,0x00000009,0x00050085,0x00000007,0x0000002f,0x0000002d, + 0x0000002e,0x00050081,0x00000007,0x00000030,0x0000002c,0x0000002f,0x00050057,0x0000000b, + 0x00000031,0x0000002b,0x00000030,0x0008004f,0x0000001a,0x00000032,0x00000031,0x00000031, + 0x00000000,0x00000001,0x00000002,0x0003003e,0x0000002a,0x00000032,0x0004003d,0x0000001e, + 0x00000034,0x00000020,0x0004003d,0x00000007,0x00000035,0x00000016,0x0004003d,0x00000007, + 0x00000037,0x00000009,0x00050085,0x00000007,0x00000038,0x00000036,0x00000037,0x00050081, + 0x00000007,0x00000039,0x00000035,0x00000038,0x00050057,0x0000000b,0x0000003a,0x00000034, + 0x00000039,0x0008004f,0x0000001a,0x0000003b,0x0000003a,0x0000003a,0x00000000,0x00000001, + 0x00000002,0x0003003e,0x00000033,0x0000003b,0x0004003d,0x0000001e,0x0000003d,0x00000020, + 0x0004003d,0x00000007,0x0000003e,0x00000016,0x0004003d,0x00000007,0x00000040,0x00000009, + 0x00050085,0x00000007,0x00000041,0x0000003f,0x00000040,0x00050081,0x00000007,0x00000042, + 0x0000003e,0x00000041,0x00050057,0x0000000b,0x00000043,0x0000003d,0x00000042,0x0008004f, + 0x0000001a,0x00000044,0x00000043,0x00000043,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x0000003c,0x00000044,0x0004003d,0x0000001e,0x00000046,0x00000020,0x0004003d,0x00000007, + 0x00000047,0x00000016,0x00050057,0x0000000b,0x00000048,0x00000046,0x00000047,0x0008004f, + 0x0000001a,0x00000049,0x00000048,0x00000048,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x00000045,0x00000049,0x0004003d,0x0000001a,0x0000004c,0x0000001c,0x00050094,0x00000006, + 0x00000051,0x0000004c,0x00000050,0x0003003e,0x0000004b,0x00000051,0x0004003d,0x0000001a, + 0x00000053,0x0000002a,0x00050094,0x00000006,0x00000054,0x00000053,0x00000050,0x0003003e, + 0x00000052,0x00000054,0x0004003d,0x0000001a,0x00000056,0x00000033,0x00050094,0x00000006, + 0x00000057,0x00000056,0x00000050,0x0003003e,0x00000055,0x00000057,0x0004003d,0x0000001a, + 0x00000059,0x0000003c,0x00050094,0x00000006,0x0000005a,0x00000059,0x00000050,0x0003003e, + 0x00000058,0x0000005a,0x0004003d,0x0000001a,0x0000005c,0x00000045,0x00050094,0x00000006, + 0x0000005d,0x0000005c,0x00000050,0x0003003e,0x0000005b,0x0000005d,0x0004003d,0x00000006, + 0x0000005f,0x0000005b,0x0004003d,0x00000006,0x00000060,0x0000004b,0x0004003d,0x00000006, + 0x00000061,0x00000052,0x0007000c,0x00000006,0x00000062,0x00000001,0x00000025,0x00000060, + 0x00000061,0x0004003d,0x00000006,0x00000063,0x00000055,0x0004003d,0x00000006,0x00000064, + 0x00000058,0x0007000c,0x00000006,0x00000065,0x00000001,0x00000025,0x00000063,0x00000064, + 0x0007000c,0x00000006,0x00000066,0x00000001,0x00000025,0x00000062,0x00000065,0x0007000c, + 0x00000006,0x00000067,0x00000001,0x00000025,0x0000005f,0x00000066,0x0003003e,0x0000005e, + 0x00000067,0x0004003d,0x00000006,0x00000069,0x0000005b,0x0004003d,0x00000006,0x0000006a, + 0x0000004b,0x0004003d,0x00000006,0x0000006b,0x00000052,0x0007000c,0x00000006,0x0000006c, + 0x00000001,0x00000028,0x0000006a,0x0000006b,0x0004003d,0x00000006,0x0000006d,0x00000055, + 0x0004003d,0x00000006,0x0000006e,0x00000058,0x0007000c,0x00000006,0x0000006f,0x00000001, + 0x00000028,0x0000006d,0x0000006e,0x0007000c,0x00000006,0x00000070,0x00000001,0x00000028, + 0x0000006c,0x0000006f,0x0007000c,0x00000006,0x00000071,0x00000001,0x00000028,0x00000069, + 0x00000070,0x0003003e,0x00000068,0x00000071,0x0004003d,0x00000006,0x00000073,0x0000004b, + 0x0004003d,0x00000006,0x00000074,0x00000052,0x00050081,0x00000006,0x00000075,0x00000073, + 0x00000074,0x0004003d,0x00000006,0x00000076,0x00000055,0x0004003d,0x00000006,0x00000077, + 0x00000058,0x00050081,0x00000006,0x00000078,0x00000076,0x00000077,0x00050083,0x00000006, + 0x00000079,0x00000075,0x00000078,0x0004007f,0x00000006,0x0000007a,0x00000079,0x00050041, + 0x0000004a,0x0000007d,0x00000072,0x0000007c,0x0003003e,0x0000007d,0x0000007a,0x0004003d, + 0x00000006,0x0000007e,0x0000004b,0x0004003d,0x00000006,0x0000007f,0x00000055,0x00050081, + 0x00000006,0x00000080,0x0000007e,0x0000007f,0x0004003d,0x00000006,0x00000081,0x00000052, + 0x0004003d,0x00000006,0x00000082,0x00000058,0x00050081,0x00000006,0x00000083,0x00000081, + 0x00000082,0x00050083,0x00000006,0x00000084,0x00000080,0x00000083,0x00050041,0x0000004a, + 0x00000086,0x00000072,0x00000085,0x0003003e,0x00000086,0x00000084,0x0004003d,0x00000006, + 0x00000088,0x0000004b,0x0004003d,0x00000006,0x00000089,0x00000052,0x00050081,0x00000006, + 0x0000008a,0x00000088,0x00000089,0x0004003d,0x00000006,0x0000008b,0x00000055,0x00050081, + 0x00000006,0x0000008c,0x0000008a,0x0000008b,0x0004003d,0x00000006,0x0000008d,0x00000058, + 0x00050081,0x00000006,0x0000008e,0x0000008c,0x0000008d,0x00050085,0x00000006,0x00000090, + 0x0000008e,0x0000008f,0x00050085,0x00000006,0x00000092,0x00000090,0x00000091,0x0007000c, + 0x00000006,0x00000094,0x00000001,0x00000028,0x00000092,0x00000093,0x0003003e,0x00000087, + 0x00000094,0x00050041,0x0000004a,0x00000096,0x00000072,0x0000007c,0x0004003d,0x00000006, + 0x00000097,0x00000096,0x0006000c,0x00000006,0x00000098,0x00000001,0x00000004,0x00000097, + 0x00050041,0x0000004a,0x00000099,0x00000072,0x00000085,0x0004003d,0x00000006,0x0000009a, + 0x00000099,0x0006000c,0x00000006,0x0000009b,0x00000001,0x00000004,0x0000009a,0x0007000c, + 0x00000006,0x0000009c,0x00000001,0x00000025,0x00000098,0x0000009b,0x0004003d,0x00000006, + 0x0000009d,0x00000087,0x00050081,0x00000006,0x0000009e,0x0000009c,0x0000009d,0x00050088, + 0x00000006,0x0000009f,0x0000000a,0x0000009e,0x0003003e,0x00000095,0x0000009f,0x0004003d, + 0x00000007,0x000000a0,0x00000072,0x0004003d,0x00000006,0x000000a1,0x00000095,0x0005008e, + 0x00000007,0x000000a2,0x000000a0,0x000000a1,0x0008000c,0x00000007,0x000000a7,0x00000001, + 0x0000002b,0x000000a2,0x000000a4,0x000000a6,0x0004003d,0x00000007,0x000000a8,0x00000009, + 0x00050085,0x00000007,0x000000a9,0x000000a7,0x000000a8,0x0003003e,0x00000072,0x000000a9, + 0x0004003d,0x0000001e,0x000000ad,0x00000020,0x0004003d,0x00000007,0x000000ae,0x00000016, + 0x0004003d,0x00000007,0x000000af,0x00000072,0x0005008e,0x00000007,0x000000b1,0x000000af, + 0x000000b0,0x00050081,0x00000007,0x000000b2,0x000000ae,0x000000b1,0x00050057,0x0000000b, + 0x000000b3,0x000000ad,0x000000b2,0x0004003d,0x0000001e,0x000000b4,0x00000020,0x0004003d, + 0x00000007,0x000000b5,0x00000016,0x0004003d,0x00000007,0x000000b6,0x00000072,0x0005008e, + 0x00000007,0x000000b8,0x000000b6,0x000000b7,0x00050081,0x00000007,0x000000b9,0x000000b5, + 0x000000b8,0x00050057,0x0000000b,0x000000ba,0x000000b4,0x000000b9,0x00050081,0x0000000b, + 0x000000bb,0x000000b3,0x000000ba,0x0005008e,0x0000000b,0x000000bc,0x000000bb,0x000000ac, + 0x0003003e,0x000000ab,0x000000bc,0x0004003d,0x0000000b,0x000000be,0x000000ab,0x0005008e, + 0x0000000b,0x000000bf,0x000000be,0x000000ac,0x0004003d,0x0000001e,0x000000c0,0x00000020, + 0x0004003d,0x00000007,0x000000c1,0x00000016,0x0004003d,0x00000007,0x000000c2,0x00000072, + 0x0005008e,0x00000007,0x000000c4,0x000000c2,0x000000c3,0x00050081,0x00000007,0x000000c5, + 0x000000c1,0x000000c4,0x00050057,0x0000000b,0x000000c6,0x000000c0,0x000000c5,0x0004003d, + 0x0000001e,0x000000c7,0x00000020,0x0004003d,0x00000007,0x000000c8,0x00000016,0x0004003d, + 0x00000007,0x000000c9,0x00000072,0x0005008e,0x00000007,0x000000ca,0x000000c9,0x000000ac, + 0x00050081,0x00000007,0x000000cb,0x000000c8,0x000000ca,0x00050057,0x0000000b,0x000000cc, + 0x000000c7,0x000000cb,0x00050081,0x0000000b,0x000000cd,0x000000c6,0x000000cc,0x0005008e, + 0x0000000b,0x000000ce,0x000000cd,0x0000008f,0x00050081,0x0000000b,0x000000cf,0x000000bf, + 0x000000ce,0x0003003e,0x000000bd,0x000000cf,0x0004003d,0x0000000b,0x000000d2,0x000000bd, + 0x00050094,0x00000006,0x000000d5,0x000000d2,0x000000d4,0x0004003d,0x00000006,0x000000d6, + 0x0000005e,0x000500b8,0x000000d1,0x000000d7,0x000000d5,0x000000d6,0x000400a8,0x000000d1, + 0x000000d8,0x000000d7,0x000300f7,0x000000da,0x00000000,0x000400fa,0x000000d8,0x000000d9, + 0x000000da,0x000200f8,0x000000d9,0x0004003d,0x0000000b,0x000000db,0x000000bd,0x00050094, + 0x00000006,0x000000dc,0x000000db,0x000000d4,0x0004003d,0x00000006,0x000000dd,0x00000068, + 0x000500ba,0x000000d1,0x000000de,0x000000dc,0x000000dd,0x000200f9,0x000000da,0x000200f8, + 0x000000da,0x000700f5,0x000000d1,0x000000df,0x000000d7,0x00000005,0x000000de,0x000000d9, + 0x0004003d,0x0000000b,0x000000e0,0x000000ab,0x0004003d,0x0000000b,0x000000e1,0x000000bd, + 0x00070050,0x000000e2,0x000000e3,0x000000df,0x000000df,0x000000df,0x000000df,0x000600a9, + 0x0000000b,0x000000e4,0x000000e3,0x000000e0,0x000000e1,0x0003003e,0x000000d0,0x000000e4, + 0x0004003d,0x0000001a,0x000000e6,0x0000001c,0x0004003d,0x0000001a,0x000000e7,0x00000033, + 0x00050081,0x0000001a,0x000000e8,0x000000e6,0x000000e7,0x0005008e,0x0000001a,0x000000e9, + 0x000000e8,0x000000ac,0x0003003e,0x000000e5,0x000000e9,0x0004003d,0x0000001a,0x000000eb, + 0x0000002a,0x0004003d,0x0000001a,0x000000ec,0x0000003c,0x00050081,0x0000001a,0x000000ed, + 0x000000eb,0x000000ec,0x0005008e,0x0000001a,0x000000ee,0x000000ed,0x000000ac,0x0003003e, + 0x000000ea,0x000000ee,0x0004003d,0x0000001a,0x000000f0,0x0000001c,0x0004003d,0x0000001a, + 0x000000f1,0x0000002a,0x00050081,0x0000001a,0x000000f2,0x000000f0,0x000000f1,0x0005008e, + 0x0000001a,0x000000f3,0x000000f2,0x000000ac,0x0003003e,0x000000ef,0x000000f3,0x0004003d, + 0x0000001a,0x000000f5,0x00000033,0x0004003d,0x0000001a,0x000000f6,0x0000003c,0x00050081, + 0x0000001a,0x000000f7,0x000000f5,0x000000f6,0x0005008e,0x0000001a,0x000000f8,0x000000f7, + 0x000000ac,0x0003003e,0x000000f4,0x000000f8,0x0004003d,0x0000001a,0x000000fa,0x000000ea, + 0x0004003d,0x0000001a,0x000000fb,0x000000e5,0x00050083,0x0000001a,0x000000fc,0x000000fa, + 0x000000fb,0x0006000c,0x00000006,0x000000fd,0x00000001,0x00000042,0x000000fc,0x0003003e, + 0x000000f9,0x000000fd,0x0004003d,0x0000001a,0x000000ff,0x000000ef,0x0004003d,0x0000001a, + 0x00000100,0x000000f4,0x00050083,0x0000001a,0x00000101,0x000000ff,0x00000100,0x0006000c, + 0x00000006,0x00000102,0x00000001,0x00000042,0x00000101,0x0003003e,0x000000fe,0x00000102, + 0x0004003d,0x00000006,0x00000105,0x000000f9,0x0004003d,0x00000006,0x00000106,0x000000fe, + 0x00050081,0x00000006,0x00000107,0x00000105,0x00000106,0x0007000c,0x00000006,0x00000108, + 0x00000001,0x00000030,0x00000104,0x00000107,0x0003003e,0x00000103,0x00000108,0x0004003d, + 0x0000000b,0x0000010b,0x000000d0,0x0008004f,0x0000001a,0x0000010c,0x0000010b,0x0000010b, + 0x00000000,0x00000001,0x00000002,0x0004003d,0x00000006,0x0000010e,0x00000103,0x00060050, + 0x0000001a,0x0000010f,0x0000010e,0x0000010e,0x0000010e,0x0008000c,0x0000001a,0x00000110, + 0x00000001,0x0000002e,0x0000010c,0x0000010d,0x0000010f,0x00050051,0x00000006,0x00000111, + 0x00000110,0x00000000,0x00050051,0x00000006,0x00000112,0x00000110,0x00000001,0x00050051, + 0x00000006,0x00000113,0x00000110,0x00000002,0x00070050,0x0000000b,0x00000114,0x00000111, + 0x00000112,0x00000113,0x0000000a,0x0003003e,0x0000010a,0x00000114,0x000100fd,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/gen_shaders.sh b/app/src/main/cpp/shaders/gen_shaders.sh new file mode 100755 index 0000000000..8c583544e3 --- /dev/null +++ b/app/src/main/cpp/shaders/gen_shaders.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +# ============================================================================= +# Regenerate the committed SPIR-V headers (*_frag.h / *_vert.h) for the native +# Vulkan compositor's post-process shaders. +# +# The Android NDK build does NOT compile GLSL; instead every *.frag / *.vert in +# this directory is pre-compiled to a SPIR-V uint32 array header that is #included +# by VulkanRendererContext.cpp. Run this whenever you edit a shader, then commit +# the regenerated *.h alongside the *.frag/*.vert source. +# +# Requires glslangValidator on PATH (e.g. the Vulkan SDK or the termux package). +# +# Usage: ./gen_shaders.sh # regenerate all shaders +# ./gen_shaders.sh nis crt # regenerate only the named shaders +# +# The upscalers and CAS also get a half-precision build: the same source with +# -DDD_HALF=1 -> _half_frag.h (array _half_code). The compositors +# pick the plain or the half set at start-up (debug.droiddeck.upscale.shaders). +# Names in HALF_ONLY are built half only. +# ============================================================================= +set -euo pipefail + +cd "$(dirname "$0")" + +if ! command -v glslangValidator >/dev/null 2>&1; then + echo "error: glslangValidator not found on PATH" >&2 + exit 1 +fi + +HALF=(sgsr sgsr_quality fsr_easu fsr_rcas cas_ffx nis_luma nis3) +HALF_ONLY=(cas_ffx nis_luma nis3) + +in_list() { + local x="$1"; shift + for y in "$@"; do [ "$x" = "$y" ] && return 0; done + return 1 +} + +gen() { + local src="$1" # e.g. nis.frag + local base="${src%.*}" # nis + local ext="${src##*.}" # frag | vert + if ! in_list "${base}" "${HALF_ONLY[@]}"; then + local vn="${base}_code" + if [ "$ext" = "vert" ]; then + vn="${base}_vert_code" + fi + local out="${base}_${ext}.h" + echo " ${src} -> ${out} (--vn ${vn})" + glslangValidator -V "${src}" --vn "${vn}" -o "${out}" + fi + if in_list "${base}" "${HALF[@]}"; then + local hvn="${base}_half_code" + local hout="${base}_half_${ext}.h" + echo " ${src} -> ${hout} (--vn ${hvn}, -DDD_HALF=1)" + glslangValidator -V -DDD_HALF=1 "${src}" --vn "${hvn}" -o "${hout}" + fi +} + +shaders=() +if [ "$#" -gt 0 ]; then + for name in "$@"; do + for f in "${name}.frag" "${name}.vert"; do + [ -f "$f" ] && shaders+=("$f") + done + done +else + for f in *.frag *.vert; do + [ -f "$f" ] && shaders+=("$f") + done +fi + +for s in "${shaders[@]}"; do + gen "$s" +done + +echo "done." diff --git a/app/src/main/cpp/shaders/hdr.frag b/app/src/main/cpp/shaders/hdr.frag new file mode 100644 index 0000000000..3a24ce392d --- /dev/null +++ b/app/src/main/cpp/shaders/hdr.frag @@ -0,0 +1,64 @@ +#version 450 + +// ============================================================================= +// Fake-HDR (dual-radius bloom + contrast lift) post effect. +// +// Ported from the OpenGL HDREffect.java shader so the Vulkan compositor's +// post-process pipeline applies the SAME fake-HDR the GL renderer's "HDR" +// toggle does. Binary on/off; HDRPower fixed at 1.30. Composable: runs at any +// resolution, after the optional scaling and CAS passes. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in pixels +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +const float HDRPower = 1.30; +const float radius1 = 0.793; +const float radius2 = 0.870; + +void main() { + vec2 texcoord = fragTexCoord; + vec2 px = 1.0 / pc.resolution; + + vec3 color = texture(InputTexture, texcoord).rgb; + + // --- BLOOM PASS 1 (radius1) --- + vec3 bloom_sum1 = texture(InputTexture, texcoord + vec2( 1.5, -1.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2(-1.5, -1.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2( 1.5, 1.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2(-1.5, 1.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2( 0.0, -2.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2( 0.0, 2.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2(-2.5, 0.0) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2( 2.5, 0.0) * radius1 * px).rgb; + bloom_sum1 *= 0.005; + + // --- BLOOM PASS 2 (radius2) --- + vec3 bloom_sum2 = texture(InputTexture, texcoord + vec2( 1.5, -1.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2(-1.5, -1.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2( 1.5, 1.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2(-1.5, 1.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2( 0.0, -2.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2( 0.0, 2.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2(-2.5, 0.0) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2( 2.5, 0.0) * radius2 * px).rgb; + bloom_sum2 *= 0.010; + + // --- FAKE HDR --- + float dist = radius2 - radius1; + vec3 HDR = (color + (bloom_sum2 - bloom_sum1)) * dist; + vec3 blend = HDR + color; + color = pow(abs(blend), vec3(abs(HDRPower))) + HDR; + + outColor = vec4(clamp(color, 0.0, 1.0), 1.0); +} diff --git a/app/src/main/cpp/shaders/nis.frag b/app/src/main/cpp/shaders/nis.frag new file mode 100644 index 0000000000..025fa4f251 --- /dev/null +++ b/app/src/main/cpp/shaders/nis.frag @@ -0,0 +1,458 @@ +#version 450 + +// ============================================================================= +// NVIDIA Image Scaling (NIS) - NVScaler spatial upscaler + adaptive sharpen. +// +// Ported from NVIDIA's reference NVScaler: +// NVIDIAGameWorks/NVIDIAImageScaling NIS/NIS_Scaler.h (+ NIS_Config.h) +// +// The MIT License (MIT) +// Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: MIT +// +// Adapted for the Winlator native Vulkan compositor: +// - #version 450 (Vulkan GLSL), single-pass FRAGMENT shader (the reference is +// an LDS-tiled compute shader). The block/LDS cooperative tile loads are +// replaced with direct per-fragment texture() fetches of the 6x6 luma +// support, and the edge map is computed inline from that support. The math +// (edge detection + 6-tap directional scale/USM blend) is the reference's. +// - The kPhaseCount x 6 scaler/USM coefficient banks (coef_scale, coef_usm, +// fp32 path) are BAKED below as const arrays - no second descriptor binding +// (the post dsLayout has ONE sampler at binding 0 shared by all pipelines). +// - Config-UBO reads are replaced by push constants + baked SDR constants; the +// sharpness-derived params are recomputed in-shader exactly as +// NVScalerUpdateConfig does, driven by the existing "Sharpness" slider. +// - fp32 only (NOT the fp16/bit-packed NIS_USE_HALF_PRECISION path) so there +// are no bitwise/bvec ops - Adreno-compile-safe. +// - HDR mode = None (SDR). The whole compositor chain is R8G8B8A8_UNORM and +// values are display(gamma)-encoded here, matching NIS LDR expectations. +// - Reuses upscale.vert: fragTexCoord spans [0,1] across the destination rect +// (= normalised output position). With kScaleX = inputW/outputW, the source +// sample position reduces to srcX = fragTexCoord.x*inputW - 0.5 (so the +// output viewport origin/size cancel out and are never needed here). +// +// Conventions match sgsr.frag / cas.frag: combined-image-sampler at binding 0, +// push-constant block leads with vec4 ndc (offset 0, consumed by upscale.vert), +// then ViewportInfo (xy = 1/inputSize texel size, zw = inputSize px) + sharpness. +// ============================================================================= + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as NVIDIA's +// NIS_USE_HALF_PRECISION path (pixels, weights, coefficient tables); positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + highp vec4 ViewportInfo; // xy = 1/inputSize (texel size), zw = inputSize in pixels + float sharpness; // "Sharpness" slider mapped to [0..1] (NIS sharpness) +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +// ---- SDR (HDR mode None) constants, from NVScalerUpdateConfig ----------------- +const float kDetectRatio = 2.0 * 1127.0 / 1024.0; // 2.201171875 +const float kDetectThres = 64.0 / 1024.0; // 0.0625 +const float kMinContrastRatio = 2.0; +const float kMaxContrastRatio = 10.0; +const float kRatioNorm = 1.0 / (kMaxContrastRatio - kMinContrastRatio); // 0.125 +const float kContrastBoost = 1.0; +const float kEps = 1.0 / 255.0; +const float kSharpStartY = 0.45; +const float kSharpEndY = 0.9; +const float kSharpScaleY = 1.0 / (kSharpEndY - kSharpStartY); // 2.222... +const int kPhaseCount = 64; + +// Sharpness-derived params (recomputed in main from pc.sharpness, read here). +float gSharpStrengthMin; +float gSharpStrengthScale; +float gSharpLimitMin; +float gSharpLimitScale; + +const float coefScale[384] = float[384]( + 0.0, 0.0, 1.0000, 0.0, 0.0, 0.0, // phase 0 + 0.0029, -0.0127, 1.0000, 0.0132, -0.0034, 0.0, // phase 1 + 0.0063, -0.0249, 0.9985, 0.0269, -0.0068, 0.0, // phase 2 + 0.0088, -0.0361, 0.9956, 0.0415, -0.0103, 0.0005, // phase 3 + 0.0117, -0.0474, 0.9932, 0.0562, -0.0142, 0.0005, // phase 4 + 0.0142, -0.0576, 0.9897, 0.0713, -0.0181, 0.0005, // phase 5 + 0.0166, -0.0674, 0.9844, 0.0874, -0.0220, 0.0010, // phase 6 + 0.0186, -0.0762, 0.9785, 0.1040, -0.0264, 0.0015, // phase 7 + 0.0205, -0.0850, 0.9727, 0.1206, -0.0308, 0.0020, // phase 8 + 0.0225, -0.0928, 0.9648, 0.1382, -0.0352, 0.0024, // phase 9 + 0.0239, -0.1006, 0.9575, 0.1558, -0.0396, 0.0029, // phase 10 + 0.0254, -0.1074, 0.9487, 0.1738, -0.0439, 0.0034, // phase 11 + 0.0264, -0.1138, 0.9390, 0.1929, -0.0488, 0.0044, // phase 12 + 0.0278, -0.1191, 0.9282, 0.2119, -0.0537, 0.0049, // phase 13 + 0.0288, -0.1245, 0.9170, 0.2310, -0.0581, 0.0059, // phase 14 + 0.0293, -0.1294, 0.9058, 0.2510, -0.0630, 0.0063, // phase 15 + 0.0303, -0.1333, 0.8926, 0.2710, -0.0679, 0.0073, // phase 16 + 0.0308, -0.1367, 0.8789, 0.2915, -0.0728, 0.0083, // phase 17 + 0.0308, -0.1401, 0.8657, 0.3120, -0.0776, 0.0093, // phase 18 + 0.0313, -0.1426, 0.8506, 0.3330, -0.0825, 0.0103, // phase 19 + 0.0313, -0.1445, 0.8354, 0.3540, -0.0874, 0.0112, // phase 20 + 0.0313, -0.1460, 0.8193, 0.3755, -0.0923, 0.0122, // phase 21 + 0.0313, -0.1470, 0.8022, 0.3965, -0.0967, 0.0137, // phase 22 + 0.0308, -0.1479, 0.7856, 0.4185, -0.1016, 0.0146, // phase 23 + 0.0303, -0.1479, 0.7681, 0.4399, -0.1060, 0.0156, // phase 24 + 0.0298, -0.1479, 0.7505, 0.4614, -0.1104, 0.0166, // phase 25 + 0.0293, -0.1470, 0.7314, 0.4829, -0.1147, 0.0181, // phase 26 + 0.0288, -0.1460, 0.7119, 0.5049, -0.1187, 0.0190, // phase 27 + 0.0278, -0.1445, 0.6929, 0.5264, -0.1226, 0.0200, // phase 28 + 0.0273, -0.1431, 0.6724, 0.5479, -0.1260, 0.0215, // phase 29 + 0.0264, -0.1411, 0.6528, 0.5693, -0.1299, 0.0225, // phase 30 + 0.0254, -0.1387, 0.6323, 0.5903, -0.1328, 0.0234, // phase 31 + 0.0244, -0.1357, 0.6113, 0.6113, -0.1357, 0.0244, // phase 32 + 0.0234, -0.1328, 0.5903, 0.6323, -0.1387, 0.0254, // phase 33 + 0.0225, -0.1299, 0.5693, 0.6528, -0.1411, 0.0264, // phase 34 + 0.0215, -0.1260, 0.5479, 0.6724, -0.1431, 0.0273, // phase 35 + 0.0200, -0.1226, 0.5264, 0.6929, -0.1445, 0.0278, // phase 36 + 0.0190, -0.1187, 0.5049, 0.7119, -0.1460, 0.0288, // phase 37 + 0.0181, -0.1147, 0.4829, 0.7314, -0.1470, 0.0293, // phase 38 + 0.0166, -0.1104, 0.4614, 0.7505, -0.1479, 0.0298, // phase 39 + 0.0156, -0.1060, 0.4399, 0.7681, -0.1479, 0.0303, // phase 40 + 0.0146, -0.1016, 0.4185, 0.7856, -0.1479, 0.0308, // phase 41 + 0.0137, -0.0967, 0.3965, 0.8022, -0.1470, 0.0313, // phase 42 + 0.0122, -0.0923, 0.3755, 0.8193, -0.1460, 0.0313, // phase 43 + 0.0112, -0.0874, 0.3540, 0.8354, -0.1445, 0.0313, // phase 44 + 0.0103, -0.0825, 0.3330, 0.8506, -0.1426, 0.0313, // phase 45 + 0.0093, -0.0776, 0.3120, 0.8657, -0.1401, 0.0308, // phase 46 + 0.0083, -0.0728, 0.2915, 0.8789, -0.1367, 0.0308, // phase 47 + 0.0073, -0.0679, 0.2710, 0.8926, -0.1333, 0.0303, // phase 48 + 0.0063, -0.0630, 0.2510, 0.9058, -0.1294, 0.0293, // phase 49 + 0.0059, -0.0581, 0.2310, 0.9170, -0.1245, 0.0288, // phase 50 + 0.0049, -0.0537, 0.2119, 0.9282, -0.1191, 0.0278, // phase 51 + 0.0044, -0.0488, 0.1929, 0.9390, -0.1138, 0.0264, // phase 52 + 0.0034, -0.0439, 0.1738, 0.9487, -0.1074, 0.0254, // phase 53 + 0.0029, -0.0396, 0.1558, 0.9575, -0.1006, 0.0239, // phase 54 + 0.0024, -0.0352, 0.1382, 0.9648, -0.0928, 0.0225, // phase 55 + 0.0020, -0.0308, 0.1206, 0.9727, -0.0850, 0.0205, // phase 56 + 0.0015, -0.0264, 0.1040, 0.9785, -0.0762, 0.0186, // phase 57 + 0.0010, -0.0220, 0.0874, 0.9844, -0.0674, 0.0166, // phase 58 + 0.0005, -0.0181, 0.0713, 0.9897, -0.0576, 0.0142, // phase 59 + 0.0005, -0.0142, 0.0562, 0.9932, -0.0474, 0.0117, // phase 60 + 0.0005, -0.0103, 0.0415, 0.9956, -0.0361, 0.0088, // phase 61 + 0.0, -0.0068, 0.0269, 0.9985, -0.0249, 0.0063, // phase 62 + 0.0, -0.0034, 0.0132, 1.0000, -0.0127, 0.0029 // phase 63 +); + +const float coefUsm[384] = float[384]( + 0.0, -0.6001, 1.2002, -0.6001, 0.0, 0.0, // phase 0 + 0.0029, -0.6084, 1.1987, -0.5903, -0.0029, 0.0, // phase 1 + 0.0049, -0.6147, 1.1958, -0.5791, -0.0068, 0.0005, // phase 2 + 0.0073, -0.6196, 1.1890, -0.5659, -0.0103, 0.0, // phase 3 + 0.0093, -0.6235, 1.1802, -0.5513, -0.0151, 0.0, // phase 4 + 0.0112, -0.6265, 1.1699, -0.5352, -0.0195, 0.0005, // phase 5 + 0.0122, -0.6270, 1.1582, -0.5181, -0.0259, 0.0005, // phase 6 + 0.0142, -0.6284, 1.1455, -0.5005, -0.0317, 0.0005, // phase 7 + 0.0156, -0.6265, 1.1274, -0.4790, -0.0386, 0.0005, // phase 8 + 0.0166, -0.6235, 1.1089, -0.4570, -0.0454, 0.0010, // phase 9 + 0.0176, -0.6187, 1.0879, -0.4346, -0.0532, 0.0010, // phase 10 + 0.0181, -0.6138, 1.0659, -0.4102, -0.0615, 0.0015, // phase 11 + 0.0190, -0.6069, 1.0405, -0.3843, -0.0698, 0.0015, // phase 12 + 0.0195, -0.6006, 1.0161, -0.3574, -0.0796, 0.0020, // phase 13 + 0.0200, -0.5928, 0.9893, -0.3286, -0.0898, 0.0024, // phase 14 + 0.0200, -0.5820, 0.9580, -0.2988, -0.1001, 0.0029, // phase 15 + 0.0200, -0.5728, 0.9292, -0.2690, -0.1104, 0.0034, // phase 16 + 0.0200, -0.5620, 0.8975, -0.2368, -0.1226, 0.0039, // phase 17 + 0.0205, -0.5498, 0.8643, -0.2046, -0.1343, 0.0044, // phase 18 + 0.0200, -0.5371, 0.8301, -0.1709, -0.1465, 0.0049, // phase 19 + 0.0195, -0.5239, 0.7944, -0.1367, -0.1587, 0.0054, // phase 20 + 0.0195, -0.5107, 0.7598, -0.1021, -0.1724, 0.0059, // phase 21 + 0.0190, -0.4966, 0.7231, -0.0649, -0.1865, 0.0063, // phase 22 + 0.0186, -0.4819, 0.6846, -0.0288, -0.1997, 0.0068, // phase 23 + 0.0186, -0.4668, 0.6460, 0.0093, -0.2144, 0.0073, // phase 24 + 0.0176, -0.4507, 0.6055, 0.0479, -0.2290, 0.0083, // phase 25 + 0.0171, -0.4370, 0.5693, 0.0859, -0.2446, 0.0088, // phase 26 + 0.0161, -0.4199, 0.5283, 0.1255, -0.2598, 0.0098, // phase 27 + 0.0161, -0.4048, 0.4883, 0.1655, -0.2754, 0.0103, // phase 28 + 0.0151, -0.3887, 0.4497, 0.2041, -0.2910, 0.0107, // phase 29 + 0.0142, -0.3711, 0.4072, 0.2446, -0.3066, 0.0117, // phase 30 + 0.0137, -0.3555, 0.3672, 0.2852, -0.3228, 0.0122, // phase 31 + 0.0132, -0.3394, 0.3262, 0.3262, -0.3394, 0.0132, // phase 32 + 0.0122, -0.3228, 0.2852, 0.3672, -0.3555, 0.0137, // phase 33 + 0.0117, -0.3066, 0.2446, 0.4072, -0.3711, 0.0142, // phase 34 + 0.0107, -0.2910, 0.2041, 0.4497, -0.3887, 0.0151, // phase 35 + 0.0103, -0.2754, 0.1655, 0.4883, -0.4048, 0.0161, // phase 36 + 0.0098, -0.2598, 0.1255, 0.5283, -0.4199, 0.0161, // phase 37 + 0.0088, -0.2446, 0.0859, 0.5693, -0.4370, 0.0171, // phase 38 + 0.0083, -0.2290, 0.0479, 0.6055, -0.4507, 0.0176, // phase 39 + 0.0073, -0.2144, 0.0093, 0.6460, -0.4668, 0.0186, // phase 40 + 0.0068, -0.1997, -0.0288, 0.6846, -0.4819, 0.0186, // phase 41 + 0.0063, -0.1865, -0.0649, 0.7231, -0.4966, 0.0190, // phase 42 + 0.0059, -0.1724, -0.1021, 0.7598, -0.5107, 0.0195, // phase 43 + 0.0054, -0.1587, -0.1367, 0.7944, -0.5239, 0.0195, // phase 44 + 0.0049, -0.1465, -0.1709, 0.8301, -0.5371, 0.0200, // phase 45 + 0.0044, -0.1343, -0.2046, 0.8643, -0.5498, 0.0205, // phase 46 + 0.0039, -0.1226, -0.2368, 0.8975, -0.5620, 0.0200, // phase 47 + 0.0034, -0.1104, -0.2690, 0.9292, -0.5728, 0.0200, // phase 48 + 0.0029, -0.1001, -0.2988, 0.9580, -0.5820, 0.0200, // phase 49 + 0.0024, -0.0898, -0.3286, 0.9893, -0.5928, 0.0200, // phase 50 + 0.0020, -0.0796, -0.3574, 1.0161, -0.6006, 0.0195, // phase 51 + 0.0015, -0.0698, -0.3843, 1.0405, -0.6069, 0.0190, // phase 52 + 0.0015, -0.0615, -0.4102, 1.0659, -0.6138, 0.0181, // phase 53 + 0.0010, -0.0532, -0.4346, 1.0879, -0.6187, 0.0176, // phase 54 + 0.0010, -0.0454, -0.4570, 1.1089, -0.6235, 0.0166, // phase 55 + 0.0005, -0.0386, -0.4790, 1.1274, -0.6265, 0.0156, // phase 56 + 0.0005, -0.0317, -0.5005, 1.1455, -0.6284, 0.0142, // phase 57 + 0.0005, -0.0259, -0.5181, 1.1582, -0.6270, 0.0122, // phase 58 + 0.0005, -0.0195, -0.5352, 1.1699, -0.6265, 0.0112, // phase 59 + 0.0, -0.0151, -0.5513, 1.1802, -0.6235, 0.0093, // phase 60 + 0.0, -0.0103, -0.5659, 1.1890, -0.6196, 0.0073, // phase 61 + 0.0005, -0.0068, -0.5791, 1.1958, -0.6147, 0.0049, // phase 62 + 0.0, -0.0029, -0.5903, 1.1987, -0.6084, 0.0029 // phase 63 +); + +float getY(vec3 rgb) { + return dot(rgb, vec3(0.2126, 0.7152, 0.0722)); +} + +// GetEdgeMap on a 3x3 luma window (pRC: R=row 0=top, C=col 0=left). +vec4 edgeAt(float p00, float p01, float p02, + float p10, float p11, float p12, + float p20, float p21, float p22) { + float g_0 = abs(p00 + p01 + p02 - p20 - p21 - p22); + float g_45 = abs(p10 + p00 + p01 - p21 - p22 - p12); + float g_90 = abs(p00 + p10 + p20 - p02 - p12 - p22); + float g_135 = abs(p10 + p20 + p21 - p01 - p02 - p12); + + float g_0_90_max = max(g_0, g_90); + float g_0_90_min = min(g_0, g_90); + float g_45_135_max = max(g_45, g_135); + float g_45_135_min = min(g_45, g_135); + + if (g_0_90_max + g_45_135_max == 0.0) { + return vec4(0.0); + } + + float e_0_90 = g_0_90_max / (g_0_90_max + g_45_135_max); + float e_45_135 = 1.0 - e_0_90; + + bool c_0_90 = (g_0_90_max > (g_0_90_min * kDetectRatio)) && (g_0_90_max > kDetectThres) && (g_0_90_max > g_45_135_min); + bool c_45_135 = (g_45_135_max > (g_45_135_min * kDetectRatio)) && (g_45_135_max > kDetectThres) && (g_45_135_max > g_0_90_min); + bool c_g_0_90 = (g_0_90_max == g_0); + bool c_g_45_135= (g_45_135_max == g_45); + + float f_e_0_90 = (c_0_90 && c_45_135) ? e_0_90 : 1.0; + float f_e_45_135 = (c_0_90 && c_45_135) ? e_45_135 : 1.0; + + float w0 = (c_0_90 && c_g_0_90) ? f_e_0_90 : 0.0; + float w90 = (c_0_90 && !c_g_0_90) ? f_e_0_90 : 0.0; + float w45 = (c_45_135 && c_g_45_135) ? f_e_45_135 : 0.0; + float w135 = (c_45_135 && !c_g_45_135)? f_e_45_135 : 0.0; + + return vec4(w0, w90, w45, w135); +} + +vec4 getInterpEdgeMap(vec4 e00, vec4 e01, vec4 e10, vec4 e11, float fx, float fy) { + vec4 h0 = mix(e00, e01, fx); + vec4 h1 = mix(e10, e11, fx); + return mix(h0, h1, fy); +} + +float calcLTI(float p0, float p1, float p2, float p3, float p4, float p5, int phase_index) { + bool selector = (phase_index <= kPhaseCount / 2); + float sel = selector ? p0 : p3; + float a_min = min(min(p1, p2), sel); + float a_max = max(max(p1, p2), sel); + sel = selector ? p2 : p5; + float b_min = min(min(p3, p4), sel); + float b_max = max(max(p3, p4), sel); + + float a_cont = a_max - a_min; + float b_cont = b_max - b_min; + + float cont_ratio = max(a_cont, b_cont) / (min(a_cont, b_cont) + kEps); + return (1.0 - clamp((cont_ratio - kMinContrastRatio) * kRatioNorm, 0.0, 1.0)) * kContrastBoost; +} + +float evalPoly6(float pxl[6], int phase_int) { + phase_int = clamp(phase_int, 0, 63); + float y = 0.0; + float y_usm = 0.0; + for (int i = 0; i < 6; ++i) { + y += coefScale[phase_int * 6 + i] * pxl[i]; + y_usm += coefUsm[phase_int * 6 + i] * pxl[i]; + } + + // piece-wise ramp based on luma (NIS_SCALE_FLOAT == 1) + float y_scale = 1.0 - clamp((y - kSharpStartY) * kSharpScaleY, 0.0, 1.0); + float y_sharpness = y_scale * gSharpStrengthScale + gSharpStrengthMin; + y_usm *= y_sharpness; + + float y_sharpness_limit = (y_scale * gSharpLimitScale + gSharpLimitMin) * y; + y_usm = min(y_sharpness_limit, max(-y_sharpness_limit, y_usm)); + y_usm *= calcLTI(pxl[0], pxl[1], pxl[2], pxl[3], pxl[4], pxl[5], phase_int); + + return y + y_usm; +} + +float filterNormal(float p[6][6], int phase_x_int, int phase_y_int) { + phase_x_int = clamp(phase_x_int, 0, 63); + phase_y_int = clamp(phase_y_int, 0, 63); + float h_acc = 0.0; + for (int j = 0; j < 6; ++j) { + float v_acc = 0.0; + for (int i = 0; i < 6; ++i) { + v_acc += p[i][j] * coefScale[phase_y_int * 6 + i]; + } + h_acc += v_acc * coefScale[phase_x_int * 6 + j]; + } + return h_acc; +} + +float addDirFilters(float p[6][6], float phase_x_frac, float phase_y_frac, + int phase_x_frac_int, int phase_y_frac_int, vec4 w) { + float f = 0.0; + if (w.x > 0.0) { + // 0 deg filter + float interp0Deg[6]; + for (int i = 0; i < 6; ++i) { + interp0Deg[i] = mix(p[i][2], p[i][3], phase_x_frac); + } + f += evalPoly6(interp0Deg, phase_y_frac_int) * w.x; + } + if (w.y > 0.0) { + // 90 deg filter + float interp90Deg[6]; + for (int i = 0; i < 6; ++i) { + interp90Deg[i] = mix(p[2][i], p[3][i], phase_y_frac); + } + f += evalPoly6(interp90Deg, phase_x_frac_int) * w.y; + } + if (w.z > 0.0) { + // 45 deg filter + float pphase_b45 = 0.5 + 0.5 * (phase_x_frac - phase_y_frac); + + float temp_interp45Deg[7]; + temp_interp45Deg[1] = mix(p[2][1], p[1][2], pphase_b45); + temp_interp45Deg[3] = mix(p[3][2], p[2][3], pphase_b45); + temp_interp45Deg[5] = mix(p[4][3], p[3][4], pphase_b45); + { + pphase_b45 = pphase_b45 - 0.5; + float a = (pphase_b45 >= 0.0) ? p[0][2] : p[2][0]; + float b = (pphase_b45 >= 0.0) ? p[1][3] : p[3][1]; + float c = (pphase_b45 >= 0.0) ? p[2][4] : p[4][2]; + float d = (pphase_b45 >= 0.0) ? p[3][5] : p[5][3]; + temp_interp45Deg[0] = mix(p[1][1], a, abs(pphase_b45)); + temp_interp45Deg[2] = mix(p[2][2], b, abs(pphase_b45)); + temp_interp45Deg[4] = mix(p[3][3], c, abs(pphase_b45)); + temp_interp45Deg[6] = mix(p[4][4], d, abs(pphase_b45)); + } + + float interp45Deg[6]; + float pphase_p45 = phase_x_frac + phase_y_frac; + if (pphase_p45 >= 1.0) { + for (int i = 0; i < 6; ++i) { + interp45Deg[i] = temp_interp45Deg[i + 1]; + } + pphase_p45 = pphase_p45 - 1.0; + } else { + for (int i = 0; i < 6; ++i) { + interp45Deg[i] = temp_interp45Deg[i]; + } + } + + f += evalPoly6(interp45Deg, int(pphase_p45 * 64.0)) * w.z; + } + if (w.w > 0.0) { + // 135 deg filter + float pphase_b135 = 0.5 * (phase_x_frac + phase_y_frac); + + float temp_interp135Deg[7]; + temp_interp135Deg[1] = mix(p[3][1], p[4][2], pphase_b135); + temp_interp135Deg[3] = mix(p[2][2], p[3][3], pphase_b135); + temp_interp135Deg[5] = mix(p[1][3], p[2][4], pphase_b135); + { + pphase_b135 = pphase_b135 - 0.5; + float a = (pphase_b135 >= 0.0) ? p[5][2] : p[3][0]; + float b = (pphase_b135 >= 0.0) ? p[4][3] : p[2][1]; + float c = (pphase_b135 >= 0.0) ? p[3][4] : p[1][2]; + float d = (pphase_b135 >= 0.0) ? p[2][5] : p[0][3]; + temp_interp135Deg[0] = mix(p[4][1], a, abs(pphase_b135)); + temp_interp135Deg[2] = mix(p[3][2], b, abs(pphase_b135)); + temp_interp135Deg[4] = mix(p[2][3], c, abs(pphase_b135)); + temp_interp135Deg[6] = mix(p[1][4], d, abs(pphase_b135)); + } + + float interp135Deg[6]; + float pphase_p135 = 1.0 + (phase_x_frac - phase_y_frac); + if (pphase_p135 >= 1.0) { + for (int i = 0; i < 6; ++i) { + interp135Deg[i] = temp_interp135Deg[i + 1]; + } + pphase_p135 = pphase_p135 - 1.0; + } else { + for (int i = 0; i < 6; ++i) { + interp135Deg[i] = temp_interp135Deg[i]; + } + } + + f += evalPoly6(interp135Deg, int(pphase_p135 * 64.0)) * w.w; + } + return f; +} + +void main() { + // Sharpness-derived params - mirror NVScalerUpdateConfig (SDR path). + float sharpness = clamp(pc.sharpness, 0.0, 1.0); + float sharpen_slider = sharpness - 0.5; + float MaxScale = (sharpen_slider >= 0.0) ? 1.25 : 1.75; + float MinScale = (sharpen_slider >= 0.0) ? 1.25 : 1.0; + float LimitScale = MinScale; + + gSharpStrengthMin = max(0.0, 0.4 + sharpen_slider * MinScale * 1.2); + float sharpStrengthMax = 1.6 + sharpen_slider * MaxScale * 1.8; + gSharpStrengthScale = sharpStrengthMax - gSharpStrengthMin; + gSharpLimitMin = max(0.1, 0.14 + sharpen_slider * LimitScale * 0.32); + float sharpLimitMax = 0.5 + sharpen_slider * LimitScale * 0.6; + gSharpLimitScale = sharpLimitMax - gSharpLimitMin; + + highp vec2 inSize = pc.ViewportInfo.zw; + highp vec2 invIn = pc.ViewportInfo.xy; + + // Source sample position in input-pixel space (output viewport cancels out). + highp float srcX = fragTexCoord.x * inSize.x - 0.5; + highp float srcY = fragTexCoord.y * inSize.y - 0.5; + highp float fsx = floor(srcX); + highp float fsy = floor(srcY); + highp float fx = srcX - fsx; + highp float fy = srcY - fsy; + int fx_int = int(fx * float(kPhaseCount)); + int fy_int = int(fy * float(kPhaseCount)); + + // 6x6 luma support: p[i][j] = luma at source texel (fsx + j - 2, fsy + i - 2). + float p[6][6]; + for (int i = 0; i < 6; ++i) { + for (int j = 0; j < 6; ++j) { + highp vec2 tc = (vec2(fsx + float(j) - 2.0, fsy + float(i) - 2.0) + 0.5) * invIn; + p[i][j] = getY(textureLod(InputTexture, tc, 0.0).rgb); + } + } + + // 2x2 edge map around the source pixel (3x3 luma window per corner). + vec4 e00 = edgeAt(p[1][1], p[1][2], p[1][3], p[2][1], p[2][2], p[2][3], p[3][1], p[3][2], p[3][3]); + vec4 e01 = edgeAt(p[1][2], p[1][3], p[1][4], p[2][2], p[2][3], p[2][4], p[3][2], p[3][3], p[3][4]); + vec4 e10 = edgeAt(p[2][1], p[2][2], p[2][3], p[3][1], p[3][2], p[3][3], p[4][1], p[4][2], p[4][3]); + vec4 e11 = edgeAt(p[2][2], p[2][3], p[2][4], p[3][2], p[3][3], p[3][4], p[4][2], p[4][3], p[4][4]); + vec4 w = getInterpEdgeMap(e00, e01, e10, e11, fx, fy); // * NIS_SCALE_INT (==1) + + float baseWeight = 1.0 - w.x - w.y - w.z - w.w; // NIS_SCALE_FLOAT - sum + float opY = filterNormal(p, fx_int, fy_int) * baseWeight; + opY += addDirFilters(p, fx, fy, fx_int, fy_int, w); + + // Bilinear color tap (coord reduces to fragTexCoord) + luma correction. + vec4 op = texture(InputTexture, fragTexCoord); + float y = getY(op.rgb); + float corr = opY - y; // * (1/NIS_SCALE_FLOAT) == 1 + op.rgb += vec3(corr); + + outColor = vec4(clamp(op.rgb, 0.0, 1.0), 1.0); +} diff --git a/app/src/main/cpp/shaders/nis3.frag b/app/src/main/cpp/shaders/nis3.frag new file mode 100644 index 0000000000..4439f7a413 --- /dev/null +++ b/app/src/main/cpp/shaders/nis3.frag @@ -0,0 +1,357 @@ +#version 450 + +// ============================================================================= +// nis3.frag (feat/nis-rewrite): nis.frag's NVScaler maths with +// - the 6x6 luma support read from the nis_luma.frag prepass (luma in alpha) +// by 9 textureGather calls instead of 36 textureLod + getY per pixel; +// - the two coefficient banks in a uniform buffer (set 1, nis_coef.h) instead +// of const arrays: indexed by the per-pixel phase, the 384-entry const arrays +// were copied into a per-pixel variable before every lookup (glslang +// OpStore %indexable), several times per pixel. +// Edge maps and filter maths are nis.frag's. Built half only (nis3_half_frag.h); +// the old set keeps nis.frag. +// ============================================================================= + +// ============================================================================= +// NVIDIA Image Scaling (NIS) - NVScaler spatial upscaler + adaptive sharpen. +// +// Ported from NVIDIA's reference NVScaler: +// NVIDIAGameWorks/NVIDIAImageScaling NIS/NIS_Scaler.h (+ NIS_Config.h) +// +// The MIT License (MIT) +// Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: MIT +// +// Adapted for the Winlator native Vulkan compositor: +// - #version 450 (Vulkan GLSL), single-pass FRAGMENT shader (the reference is +// an LDS-tiled compute shader). The block/LDS cooperative tile loads are +// replaced with direct per-fragment texture() fetches of the 6x6 luma +// support, and the edge map is computed inline from that support. The math +// (edge detection + 6-tap directional scale/USM blend) is the reference's. +// - The kPhaseCount x 6 scaler/USM coefficient banks (coef_scale, coef_usm, +// fp32 path) are BAKED below as const arrays - no second descriptor binding +// (the post dsLayout has ONE sampler at binding 0 shared by all pipelines). +// - Config-UBO reads are replaced by push constants + baked SDR constants; the +// sharpness-derived params are recomputed in-shader exactly as +// NVScalerUpdateConfig does, driven by the existing "Sharpness" slider. +// - fp32 only (NOT the fp16/bit-packed NIS_USE_HALF_PRECISION path) so there +// are no bitwise/bvec ops - Adreno-compile-safe. +// - HDR mode = None (SDR). The whole compositor chain is R8G8B8A8_UNORM and +// values are display(gamma)-encoded here, matching NIS LDR expectations. +// - Reuses upscale.vert: fragTexCoord spans [0,1] across the destination rect +// (= normalised output position). With kScaleX = inputW/outputW, the source +// sample position reduces to srcX = fragTexCoord.x*inputW - 0.5 (so the +// output viewport origin/size cancel out and are never needed here). +// +// Conventions match sgsr.frag / cas.frag: combined-image-sampler at binding 0, +// push-constant block leads with vec4 ndc (offset 0, consumed by upscale.vert), +// then ViewportInfo (xy = 1/inputSize texel size, zw = inputSize px) + sharpness. +// ============================================================================= + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as NVIDIA's +// NIS_USE_HALF_PRECISION path (pixels, weights, coefficient tables); positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + highp vec4 ViewportInfo; // xy = 1/inputSize (texel size), zw = inputSize in pixels + float sharpness; // "Sharpness" slider mapped to [0..1] (NIS sharpness) +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +// ---- SDR (HDR mode None) constants, from NVScalerUpdateConfig ----------------- +const float kDetectRatio = 2.0 * 1127.0 / 1024.0; // 2.201171875 +const float kDetectThres = 64.0 / 1024.0; // 0.0625 +const float kMinContrastRatio = 2.0; +const float kMaxContrastRatio = 10.0; +const float kRatioNorm = 1.0 / (kMaxContrastRatio - kMinContrastRatio); // 0.125 +const float kContrastBoost = 1.0; +const float kEps = 1.0 / 255.0; +const float kSharpStartY = 0.45; +const float kSharpEndY = 0.9; +const float kSharpScaleY = 1.0 / (kSharpEndY - kSharpStartY); // 2.222... +const int kPhaseCount = 64; + +// Sharpness-derived params (recomputed in main from pc.sharpness, read here). +float gSharpStrengthMin; +float gSharpStrengthScale; +float gSharpLimitMin; +float gSharpLimitScale; + +// NVIDIA NIS coef_scale / coef_usm (64 phases x 6 taps, the values nis.frag bakes), filled by the +// compositor from nis_coef.h: two vec4 per phase (taps 0-3, taps 4-5 + 2 zeros), std140. +layout(std140, set = 1, binding = 0) uniform NisCoef { + vec4 scale[128]; + vec4 usm[128]; +} nisCoef; + +float getY(vec3 rgb) { + return 0.2126 * rgb.x + 0.7152 * rgb.y + 0.0722 * rgb.z; +} + +// GetEdgeMap on a 3x3 luma window (pRC: R=row 0=top, C=col 0=left). +vec4 edgeAt(float p00, float p01, float p02, + float p10, float p11, float p12, + float p20, float p21, float p22) { + float g_0 = abs(p00 + p01 + p02 - p20 - p21 - p22); + float g_45 = abs(p10 + p00 + p01 - p21 - p22 - p12); + float g_90 = abs(p00 + p10 + p20 - p02 - p12 - p22); + float g_135 = abs(p10 + p20 + p21 - p01 - p02 - p12); + + float g_0_90_max = max(g_0, g_90); + float g_0_90_min = min(g_0, g_90); + float g_45_135_max = max(g_45, g_135); + float g_45_135_min = min(g_45, g_135); + + if (g_0_90_max + g_45_135_max == 0.0) { + return vec4(0.0); + } + + float e_0_90 = min(g_0_90_max / (g_0_90_max + g_45_135_max), 1.0); + float e_45_135 = 1.0 - e_0_90; + + bool c_0_90 = (g_0_90_max > (g_0_90_min * kDetectRatio)) && (g_0_90_max > kDetectThres) && (g_0_90_max > g_45_135_min); + bool c_45_135 = (g_45_135_max > (g_45_135_min * kDetectRatio)) && (g_45_135_max > kDetectThres) && (g_45_135_max > g_0_90_min); + bool c_g_0_90 = (g_0_90_max == g_0); + bool c_g_45_135= (g_45_135_max == g_45); + + float f_e_0_90 = (c_0_90 && c_45_135) ? e_0_90 : 1.0; + float f_e_45_135 = (c_0_90 && c_45_135) ? e_45_135 : 1.0; + + float w0 = (c_0_90 && c_g_0_90) ? f_e_0_90 : 0.0; + float w90 = (c_0_90 && !c_g_0_90) ? f_e_0_90 : 0.0; + float w45 = (c_45_135 && c_g_45_135) ? f_e_45_135 : 0.0; + float w135 = (c_45_135 && !c_g_45_135)? f_e_45_135 : 0.0; + + return vec4(w0, w90, w45, w135); +} + +vec4 getInterpEdgeMap(vec4 e00, vec4 e01, vec4 e10, vec4 e11, float fx, float fy) { + vec4 h0 = mix(e00, e01, fx); + vec4 h1 = mix(e10, e11, fx); + return mix(h0, h1, fy); +} + +float calcLTI(float p0, float p1, float p2, float p3, float p4, float p5, int phase_index) { + bool selector = (phase_index <= kPhaseCount / 2); + float sel = selector ? p0 : p3; + float a_min = min(min(p1, p2), sel); + float a_max = max(max(p1, p2), sel); + sel = selector ? p2 : p5; + float b_min = min(min(p3, p4), sel); + float b_max = max(max(p3, p4), sel); + + float a_cont = a_max - a_min; + float b_cont = b_max - b_min; + + float cont_ratio = max(a_cont, b_cont) / (min(a_cont, b_cont) + kEps); + return (1.0 - clamp((cont_ratio - kMinContrastRatio) * kRatioNorm, 0.0, 1.0)) * kContrastBoost; +} + +float evalPoly6(float pxl[6], int phase_int) { + phase_int = clamp(phase_int, 0, 63); + vec4 s0 = nisCoef.scale[phase_int * 2], s1 = nisCoef.scale[phase_int * 2 + 1]; + vec4 u0 = nisCoef.usm[phase_int * 2], u1 = nisCoef.usm[phase_int * 2 + 1]; + float y = 0.0; + y += s0.x * pxl[0]; y += s0.y * pxl[1]; y += s0.z * pxl[2]; + y += s0.w * pxl[3]; y += s1.x * pxl[4]; y += s1.y * pxl[5]; + float y_usm = 0.0; + y_usm += u0.x * pxl[0]; y_usm += u0.y * pxl[1]; y_usm += u0.z * pxl[2]; + y_usm += u0.w * pxl[3]; y_usm += u1.x * pxl[4]; y_usm += u1.y * pxl[5]; + + // piece-wise ramp based on luma (NIS_SCALE_FLOAT == 1) + float y_scale = 1.0 - clamp((y - kSharpStartY) * kSharpScaleY, 0.0, 1.0); + float y_sharpness = y_scale * gSharpStrengthScale + gSharpStrengthMin; + y_usm *= y_sharpness; + + float y_sharpness_limit = (y_scale * gSharpLimitScale + gSharpLimitMin) * y; + y_usm = min(y_sharpness_limit, max(-y_sharpness_limit, y_usm)); + y_usm *= calcLTI(pxl[0], pxl[1], pxl[2], pxl[3], pxl[4], pxl[5], phase_int); + + return y + y_usm; +} + +float filterNormal(float p[6][6], int phase_x_int, int phase_y_int) { + phase_x_int = clamp(phase_x_int, 0, 63); + phase_y_int = clamp(phase_y_int, 0, 63); + vec4 y0 = nisCoef.scale[phase_y_int * 2], y1 = nisCoef.scale[phase_y_int * 2 + 1]; + vec4 x0 = nisCoef.scale[phase_x_int * 2], x1 = nisCoef.scale[phase_x_int * 2 + 1]; + float cy[6] = float[6](y0.x, y0.y, y0.z, y0.w, y1.x, y1.y); + float cx[6] = float[6](x0.x, x0.y, x0.z, x0.w, x1.x, x1.y); + float h_acc = 0.0; + for (int j = 0; j < 6; ++j) { + float v_acc = 0.0; + for (int i = 0; i < 6; ++i) { + v_acc += p[i][j] * cy[i]; + } + h_acc += v_acc * cx[j]; + } + return h_acc; +} + +float addDirFilters(float p[6][6], float phase_x_frac, float phase_y_frac, + int phase_x_frac_int, int phase_y_frac_int, vec4 w) { + float f = 0.0; + if (w.x > 0.0) { + // 0 deg filter + float interp0Deg[6]; + for (int i = 0; i < 6; ++i) { + interp0Deg[i] = mix(p[i][2], p[i][3], phase_x_frac); + } + f += evalPoly6(interp0Deg, phase_y_frac_int) * w.x; + } + if (w.y > 0.0) { + // 90 deg filter + float interp90Deg[6]; + for (int i = 0; i < 6; ++i) { + interp90Deg[i] = mix(p[2][i], p[3][i], phase_y_frac); + } + f += evalPoly6(interp90Deg, phase_x_frac_int) * w.y; + } + if (w.z > 0.0) { + // 45 deg filter + float pphase_b45 = 0.5 + 0.5 * (phase_x_frac - phase_y_frac); + + float temp_interp45Deg[7]; + temp_interp45Deg[1] = mix(p[2][1], p[1][2], pphase_b45); + temp_interp45Deg[3] = mix(p[3][2], p[2][3], pphase_b45); + temp_interp45Deg[5] = mix(p[4][3], p[3][4], pphase_b45); + { + pphase_b45 = pphase_b45 - 0.5; + float a = (pphase_b45 >= 0.0) ? p[0][2] : p[2][0]; + float b = (pphase_b45 >= 0.0) ? p[1][3] : p[3][1]; + float c = (pphase_b45 >= 0.0) ? p[2][4] : p[4][2]; + float d = (pphase_b45 >= 0.0) ? p[3][5] : p[5][3]; + temp_interp45Deg[0] = mix(p[1][1], a, abs(pphase_b45)); + temp_interp45Deg[2] = mix(p[2][2], b, abs(pphase_b45)); + temp_interp45Deg[4] = mix(p[3][3], c, abs(pphase_b45)); + temp_interp45Deg[6] = mix(p[4][4], d, abs(pphase_b45)); + } + + float interp45Deg[6]; + float pphase_p45 = phase_x_frac + phase_y_frac; + if (pphase_p45 >= 1.0) { + for (int i = 0; i < 6; ++i) { + interp45Deg[i] = temp_interp45Deg[i + 1]; + } + pphase_p45 = pphase_p45 - 1.0; + } else { + for (int i = 0; i < 6; ++i) { + interp45Deg[i] = temp_interp45Deg[i]; + } + } + + f += evalPoly6(interp45Deg, int(pphase_p45 * 64.0)) * w.z; + } + if (w.w > 0.0) { + // 135 deg filter + float pphase_b135 = 0.5 * (phase_x_frac + phase_y_frac); + + float temp_interp135Deg[7]; + temp_interp135Deg[1] = mix(p[3][1], p[4][2], pphase_b135); + temp_interp135Deg[3] = mix(p[2][2], p[3][3], pphase_b135); + temp_interp135Deg[5] = mix(p[1][3], p[2][4], pphase_b135); + { + pphase_b135 = pphase_b135 - 0.5; + float a = (pphase_b135 >= 0.0) ? p[5][2] : p[3][0]; + float b = (pphase_b135 >= 0.0) ? p[4][3] : p[2][1]; + float c = (pphase_b135 >= 0.0) ? p[3][4] : p[1][2]; + float d = (pphase_b135 >= 0.0) ? p[2][5] : p[0][3]; + temp_interp135Deg[0] = mix(p[4][1], a, abs(pphase_b135)); + temp_interp135Deg[2] = mix(p[3][2], b, abs(pphase_b135)); + temp_interp135Deg[4] = mix(p[2][3], c, abs(pphase_b135)); + temp_interp135Deg[6] = mix(p[1][4], d, abs(pphase_b135)); + } + + float interp135Deg[6]; + float pphase_p135 = 1.0 + (phase_x_frac - phase_y_frac); + if (pphase_p135 >= 1.0) { + for (int i = 0; i < 6; ++i) { + interp135Deg[i] = temp_interp135Deg[i + 1]; + } + pphase_p135 = pphase_p135 - 1.0; + } else { + for (int i = 0; i < 6; ++i) { + interp135Deg[i] = temp_interp135Deg[i]; + } + } + + f += evalPoly6(interp135Deg, int(pphase_p135 * 64.0)) * w.w; + } + return f; +} + +void main() { + // Sharpness-derived params - mirror NVScalerUpdateConfig (SDR path). + float sharpness = clamp(pc.sharpness, 0.0, 1.0); + float sharpen_slider = sharpness - 0.5; + float MaxScale = (sharpen_slider >= 0.0) ? 1.25 : 1.75; + float MinScale = (sharpen_slider >= 0.0) ? 1.25 : 1.0; + float LimitScale = (sharpen_slider >= 0.0) ? 1.25 : 1.0; + + gSharpStrengthMin = max(0.0, 0.4 + sharpen_slider * MinScale * 1.2); + float sharpStrengthMax = 1.6 + sharpen_slider * MaxScale * 1.8; + gSharpStrengthScale = sharpStrengthMax - gSharpStrengthMin; + gSharpLimitMin = max(0.1, 0.14 + sharpen_slider * LimitScale * 0.32); + float sharpLimitMax = 0.5 + sharpen_slider * LimitScale * 0.6; + gSharpLimitScale = sharpLimitMax - gSharpLimitMin; + + highp vec2 inSize = pc.ViewportInfo.zw; + highp vec2 invIn = pc.ViewportInfo.xy; + + // Source sample position in input-pixel space (output viewport cancels out). + highp float srcX = fragTexCoord.x * inSize.x - 0.5; + highp float srcY = fragTexCoord.y * inSize.y - 0.5; + highp float fsx = floor(srcX); + highp float fsy = floor(srcY); + highp float fx = srcX - fsx; + highp float fy = srcY - fsy; + int fx_int = int(fx * float(kPhaseCount)); + int fy_int = int(fy * float(kPhaseCount)); + + // 6x6 luma support: p[i][j] = luma at source texel (fsx + j - 2, fsy + i - 2), from the + // prepass alpha. A gather at the shared corner of texels (x, y)..(x + 1, y + 1) returns + // .w = (x, y), .z = (x + 1, y), .x = (x, y + 1), .y = (x + 1, y + 1); block (bi, bj) starts + // at x = fsx - 2 + 2 bj, y = fsy - 2 + 2 bi, so its corner is (fsx + 2 bj - 1, fsy + 2 bi - 1). + // Clamp-to-edge clamps each gathered texel like the per-texel fetches did. + float p[6][6]; + for (int bi = 0; bi < 3; ++bi) { + for (int bj = 0; bj < 3; ++bj) { + highp vec2 tc = vec2(fsx + float(2 * bj - 1), fsy + float(2 * bi - 1)) * invIn; + vec4 g = textureGather(InputTexture, tc, 3); + p[2 * bi][2 * bj] = g.w; + p[2 * bi][2 * bj + 1] = g.z; + p[2 * bi + 1][2 * bj] = g.x; + p[2 * bi + 1][2 * bj + 1] = g.y; + } + } + + // 2x2 edge map around the source pixel (3x3 luma window per corner). + vec4 e00 = edgeAt(p[1][1], p[1][2], p[1][3], p[2][1], p[2][2], p[2][3], p[3][1], p[3][2], p[3][3]); + vec4 e01 = edgeAt(p[1][2], p[1][3], p[1][4], p[2][2], p[2][3], p[2][4], p[3][2], p[3][3], p[3][4]); + vec4 e10 = edgeAt(p[2][1], p[2][2], p[2][3], p[3][1], p[3][2], p[3][3], p[4][1], p[4][2], p[4][3]); + vec4 e11 = edgeAt(p[2][2], p[2][3], p[2][4], p[3][2], p[3][3], p[3][4], p[4][2], p[4][3], p[4][4]); + vec4 w = getInterpEdgeMap(e00, e01, e10, e11, fx, fy); // * NIS_SCALE_INT (==1) + + float baseWeight = 1.0 - w.x - w.y - w.z - w.w; // NIS_SCALE_FLOAT - sum + float opY = filterNormal(p, fx_int, fy_int) * baseWeight; + opY += addDirFilters(p, fx, fy, fx_int, fy_int, w); + + // Bilinear color tap from the prepass rgb (= the game image) + luma correction. + vec4 op = texture(InputTexture, fragTexCoord); + float y = getY(op.rgb); + float corr = opY - y; // * (1/NIS_SCALE_FLOAT) == 1 + op.rgb += vec3(corr); + + outColor = vec4(clamp(op.rgb, 0.0, 1.0), 1.0); +} diff --git a/app/src/main/cpp/shaders/nis3_half_frag.h b/app/src/main/cpp/shaders/nis3_half_frag.h new file mode 100644 index 0000000000..7603498099 --- /dev/null +++ b/app/src/main/cpp/shaders/nis3_half_frag.h @@ -0,0 +1,1364 @@ + // 1116.2.0 + #pragma once +const uint32_t nis3_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x000005a2,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000462,0x00000595,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00050005,0x0000000b,0x59746567,0x33667628,0x0000003b,0x00030005,0x0000000a, + 0x00626772,0x000b0005,0x00000019,0x65676465,0x66287441,0x31663b31,0x3b31663b,0x663b3166, + 0x31663b31,0x3b31663b,0x663b3166,0x00003b31,0x00030005,0x00000010,0x00303070,0x00030005, + 0x00000011,0x00313070,0x00030005,0x00000012,0x00323070,0x00030005,0x00000013,0x00303170, + 0x00030005,0x00000014,0x00313170,0x00030005,0x00000015,0x00323170,0x00030005,0x00000016, + 0x00303270,0x00030005,0x00000017,0x00313270,0x00030005,0x00000018,0x00323270,0x000c0005, + 0x00000023,0x49746567,0x7265746e,0x67644570,0x70614d65,0x34667628,0x3466763b,0x3466763b, + 0x3466763b,0x3b31663b,0x003b3166,0x00030005,0x0000001d,0x00303065,0x00030005,0x0000001e, + 0x00313065,0x00030005,0x0000001f,0x00303165,0x00030005,0x00000020,0x00313165,0x00030005, + 0x00000021,0x00007866,0x00030005,0x00000022,0x00007966,0x000a0005,0x0000002f,0x636c6163, + 0x2849544c,0x663b3166,0x31663b31,0x3b31663b,0x663b3166,0x31693b31,0x0000003b,0x00030005, + 0x00000028,0x00003070,0x00030005,0x00000029,0x00003170,0x00030005,0x0000002a,0x00003270, + 0x00030005,0x0000002b,0x00003370,0x00030005,0x0000002c,0x00003470,0x00030005,0x0000002d, + 0x00003570,0x00050005,0x0000002e,0x73616870,0x6e695f65,0x00786564,0x00070005,0x00000038, + 0x6c617665,0x796c6f50,0x31662836,0x3b5d365b,0x003b3169,0x00030005,0x00000036,0x006c7870, + 0x00050005,0x00000037,0x73616870,0x6e695f65,0x00000074,0x000a0005,0x00000040,0x746c6966, + 0x6f4e7265,0x6c616d72,0x5b316628,0x365b5d36,0x31693b5d,0x3b31693b,0x00000000,0x00030005, + 0x0000003d,0x00000070,0x00050005,0x0000003e,0x73616870,0x5f785f65,0x00746e69,0x00050005, + 0x0000003f,0x73616870,0x5f795f65,0x00746e69,0x000c0005,0x00000049,0x44646461,0x69467269, + 0x7265746c,0x31662873,0x5b5d365b,0x663b5d36,0x31663b31,0x3b31693b,0x763b3169,0x003b3466, + 0x00030005,0x00000043,0x00000070,0x00060005,0x00000044,0x73616870,0x5f785f65,0x63617266, + 0x00000000,0x00060005,0x00000045,0x73616870,0x5f795f65,0x63617266,0x00000000,0x00070005, + 0x00000046,0x73616870,0x5f785f65,0x63617266,0x746e695f,0x00000000,0x00070005,0x00000047, + 0x73616870,0x5f795f65,0x63617266,0x746e695f,0x00000000,0x00030005,0x00000048,0x00000077, + 0x00030005,0x0000005e,0x00305f67,0x00040005,0x0000006b,0x35345f67,0x00000000,0x00040005, + 0x00000078,0x30395f67,0x00000000,0x00040005,0x00000085,0x33315f67,0x00000035,0x00050005, + 0x00000092,0x5f305f67,0x6d5f3039,0x00007861,0x00050005,0x00000096,0x5f305f67,0x6d5f3039, + 0x00006e69,0x00060005,0x0000009a,0x35345f67,0x3533315f,0x78616d5f,0x00000000,0x00060005, + 0x0000009e,0x35345f67,0x3533315f,0x6e696d5f,0x00000000,0x00040005,0x000000ac,0x5f305f65, + 0x00003039,0x00050005,0x000000b4,0x35345f65,0x3533315f,0x00000000,0x00040005,0x000000b8, + 0x5f305f63,0x00003039,0x00050005,0x000000c6,0x35345f63,0x3533315f,0x00000000,0x00050005, + 0x000000d2,0x5f675f63,0x30395f30,0x00000000,0x00050005,0x000000d6,0x5f675f63,0x315f3534, + 0x00003533,0x00050005,0x000000da,0x5f655f66,0x30395f30,0x00000000,0x00050005,0x000000e0, + 0x5f655f66,0x315f3534,0x00003533,0x00030005,0x000000e6,0x00003077,0x00030005,0x000000ec, + 0x00303977,0x00030005,0x000000f3,0x00353477,0x00040005,0x000000f9,0x35333177,0x00000000, + 0x00030005,0x00000107,0x00003068,0x00030005,0x0000010d,0x00003168,0x00050005,0x0000011a, + 0x656c6573,0x726f7463,0x00000000,0x00030005,0x0000011e,0x006c6573,0x00040005,0x00000123, + 0x696d5f61,0x0000006e,0x00040005,0x00000129,0x616d5f61,0x00000078,0x00040005,0x00000133, + 0x696d5f62,0x0000006e,0x00040005,0x00000139,0x616d5f62,0x00000078,0x00040005,0x0000013f, + 0x6f635f61,0x0000746e,0x00040005,0x00000143,0x6f635f62,0x0000746e,0x00050005,0x00000147, + 0x746e6f63,0x7461725f,0x00006f69,0x00030005,0x0000015f,0x00003073,0x00040005,0x00000163, + 0x4373694e,0x0066656f,0x00050006,0x00000163,0x00000000,0x6c616373,0x00000065,0x00040006, + 0x00000163,0x00000001,0x006d7375,0x00040005,0x00000165,0x4373696e,0x0066656f,0x00030005, + 0x0000016c,0x00003173,0x00030005,0x00000173,0x00003075,0x00030005,0x00000178,0x00003175, + 0x00030005,0x0000017e,0x00000079,0x00040005,0x000001ad,0x73755f79,0x0000006d,0x00040005, + 0x000001d8,0x63735f79,0x00656c61,0x00050005,0x000001e0,0x68735f79,0x6e707261,0x00737365, + 0x00070005,0x000001e3,0x61685367,0x74537072,0x676e6572,0x63536874,0x00656c61,0x00070005, + 0x000001e6,0x61685367,0x74537072,0x676e6572,0x694d6874,0x0000006e,0x00070005,0x000001ec, + 0x68735f79,0x6e707261,0x5f737365,0x696d696c,0x00000074,0x00070005,0x000001ee,0x61685367, + 0x694c7072,0x5374696d,0x656c6163,0x00000000,0x00060005,0x000001f1,0x61685367,0x694c7072, + 0x4d74696d,0x00006e69,0x00040005,0x000001fc,0x61726170,0x0000006d,0x00040005,0x000001ff, + 0x61726170,0x0000006d,0x00040005,0x00000202,0x61726170,0x0000006d,0x00040005,0x00000205, + 0x61726170,0x0000006d,0x00040005,0x00000208,0x61726170,0x0000006d,0x00040005,0x0000020b, + 0x61726170,0x0000006d,0x00040005,0x0000020e,0x61726170,0x0000006d,0x00030005,0x0000021c, + 0x00003079,0x00030005,0x00000221,0x00003179,0x00030005,0x00000227,0x00003078,0x00030005, + 0x0000022c,0x00003178,0x00030005,0x00000232,0x00007963,0x00030005,0x00000240,0x00007863, + 0x00040005,0x0000024e,0x63615f68,0x00000063,0x00030005,0x0000024f,0x0000006a,0x00040005, + 0x00000258,0x63615f76,0x00000063,0x00030005,0x00000259,0x00000069,0x00030005,0x00000279, + 0x00000066,0x00030005,0x0000027f,0x00000069,0x00050005,0x00000287,0x65746e69,0x44307072, + 0x00006765,0x00040005,0x00000294,0x61726170,0x0000006d,0x00040005,0x00000296,0x61726170, + 0x0000006d,0x00030005,0x000002a3,0x00000069,0x00050005,0x000002ab,0x65746e69,0x30397072, + 0x00676544,0x00040005,0x000002b8,0x61726170,0x0000006d,0x00040005,0x000002ba,0x61726170, + 0x0000006d,0x00050005,0x000002c7,0x61687070,0x625f6573,0x00003534,0x00070005,0x000002d1, + 0x706d6574,0x746e695f,0x34707265,0x67654435,0x00000000,0x00030005,0x000002e9,0x00000061, + 0x00030005,0x000002f5,0x00000062,0x00030005,0x00000301,0x00000063,0x00030005,0x0000030d, + 0x00000064,0x00050005,0x00000335,0x61687070,0x705f6573,0x00003534,0x00030005,0x0000033d, + 0x00000069,0x00050005,0x00000345,0x65746e69,0x35347072,0x00676544,0x00030005,0x00000351, + 0x00000069,0x00040005,0x00000364,0x61726170,0x0000006d,0x00040005,0x00000366,0x61726170, + 0x0000006d,0x00050005,0x00000372,0x61687070,0x625f6573,0x00353331,0x00070005,0x00000377, + 0x706d6574,0x746e695f,0x31707265,0x65443533,0x00000067,0x00030005,0x0000038f,0x00000061, + 0x00030005,0x0000039b,0x00000062,0x00030005,0x000003a7,0x00000063,0x00030005,0x000003b3, + 0x00000064,0x00050005,0x000003db,0x61687070,0x705f6573,0x00353331,0x00030005,0x000003e4, + 0x00000069,0x00060005,0x000003ec,0x65746e69,0x33317072,0x67654435,0x00000000,0x00030005, + 0x000003f8,0x00000069,0x00040005,0x0000040a,0x61726170,0x0000006d,0x00040005,0x0000040c, + 0x61726170,0x0000006d,0x00050005,0x00000416,0x72616873,0x73656e70,0x00000073,0x00030005, + 0x00000417,0x00004350,0x00040006,0x00000417,0x00000000,0x0063646e,0x00070006,0x00000417, + 0x00000001,0x77656956,0x74726f70,0x6f666e49,0x00000000,0x00060006,0x00000417,0x00000002, + 0x72616873,0x73656e70,0x00000073,0x00030005,0x00000419,0x00006370,0x00060005,0x0000041e, + 0x72616873,0x5f6e6570,0x64696c73,0x00007265,0x00050005,0x00000421,0x5378614d,0x656c6163, + 0x00000000,0x00050005,0x00000427,0x536e694d,0x656c6163,0x00000000,0x00050005,0x0000042b, + 0x696d694c,0x61635374,0x0000656c,0x00070005,0x00000437,0x72616873,0x72745370,0x74676e65, + 0x78614d68,0x00000000,0x00060005,0x0000044b,0x72616873,0x6d694c70,0x614d7469,0x00000078, + 0x00040005,0x00000457,0x69536e69,0x0000657a,0x00040005,0x0000045c,0x49766e69,0x0000006e, + 0x00040005,0x00000460,0x58637273,0x00000000,0x00060005,0x00000462,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00040005,0x0000046a,0x59637273,0x00000000,0x00030005,0x00000471, + 0x00787366,0x00030005,0x00000474,0x00797366,0x00030005,0x00000477,0x00007866,0x00030005, + 0x0000047b,0x00007966,0x00040005,0x0000047f,0x695f7866,0x0000746e,0x00040005,0x00000483, + 0x695f7966,0x0000746e,0x00030005,0x00000487,0x00006962,0x00030005,0x0000048f,0x00006a62, + 0x00030005,0x00000497,0x00006374,0x00030005,0x000004a7,0x00000067,0x00060005,0x000004ab, + 0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x000004af,0x00000070,0x00030005, + 0x000004d4,0x00303065,0x00040005,0x000004d5,0x61726170,0x0000006d,0x00040005,0x000004d8, + 0x61726170,0x0000006d,0x00040005,0x000004db,0x61726170,0x0000006d,0x00040005,0x000004de, + 0x61726170,0x0000006d,0x00040005,0x000004e1,0x61726170,0x0000006d,0x00040005,0x000004e4, + 0x61726170,0x0000006d,0x00040005,0x000004e7,0x61726170,0x0000006d,0x00040005,0x000004ea, + 0x61726170,0x0000006d,0x00040005,0x000004ed,0x61726170,0x0000006d,0x00030005,0x000004f1, + 0x00313065,0x00040005,0x000004f2,0x61726170,0x0000006d,0x00040005,0x000004f5,0x61726170, + 0x0000006d,0x00040005,0x000004f8,0x61726170,0x0000006d,0x00040005,0x000004fb,0x61726170, + 0x0000006d,0x00040005,0x000004fe,0x61726170,0x0000006d,0x00040005,0x00000501,0x61726170, + 0x0000006d,0x00040005,0x00000504,0x61726170,0x0000006d,0x00040005,0x00000507,0x61726170, + 0x0000006d,0x00040005,0x0000050a,0x61726170,0x0000006d,0x00030005,0x0000050e,0x00303165, + 0x00040005,0x0000050f,0x61726170,0x0000006d,0x00040005,0x00000512,0x61726170,0x0000006d, + 0x00040005,0x00000515,0x61726170,0x0000006d,0x00040005,0x00000518,0x61726170,0x0000006d, + 0x00040005,0x0000051b,0x61726170,0x0000006d,0x00040005,0x0000051e,0x61726170,0x0000006d, + 0x00040005,0x00000521,0x61726170,0x0000006d,0x00040005,0x00000524,0x61726170,0x0000006d, + 0x00040005,0x00000527,0x61726170,0x0000006d,0x00030005,0x0000052b,0x00313165,0x00040005, + 0x0000052c,0x61726170,0x0000006d,0x00040005,0x0000052f,0x61726170,0x0000006d,0x00040005, + 0x00000532,0x61726170,0x0000006d,0x00040005,0x00000535,0x61726170,0x0000006d,0x00040005, + 0x00000538,0x61726170,0x0000006d,0x00040005,0x0000053b,0x61726170,0x0000006d,0x00040005, + 0x0000053e,0x61726170,0x0000006d,0x00040005,0x00000541,0x61726170,0x0000006d,0x00040005, + 0x00000544,0x61726170,0x0000006d,0x00030005,0x00000548,0x00000077,0x00040005,0x00000549, + 0x61726170,0x0000006d,0x00040005,0x0000054b,0x61726170,0x0000006d,0x00040005,0x0000054d, + 0x61726170,0x0000006d,0x00040005,0x0000054f,0x61726170,0x0000006d,0x00040005,0x00000551, + 0x61726170,0x0000006d,0x00040005,0x00000553,0x61726170,0x0000006d,0x00050005,0x00000556, + 0x65736162,0x67696557,0x00007468,0x00030005,0x00000563,0x0059706f,0x00040005,0x00000564, + 0x61726170,0x0000006d,0x00040005,0x00000566,0x61726170,0x0000006d,0x00040005,0x00000568, + 0x61726170,0x0000006d,0x00040005,0x0000056d,0x61726170,0x0000006d,0x00040005,0x0000056f, + 0x61726170,0x0000006d,0x00040005,0x00000571,0x61726170,0x0000006d,0x00040005,0x00000573, + 0x61726170,0x0000006d,0x00040005,0x00000575,0x61726170,0x0000006d,0x00040005,0x00000577, + 0x61726170,0x0000006d,0x00030005,0x0000057c,0x0000706f,0x00030005,0x00000580,0x00000079, + 0x00040005,0x00000581,0x61726170,0x0000006d,0x00040005,0x00000585,0x72726f63,0x00000000, + 0x00050005,0x00000595,0x4374756f,0x726f6c6f,0x00000000,0x00030047,0x0000000a,0x00000000, + 0x00030047,0x0000000b,0x00000000,0x00030047,0x00000010,0x00000000,0x00030047,0x00000011, + 0x00000000,0x00030047,0x00000012,0x00000000,0x00030047,0x00000013,0x00000000,0x00030047, + 0x00000014,0x00000000,0x00030047,0x00000015,0x00000000,0x00030047,0x00000016,0x00000000, + 0x00030047,0x00000017,0x00000000,0x00030047,0x00000018,0x00000000,0x00030047,0x00000019, + 0x00000000,0x00030047,0x0000001d,0x00000000,0x00030047,0x0000001e,0x00000000,0x00030047, + 0x0000001f,0x00000000,0x00030047,0x00000020,0x00000000,0x00030047,0x00000021,0x00000000, + 0x00030047,0x00000022,0x00000000,0x00030047,0x00000023,0x00000000,0x00030047,0x00000028, + 0x00000000,0x00030047,0x00000029,0x00000000,0x00030047,0x0000002a,0x00000000,0x00030047, + 0x0000002b,0x00000000,0x00030047,0x0000002c,0x00000000,0x00030047,0x0000002d,0x00000000, + 0x00030047,0x0000002f,0x00000000,0x00030047,0x00000036,0x00000000,0x00030047,0x00000038, + 0x00000000,0x00030047,0x0000003d,0x00000000,0x00030047,0x00000040,0x00000000,0x00030047, + 0x00000043,0x00000000,0x00030047,0x00000044,0x00000000,0x00030047,0x00000045,0x00000000, + 0x00030047,0x00000048,0x00000000,0x00030047,0x00000049,0x00000000,0x00030047,0x0000004e, + 0x00000000,0x00030047,0x0000004f,0x00000000,0x00030047,0x00000053,0x00000000,0x00030047, + 0x00000054,0x00000000,0x00030047,0x00000055,0x00000000,0x00030047,0x00000059,0x00000000, + 0x00030047,0x0000005a,0x00000000,0x00030047,0x0000005b,0x00000000,0x00030047,0x0000005e, + 0x00000000,0x00030047,0x0000005f,0x00000000,0x00030047,0x00000060,0x00000000,0x00030047, + 0x00000061,0x00000000,0x00030047,0x00000062,0x00000000,0x00030047,0x00000063,0x00000000, + 0x00030047,0x00000064,0x00000000,0x00030047,0x00000065,0x00000000,0x00030047,0x00000066, + 0x00000000,0x00030047,0x00000067,0x00000000,0x00030047,0x00000068,0x00000000,0x00030047, + 0x00000069,0x00000000,0x00030047,0x0000006a,0x00000000,0x00030047,0x0000006b,0x00000000, + 0x00030047,0x0000006c,0x00000000,0x00030047,0x0000006d,0x00000000,0x00030047,0x0000006e, + 0x00000000,0x00030047,0x0000006f,0x00000000,0x00030047,0x00000070,0x00000000,0x00030047, + 0x00000071,0x00000000,0x00030047,0x00000072,0x00000000,0x00030047,0x00000073,0x00000000, + 0x00030047,0x00000074,0x00000000,0x00030047,0x00000075,0x00000000,0x00030047,0x00000076, + 0x00000000,0x00030047,0x00000077,0x00000000,0x00030047,0x00000078,0x00000000,0x00030047, + 0x00000079,0x00000000,0x00030047,0x0000007a,0x00000000,0x00030047,0x0000007b,0x00000000, + 0x00030047,0x0000007c,0x00000000,0x00030047,0x0000007d,0x00000000,0x00030047,0x0000007e, + 0x00000000,0x00030047,0x0000007f,0x00000000,0x00030047,0x00000080,0x00000000,0x00030047, + 0x00000081,0x00000000,0x00030047,0x00000082,0x00000000,0x00030047,0x00000083,0x00000000, + 0x00030047,0x00000084,0x00000000,0x00030047,0x00000085,0x00000000,0x00030047,0x00000086, + 0x00000000,0x00030047,0x00000087,0x00000000,0x00030047,0x00000088,0x00000000,0x00030047, + 0x00000089,0x00000000,0x00030047,0x0000008a,0x00000000,0x00030047,0x0000008b,0x00000000, + 0x00030047,0x0000008c,0x00000000,0x00030047,0x0000008d,0x00000000,0x00030047,0x0000008e, + 0x00000000,0x00030047,0x0000008f,0x00000000,0x00030047,0x00000090,0x00000000,0x00030047, + 0x00000091,0x00000000,0x00030047,0x00000092,0x00000000,0x00030047,0x00000093,0x00000000, + 0x00030047,0x00000094,0x00000000,0x00030047,0x00000095,0x00000000,0x00030047,0x00000096, + 0x00000000,0x00030047,0x00000097,0x00000000,0x00030047,0x00000098,0x00000000,0x00030047, + 0x00000099,0x00000000,0x00030047,0x0000009a,0x00000000,0x00030047,0x0000009b,0x00000000, + 0x00030047,0x0000009c,0x00000000,0x00030047,0x0000009d,0x00000000,0x00030047,0x0000009e, + 0x00000000,0x00030047,0x0000009f,0x00000000,0x00030047,0x000000a0,0x00000000,0x00030047, + 0x000000a1,0x00000000,0x00030047,0x000000a2,0x00000000,0x00030047,0x000000a3,0x00000000, + 0x00030047,0x000000a4,0x00000000,0x00030047,0x000000ac,0x00000000,0x00030047,0x000000ad, + 0x00000000,0x00030047,0x000000ae,0x00000000,0x00030047,0x000000af,0x00000000,0x00030047, + 0x000000b0,0x00000000,0x00030047,0x000000b1,0x00000000,0x00030047,0x000000b2,0x00000000, + 0x00030047,0x000000b3,0x00000000,0x00030047,0x000000b4,0x00000000,0x00030047,0x000000b5, + 0x00000000,0x00030047,0x000000b6,0x00000000,0x00030047,0x000000b9,0x00000000,0x00030047, + 0x000000ba,0x00000000,0x00030047,0x000000bb,0x00000000,0x00030047,0x000000bc,0x00000000, + 0x00030047,0x000000be,0x00000000,0x00030047,0x000000bf,0x00000000,0x00030047,0x000000c2, + 0x00000000,0x00030047,0x000000c3,0x00000000,0x00030047,0x000000c7,0x00000000,0x00030047, + 0x000000c8,0x00000000,0x00030047,0x000000c9,0x00000000,0x00030047,0x000000cb,0x00000000, + 0x00030047,0x000000ce,0x00000000,0x00030047,0x000000cf,0x00000000,0x00030047,0x000000d3, + 0x00000000,0x00030047,0x000000d4,0x00000000,0x00030047,0x000000d7,0x00000000,0x00030047, + 0x000000d8,0x00000000,0x00030047,0x000000da,0x00000000,0x00030047,0x000000de,0x00000000, + 0x00030047,0x000000e0,0x00000000,0x00030047,0x000000e4,0x00000000,0x00030047,0x000000e6, + 0x00000000,0x00030047,0x000000ea,0x00000000,0x00030047,0x000000ec,0x00000000,0x00030047, + 0x000000f1,0x00000000,0x00030047,0x000000f3,0x00000000,0x00030047,0x000000f7,0x00000000, + 0x00030047,0x000000f9,0x00000000,0x00030047,0x000000fe,0x00000000,0x00030047,0x00000100, + 0x00000000,0x00030047,0x00000101,0x00000000,0x00030047,0x00000102,0x00000000,0x00030047, + 0x00000103,0x00000000,0x00030047,0x00000104,0x00000000,0x00030047,0x00000107,0x00000000, + 0x00030047,0x00000108,0x00000000,0x00030047,0x00000109,0x00000000,0x00030047,0x0000010a, + 0x00000000,0x00030047,0x0000010b,0x00000000,0x00030047,0x0000010c,0x00000000,0x00030047, + 0x0000010d,0x00000000,0x00030047,0x0000010e,0x00000000,0x00030047,0x0000010f,0x00000000, + 0x00030047,0x00000110,0x00000000,0x00030047,0x00000111,0x00000000,0x00030047,0x00000112, + 0x00000000,0x00030047,0x00000113,0x00000000,0x00030047,0x00000114,0x00000000,0x00030047, + 0x00000115,0x00000000,0x00030047,0x00000116,0x00000000,0x00030047,0x00000117,0x00000000, + 0x00030047,0x0000011e,0x00000000,0x00030047,0x00000120,0x00000000,0x00030047,0x00000121, + 0x00000000,0x00030047,0x00000123,0x00000000,0x00030047,0x00000124,0x00000000,0x00030047, + 0x00000125,0x00000000,0x00030047,0x00000126,0x00000000,0x00030047,0x00000127,0x00000000, + 0x00030047,0x00000128,0x00000000,0x00030047,0x00000129,0x00000000,0x00030047,0x0000012a, + 0x00000000,0x00030047,0x0000012b,0x00000000,0x00030047,0x0000012c,0x00000000,0x00030047, + 0x0000012d,0x00000000,0x00030047,0x0000012e,0x00000000,0x00030047,0x00000130,0x00000000, + 0x00030047,0x00000131,0x00000000,0x00030047,0x00000133,0x00000000,0x00030047,0x00000134, + 0x00000000,0x00030047,0x00000135,0x00000000,0x00030047,0x00000136,0x00000000,0x00030047, + 0x00000137,0x00000000,0x00030047,0x00000138,0x00000000,0x00030047,0x00000139,0x00000000, + 0x00030047,0x0000013a,0x00000000,0x00030047,0x0000013b,0x00000000,0x00030047,0x0000013c, + 0x00000000,0x00030047,0x0000013d,0x00000000,0x00030047,0x0000013e,0x00000000,0x00030047, + 0x0000013f,0x00000000,0x00030047,0x00000140,0x00000000,0x00030047,0x00000141,0x00000000, + 0x00030047,0x00000142,0x00000000,0x00030047,0x00000143,0x00000000,0x00030047,0x00000144, + 0x00000000,0x00030047,0x00000145,0x00000000,0x00030047,0x00000146,0x00000000,0x00030047, + 0x00000147,0x00000000,0x00030047,0x00000148,0x00000000,0x00030047,0x00000149,0x00000000, + 0x00030047,0x0000014a,0x00000000,0x00030047,0x0000014b,0x00000000,0x00030047,0x0000014c, + 0x00000000,0x00030047,0x0000014d,0x00000000,0x00030047,0x0000014e,0x00000000,0x00030047, + 0x0000014f,0x00000000,0x00030047,0x00000150,0x00000000,0x00030047,0x00000151,0x00000000, + 0x00030047,0x00000152,0x00000000,0x00030047,0x00000153,0x00000000,0x00030047,0x00000154, + 0x00000000,0x00030047,0x00000155,0x00000000,0x00030047,0x00000156,0x00000000,0x00030047, + 0x00000157,0x00000000,0x00030047,0x00000158,0x00000000,0x00030047,0x0000015f,0x00000000, + 0x00040047,0x00000161,0x00000006,0x00000010,0x00040047,0x00000162,0x00000006,0x00000010, + 0x00030047,0x00000163,0x00000002,0x00040048,0x00000163,0x00000000,0x00000000,0x00050048, + 0x00000163,0x00000000,0x00000023,0x00000000,0x00040048,0x00000163,0x00000001,0x00000000, + 0x00050048,0x00000163,0x00000001,0x00000023,0x00000800,0x00040047,0x00000165,0x00000021, + 0x00000000,0x00040047,0x00000165,0x00000022,0x00000001,0x00030047,0x0000016b,0x00000000, + 0x00030047,0x0000016c,0x00000000,0x00030047,0x00000172,0x00000000,0x00030047,0x00000173, + 0x00000000,0x00030047,0x00000177,0x00000000,0x00030047,0x00000178,0x00000000,0x00030047, + 0x0000017d,0x00000000,0x00030047,0x0000017e,0x00000000,0x00030047,0x00000180,0x00000000, + 0x00030047,0x00000182,0x00000000,0x00030047,0x00000183,0x00000000,0x00030047,0x00000184, + 0x00000000,0x00030047,0x00000185,0x00000000,0x00030047,0x00000187,0x00000000,0x00030047, + 0x00000189,0x00000000,0x00030047,0x0000018a,0x00000000,0x00030047,0x0000018b,0x00000000, + 0x00030047,0x0000018c,0x00000000,0x00030047,0x0000018e,0x00000000,0x00030047,0x00000190, + 0x00000000,0x00030047,0x00000191,0x00000000,0x00030047,0x00000192,0x00000000,0x00030047, + 0x00000193,0x00000000,0x00030047,0x00000196,0x00000000,0x00030047,0x00000199,0x00000000, + 0x00030047,0x0000019a,0x00000000,0x00030047,0x0000019b,0x00000000,0x00030047,0x0000019c, + 0x00000000,0x00030047,0x0000019e,0x00000000,0x00030047,0x000001a1,0x00000000,0x00030047, + 0x000001a2,0x00000000,0x00030047,0x000001a3,0x00000000,0x00030047,0x000001a4,0x00000000, + 0x00030047,0x000001a6,0x00000000,0x00030047,0x000001a9,0x00000000,0x00030047,0x000001aa, + 0x00000000,0x00030047,0x000001ab,0x00000000,0x00030047,0x000001ac,0x00000000,0x00030047, + 0x000001ad,0x00000000,0x00030047,0x000001af,0x00000000,0x00030047,0x000001b1,0x00000000, + 0x00030047,0x000001b2,0x00000000,0x00030047,0x000001b3,0x00000000,0x00030047,0x000001b4, + 0x00000000,0x00030047,0x000001b6,0x00000000,0x00030047,0x000001b8,0x00000000,0x00030047, + 0x000001b9,0x00000000,0x00030047,0x000001ba,0x00000000,0x00030047,0x000001bb,0x00000000, + 0x00030047,0x000001bd,0x00000000,0x00030047,0x000001bf,0x00000000,0x00030047,0x000001c0, + 0x00000000,0x00030047,0x000001c1,0x00000000,0x00030047,0x000001c2,0x00000000,0x00030047, + 0x000001c4,0x00000000,0x00030047,0x000001c6,0x00000000,0x00030047,0x000001c7,0x00000000, + 0x00030047,0x000001c8,0x00000000,0x00030047,0x000001c9,0x00000000,0x00030047,0x000001cb, + 0x00000000,0x00030047,0x000001cd,0x00000000,0x00030047,0x000001ce,0x00000000,0x00030047, + 0x000001cf,0x00000000,0x00030047,0x000001d0,0x00000000,0x00030047,0x000001d2,0x00000000, + 0x00030047,0x000001d4,0x00000000,0x00030047,0x000001d5,0x00000000,0x00030047,0x000001d6, + 0x00000000,0x00030047,0x000001d7,0x00000000,0x00030047,0x000001d8,0x00000000,0x00030047, + 0x000001d9,0x00000000,0x00030047,0x000001da,0x00000000,0x00030047,0x000001db,0x00000000, + 0x00030047,0x000001dc,0x00000000,0x00030047,0x000001dd,0x00000000,0x00030047,0x000001de, + 0x00000000,0x00030047,0x000001df,0x00000000,0x00030047,0x000001e0,0x00000000,0x00030047, + 0x000001e1,0x00000000,0x00030047,0x000001e3,0x00000000,0x00030047,0x000001e4,0x00000000, + 0x00030047,0x000001e5,0x00000000,0x00030047,0x000001e6,0x00000000,0x00030047,0x000001e7, + 0x00000000,0x00030047,0x000001e8,0x00000000,0x00030047,0x000001e9,0x00000000,0x00030047, + 0x000001ea,0x00000000,0x00030047,0x000001eb,0x00000000,0x00030047,0x000001ec,0x00000000, + 0x00030047,0x000001ed,0x00000000,0x00030047,0x000001ee,0x00000000,0x00030047,0x000001ef, + 0x00000000,0x00030047,0x000001f0,0x00000000,0x00030047,0x000001f1,0x00000000,0x00030047, + 0x000001f2,0x00000000,0x00030047,0x000001f3,0x00000000,0x00030047,0x000001f4,0x00000000, + 0x00030047,0x000001f5,0x00000000,0x00030047,0x000001f6,0x00000000,0x00030047,0x000001f7, + 0x00000000,0x00030047,0x000001f8,0x00000000,0x00030047,0x000001f9,0x00000000,0x00030047, + 0x000001fa,0x00000000,0x00030047,0x000001fb,0x00000000,0x00030047,0x000001fc,0x00000000, + 0x00030047,0x000001fe,0x00000000,0x00030047,0x000001ff,0x00000000,0x00030047,0x00000201, + 0x00000000,0x00030047,0x00000202,0x00000000,0x00030047,0x00000204,0x00000000,0x00030047, + 0x00000205,0x00000000,0x00030047,0x00000207,0x00000000,0x00030047,0x00000208,0x00000000, + 0x00030047,0x0000020a,0x00000000,0x00030047,0x0000020b,0x00000000,0x00030047,0x0000020d, + 0x00000000,0x00030047,0x00000210,0x00000000,0x00030047,0x00000211,0x00000000,0x00030047, + 0x00000212,0x00000000,0x00030047,0x00000213,0x00000000,0x00030047,0x00000214,0x00000000, + 0x00030047,0x00000215,0x00000000,0x00030047,0x0000021c,0x00000000,0x00030047,0x00000220, + 0x00000000,0x00030047,0x00000221,0x00000000,0x00030047,0x00000226,0x00000000,0x00030047, + 0x00000227,0x00000000,0x00030047,0x0000022b,0x00000000,0x00030047,0x0000022c,0x00000000, + 0x00030047,0x00000231,0x00000000,0x00030047,0x00000232,0x00000000,0x00030047,0x00000234, + 0x00000000,0x00030047,0x00000236,0x00000000,0x00030047,0x00000238,0x00000000,0x00030047, + 0x0000023a,0x00000000,0x00030047,0x0000023c,0x00000000,0x00030047,0x0000023e,0x00000000, + 0x00030047,0x00000240,0x00000000,0x00030047,0x00000242,0x00000000,0x00030047,0x00000244, + 0x00000000,0x00030047,0x00000246,0x00000000,0x00030047,0x00000248,0x00000000,0x00030047, + 0x0000024a,0x00000000,0x00030047,0x0000024c,0x00000000,0x00030047,0x0000024e,0x00000000, + 0x00030047,0x00000258,0x00000000,0x00030047,0x00000264,0x00000000,0x00030047,0x00000267, + 0x00000000,0x00030047,0x00000268,0x00000000,0x00030047,0x00000269,0x00000000,0x00030047, + 0x0000026a,0x00000000,0x00030047,0x0000026d,0x00000000,0x00030047,0x00000270,0x00000000, + 0x00030047,0x00000271,0x00000000,0x00030047,0x00000272,0x00000000,0x00030047,0x00000273, + 0x00000000,0x00030047,0x00000276,0x00000000,0x00030047,0x00000279,0x00000000,0x00030047, + 0x0000027b,0x00000000,0x00030047,0x00000287,0x00000000,0x00030047,0x0000028b,0x00000000, + 0x00030047,0x0000028e,0x00000000,0x00030047,0x0000028f,0x00000000,0x00030047,0x00000290, + 0x00000000,0x00030047,0x00000294,0x00000000,0x00030047,0x00000295,0x00000000,0x00030047, + 0x00000298,0x00000000,0x00030047,0x0000029a,0x00000000,0x00030047,0x0000029b,0x00000000, + 0x00030047,0x0000029c,0x00000000,0x00030047,0x0000029d,0x00000000,0x00030047,0x0000029f, + 0x00000000,0x00030047,0x000002ab,0x00000000,0x00030047,0x000002af,0x00000000,0x00030047, + 0x000002b2,0x00000000,0x00030047,0x000002b3,0x00000000,0x00030047,0x000002b4,0x00000000, + 0x00030047,0x000002b8,0x00000000,0x00030047,0x000002b9,0x00000000,0x00030047,0x000002bc, + 0x00000000,0x00030047,0x000002be,0x00000000,0x00030047,0x000002bf,0x00000000,0x00030047, + 0x000002c0,0x00000000,0x00030047,0x000002c1,0x00000000,0x00030047,0x000002c3,0x00000000, + 0x00030047,0x000002c7,0x00000000,0x00030047,0x000002c9,0x00000000,0x00030047,0x000002ca, + 0x00000000,0x00030047,0x000002cb,0x00000000,0x00030047,0x000002cc,0x00000000,0x00030047, + 0x000002cd,0x00000000,0x00030047,0x000002d1,0x00000000,0x00030047,0x000002d3,0x00000000, + 0x00030047,0x000002d5,0x00000000,0x00030047,0x000002d6,0x00000000,0x00030047,0x000002d7, + 0x00000000,0x00030047,0x000002da,0x00000000,0x00030047,0x000002dc,0x00000000,0x00030047, + 0x000002dd,0x00000000,0x00030047,0x000002de,0x00000000,0x00030047,0x000002e1,0x00000000, + 0x00030047,0x000002e3,0x00000000,0x00030047,0x000002e4,0x00000000,0x00030047,0x000002e5, + 0x00000000,0x00030047,0x000002e7,0x00000000,0x00030047,0x000002e8,0x00000000,0x00030047, + 0x000002e9,0x00000000,0x00030047,0x000002ea,0x00000000,0x00030047,0x000002ec,0x00000000, + 0x00030047,0x000002f0,0x00000000,0x00030047,0x000002f3,0x00000000,0x00030047,0x000002f4, + 0x00000000,0x00030047,0x000002f5,0x00000000,0x00030047,0x000002f6,0x00000000,0x00030047, + 0x000002f8,0x00000000,0x00030047,0x000002fc,0x00000000,0x00030047,0x000002ff,0x00000000, + 0x00030047,0x00000300,0x00000000,0x00030047,0x00000301,0x00000000,0x00030047,0x00000302, + 0x00000000,0x00030047,0x00000304,0x00000000,0x00030047,0x00000308,0x00000000,0x00030047, + 0x0000030b,0x00000000,0x00030047,0x0000030c,0x00000000,0x00030047,0x0000030d,0x00000000, + 0x00030047,0x0000030e,0x00000000,0x00030047,0x00000310,0x00000000,0x00030047,0x00000314, + 0x00000000,0x00030047,0x00000317,0x00000000,0x00030047,0x00000318,0x00000000,0x00030047, + 0x0000031a,0x00000000,0x00030047,0x0000031b,0x00000000,0x00030047,0x0000031c,0x00000000, + 0x00030047,0x0000031d,0x00000000,0x00030047,0x0000031e,0x00000000,0x00030047,0x00000321, + 0x00000000,0x00030047,0x00000322,0x00000000,0x00030047,0x00000323,0x00000000,0x00030047, + 0x00000324,0x00000000,0x00030047,0x00000325,0x00000000,0x00030047,0x00000328,0x00000000, + 0x00030047,0x00000329,0x00000000,0x00030047,0x0000032a,0x00000000,0x00030047,0x0000032b, + 0x00000000,0x00030047,0x0000032c,0x00000000,0x00030047,0x0000032f,0x00000000,0x00030047, + 0x00000330,0x00000000,0x00030047,0x00000331,0x00000000,0x00030047,0x00000332,0x00000000, + 0x00030047,0x00000333,0x00000000,0x00030047,0x00000335,0x00000000,0x00030047,0x00000336, + 0x00000000,0x00030047,0x00000337,0x00000000,0x00030047,0x00000338,0x00000000,0x00030047, + 0x00000339,0x00000000,0x00030047,0x00000345,0x00000000,0x00030047,0x0000034a,0x00000000, + 0x00030047,0x0000034e,0x00000000,0x00030047,0x0000034f,0x00000000,0x00030047,0x0000035c, + 0x00000000,0x00030047,0x00000360,0x00000000,0x00030047,0x00000362,0x00000000,0x00030047, + 0x00000363,0x00000000,0x00030047,0x00000364,0x00000000,0x00030047,0x00000365,0x00000000, + 0x00030047,0x00000367,0x00000000,0x00030047,0x00000369,0x00000000,0x00030047,0x0000036a, + 0x00000000,0x00030047,0x0000036b,0x00000000,0x00030047,0x0000036c,0x00000000,0x00030047, + 0x0000036e,0x00000000,0x00030047,0x00000372,0x00000000,0x00030047,0x00000373,0x00000000, + 0x00030047,0x00000374,0x00000000,0x00030047,0x00000375,0x00000000,0x00030047,0x00000376, + 0x00000000,0x00030047,0x00000377,0x00000000,0x00030047,0x00000379,0x00000000,0x00030047, + 0x0000037b,0x00000000,0x00030047,0x0000037c,0x00000000,0x00030047,0x0000037d,0x00000000, + 0x00030047,0x00000380,0x00000000,0x00030047,0x00000382,0x00000000,0x00030047,0x00000383, + 0x00000000,0x00030047,0x00000384,0x00000000,0x00030047,0x00000387,0x00000000,0x00030047, + 0x00000389,0x00000000,0x00030047,0x0000038a,0x00000000,0x00030047,0x0000038b,0x00000000, + 0x00030047,0x0000038d,0x00000000,0x00030047,0x0000038e,0x00000000,0x00030047,0x0000038f, + 0x00000000,0x00030047,0x00000390,0x00000000,0x00030047,0x00000392,0x00000000,0x00030047, + 0x00000396,0x00000000,0x00030047,0x00000399,0x00000000,0x00030047,0x0000039a,0x00000000, + 0x00030047,0x0000039b,0x00000000,0x00030047,0x0000039c,0x00000000,0x00030047,0x0000039e, + 0x00000000,0x00030047,0x000003a2,0x00000000,0x00030047,0x000003a5,0x00000000,0x00030047, + 0x000003a6,0x00000000,0x00030047,0x000003a7,0x00000000,0x00030047,0x000003a8,0x00000000, + 0x00030047,0x000003aa,0x00000000,0x00030047,0x000003ae,0x00000000,0x00030047,0x000003b1, + 0x00000000,0x00030047,0x000003b2,0x00000000,0x00030047,0x000003b3,0x00000000,0x00030047, + 0x000003b4,0x00000000,0x00030047,0x000003b6,0x00000000,0x00030047,0x000003ba,0x00000000, + 0x00030047,0x000003bd,0x00000000,0x00030047,0x000003be,0x00000000,0x00030047,0x000003c0, + 0x00000000,0x00030047,0x000003c1,0x00000000,0x00030047,0x000003c2,0x00000000,0x00030047, + 0x000003c3,0x00000000,0x00030047,0x000003c4,0x00000000,0x00030047,0x000003c7,0x00000000, + 0x00030047,0x000003c8,0x00000000,0x00030047,0x000003c9,0x00000000,0x00030047,0x000003ca, + 0x00000000,0x00030047,0x000003cb,0x00000000,0x00030047,0x000003ce,0x00000000,0x00030047, + 0x000003cf,0x00000000,0x00030047,0x000003d0,0x00000000,0x00030047,0x000003d1,0x00000000, + 0x00030047,0x000003d2,0x00000000,0x00030047,0x000003d5,0x00000000,0x00030047,0x000003d6, + 0x00000000,0x00030047,0x000003d7,0x00000000,0x00030047,0x000003d8,0x00000000,0x00030047, + 0x000003d9,0x00000000,0x00030047,0x000003db,0x00000000,0x00030047,0x000003dc,0x00000000, + 0x00030047,0x000003dd,0x00000000,0x00030047,0x000003de,0x00000000,0x00030047,0x000003df, + 0x00000000,0x00030047,0x000003e0,0x00000000,0x00030047,0x000003ec,0x00000000,0x00030047, + 0x000003f1,0x00000000,0x00030047,0x000003f5,0x00000000,0x00030047,0x000003f6,0x00000000, + 0x00030047,0x00000403,0x00000000,0x00030047,0x00000407,0x00000000,0x00030047,0x00000408, + 0x00000000,0x00030047,0x00000409,0x00000000,0x00030047,0x0000040a,0x00000000,0x00030047, + 0x0000040b,0x00000000,0x00030047,0x0000040d,0x00000000,0x00030047,0x0000040f,0x00000000, + 0x00030047,0x00000410,0x00000000,0x00030047,0x00000411,0x00000000,0x00030047,0x00000412, + 0x00000000,0x00030047,0x00000413,0x00000000,0x00030047,0x00000416,0x00000000,0x00030047, + 0x00000417,0x00000002,0x00050048,0x00000417,0x00000000,0x00000023,0x00000000,0x00050048, + 0x00000417,0x00000001,0x00000023,0x00000010,0x00040048,0x00000417,0x00000002,0x00000000, + 0x00050048,0x00000417,0x00000002,0x00000023,0x00000020,0x00030047,0x0000041c,0x00000000, + 0x00030047,0x0000041d,0x00000000,0x00030047,0x0000041e,0x00000000,0x00030047,0x0000041f, + 0x00000000,0x00030047,0x00000420,0x00000000,0x00030047,0x00000421,0x00000000,0x00030047, + 0x00000422,0x00000000,0x00030047,0x00000427,0x00000000,0x00030047,0x00000428,0x00000000, + 0x00030047,0x0000042b,0x00000000,0x00030047,0x0000042c,0x00000000,0x00030047,0x00000430, + 0x00000000,0x00030047,0x00000431,0x00000000,0x00030047,0x00000432,0x00000000,0x00030047, + 0x00000434,0x00000000,0x00030047,0x00000435,0x00000000,0x00030047,0x00000436,0x00000000, + 0x00030047,0x00000437,0x00000000,0x00030047,0x00000439,0x00000000,0x00030047,0x0000043a, + 0x00000000,0x00030047,0x0000043b,0x00000000,0x00030047,0x0000043d,0x00000000,0x00030047, + 0x0000043e,0x00000000,0x00030047,0x0000043f,0x00000000,0x00030047,0x00000440,0x00000000, + 0x00030047,0x00000441,0x00000000,0x00030047,0x00000444,0x00000000,0x00030047,0x00000445, + 0x00000000,0x00030047,0x00000446,0x00000000,0x00030047,0x00000448,0x00000000,0x00030047, + 0x00000449,0x00000000,0x00030047,0x0000044a,0x00000000,0x00030047,0x0000044b,0x00000000, + 0x00030047,0x0000044c,0x00000000,0x00030047,0x0000044d,0x00000000,0x00030047,0x0000044e, + 0x00000000,0x00030047,0x00000450,0x00000000,0x00030047,0x00000451,0x00000000,0x00030047, + 0x00000452,0x00000000,0x00030047,0x00000453,0x00000000,0x00030047,0x00000454,0x00000000, + 0x00040047,0x00000462,0x0000001e,0x00000000,0x00030047,0x000004a7,0x00000000,0x00030047, + 0x000004ab,0x00000000,0x00040047,0x000004ab,0x00000021,0x00000000,0x00040047,0x000004ab, + 0x00000022,0x00000000,0x00030047,0x000004ac,0x00000000,0x00030047,0x000004ae,0x00000000, + 0x00030047,0x000004af,0x00000000,0x00030047,0x000004b5,0x00000000,0x00030047,0x000004bd, + 0x00000000,0x00030047,0x000004c5,0x00000000,0x00030047,0x000004ce,0x00000000,0x00030047, + 0x000004d4,0x00000000,0x00030047,0x000004d5,0x00000000,0x00030047,0x000004d7,0x00000000, + 0x00030047,0x000004d8,0x00000000,0x00030047,0x000004da,0x00000000,0x00030047,0x000004db, + 0x00000000,0x00030047,0x000004dd,0x00000000,0x00030047,0x000004de,0x00000000,0x00030047, + 0x000004e0,0x00000000,0x00030047,0x000004e1,0x00000000,0x00030047,0x000004e3,0x00000000, + 0x00030047,0x000004e4,0x00000000,0x00030047,0x000004e6,0x00000000,0x00030047,0x000004e7, + 0x00000000,0x00030047,0x000004e9,0x00000000,0x00030047,0x000004ea,0x00000000,0x00030047, + 0x000004ec,0x00000000,0x00030047,0x000004ed,0x00000000,0x00030047,0x000004ef,0x00000000, + 0x00030047,0x000004f0,0x00000000,0x00030047,0x000004f1,0x00000000,0x00030047,0x000004f2, + 0x00000000,0x00030047,0x000004f4,0x00000000,0x00030047,0x000004f5,0x00000000,0x00030047, + 0x000004f7,0x00000000,0x00030047,0x000004f8,0x00000000,0x00030047,0x000004fa,0x00000000, + 0x00030047,0x000004fb,0x00000000,0x00030047,0x000004fd,0x00000000,0x00030047,0x000004fe, + 0x00000000,0x00030047,0x00000500,0x00000000,0x00030047,0x00000501,0x00000000,0x00030047, + 0x00000503,0x00000000,0x00030047,0x00000504,0x00000000,0x00030047,0x00000506,0x00000000, + 0x00030047,0x00000507,0x00000000,0x00030047,0x00000509,0x00000000,0x00030047,0x0000050a, + 0x00000000,0x00030047,0x0000050c,0x00000000,0x00030047,0x0000050d,0x00000000,0x00030047, + 0x0000050e,0x00000000,0x00030047,0x0000050f,0x00000000,0x00030047,0x00000511,0x00000000, + 0x00030047,0x00000512,0x00000000,0x00030047,0x00000514,0x00000000,0x00030047,0x00000515, + 0x00000000,0x00030047,0x00000517,0x00000000,0x00030047,0x00000518,0x00000000,0x00030047, + 0x0000051a,0x00000000,0x00030047,0x0000051b,0x00000000,0x00030047,0x0000051d,0x00000000, + 0x00030047,0x0000051e,0x00000000,0x00030047,0x00000520,0x00000000,0x00030047,0x00000521, + 0x00000000,0x00030047,0x00000523,0x00000000,0x00030047,0x00000524,0x00000000,0x00030047, + 0x00000526,0x00000000,0x00030047,0x00000527,0x00000000,0x00030047,0x00000529,0x00000000, + 0x00030047,0x0000052a,0x00000000,0x00030047,0x0000052b,0x00000000,0x00030047,0x0000052c, + 0x00000000,0x00030047,0x0000052e,0x00000000,0x00030047,0x0000052f,0x00000000,0x00030047, + 0x00000531,0x00000000,0x00030047,0x00000532,0x00000000,0x00030047,0x00000534,0x00000000, + 0x00030047,0x00000535,0x00000000,0x00030047,0x00000537,0x00000000,0x00030047,0x00000538, + 0x00000000,0x00030047,0x0000053a,0x00000000,0x00030047,0x0000053b,0x00000000,0x00030047, + 0x0000053d,0x00000000,0x00030047,0x0000053e,0x00000000,0x00030047,0x00000540,0x00000000, + 0x00030047,0x00000541,0x00000000,0x00030047,0x00000543,0x00000000,0x00030047,0x00000544, + 0x00000000,0x00030047,0x00000546,0x00000000,0x00030047,0x00000547,0x00000000,0x00030047, + 0x00000548,0x00000000,0x00030047,0x00000549,0x00000000,0x00030047,0x0000054a,0x00000000, + 0x00030047,0x0000054b,0x00000000,0x00030047,0x0000054c,0x00000000,0x00030047,0x0000054d, + 0x00000000,0x00030047,0x0000054e,0x00000000,0x00030047,0x0000054f,0x00000000,0x00030047, + 0x00000550,0x00000000,0x00030047,0x00000551,0x00000000,0x00030047,0x00000553,0x00000000, + 0x00030047,0x00000555,0x00000000,0x00030047,0x00000556,0x00000000,0x00030047,0x00000558, + 0x00000000,0x00030047,0x00000559,0x00000000,0x00030047,0x0000055b,0x00000000,0x00030047, + 0x0000055c,0x00000000,0x00030047,0x0000055e,0x00000000,0x00030047,0x0000055f,0x00000000, + 0x00030047,0x00000561,0x00000000,0x00030047,0x00000562,0x00000000,0x00030047,0x00000563, + 0x00000000,0x00030047,0x00000564,0x00000000,0x00030047,0x00000565,0x00000000,0x00030047, + 0x0000056a,0x00000000,0x00030047,0x0000056b,0x00000000,0x00030047,0x0000056c,0x00000000, + 0x00030047,0x0000056d,0x00000000,0x00030047,0x0000056e,0x00000000,0x00030047,0x0000056f, + 0x00000000,0x00030047,0x00000571,0x00000000,0x00030047,0x00000577,0x00000000,0x00030047, + 0x00000578,0x00000000,0x00030047,0x00000579,0x00000000,0x00030047,0x0000057a,0x00000000, + 0x00030047,0x0000057b,0x00000000,0x00030047,0x0000057c,0x00000000,0x00030047,0x0000057d, + 0x00000000,0x00030047,0x0000057f,0x00000000,0x00030047,0x00000580,0x00000000,0x00030047, + 0x00000581,0x00000000,0x00030047,0x00000582,0x00000000,0x00030047,0x00000583,0x00000000, + 0x00030047,0x00000584,0x00000000,0x00030047,0x00000585,0x00000000,0x00030047,0x00000586, + 0x00000000,0x00030047,0x00000587,0x00000000,0x00030047,0x00000588,0x00000000,0x00030047, + 0x00000589,0x00000000,0x00030047,0x0000058a,0x00000000,0x00030047,0x0000058b,0x00000000, + 0x00030047,0x0000058c,0x00000000,0x00030047,0x0000058d,0x00000000,0x00030047,0x00000595, + 0x00000000,0x00040047,0x00000595,0x0000001e,0x00000000,0x00030047,0x00000596,0x00000000, + 0x00030047,0x00000597,0x00000000,0x00030047,0x00000598,0x00000000,0x00030047,0x00000599, + 0x00000000,0x00030047,0x0000059a,0x00000000,0x00030047,0x0000059b,0x00000000,0x00030047, + 0x0000059c,0x00000000,0x00030047,0x0000059d,0x00000000,0x00030047,0x0000059e,0x00000000, + 0x00030047,0x0000059f,0x00000000,0x00030047,0x000005a0,0x00000000,0x00020013,0x00000002, + 0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007, + 0x00000006,0x00000003,0x00040020,0x00000008,0x00000007,0x00000007,0x00040021,0x00000009, + 0x00000006,0x00000008,0x00040020,0x0000000d,0x00000007,0x00000006,0x00040017,0x0000000e, + 0x00000006,0x00000004,0x000c0021,0x0000000f,0x0000000e,0x0000000d,0x0000000d,0x0000000d, + 0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x00040020,0x0000001b, + 0x00000007,0x0000000e,0x00090021,0x0000001c,0x0000000e,0x0000001b,0x0000001b,0x0000001b, + 0x0000001b,0x0000000d,0x0000000d,0x00040015,0x00000025,0x00000020,0x00000001,0x00040020, + 0x00000026,0x00000007,0x00000025,0x000a0021,0x00000027,0x00000006,0x0000000d,0x0000000d, + 0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x00000026,0x00040015,0x00000031,0x00000020, + 0x00000000,0x0004002b,0x00000031,0x00000032,0x00000006,0x0004001c,0x00000033,0x00000006, + 0x00000032,0x00040020,0x00000034,0x00000007,0x00000033,0x00050021,0x00000035,0x00000006, + 0x00000034,0x00000026,0x0004001c,0x0000003a,0x00000033,0x00000032,0x00040020,0x0000003b, + 0x00000007,0x0000003a,0x00060021,0x0000003c,0x00000006,0x0000003b,0x00000026,0x00000026, + 0x00090021,0x00000042,0x00000006,0x0000003b,0x0000000d,0x0000000d,0x00000026,0x00000026, + 0x0000001b,0x0004002b,0x00000006,0x0000004b,0x3e59b3d0,0x0004002b,0x00000031,0x0000004c, + 0x00000000,0x0004002b,0x00000006,0x00000050,0x3f371759,0x0004002b,0x00000031,0x00000051, + 0x00000001,0x0004002b,0x00000006,0x00000056,0x3d93dd98,0x0004002b,0x00000031,0x00000057, + 0x00000002,0x0004002b,0x00000006,0x000000a5,0x00000000,0x00020014,0x000000a6,0x0007002c, + 0x0000000e,0x000000aa,0x000000a5,0x000000a5,0x000000a5,0x000000a5,0x0004002b,0x00000006, + 0x000000b2,0x3f800000,0x00040020,0x000000b7,0x00000007,0x000000a6,0x0004002b,0x00000006, + 0x000000bb,0x400ce000,0x0004002b,0x00000006,0x000000bf,0x3d800000,0x0004002b,0x00000025, + 0x0000011c,0x00000020,0x0004002b,0x00000006,0x0000014e,0x3b808081,0x0004002b,0x00000006, + 0x00000152,0x40000000,0x0004002b,0x00000006,0x00000154,0x3e000000,0x0004002b,0x00000025, + 0x0000015c,0x00000000,0x0004002b,0x00000025,0x0000015d,0x0000003f,0x0004002b,0x00000031, + 0x00000160,0x00000080,0x0004001c,0x00000161,0x0000000e,0x00000160,0x0004001c,0x00000162, + 0x0000000e,0x00000160,0x0004001e,0x00000163,0x00000161,0x00000162,0x00040020,0x00000164, + 0x00000002,0x00000163,0x0004003b,0x00000164,0x00000165,0x00000002,0x0004002b,0x00000025, + 0x00000167,0x00000002,0x00040020,0x00000169,0x00000002,0x0000000e,0x0004002b,0x00000025, + 0x0000016f,0x00000001,0x0004002b,0x00000031,0x00000194,0x00000003,0x0004002b,0x00000025, + 0x00000197,0x00000003,0x0004002b,0x00000025,0x0000019f,0x00000004,0x0004002b,0x00000025, + 0x000001a7,0x00000005,0x0004002b,0x00000006,0x000001da,0x3ee66666,0x0004002b,0x00000006, + 0x000001dc,0x400e38e4,0x00040020,0x000001e2,0x00000006,0x00000006,0x0004003b,0x000001e2, + 0x000001e3,0x00000006,0x0004003b,0x000001e2,0x000001e6,0x00000006,0x0004003b,0x000001e2, + 0x000001ee,0x00000006,0x0004003b,0x000001e2,0x000001f1,0x00000006,0x0004002b,0x00000025, + 0x00000256,0x00000006,0x0004002b,0x00000006,0x000002c8,0x3f000000,0x0004002b,0x00000031, + 0x000002ce,0x00000007,0x0004001c,0x000002cf,0x00000006,0x000002ce,0x00040020,0x000002d0, + 0x00000007,0x000002cf,0x0004002b,0x00000006,0x00000361,0x42800000,0x0005001e,0x00000417, + 0x0000000e,0x0000000e,0x00000006,0x00040020,0x00000418,0x00000009,0x00000417,0x0004003b, + 0x00000418,0x00000419,0x00000009,0x00040020,0x0000041a,0x00000009,0x00000006,0x0004002b, + 0x00000006,0x00000424,0x3fa00000,0x0004002b,0x00000006,0x00000425,0x3fe00000,0x0004002b, + 0x00000006,0x0000042f,0x3ecccccd,0x0004002b,0x00000006,0x00000433,0x3f99999a,0x0004002b, + 0x00000006,0x00000438,0x3fcccccd,0x0004002b,0x00000006,0x0000043c,0x3fe66666,0x0004002b, + 0x00000006,0x00000442,0x3dcccccd,0x0004002b,0x00000006,0x00000443,0x3e0f5c29,0x0004002b, + 0x00000006,0x00000447,0x3ea3d70a,0x0004002b,0x00000006,0x0000044f,0x3f19999a,0x00040017, + 0x00000455,0x00000006,0x00000002,0x00040020,0x00000456,0x00000007,0x00000455,0x00040020, + 0x00000458,0x00000009,0x0000000e,0x00040020,0x00000461,0x00000001,0x00000455,0x0004003b, + 0x00000461,0x00000462,0x00000001,0x00040020,0x00000463,0x00000001,0x00000006,0x00090019, + 0x000004a8,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000, + 0x0003001b,0x000004a9,0x000004a8,0x00040020,0x000004aa,0x00000000,0x000004a9,0x0004003b, + 0x000004aa,0x000004ab,0x00000000,0x00040020,0x00000594,0x00000003,0x0000000e,0x0004003b, + 0x00000594,0x00000595,0x00000003,0x0004002b,0x00000006,0x0000059f,0x41200000,0x0004002b, + 0x00000006,0x000005a0,0x3f666666,0x0004002b,0x00000025,0x000005a1,0x00000040,0x00050036, + 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x0000000d, + 0x00000416,0x00000007,0x0004003b,0x0000000d,0x0000041e,0x00000007,0x0004003b,0x0000000d, + 0x00000421,0x00000007,0x0004003b,0x0000000d,0x00000427,0x00000007,0x0004003b,0x0000000d, + 0x0000042b,0x00000007,0x0004003b,0x0000000d,0x00000437,0x00000007,0x0004003b,0x0000000d, + 0x0000044b,0x00000007,0x0004003b,0x00000456,0x00000457,0x00000007,0x0004003b,0x00000456, + 0x0000045c,0x00000007,0x0004003b,0x0000000d,0x00000460,0x00000007,0x0004003b,0x0000000d, + 0x0000046a,0x00000007,0x0004003b,0x0000000d,0x00000471,0x00000007,0x0004003b,0x0000000d, + 0x00000474,0x00000007,0x0004003b,0x0000000d,0x00000477,0x00000007,0x0004003b,0x0000000d, + 0x0000047b,0x00000007,0x0004003b,0x00000026,0x0000047f,0x00000007,0x0004003b,0x00000026, + 0x00000483,0x00000007,0x0004003b,0x00000026,0x00000487,0x00000007,0x0004003b,0x00000026, + 0x0000048f,0x00000007,0x0004003b,0x00000456,0x00000497,0x00000007,0x0004003b,0x0000001b, + 0x000004a7,0x00000007,0x0004003b,0x0000003b,0x000004af,0x00000007,0x0004003b,0x0000001b, + 0x000004d4,0x00000007,0x0004003b,0x0000000d,0x000004d5,0x00000007,0x0004003b,0x0000000d, + 0x000004d8,0x00000007,0x0004003b,0x0000000d,0x000004db,0x00000007,0x0004003b,0x0000000d, + 0x000004de,0x00000007,0x0004003b,0x0000000d,0x000004e1,0x00000007,0x0004003b,0x0000000d, + 0x000004e4,0x00000007,0x0004003b,0x0000000d,0x000004e7,0x00000007,0x0004003b,0x0000000d, + 0x000004ea,0x00000007,0x0004003b,0x0000000d,0x000004ed,0x00000007,0x0004003b,0x0000001b, + 0x000004f1,0x00000007,0x0004003b,0x0000000d,0x000004f2,0x00000007,0x0004003b,0x0000000d, + 0x000004f5,0x00000007,0x0004003b,0x0000000d,0x000004f8,0x00000007,0x0004003b,0x0000000d, + 0x000004fb,0x00000007,0x0004003b,0x0000000d,0x000004fe,0x00000007,0x0004003b,0x0000000d, + 0x00000501,0x00000007,0x0004003b,0x0000000d,0x00000504,0x00000007,0x0004003b,0x0000000d, + 0x00000507,0x00000007,0x0004003b,0x0000000d,0x0000050a,0x00000007,0x0004003b,0x0000001b, + 0x0000050e,0x00000007,0x0004003b,0x0000000d,0x0000050f,0x00000007,0x0004003b,0x0000000d, + 0x00000512,0x00000007,0x0004003b,0x0000000d,0x00000515,0x00000007,0x0004003b,0x0000000d, + 0x00000518,0x00000007,0x0004003b,0x0000000d,0x0000051b,0x00000007,0x0004003b,0x0000000d, + 0x0000051e,0x00000007,0x0004003b,0x0000000d,0x00000521,0x00000007,0x0004003b,0x0000000d, + 0x00000524,0x00000007,0x0004003b,0x0000000d,0x00000527,0x00000007,0x0004003b,0x0000001b, + 0x0000052b,0x00000007,0x0004003b,0x0000000d,0x0000052c,0x00000007,0x0004003b,0x0000000d, + 0x0000052f,0x00000007,0x0004003b,0x0000000d,0x00000532,0x00000007,0x0004003b,0x0000000d, + 0x00000535,0x00000007,0x0004003b,0x0000000d,0x00000538,0x00000007,0x0004003b,0x0000000d, + 0x0000053b,0x00000007,0x0004003b,0x0000000d,0x0000053e,0x00000007,0x0004003b,0x0000000d, + 0x00000541,0x00000007,0x0004003b,0x0000000d,0x00000544,0x00000007,0x0004003b,0x0000001b, + 0x00000548,0x00000007,0x0004003b,0x0000001b,0x00000549,0x00000007,0x0004003b,0x0000001b, + 0x0000054b,0x00000007,0x0004003b,0x0000001b,0x0000054d,0x00000007,0x0004003b,0x0000001b, + 0x0000054f,0x00000007,0x0004003b,0x0000000d,0x00000551,0x00000007,0x0004003b,0x0000000d, + 0x00000553,0x00000007,0x0004003b,0x0000000d,0x00000556,0x00000007,0x0004003b,0x0000000d, + 0x00000563,0x00000007,0x0004003b,0x0000003b,0x00000564,0x00000007,0x0004003b,0x00000026, + 0x00000566,0x00000007,0x0004003b,0x00000026,0x00000568,0x00000007,0x0004003b,0x0000003b, + 0x0000056d,0x00000007,0x0004003b,0x0000000d,0x0000056f,0x00000007,0x0004003b,0x0000000d, + 0x00000571,0x00000007,0x0004003b,0x00000026,0x00000573,0x00000007,0x0004003b,0x00000026, + 0x00000575,0x00000007,0x0004003b,0x0000001b,0x00000577,0x00000007,0x0004003b,0x0000001b, + 0x0000057c,0x00000007,0x0004003b,0x0000000d,0x00000580,0x00000007,0x0004003b,0x00000008, + 0x00000581,0x00000007,0x0004003b,0x0000000d,0x00000585,0x00000007,0x00050041,0x0000041a, + 0x0000041b,0x00000419,0x00000167,0x0004003d,0x00000006,0x0000041c,0x0000041b,0x0008000c, + 0x00000006,0x0000041d,0x00000001,0x0000002b,0x0000041c,0x000000a5,0x000000b2,0x0003003e, + 0x00000416,0x0000041d,0x0004003d,0x00000006,0x0000041f,0x00000416,0x00050083,0x00000006, + 0x00000420,0x0000041f,0x000002c8,0x0003003e,0x0000041e,0x00000420,0x0004003d,0x00000006, + 0x00000422,0x0000041e,0x000500be,0x000000a6,0x00000423,0x00000422,0x000000a5,0x000600a9, + 0x00000006,0x00000426,0x00000423,0x00000424,0x00000425,0x0003003e,0x00000421,0x00000426, + 0x0004003d,0x00000006,0x00000428,0x0000041e,0x000500be,0x000000a6,0x00000429,0x00000428, + 0x000000a5,0x000600a9,0x00000006,0x0000042a,0x00000429,0x00000424,0x000000b2,0x0003003e, + 0x00000427,0x0000042a,0x0004003d,0x00000006,0x0000042c,0x0000041e,0x000500be,0x000000a6, + 0x0000042d,0x0000042c,0x000000a5,0x000600a9,0x00000006,0x0000042e,0x0000042d,0x00000424, + 0x000000b2,0x0003003e,0x0000042b,0x0000042e,0x0004003d,0x00000006,0x00000430,0x0000041e, + 0x0004003d,0x00000006,0x00000431,0x00000427,0x00050085,0x00000006,0x00000432,0x00000430, + 0x00000431,0x00050085,0x00000006,0x00000434,0x00000432,0x00000433,0x00050081,0x00000006, + 0x00000435,0x0000042f,0x00000434,0x0007000c,0x00000006,0x00000436,0x00000001,0x00000028, + 0x000000a5,0x00000435,0x0003003e,0x000001e6,0x00000436,0x0004003d,0x00000006,0x00000439, + 0x0000041e,0x0004003d,0x00000006,0x0000043a,0x00000421,0x00050085,0x00000006,0x0000043b, + 0x00000439,0x0000043a,0x00050085,0x00000006,0x0000043d,0x0000043b,0x0000043c,0x00050081, + 0x00000006,0x0000043e,0x00000438,0x0000043d,0x0003003e,0x00000437,0x0000043e,0x0004003d, + 0x00000006,0x0000043f,0x00000437,0x0004003d,0x00000006,0x00000440,0x000001e6,0x00050083, + 0x00000006,0x00000441,0x0000043f,0x00000440,0x0003003e,0x000001e3,0x00000441,0x0004003d, + 0x00000006,0x00000444,0x0000041e,0x0004003d,0x00000006,0x00000445,0x0000042b,0x00050085, + 0x00000006,0x00000446,0x00000444,0x00000445,0x00050085,0x00000006,0x00000448,0x00000446, + 0x00000447,0x00050081,0x00000006,0x00000449,0x00000443,0x00000448,0x0007000c,0x00000006, + 0x0000044a,0x00000001,0x00000028,0x00000442,0x00000449,0x0003003e,0x000001f1,0x0000044a, + 0x0004003d,0x00000006,0x0000044c,0x0000041e,0x0004003d,0x00000006,0x0000044d,0x0000042b, + 0x00050085,0x00000006,0x0000044e,0x0000044c,0x0000044d,0x00050085,0x00000006,0x00000450, + 0x0000044e,0x0000044f,0x00050081,0x00000006,0x00000451,0x000002c8,0x00000450,0x0003003e, + 0x0000044b,0x00000451,0x0004003d,0x00000006,0x00000452,0x0000044b,0x0004003d,0x00000006, + 0x00000453,0x000001f1,0x00050083,0x00000006,0x00000454,0x00000452,0x00000453,0x0003003e, + 0x000001ee,0x00000454,0x00050041,0x00000458,0x00000459,0x00000419,0x0000016f,0x0004003d, + 0x0000000e,0x0000045a,0x00000459,0x0007004f,0x00000455,0x0000045b,0x0000045a,0x0000045a, + 0x00000002,0x00000003,0x0003003e,0x00000457,0x0000045b,0x00050041,0x00000458,0x0000045d, + 0x00000419,0x0000016f,0x0004003d,0x0000000e,0x0000045e,0x0000045d,0x0007004f,0x00000455, + 0x0000045f,0x0000045e,0x0000045e,0x00000000,0x00000001,0x0003003e,0x0000045c,0x0000045f, + 0x00050041,0x00000463,0x00000464,0x00000462,0x0000004c,0x0004003d,0x00000006,0x00000465, + 0x00000464,0x00050041,0x0000000d,0x00000466,0x00000457,0x0000004c,0x0004003d,0x00000006, + 0x00000467,0x00000466,0x00050085,0x00000006,0x00000468,0x00000465,0x00000467,0x00050083, + 0x00000006,0x00000469,0x00000468,0x000002c8,0x0003003e,0x00000460,0x00000469,0x00050041, + 0x00000463,0x0000046b,0x00000462,0x00000051,0x0004003d,0x00000006,0x0000046c,0x0000046b, + 0x00050041,0x0000000d,0x0000046d,0x00000457,0x00000051,0x0004003d,0x00000006,0x0000046e, + 0x0000046d,0x00050085,0x00000006,0x0000046f,0x0000046c,0x0000046e,0x00050083,0x00000006, + 0x00000470,0x0000046f,0x000002c8,0x0003003e,0x0000046a,0x00000470,0x0004003d,0x00000006, + 0x00000472,0x00000460,0x0006000c,0x00000006,0x00000473,0x00000001,0x00000008,0x00000472, + 0x0003003e,0x00000471,0x00000473,0x0004003d,0x00000006,0x00000475,0x0000046a,0x0006000c, + 0x00000006,0x00000476,0x00000001,0x00000008,0x00000475,0x0003003e,0x00000474,0x00000476, + 0x0004003d,0x00000006,0x00000478,0x00000460,0x0004003d,0x00000006,0x00000479,0x00000471, + 0x00050083,0x00000006,0x0000047a,0x00000478,0x00000479,0x0003003e,0x00000477,0x0000047a, + 0x0004003d,0x00000006,0x0000047c,0x0000046a,0x0004003d,0x00000006,0x0000047d,0x00000474, + 0x00050083,0x00000006,0x0000047e,0x0000047c,0x0000047d,0x0003003e,0x0000047b,0x0000047e, + 0x0004003d,0x00000006,0x00000480,0x00000477,0x00050085,0x00000006,0x00000481,0x00000480, + 0x00000361,0x0004006e,0x00000025,0x00000482,0x00000481,0x0003003e,0x0000047f,0x00000482, + 0x0004003d,0x00000006,0x00000484,0x0000047b,0x00050085,0x00000006,0x00000485,0x00000484, + 0x00000361,0x0004006e,0x00000025,0x00000486,0x00000485,0x0003003e,0x00000483,0x00000486, + 0x0003003e,0x00000487,0x0000015c,0x000200f9,0x00000488,0x000200f8,0x00000488,0x000400f6, + 0x0000048a,0x0000048b,0x00000000,0x000200f9,0x0000048c,0x000200f8,0x0000048c,0x0004003d, + 0x00000025,0x0000048d,0x00000487,0x000500b1,0x000000a6,0x0000048e,0x0000048d,0x00000197, + 0x000400fa,0x0000048e,0x00000489,0x0000048a,0x000200f8,0x00000489,0x0003003e,0x0000048f, + 0x0000015c,0x000200f9,0x00000490,0x000200f8,0x00000490,0x000400f6,0x00000492,0x00000493, + 0x00000000,0x000200f9,0x00000494,0x000200f8,0x00000494,0x0004003d,0x00000025,0x00000495, + 0x0000048f,0x000500b1,0x000000a6,0x00000496,0x00000495,0x00000197,0x000400fa,0x00000496, + 0x00000491,0x00000492,0x000200f8,0x00000491,0x0004003d,0x00000006,0x00000498,0x00000471, + 0x0004003d,0x00000025,0x00000499,0x0000048f,0x00050084,0x00000025,0x0000049a,0x00000167, + 0x00000499,0x00050082,0x00000025,0x0000049b,0x0000049a,0x0000016f,0x0004006f,0x00000006, + 0x0000049c,0x0000049b,0x00050081,0x00000006,0x0000049d,0x00000498,0x0000049c,0x0004003d, + 0x00000006,0x0000049e,0x00000474,0x0004003d,0x00000025,0x0000049f,0x00000487,0x00050084, + 0x00000025,0x000004a0,0x00000167,0x0000049f,0x00050082,0x00000025,0x000004a1,0x000004a0, + 0x0000016f,0x0004006f,0x00000006,0x000004a2,0x000004a1,0x00050081,0x00000006,0x000004a3, + 0x0000049e,0x000004a2,0x00050050,0x00000455,0x000004a4,0x0000049d,0x000004a3,0x0004003d, + 0x00000455,0x000004a5,0x0000045c,0x00050085,0x00000455,0x000004a6,0x000004a4,0x000004a5, + 0x0003003e,0x00000497,0x000004a6,0x0004003d,0x000004a9,0x000004ac,0x000004ab,0x0004003d, + 0x00000455,0x000004ad,0x00000497,0x00060060,0x0000000e,0x000004ae,0x000004ac,0x000004ad, + 0x00000197,0x0003003e,0x000004a7,0x000004ae,0x0004003d,0x00000025,0x000004b0,0x00000487, + 0x00050084,0x00000025,0x000004b1,0x00000167,0x000004b0,0x0004003d,0x00000025,0x000004b2, + 0x0000048f,0x00050084,0x00000025,0x000004b3,0x00000167,0x000004b2,0x00050041,0x0000000d, + 0x000004b4,0x000004a7,0x00000194,0x0004003d,0x00000006,0x000004b5,0x000004b4,0x00060041, + 0x0000000d,0x000004b6,0x000004af,0x000004b1,0x000004b3,0x0003003e,0x000004b6,0x000004b5, + 0x0004003d,0x00000025,0x000004b7,0x00000487,0x00050084,0x00000025,0x000004b8,0x00000167, + 0x000004b7,0x0004003d,0x00000025,0x000004b9,0x0000048f,0x00050084,0x00000025,0x000004ba, + 0x00000167,0x000004b9,0x00050080,0x00000025,0x000004bb,0x000004ba,0x0000016f,0x00050041, + 0x0000000d,0x000004bc,0x000004a7,0x00000057,0x0004003d,0x00000006,0x000004bd,0x000004bc, + 0x00060041,0x0000000d,0x000004be,0x000004af,0x000004b8,0x000004bb,0x0003003e,0x000004be, + 0x000004bd,0x0004003d,0x00000025,0x000004bf,0x00000487,0x00050084,0x00000025,0x000004c0, + 0x00000167,0x000004bf,0x00050080,0x00000025,0x000004c1,0x000004c0,0x0000016f,0x0004003d, + 0x00000025,0x000004c2,0x0000048f,0x00050084,0x00000025,0x000004c3,0x00000167,0x000004c2, + 0x00050041,0x0000000d,0x000004c4,0x000004a7,0x0000004c,0x0004003d,0x00000006,0x000004c5, + 0x000004c4,0x00060041,0x0000000d,0x000004c6,0x000004af,0x000004c1,0x000004c3,0x0003003e, + 0x000004c6,0x000004c5,0x0004003d,0x00000025,0x000004c7,0x00000487,0x00050084,0x00000025, + 0x000004c8,0x00000167,0x000004c7,0x00050080,0x00000025,0x000004c9,0x000004c8,0x0000016f, + 0x0004003d,0x00000025,0x000004ca,0x0000048f,0x00050084,0x00000025,0x000004cb,0x00000167, + 0x000004ca,0x00050080,0x00000025,0x000004cc,0x000004cb,0x0000016f,0x00050041,0x0000000d, + 0x000004cd,0x000004a7,0x00000051,0x0004003d,0x00000006,0x000004ce,0x000004cd,0x00060041, + 0x0000000d,0x000004cf,0x000004af,0x000004c9,0x000004cc,0x0003003e,0x000004cf,0x000004ce, + 0x000200f9,0x00000493,0x000200f8,0x00000493,0x0004003d,0x00000025,0x000004d0,0x0000048f, + 0x00050080,0x00000025,0x000004d1,0x000004d0,0x0000016f,0x0003003e,0x0000048f,0x000004d1, + 0x000200f9,0x00000490,0x000200f8,0x00000492,0x000200f9,0x0000048b,0x000200f8,0x0000048b, + 0x0004003d,0x00000025,0x000004d2,0x00000487,0x00050080,0x00000025,0x000004d3,0x000004d2, + 0x0000016f,0x0003003e,0x00000487,0x000004d3,0x000200f9,0x00000488,0x000200f8,0x0000048a, + 0x00060041,0x0000000d,0x000004d6,0x000004af,0x0000016f,0x0000016f,0x0004003d,0x00000006, + 0x000004d7,0x000004d6,0x0003003e,0x000004d5,0x000004d7,0x00060041,0x0000000d,0x000004d9, + 0x000004af,0x0000016f,0x00000167,0x0004003d,0x00000006,0x000004da,0x000004d9,0x0003003e, + 0x000004d8,0x000004da,0x00060041,0x0000000d,0x000004dc,0x000004af,0x0000016f,0x00000197, + 0x0004003d,0x00000006,0x000004dd,0x000004dc,0x0003003e,0x000004db,0x000004dd,0x00060041, + 0x0000000d,0x000004df,0x000004af,0x00000167,0x0000016f,0x0004003d,0x00000006,0x000004e0, + 0x000004df,0x0003003e,0x000004de,0x000004e0,0x00060041,0x0000000d,0x000004e2,0x000004af, + 0x00000167,0x00000167,0x0004003d,0x00000006,0x000004e3,0x000004e2,0x0003003e,0x000004e1, + 0x000004e3,0x00060041,0x0000000d,0x000004e5,0x000004af,0x00000167,0x00000197,0x0004003d, + 0x00000006,0x000004e6,0x000004e5,0x0003003e,0x000004e4,0x000004e6,0x00060041,0x0000000d, + 0x000004e8,0x000004af,0x00000197,0x0000016f,0x0004003d,0x00000006,0x000004e9,0x000004e8, + 0x0003003e,0x000004e7,0x000004e9,0x00060041,0x0000000d,0x000004eb,0x000004af,0x00000197, + 0x00000167,0x0004003d,0x00000006,0x000004ec,0x000004eb,0x0003003e,0x000004ea,0x000004ec, + 0x00060041,0x0000000d,0x000004ee,0x000004af,0x00000197,0x00000197,0x0004003d,0x00000006, + 0x000004ef,0x000004ee,0x0003003e,0x000004ed,0x000004ef,0x000d0039,0x0000000e,0x000004f0, + 0x00000019,0x000004d5,0x000004d8,0x000004db,0x000004de,0x000004e1,0x000004e4,0x000004e7, + 0x000004ea,0x000004ed,0x0003003e,0x000004d4,0x000004f0,0x00060041,0x0000000d,0x000004f3, + 0x000004af,0x0000016f,0x00000167,0x0004003d,0x00000006,0x000004f4,0x000004f3,0x0003003e, + 0x000004f2,0x000004f4,0x00060041,0x0000000d,0x000004f6,0x000004af,0x0000016f,0x00000197, + 0x0004003d,0x00000006,0x000004f7,0x000004f6,0x0003003e,0x000004f5,0x000004f7,0x00060041, + 0x0000000d,0x000004f9,0x000004af,0x0000016f,0x0000019f,0x0004003d,0x00000006,0x000004fa, + 0x000004f9,0x0003003e,0x000004f8,0x000004fa,0x00060041,0x0000000d,0x000004fc,0x000004af, + 0x00000167,0x00000167,0x0004003d,0x00000006,0x000004fd,0x000004fc,0x0003003e,0x000004fb, + 0x000004fd,0x00060041,0x0000000d,0x000004ff,0x000004af,0x00000167,0x00000197,0x0004003d, + 0x00000006,0x00000500,0x000004ff,0x0003003e,0x000004fe,0x00000500,0x00060041,0x0000000d, + 0x00000502,0x000004af,0x00000167,0x0000019f,0x0004003d,0x00000006,0x00000503,0x00000502, + 0x0003003e,0x00000501,0x00000503,0x00060041,0x0000000d,0x00000505,0x000004af,0x00000197, + 0x00000167,0x0004003d,0x00000006,0x00000506,0x00000505,0x0003003e,0x00000504,0x00000506, + 0x00060041,0x0000000d,0x00000508,0x000004af,0x00000197,0x00000197,0x0004003d,0x00000006, + 0x00000509,0x00000508,0x0003003e,0x00000507,0x00000509,0x00060041,0x0000000d,0x0000050b, + 0x000004af,0x00000197,0x0000019f,0x0004003d,0x00000006,0x0000050c,0x0000050b,0x0003003e, + 0x0000050a,0x0000050c,0x000d0039,0x0000000e,0x0000050d,0x00000019,0x000004f2,0x000004f5, + 0x000004f8,0x000004fb,0x000004fe,0x00000501,0x00000504,0x00000507,0x0000050a,0x0003003e, + 0x000004f1,0x0000050d,0x00060041,0x0000000d,0x00000510,0x000004af,0x00000167,0x0000016f, + 0x0004003d,0x00000006,0x00000511,0x00000510,0x0003003e,0x0000050f,0x00000511,0x00060041, + 0x0000000d,0x00000513,0x000004af,0x00000167,0x00000167,0x0004003d,0x00000006,0x00000514, + 0x00000513,0x0003003e,0x00000512,0x00000514,0x00060041,0x0000000d,0x00000516,0x000004af, + 0x00000167,0x00000197,0x0004003d,0x00000006,0x00000517,0x00000516,0x0003003e,0x00000515, + 0x00000517,0x00060041,0x0000000d,0x00000519,0x000004af,0x00000197,0x0000016f,0x0004003d, + 0x00000006,0x0000051a,0x00000519,0x0003003e,0x00000518,0x0000051a,0x00060041,0x0000000d, + 0x0000051c,0x000004af,0x00000197,0x00000167,0x0004003d,0x00000006,0x0000051d,0x0000051c, + 0x0003003e,0x0000051b,0x0000051d,0x00060041,0x0000000d,0x0000051f,0x000004af,0x00000197, + 0x00000197,0x0004003d,0x00000006,0x00000520,0x0000051f,0x0003003e,0x0000051e,0x00000520, + 0x00060041,0x0000000d,0x00000522,0x000004af,0x0000019f,0x0000016f,0x0004003d,0x00000006, + 0x00000523,0x00000522,0x0003003e,0x00000521,0x00000523,0x00060041,0x0000000d,0x00000525, + 0x000004af,0x0000019f,0x00000167,0x0004003d,0x00000006,0x00000526,0x00000525,0x0003003e, + 0x00000524,0x00000526,0x00060041,0x0000000d,0x00000528,0x000004af,0x0000019f,0x00000197, + 0x0004003d,0x00000006,0x00000529,0x00000528,0x0003003e,0x00000527,0x00000529,0x000d0039, + 0x0000000e,0x0000052a,0x00000019,0x0000050f,0x00000512,0x00000515,0x00000518,0x0000051b, + 0x0000051e,0x00000521,0x00000524,0x00000527,0x0003003e,0x0000050e,0x0000052a,0x00060041, + 0x0000000d,0x0000052d,0x000004af,0x00000167,0x00000167,0x0004003d,0x00000006,0x0000052e, + 0x0000052d,0x0003003e,0x0000052c,0x0000052e,0x00060041,0x0000000d,0x00000530,0x000004af, + 0x00000167,0x00000197,0x0004003d,0x00000006,0x00000531,0x00000530,0x0003003e,0x0000052f, + 0x00000531,0x00060041,0x0000000d,0x00000533,0x000004af,0x00000167,0x0000019f,0x0004003d, + 0x00000006,0x00000534,0x00000533,0x0003003e,0x00000532,0x00000534,0x00060041,0x0000000d, + 0x00000536,0x000004af,0x00000197,0x00000167,0x0004003d,0x00000006,0x00000537,0x00000536, + 0x0003003e,0x00000535,0x00000537,0x00060041,0x0000000d,0x00000539,0x000004af,0x00000197, + 0x00000197,0x0004003d,0x00000006,0x0000053a,0x00000539,0x0003003e,0x00000538,0x0000053a, + 0x00060041,0x0000000d,0x0000053c,0x000004af,0x00000197,0x0000019f,0x0004003d,0x00000006, + 0x0000053d,0x0000053c,0x0003003e,0x0000053b,0x0000053d,0x00060041,0x0000000d,0x0000053f, + 0x000004af,0x0000019f,0x00000167,0x0004003d,0x00000006,0x00000540,0x0000053f,0x0003003e, + 0x0000053e,0x00000540,0x00060041,0x0000000d,0x00000542,0x000004af,0x0000019f,0x00000197, + 0x0004003d,0x00000006,0x00000543,0x00000542,0x0003003e,0x00000541,0x00000543,0x00060041, + 0x0000000d,0x00000545,0x000004af,0x0000019f,0x0000019f,0x0004003d,0x00000006,0x00000546, + 0x00000545,0x0003003e,0x00000544,0x00000546,0x000d0039,0x0000000e,0x00000547,0x00000019, + 0x0000052c,0x0000052f,0x00000532,0x00000535,0x00000538,0x0000053b,0x0000053e,0x00000541, + 0x00000544,0x0003003e,0x0000052b,0x00000547,0x0004003d,0x0000000e,0x0000054a,0x000004d4, + 0x0003003e,0x00000549,0x0000054a,0x0004003d,0x0000000e,0x0000054c,0x000004f1,0x0003003e, + 0x0000054b,0x0000054c,0x0004003d,0x0000000e,0x0000054e,0x0000050e,0x0003003e,0x0000054d, + 0x0000054e,0x0004003d,0x0000000e,0x00000550,0x0000052b,0x0003003e,0x0000054f,0x00000550, + 0x0004003d,0x00000006,0x00000552,0x00000477,0x0003003e,0x00000551,0x00000552,0x0004003d, + 0x00000006,0x00000554,0x0000047b,0x0003003e,0x00000553,0x00000554,0x000a0039,0x0000000e, + 0x00000555,0x00000023,0x00000549,0x0000054b,0x0000054d,0x0000054f,0x00000551,0x00000553, + 0x0003003e,0x00000548,0x00000555,0x00050041,0x0000000d,0x00000557,0x00000548,0x0000004c, + 0x0004003d,0x00000006,0x00000558,0x00000557,0x00050083,0x00000006,0x00000559,0x000000b2, + 0x00000558,0x00050041,0x0000000d,0x0000055a,0x00000548,0x00000051,0x0004003d,0x00000006, + 0x0000055b,0x0000055a,0x00050083,0x00000006,0x0000055c,0x00000559,0x0000055b,0x00050041, + 0x0000000d,0x0000055d,0x00000548,0x00000057,0x0004003d,0x00000006,0x0000055e,0x0000055d, + 0x00050083,0x00000006,0x0000055f,0x0000055c,0x0000055e,0x00050041,0x0000000d,0x00000560, + 0x00000548,0x00000194,0x0004003d,0x00000006,0x00000561,0x00000560,0x00050083,0x00000006, + 0x00000562,0x0000055f,0x00000561,0x0003003e,0x00000556,0x00000562,0x0004003d,0x0000003a, + 0x00000565,0x000004af,0x0003003e,0x00000564,0x00000565,0x0004003d,0x00000025,0x00000567, + 0x0000047f,0x0003003e,0x00000566,0x00000567,0x0004003d,0x00000025,0x00000569,0x00000483, + 0x0003003e,0x00000568,0x00000569,0x00070039,0x00000006,0x0000056a,0x00000040,0x00000564, + 0x00000566,0x00000568,0x0004003d,0x00000006,0x0000056b,0x00000556,0x00050085,0x00000006, + 0x0000056c,0x0000056a,0x0000056b,0x0003003e,0x00000563,0x0000056c,0x0004003d,0x0000003a, + 0x0000056e,0x000004af,0x0003003e,0x0000056d,0x0000056e,0x0004003d,0x00000006,0x00000570, + 0x00000477,0x0003003e,0x0000056f,0x00000570,0x0004003d,0x00000006,0x00000572,0x0000047b, + 0x0003003e,0x00000571,0x00000572,0x0004003d,0x00000025,0x00000574,0x0000047f,0x0003003e, + 0x00000573,0x00000574,0x0004003d,0x00000025,0x00000576,0x00000483,0x0003003e,0x00000575, + 0x00000576,0x0004003d,0x0000000e,0x00000578,0x00000548,0x0003003e,0x00000577,0x00000578, + 0x000a0039,0x00000006,0x00000579,0x00000049,0x0000056d,0x0000056f,0x00000571,0x00000573, + 0x00000575,0x00000577,0x0004003d,0x00000006,0x0000057a,0x00000563,0x00050081,0x00000006, + 0x0000057b,0x0000057a,0x00000579,0x0003003e,0x00000563,0x0000057b,0x0004003d,0x000004a9, + 0x0000057d,0x000004ab,0x0004003d,0x00000455,0x0000057e,0x00000462,0x00050057,0x0000000e, + 0x0000057f,0x0000057d,0x0000057e,0x0003003e,0x0000057c,0x0000057f,0x0004003d,0x0000000e, + 0x00000582,0x0000057c,0x0008004f,0x00000007,0x00000583,0x00000582,0x00000582,0x00000000, + 0x00000001,0x00000002,0x0003003e,0x00000581,0x00000583,0x00050039,0x00000006,0x00000584, + 0x0000000b,0x00000581,0x0003003e,0x00000580,0x00000584,0x0004003d,0x00000006,0x00000586, + 0x00000563,0x0004003d,0x00000006,0x00000587,0x00000580,0x00050083,0x00000006,0x00000588, + 0x00000586,0x00000587,0x0003003e,0x00000585,0x00000588,0x0004003d,0x00000006,0x00000589, + 0x00000585,0x00060050,0x00000007,0x0000058a,0x00000589,0x00000589,0x00000589,0x0004003d, + 0x0000000e,0x0000058b,0x0000057c,0x0008004f,0x00000007,0x0000058c,0x0000058b,0x0000058b, + 0x00000000,0x00000001,0x00000002,0x00050081,0x00000007,0x0000058d,0x0000058c,0x0000058a, + 0x00050041,0x0000000d,0x0000058e,0x0000057c,0x0000004c,0x00050051,0x00000006,0x0000058f, + 0x0000058d,0x00000000,0x0003003e,0x0000058e,0x0000058f,0x00050041,0x0000000d,0x00000590, + 0x0000057c,0x00000051,0x00050051,0x00000006,0x00000591,0x0000058d,0x00000001,0x0003003e, + 0x00000590,0x00000591,0x00050041,0x0000000d,0x00000592,0x0000057c,0x00000057,0x00050051, + 0x00000006,0x00000593,0x0000058d,0x00000002,0x0003003e,0x00000592,0x00000593,0x0004003d, + 0x0000000e,0x00000596,0x0000057c,0x0008004f,0x00000007,0x00000597,0x00000596,0x00000596, + 0x00000000,0x00000001,0x00000002,0x00060050,0x00000007,0x00000598,0x000000a5,0x000000a5, + 0x000000a5,0x00060050,0x00000007,0x00000599,0x000000b2,0x000000b2,0x000000b2,0x0008000c, + 0x00000007,0x0000059a,0x00000001,0x0000002b,0x00000597,0x00000598,0x00000599,0x00050051, + 0x00000006,0x0000059b,0x0000059a,0x00000000,0x00050051,0x00000006,0x0000059c,0x0000059a, + 0x00000001,0x00050051,0x00000006,0x0000059d,0x0000059a,0x00000002,0x00070050,0x0000000e, + 0x0000059e,0x0000059b,0x0000059c,0x0000059d,0x000000b2,0x0003003e,0x00000595,0x0000059e, + 0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000b,0x00000000,0x00000009,0x00030037, + 0x00000008,0x0000000a,0x000200f8,0x0000000c,0x00050041,0x0000000d,0x0000004d,0x0000000a, + 0x0000004c,0x0004003d,0x00000006,0x0000004e,0x0000004d,0x00050085,0x00000006,0x0000004f, + 0x0000004b,0x0000004e,0x00050041,0x0000000d,0x00000052,0x0000000a,0x00000051,0x0004003d, + 0x00000006,0x00000053,0x00000052,0x00050085,0x00000006,0x00000054,0x00000050,0x00000053, + 0x00050081,0x00000006,0x00000055,0x0000004f,0x00000054,0x00050041,0x0000000d,0x00000058, + 0x0000000a,0x00000057,0x0004003d,0x00000006,0x00000059,0x00000058,0x00050085,0x00000006, + 0x0000005a,0x00000056,0x00000059,0x00050081,0x00000006,0x0000005b,0x00000055,0x0000005a, + 0x000200fe,0x0000005b,0x00010038,0x00050036,0x0000000e,0x00000019,0x00000000,0x0000000f, + 0x00030037,0x0000000d,0x00000010,0x00030037,0x0000000d,0x00000011,0x00030037,0x0000000d, + 0x00000012,0x00030037,0x0000000d,0x00000013,0x00030037,0x0000000d,0x00000014,0x00030037, + 0x0000000d,0x00000015,0x00030037,0x0000000d,0x00000016,0x00030037,0x0000000d,0x00000017, + 0x00030037,0x0000000d,0x00000018,0x000200f8,0x0000001a,0x0004003b,0x0000000d,0x0000005e, + 0x00000007,0x0004003b,0x0000000d,0x0000006b,0x00000007,0x0004003b,0x0000000d,0x00000078, + 0x00000007,0x0004003b,0x0000000d,0x00000085,0x00000007,0x0004003b,0x0000000d,0x00000092, + 0x00000007,0x0004003b,0x0000000d,0x00000096,0x00000007,0x0004003b,0x0000000d,0x0000009a, + 0x00000007,0x0004003b,0x0000000d,0x0000009e,0x00000007,0x0004003b,0x0000000d,0x000000ac, + 0x00000007,0x0004003b,0x0000000d,0x000000b4,0x00000007,0x0004003b,0x000000b7,0x000000b8, + 0x00000007,0x0004003b,0x000000b7,0x000000c6,0x00000007,0x0004003b,0x000000b7,0x000000d2, + 0x00000007,0x0004003b,0x000000b7,0x000000d6,0x00000007,0x0004003b,0x0000000d,0x000000da, + 0x00000007,0x0004003b,0x0000000d,0x000000e0,0x00000007,0x0004003b,0x0000000d,0x000000e6, + 0x00000007,0x0004003b,0x0000000d,0x000000ec,0x00000007,0x0004003b,0x0000000d,0x000000f3, + 0x00000007,0x0004003b,0x0000000d,0x000000f9,0x00000007,0x0004003d,0x00000006,0x0000005f, + 0x00000010,0x0004003d,0x00000006,0x00000060,0x00000011,0x00050081,0x00000006,0x00000061, + 0x0000005f,0x00000060,0x0004003d,0x00000006,0x00000062,0x00000012,0x00050081,0x00000006, + 0x00000063,0x00000061,0x00000062,0x0004003d,0x00000006,0x00000064,0x00000016,0x00050083, + 0x00000006,0x00000065,0x00000063,0x00000064,0x0004003d,0x00000006,0x00000066,0x00000017, + 0x00050083,0x00000006,0x00000067,0x00000065,0x00000066,0x0004003d,0x00000006,0x00000068, + 0x00000018,0x00050083,0x00000006,0x00000069,0x00000067,0x00000068,0x0006000c,0x00000006, + 0x0000006a,0x00000001,0x00000004,0x00000069,0x0003003e,0x0000005e,0x0000006a,0x0004003d, + 0x00000006,0x0000006c,0x00000013,0x0004003d,0x00000006,0x0000006d,0x00000010,0x00050081, + 0x00000006,0x0000006e,0x0000006c,0x0000006d,0x0004003d,0x00000006,0x0000006f,0x00000011, + 0x00050081,0x00000006,0x00000070,0x0000006e,0x0000006f,0x0004003d,0x00000006,0x00000071, + 0x00000017,0x00050083,0x00000006,0x00000072,0x00000070,0x00000071,0x0004003d,0x00000006, + 0x00000073,0x00000018,0x00050083,0x00000006,0x00000074,0x00000072,0x00000073,0x0004003d, + 0x00000006,0x00000075,0x00000015,0x00050083,0x00000006,0x00000076,0x00000074,0x00000075, + 0x0006000c,0x00000006,0x00000077,0x00000001,0x00000004,0x00000076,0x0003003e,0x0000006b, + 0x00000077,0x0004003d,0x00000006,0x00000079,0x00000010,0x0004003d,0x00000006,0x0000007a, + 0x00000013,0x00050081,0x00000006,0x0000007b,0x00000079,0x0000007a,0x0004003d,0x00000006, + 0x0000007c,0x00000016,0x00050081,0x00000006,0x0000007d,0x0000007b,0x0000007c,0x0004003d, + 0x00000006,0x0000007e,0x00000012,0x00050083,0x00000006,0x0000007f,0x0000007d,0x0000007e, + 0x0004003d,0x00000006,0x00000080,0x00000015,0x00050083,0x00000006,0x00000081,0x0000007f, + 0x00000080,0x0004003d,0x00000006,0x00000082,0x00000018,0x00050083,0x00000006,0x00000083, + 0x00000081,0x00000082,0x0006000c,0x00000006,0x00000084,0x00000001,0x00000004,0x00000083, + 0x0003003e,0x00000078,0x00000084,0x0004003d,0x00000006,0x00000086,0x00000013,0x0004003d, + 0x00000006,0x00000087,0x00000016,0x00050081,0x00000006,0x00000088,0x00000086,0x00000087, + 0x0004003d,0x00000006,0x00000089,0x00000017,0x00050081,0x00000006,0x0000008a,0x00000088, + 0x00000089,0x0004003d,0x00000006,0x0000008b,0x00000011,0x00050083,0x00000006,0x0000008c, + 0x0000008a,0x0000008b,0x0004003d,0x00000006,0x0000008d,0x00000012,0x00050083,0x00000006, + 0x0000008e,0x0000008c,0x0000008d,0x0004003d,0x00000006,0x0000008f,0x00000015,0x00050083, + 0x00000006,0x00000090,0x0000008e,0x0000008f,0x0006000c,0x00000006,0x00000091,0x00000001, + 0x00000004,0x00000090,0x0003003e,0x00000085,0x00000091,0x0004003d,0x00000006,0x00000093, + 0x0000005e,0x0004003d,0x00000006,0x00000094,0x00000078,0x0007000c,0x00000006,0x00000095, + 0x00000001,0x00000028,0x00000093,0x00000094,0x0003003e,0x00000092,0x00000095,0x0004003d, + 0x00000006,0x00000097,0x0000005e,0x0004003d,0x00000006,0x00000098,0x00000078,0x0007000c, + 0x00000006,0x00000099,0x00000001,0x00000025,0x00000097,0x00000098,0x0003003e,0x00000096, + 0x00000099,0x0004003d,0x00000006,0x0000009b,0x0000006b,0x0004003d,0x00000006,0x0000009c, + 0x00000085,0x0007000c,0x00000006,0x0000009d,0x00000001,0x00000028,0x0000009b,0x0000009c, + 0x0003003e,0x0000009a,0x0000009d,0x0004003d,0x00000006,0x0000009f,0x0000006b,0x0004003d, + 0x00000006,0x000000a0,0x00000085,0x0007000c,0x00000006,0x000000a1,0x00000001,0x00000025, + 0x0000009f,0x000000a0,0x0003003e,0x0000009e,0x000000a1,0x0004003d,0x00000006,0x000000a2, + 0x00000092,0x0004003d,0x00000006,0x000000a3,0x0000009a,0x00050081,0x00000006,0x000000a4, + 0x000000a2,0x000000a3,0x000500b4,0x000000a6,0x000000a7,0x000000a4,0x000000a5,0x000300f7, + 0x000000a9,0x00000000,0x000400fa,0x000000a7,0x000000a8,0x000000a9,0x000200f8,0x000000a8, + 0x000200fe,0x000000aa,0x000200f8,0x000000a9,0x0004003d,0x00000006,0x000000ad,0x00000092, + 0x0004003d,0x00000006,0x000000ae,0x00000092,0x0004003d,0x00000006,0x000000af,0x0000009a, + 0x00050081,0x00000006,0x000000b0,0x000000ae,0x000000af,0x00050088,0x00000006,0x000000b1, + 0x000000ad,0x000000b0,0x0007000c,0x00000006,0x000000b3,0x00000001,0x00000025,0x000000b1, + 0x000000b2,0x0003003e,0x000000ac,0x000000b3,0x0004003d,0x00000006,0x000000b5,0x000000ac, + 0x00050083,0x00000006,0x000000b6,0x000000b2,0x000000b5,0x0003003e,0x000000b4,0x000000b6, + 0x0004003d,0x00000006,0x000000b9,0x00000092,0x0004003d,0x00000006,0x000000ba,0x00000096, + 0x00050085,0x00000006,0x000000bc,0x000000ba,0x000000bb,0x000500ba,0x000000a6,0x000000bd, + 0x000000b9,0x000000bc,0x0004003d,0x00000006,0x000000be,0x00000092,0x000500ba,0x000000a6, + 0x000000c0,0x000000be,0x000000bf,0x000500a7,0x000000a6,0x000000c1,0x000000bd,0x000000c0, + 0x0004003d,0x00000006,0x000000c2,0x00000092,0x0004003d,0x00000006,0x000000c3,0x0000009e, + 0x000500ba,0x000000a6,0x000000c4,0x000000c2,0x000000c3,0x000500a7,0x000000a6,0x000000c5, + 0x000000c1,0x000000c4,0x0003003e,0x000000b8,0x000000c5,0x0004003d,0x00000006,0x000000c7, + 0x0000009a,0x0004003d,0x00000006,0x000000c8,0x0000009e,0x00050085,0x00000006,0x000000c9, + 0x000000c8,0x000000bb,0x000500ba,0x000000a6,0x000000ca,0x000000c7,0x000000c9,0x0004003d, + 0x00000006,0x000000cb,0x0000009a,0x000500ba,0x000000a6,0x000000cc,0x000000cb,0x000000bf, + 0x000500a7,0x000000a6,0x000000cd,0x000000ca,0x000000cc,0x0004003d,0x00000006,0x000000ce, + 0x0000009a,0x0004003d,0x00000006,0x000000cf,0x00000096,0x000500ba,0x000000a6,0x000000d0, + 0x000000ce,0x000000cf,0x000500a7,0x000000a6,0x000000d1,0x000000cd,0x000000d0,0x0003003e, + 0x000000c6,0x000000d1,0x0004003d,0x00000006,0x000000d3,0x00000092,0x0004003d,0x00000006, + 0x000000d4,0x0000005e,0x000500b4,0x000000a6,0x000000d5,0x000000d3,0x000000d4,0x0003003e, + 0x000000d2,0x000000d5,0x0004003d,0x00000006,0x000000d7,0x0000009a,0x0004003d,0x00000006, + 0x000000d8,0x0000006b,0x000500b4,0x000000a6,0x000000d9,0x000000d7,0x000000d8,0x0003003e, + 0x000000d6,0x000000d9,0x0004003d,0x000000a6,0x000000db,0x000000b8,0x0004003d,0x000000a6, + 0x000000dc,0x000000c6,0x000500a7,0x000000a6,0x000000dd,0x000000db,0x000000dc,0x0004003d, + 0x00000006,0x000000de,0x000000ac,0x000600a9,0x00000006,0x000000df,0x000000dd,0x000000de, + 0x000000b2,0x0003003e,0x000000da,0x000000df,0x0004003d,0x000000a6,0x000000e1,0x000000b8, + 0x0004003d,0x000000a6,0x000000e2,0x000000c6,0x000500a7,0x000000a6,0x000000e3,0x000000e1, + 0x000000e2,0x0004003d,0x00000006,0x000000e4,0x000000b4,0x000600a9,0x00000006,0x000000e5, + 0x000000e3,0x000000e4,0x000000b2,0x0003003e,0x000000e0,0x000000e5,0x0004003d,0x000000a6, + 0x000000e7,0x000000b8,0x0004003d,0x000000a6,0x000000e8,0x000000d2,0x000500a7,0x000000a6, + 0x000000e9,0x000000e7,0x000000e8,0x0004003d,0x00000006,0x000000ea,0x000000da,0x000600a9, + 0x00000006,0x000000eb,0x000000e9,0x000000ea,0x000000a5,0x0003003e,0x000000e6,0x000000eb, + 0x0004003d,0x000000a6,0x000000ed,0x000000b8,0x0004003d,0x000000a6,0x000000ee,0x000000d2, + 0x000400a8,0x000000a6,0x000000ef,0x000000ee,0x000500a7,0x000000a6,0x000000f0,0x000000ed, + 0x000000ef,0x0004003d,0x00000006,0x000000f1,0x000000da,0x000600a9,0x00000006,0x000000f2, + 0x000000f0,0x000000f1,0x000000a5,0x0003003e,0x000000ec,0x000000f2,0x0004003d,0x000000a6, + 0x000000f4,0x000000c6,0x0004003d,0x000000a6,0x000000f5,0x000000d6,0x000500a7,0x000000a6, + 0x000000f6,0x000000f4,0x000000f5,0x0004003d,0x00000006,0x000000f7,0x000000e0,0x000600a9, + 0x00000006,0x000000f8,0x000000f6,0x000000f7,0x000000a5,0x0003003e,0x000000f3,0x000000f8, + 0x0004003d,0x000000a6,0x000000fa,0x000000c6,0x0004003d,0x000000a6,0x000000fb,0x000000d6, + 0x000400a8,0x000000a6,0x000000fc,0x000000fb,0x000500a7,0x000000a6,0x000000fd,0x000000fa, + 0x000000fc,0x0004003d,0x00000006,0x000000fe,0x000000e0,0x000600a9,0x00000006,0x000000ff, + 0x000000fd,0x000000fe,0x000000a5,0x0003003e,0x000000f9,0x000000ff,0x0004003d,0x00000006, + 0x00000100,0x000000e6,0x0004003d,0x00000006,0x00000101,0x000000ec,0x0004003d,0x00000006, + 0x00000102,0x000000f3,0x0004003d,0x00000006,0x00000103,0x000000f9,0x00070050,0x0000000e, + 0x00000104,0x00000100,0x00000101,0x00000102,0x00000103,0x000200fe,0x00000104,0x00010038, + 0x00050036,0x0000000e,0x00000023,0x00000000,0x0000001c,0x00030037,0x0000001b,0x0000001d, + 0x00030037,0x0000001b,0x0000001e,0x00030037,0x0000001b,0x0000001f,0x00030037,0x0000001b, + 0x00000020,0x00030037,0x0000000d,0x00000021,0x00030037,0x0000000d,0x00000022,0x000200f8, + 0x00000024,0x0004003b,0x0000001b,0x00000107,0x00000007,0x0004003b,0x0000001b,0x0000010d, + 0x00000007,0x0004003d,0x0000000e,0x00000108,0x0000001d,0x0004003d,0x0000000e,0x00000109, + 0x0000001e,0x0004003d,0x00000006,0x0000010a,0x00000021,0x00070050,0x0000000e,0x0000010b, + 0x0000010a,0x0000010a,0x0000010a,0x0000010a,0x0008000c,0x0000000e,0x0000010c,0x00000001, + 0x0000002e,0x00000108,0x00000109,0x0000010b,0x0003003e,0x00000107,0x0000010c,0x0004003d, + 0x0000000e,0x0000010e,0x0000001f,0x0004003d,0x0000000e,0x0000010f,0x00000020,0x0004003d, + 0x00000006,0x00000110,0x00000021,0x00070050,0x0000000e,0x00000111,0x00000110,0x00000110, + 0x00000110,0x00000110,0x0008000c,0x0000000e,0x00000112,0x00000001,0x0000002e,0x0000010e, + 0x0000010f,0x00000111,0x0003003e,0x0000010d,0x00000112,0x0004003d,0x0000000e,0x00000113, + 0x00000107,0x0004003d,0x0000000e,0x00000114,0x0000010d,0x0004003d,0x00000006,0x00000115, + 0x00000022,0x00070050,0x0000000e,0x00000116,0x00000115,0x00000115,0x00000115,0x00000115, + 0x0008000c,0x0000000e,0x00000117,0x00000001,0x0000002e,0x00000113,0x00000114,0x00000116, + 0x000200fe,0x00000117,0x00010038,0x00050036,0x00000006,0x0000002f,0x00000000,0x00000027, + 0x00030037,0x0000000d,0x00000028,0x00030037,0x0000000d,0x00000029,0x00030037,0x0000000d, + 0x0000002a,0x00030037,0x0000000d,0x0000002b,0x00030037,0x0000000d,0x0000002c,0x00030037, + 0x0000000d,0x0000002d,0x00030037,0x00000026,0x0000002e,0x000200f8,0x00000030,0x0004003b, + 0x000000b7,0x0000011a,0x00000007,0x0004003b,0x0000000d,0x0000011e,0x00000007,0x0004003b, + 0x0000000d,0x00000123,0x00000007,0x0004003b,0x0000000d,0x00000129,0x00000007,0x0004003b, + 0x0000000d,0x00000133,0x00000007,0x0004003b,0x0000000d,0x00000139,0x00000007,0x0004003b, + 0x0000000d,0x0000013f,0x00000007,0x0004003b,0x0000000d,0x00000143,0x00000007,0x0004003b, + 0x0000000d,0x00000147,0x00000007,0x0004003d,0x00000025,0x0000011b,0x0000002e,0x000500b3, + 0x000000a6,0x0000011d,0x0000011b,0x0000011c,0x0003003e,0x0000011a,0x0000011d,0x0004003d, + 0x000000a6,0x0000011f,0x0000011a,0x0004003d,0x00000006,0x00000120,0x00000028,0x0004003d, + 0x00000006,0x00000121,0x0000002b,0x000600a9,0x00000006,0x00000122,0x0000011f,0x00000120, + 0x00000121,0x0003003e,0x0000011e,0x00000122,0x0004003d,0x00000006,0x00000124,0x00000029, + 0x0004003d,0x00000006,0x00000125,0x0000002a,0x0007000c,0x00000006,0x00000126,0x00000001, + 0x00000025,0x00000124,0x00000125,0x0004003d,0x00000006,0x00000127,0x0000011e,0x0007000c, + 0x00000006,0x00000128,0x00000001,0x00000025,0x00000126,0x00000127,0x0003003e,0x00000123, + 0x00000128,0x0004003d,0x00000006,0x0000012a,0x00000029,0x0004003d,0x00000006,0x0000012b, + 0x0000002a,0x0007000c,0x00000006,0x0000012c,0x00000001,0x00000028,0x0000012a,0x0000012b, + 0x0004003d,0x00000006,0x0000012d,0x0000011e,0x0007000c,0x00000006,0x0000012e,0x00000001, + 0x00000028,0x0000012c,0x0000012d,0x0003003e,0x00000129,0x0000012e,0x0004003d,0x000000a6, + 0x0000012f,0x0000011a,0x0004003d,0x00000006,0x00000130,0x0000002a,0x0004003d,0x00000006, + 0x00000131,0x0000002d,0x000600a9,0x00000006,0x00000132,0x0000012f,0x00000130,0x00000131, + 0x0003003e,0x0000011e,0x00000132,0x0004003d,0x00000006,0x00000134,0x0000002b,0x0004003d, + 0x00000006,0x00000135,0x0000002c,0x0007000c,0x00000006,0x00000136,0x00000001,0x00000025, + 0x00000134,0x00000135,0x0004003d,0x00000006,0x00000137,0x0000011e,0x0007000c,0x00000006, + 0x00000138,0x00000001,0x00000025,0x00000136,0x00000137,0x0003003e,0x00000133,0x00000138, + 0x0004003d,0x00000006,0x0000013a,0x0000002b,0x0004003d,0x00000006,0x0000013b,0x0000002c, + 0x0007000c,0x00000006,0x0000013c,0x00000001,0x00000028,0x0000013a,0x0000013b,0x0004003d, + 0x00000006,0x0000013d,0x0000011e,0x0007000c,0x00000006,0x0000013e,0x00000001,0x00000028, + 0x0000013c,0x0000013d,0x0003003e,0x00000139,0x0000013e,0x0004003d,0x00000006,0x00000140, + 0x00000129,0x0004003d,0x00000006,0x00000141,0x00000123,0x00050083,0x00000006,0x00000142, + 0x00000140,0x00000141,0x0003003e,0x0000013f,0x00000142,0x0004003d,0x00000006,0x00000144, + 0x00000139,0x0004003d,0x00000006,0x00000145,0x00000133,0x00050083,0x00000006,0x00000146, + 0x00000144,0x00000145,0x0003003e,0x00000143,0x00000146,0x0004003d,0x00000006,0x00000148, + 0x0000013f,0x0004003d,0x00000006,0x00000149,0x00000143,0x0007000c,0x00000006,0x0000014a, + 0x00000001,0x00000028,0x00000148,0x00000149,0x0004003d,0x00000006,0x0000014b,0x0000013f, + 0x0004003d,0x00000006,0x0000014c,0x00000143,0x0007000c,0x00000006,0x0000014d,0x00000001, + 0x00000025,0x0000014b,0x0000014c,0x00050081,0x00000006,0x0000014f,0x0000014d,0x0000014e, + 0x00050088,0x00000006,0x00000150,0x0000014a,0x0000014f,0x0003003e,0x00000147,0x00000150, + 0x0004003d,0x00000006,0x00000151,0x00000147,0x00050083,0x00000006,0x00000153,0x00000151, + 0x00000152,0x00050085,0x00000006,0x00000155,0x00000153,0x00000154,0x0008000c,0x00000006, + 0x00000156,0x00000001,0x0000002b,0x00000155,0x000000a5,0x000000b2,0x00050083,0x00000006, + 0x00000157,0x000000b2,0x00000156,0x00050085,0x00000006,0x00000158,0x00000157,0x000000b2, + 0x000200fe,0x00000158,0x00010038,0x00050036,0x00000006,0x00000038,0x00000000,0x00000035, + 0x00030037,0x00000034,0x00000036,0x00030037,0x00000026,0x00000037,0x000200f8,0x00000039, + 0x0004003b,0x0000001b,0x0000015f,0x00000007,0x0004003b,0x0000001b,0x0000016c,0x00000007, + 0x0004003b,0x0000001b,0x00000173,0x00000007,0x0004003b,0x0000001b,0x00000178,0x00000007, + 0x0004003b,0x0000000d,0x0000017e,0x00000007,0x0004003b,0x0000000d,0x000001ad,0x00000007, + 0x0004003b,0x0000000d,0x000001d8,0x00000007,0x0004003b,0x0000000d,0x000001e0,0x00000007, + 0x0004003b,0x0000000d,0x000001ec,0x00000007,0x0004003b,0x0000000d,0x000001fc,0x00000007, + 0x0004003b,0x0000000d,0x000001ff,0x00000007,0x0004003b,0x0000000d,0x00000202,0x00000007, + 0x0004003b,0x0000000d,0x00000205,0x00000007,0x0004003b,0x0000000d,0x00000208,0x00000007, + 0x0004003b,0x0000000d,0x0000020b,0x00000007,0x0004003b,0x00000026,0x0000020e,0x00000007, + 0x0004003d,0x00000025,0x0000015b,0x00000037,0x0008000c,0x00000025,0x0000015e,0x00000001, + 0x0000002d,0x0000015b,0x0000015c,0x0000015d,0x0003003e,0x00000037,0x0000015e,0x0004003d, + 0x00000025,0x00000166,0x00000037,0x00050084,0x00000025,0x00000168,0x00000166,0x00000167, + 0x00060041,0x00000169,0x0000016a,0x00000165,0x0000015c,0x00000168,0x0004003d,0x0000000e, + 0x0000016b,0x0000016a,0x0003003e,0x0000015f,0x0000016b,0x0004003d,0x00000025,0x0000016d, + 0x00000037,0x00050084,0x00000025,0x0000016e,0x0000016d,0x00000167,0x00050080,0x00000025, + 0x00000170,0x0000016e,0x0000016f,0x00060041,0x00000169,0x00000171,0x00000165,0x0000015c, + 0x00000170,0x0004003d,0x0000000e,0x00000172,0x00000171,0x0003003e,0x0000016c,0x00000172, + 0x0004003d,0x00000025,0x00000174,0x00000037,0x00050084,0x00000025,0x00000175,0x00000174, + 0x00000167,0x00060041,0x00000169,0x00000176,0x00000165,0x0000016f,0x00000175,0x0004003d, + 0x0000000e,0x00000177,0x00000176,0x0003003e,0x00000173,0x00000177,0x0004003d,0x00000025, + 0x00000179,0x00000037,0x00050084,0x00000025,0x0000017a,0x00000179,0x00000167,0x00050080, + 0x00000025,0x0000017b,0x0000017a,0x0000016f,0x00060041,0x00000169,0x0000017c,0x00000165, + 0x0000016f,0x0000017b,0x0004003d,0x0000000e,0x0000017d,0x0000017c,0x0003003e,0x00000178, + 0x0000017d,0x0003003e,0x0000017e,0x000000a5,0x00050041,0x0000000d,0x0000017f,0x0000015f, + 0x0000004c,0x0004003d,0x00000006,0x00000180,0x0000017f,0x00050041,0x0000000d,0x00000181, + 0x00000036,0x0000015c,0x0004003d,0x00000006,0x00000182,0x00000181,0x00050085,0x00000006, + 0x00000183,0x00000180,0x00000182,0x0004003d,0x00000006,0x00000184,0x0000017e,0x00050081, + 0x00000006,0x00000185,0x00000184,0x00000183,0x0003003e,0x0000017e,0x00000185,0x00050041, + 0x0000000d,0x00000186,0x0000015f,0x00000051,0x0004003d,0x00000006,0x00000187,0x00000186, + 0x00050041,0x0000000d,0x00000188,0x00000036,0x0000016f,0x0004003d,0x00000006,0x00000189, + 0x00000188,0x00050085,0x00000006,0x0000018a,0x00000187,0x00000189,0x0004003d,0x00000006, + 0x0000018b,0x0000017e,0x00050081,0x00000006,0x0000018c,0x0000018b,0x0000018a,0x0003003e, + 0x0000017e,0x0000018c,0x00050041,0x0000000d,0x0000018d,0x0000015f,0x00000057,0x0004003d, + 0x00000006,0x0000018e,0x0000018d,0x00050041,0x0000000d,0x0000018f,0x00000036,0x00000167, + 0x0004003d,0x00000006,0x00000190,0x0000018f,0x00050085,0x00000006,0x00000191,0x0000018e, + 0x00000190,0x0004003d,0x00000006,0x00000192,0x0000017e,0x00050081,0x00000006,0x00000193, + 0x00000192,0x00000191,0x0003003e,0x0000017e,0x00000193,0x00050041,0x0000000d,0x00000195, + 0x0000015f,0x00000194,0x0004003d,0x00000006,0x00000196,0x00000195,0x00050041,0x0000000d, + 0x00000198,0x00000036,0x00000197,0x0004003d,0x00000006,0x00000199,0x00000198,0x00050085, + 0x00000006,0x0000019a,0x00000196,0x00000199,0x0004003d,0x00000006,0x0000019b,0x0000017e, + 0x00050081,0x00000006,0x0000019c,0x0000019b,0x0000019a,0x0003003e,0x0000017e,0x0000019c, + 0x00050041,0x0000000d,0x0000019d,0x0000016c,0x0000004c,0x0004003d,0x00000006,0x0000019e, + 0x0000019d,0x00050041,0x0000000d,0x000001a0,0x00000036,0x0000019f,0x0004003d,0x00000006, + 0x000001a1,0x000001a0,0x00050085,0x00000006,0x000001a2,0x0000019e,0x000001a1,0x0004003d, + 0x00000006,0x000001a3,0x0000017e,0x00050081,0x00000006,0x000001a4,0x000001a3,0x000001a2, + 0x0003003e,0x0000017e,0x000001a4,0x00050041,0x0000000d,0x000001a5,0x0000016c,0x00000051, + 0x0004003d,0x00000006,0x000001a6,0x000001a5,0x00050041,0x0000000d,0x000001a8,0x00000036, + 0x000001a7,0x0004003d,0x00000006,0x000001a9,0x000001a8,0x00050085,0x00000006,0x000001aa, + 0x000001a6,0x000001a9,0x0004003d,0x00000006,0x000001ab,0x0000017e,0x00050081,0x00000006, + 0x000001ac,0x000001ab,0x000001aa,0x0003003e,0x0000017e,0x000001ac,0x0003003e,0x000001ad, + 0x000000a5,0x00050041,0x0000000d,0x000001ae,0x00000173,0x0000004c,0x0004003d,0x00000006, + 0x000001af,0x000001ae,0x00050041,0x0000000d,0x000001b0,0x00000036,0x0000015c,0x0004003d, + 0x00000006,0x000001b1,0x000001b0,0x00050085,0x00000006,0x000001b2,0x000001af,0x000001b1, + 0x0004003d,0x00000006,0x000001b3,0x000001ad,0x00050081,0x00000006,0x000001b4,0x000001b3, + 0x000001b2,0x0003003e,0x000001ad,0x000001b4,0x00050041,0x0000000d,0x000001b5,0x00000173, + 0x00000051,0x0004003d,0x00000006,0x000001b6,0x000001b5,0x00050041,0x0000000d,0x000001b7, + 0x00000036,0x0000016f,0x0004003d,0x00000006,0x000001b8,0x000001b7,0x00050085,0x00000006, + 0x000001b9,0x000001b6,0x000001b8,0x0004003d,0x00000006,0x000001ba,0x000001ad,0x00050081, + 0x00000006,0x000001bb,0x000001ba,0x000001b9,0x0003003e,0x000001ad,0x000001bb,0x00050041, + 0x0000000d,0x000001bc,0x00000173,0x00000057,0x0004003d,0x00000006,0x000001bd,0x000001bc, + 0x00050041,0x0000000d,0x000001be,0x00000036,0x00000167,0x0004003d,0x00000006,0x000001bf, + 0x000001be,0x00050085,0x00000006,0x000001c0,0x000001bd,0x000001bf,0x0004003d,0x00000006, + 0x000001c1,0x000001ad,0x00050081,0x00000006,0x000001c2,0x000001c1,0x000001c0,0x0003003e, + 0x000001ad,0x000001c2,0x00050041,0x0000000d,0x000001c3,0x00000173,0x00000194,0x0004003d, + 0x00000006,0x000001c4,0x000001c3,0x00050041,0x0000000d,0x000001c5,0x00000036,0x00000197, + 0x0004003d,0x00000006,0x000001c6,0x000001c5,0x00050085,0x00000006,0x000001c7,0x000001c4, + 0x000001c6,0x0004003d,0x00000006,0x000001c8,0x000001ad,0x00050081,0x00000006,0x000001c9, + 0x000001c8,0x000001c7,0x0003003e,0x000001ad,0x000001c9,0x00050041,0x0000000d,0x000001ca, + 0x00000178,0x0000004c,0x0004003d,0x00000006,0x000001cb,0x000001ca,0x00050041,0x0000000d, + 0x000001cc,0x00000036,0x0000019f,0x0004003d,0x00000006,0x000001cd,0x000001cc,0x00050085, + 0x00000006,0x000001ce,0x000001cb,0x000001cd,0x0004003d,0x00000006,0x000001cf,0x000001ad, + 0x00050081,0x00000006,0x000001d0,0x000001cf,0x000001ce,0x0003003e,0x000001ad,0x000001d0, + 0x00050041,0x0000000d,0x000001d1,0x00000178,0x00000051,0x0004003d,0x00000006,0x000001d2, + 0x000001d1,0x00050041,0x0000000d,0x000001d3,0x00000036,0x000001a7,0x0004003d,0x00000006, + 0x000001d4,0x000001d3,0x00050085,0x00000006,0x000001d5,0x000001d2,0x000001d4,0x0004003d, + 0x00000006,0x000001d6,0x000001ad,0x00050081,0x00000006,0x000001d7,0x000001d6,0x000001d5, + 0x0003003e,0x000001ad,0x000001d7,0x0004003d,0x00000006,0x000001d9,0x0000017e,0x00050083, + 0x00000006,0x000001db,0x000001d9,0x000001da,0x00050085,0x00000006,0x000001dd,0x000001db, + 0x000001dc,0x0008000c,0x00000006,0x000001de,0x00000001,0x0000002b,0x000001dd,0x000000a5, + 0x000000b2,0x00050083,0x00000006,0x000001df,0x000000b2,0x000001de,0x0003003e,0x000001d8, + 0x000001df,0x0004003d,0x00000006,0x000001e1,0x000001d8,0x0004003d,0x00000006,0x000001e4, + 0x000001e3,0x00050085,0x00000006,0x000001e5,0x000001e1,0x000001e4,0x0004003d,0x00000006, + 0x000001e7,0x000001e6,0x00050081,0x00000006,0x000001e8,0x000001e5,0x000001e7,0x0003003e, + 0x000001e0,0x000001e8,0x0004003d,0x00000006,0x000001e9,0x000001e0,0x0004003d,0x00000006, + 0x000001ea,0x000001ad,0x00050085,0x00000006,0x000001eb,0x000001ea,0x000001e9,0x0003003e, + 0x000001ad,0x000001eb,0x0004003d,0x00000006,0x000001ed,0x000001d8,0x0004003d,0x00000006, + 0x000001ef,0x000001ee,0x00050085,0x00000006,0x000001f0,0x000001ed,0x000001ef,0x0004003d, + 0x00000006,0x000001f2,0x000001f1,0x00050081,0x00000006,0x000001f3,0x000001f0,0x000001f2, + 0x0004003d,0x00000006,0x000001f4,0x0000017e,0x00050085,0x00000006,0x000001f5,0x000001f3, + 0x000001f4,0x0003003e,0x000001ec,0x000001f5,0x0004003d,0x00000006,0x000001f6,0x000001ec, + 0x0004003d,0x00000006,0x000001f7,0x000001ec,0x0004007f,0x00000006,0x000001f8,0x000001f7, + 0x0004003d,0x00000006,0x000001f9,0x000001ad,0x0007000c,0x00000006,0x000001fa,0x00000001, + 0x00000028,0x000001f8,0x000001f9,0x0007000c,0x00000006,0x000001fb,0x00000001,0x00000025, + 0x000001f6,0x000001fa,0x0003003e,0x000001ad,0x000001fb,0x00050041,0x0000000d,0x000001fd, + 0x00000036,0x0000015c,0x0004003d,0x00000006,0x000001fe,0x000001fd,0x0003003e,0x000001fc, + 0x000001fe,0x00050041,0x0000000d,0x00000200,0x00000036,0x0000016f,0x0004003d,0x00000006, + 0x00000201,0x00000200,0x0003003e,0x000001ff,0x00000201,0x00050041,0x0000000d,0x00000203, + 0x00000036,0x00000167,0x0004003d,0x00000006,0x00000204,0x00000203,0x0003003e,0x00000202, + 0x00000204,0x00050041,0x0000000d,0x00000206,0x00000036,0x00000197,0x0004003d,0x00000006, + 0x00000207,0x00000206,0x0003003e,0x00000205,0x00000207,0x00050041,0x0000000d,0x00000209, + 0x00000036,0x0000019f,0x0004003d,0x00000006,0x0000020a,0x00000209,0x0003003e,0x00000208, + 0x0000020a,0x00050041,0x0000000d,0x0000020c,0x00000036,0x000001a7,0x0004003d,0x00000006, + 0x0000020d,0x0000020c,0x0003003e,0x0000020b,0x0000020d,0x0004003d,0x00000025,0x0000020f, + 0x00000037,0x0003003e,0x0000020e,0x0000020f,0x000b0039,0x00000006,0x00000210,0x0000002f, + 0x000001fc,0x000001ff,0x00000202,0x00000205,0x00000208,0x0000020b,0x0000020e,0x0004003d, + 0x00000006,0x00000211,0x000001ad,0x00050085,0x00000006,0x00000212,0x00000211,0x00000210, + 0x0003003e,0x000001ad,0x00000212,0x0004003d,0x00000006,0x00000213,0x0000017e,0x0004003d, + 0x00000006,0x00000214,0x000001ad,0x00050081,0x00000006,0x00000215,0x00000213,0x00000214, + 0x000200fe,0x00000215,0x00010038,0x00050036,0x00000006,0x00000040,0x00000000,0x0000003c, + 0x00030037,0x0000003b,0x0000003d,0x00030037,0x00000026,0x0000003e,0x00030037,0x00000026, + 0x0000003f,0x000200f8,0x00000041,0x0004003b,0x0000001b,0x0000021c,0x00000007,0x0004003b, + 0x0000001b,0x00000221,0x00000007,0x0004003b,0x0000001b,0x00000227,0x00000007,0x0004003b, + 0x0000001b,0x0000022c,0x00000007,0x0004003b,0x00000034,0x00000232,0x00000007,0x0004003b, + 0x00000034,0x00000240,0x00000007,0x0004003b,0x0000000d,0x0000024e,0x00000007,0x0004003b, + 0x00000026,0x0000024f,0x00000007,0x0004003b,0x0000000d,0x00000258,0x00000007,0x0004003b, + 0x00000026,0x00000259,0x00000007,0x0004003d,0x00000025,0x00000218,0x0000003e,0x0008000c, + 0x00000025,0x00000219,0x00000001,0x0000002d,0x00000218,0x0000015c,0x0000015d,0x0003003e, + 0x0000003e,0x00000219,0x0004003d,0x00000025,0x0000021a,0x0000003f,0x0008000c,0x00000025, + 0x0000021b,0x00000001,0x0000002d,0x0000021a,0x0000015c,0x0000015d,0x0003003e,0x0000003f, + 0x0000021b,0x0004003d,0x00000025,0x0000021d,0x0000003f,0x00050084,0x00000025,0x0000021e, + 0x0000021d,0x00000167,0x00060041,0x00000169,0x0000021f,0x00000165,0x0000015c,0x0000021e, + 0x0004003d,0x0000000e,0x00000220,0x0000021f,0x0003003e,0x0000021c,0x00000220,0x0004003d, + 0x00000025,0x00000222,0x0000003f,0x00050084,0x00000025,0x00000223,0x00000222,0x00000167, + 0x00050080,0x00000025,0x00000224,0x00000223,0x0000016f,0x00060041,0x00000169,0x00000225, + 0x00000165,0x0000015c,0x00000224,0x0004003d,0x0000000e,0x00000226,0x00000225,0x0003003e, + 0x00000221,0x00000226,0x0004003d,0x00000025,0x00000228,0x0000003e,0x00050084,0x00000025, + 0x00000229,0x00000228,0x00000167,0x00060041,0x00000169,0x0000022a,0x00000165,0x0000015c, + 0x00000229,0x0004003d,0x0000000e,0x0000022b,0x0000022a,0x0003003e,0x00000227,0x0000022b, + 0x0004003d,0x00000025,0x0000022d,0x0000003e,0x00050084,0x00000025,0x0000022e,0x0000022d, + 0x00000167,0x00050080,0x00000025,0x0000022f,0x0000022e,0x0000016f,0x00060041,0x00000169, + 0x00000230,0x00000165,0x0000015c,0x0000022f,0x0004003d,0x0000000e,0x00000231,0x00000230, + 0x0003003e,0x0000022c,0x00000231,0x00050041,0x0000000d,0x00000233,0x0000021c,0x0000004c, + 0x0004003d,0x00000006,0x00000234,0x00000233,0x00050041,0x0000000d,0x00000235,0x0000021c, + 0x00000051,0x0004003d,0x00000006,0x00000236,0x00000235,0x00050041,0x0000000d,0x00000237, + 0x0000021c,0x00000057,0x0004003d,0x00000006,0x00000238,0x00000237,0x00050041,0x0000000d, + 0x00000239,0x0000021c,0x00000194,0x0004003d,0x00000006,0x0000023a,0x00000239,0x00050041, + 0x0000000d,0x0000023b,0x00000221,0x0000004c,0x0004003d,0x00000006,0x0000023c,0x0000023b, + 0x00050041,0x0000000d,0x0000023d,0x00000221,0x00000051,0x0004003d,0x00000006,0x0000023e, + 0x0000023d,0x00090050,0x00000033,0x0000023f,0x00000234,0x00000236,0x00000238,0x0000023a, + 0x0000023c,0x0000023e,0x0003003e,0x00000232,0x0000023f,0x00050041,0x0000000d,0x00000241, + 0x00000227,0x0000004c,0x0004003d,0x00000006,0x00000242,0x00000241,0x00050041,0x0000000d, + 0x00000243,0x00000227,0x00000051,0x0004003d,0x00000006,0x00000244,0x00000243,0x00050041, + 0x0000000d,0x00000245,0x00000227,0x00000057,0x0004003d,0x00000006,0x00000246,0x00000245, + 0x00050041,0x0000000d,0x00000247,0x00000227,0x00000194,0x0004003d,0x00000006,0x00000248, + 0x00000247,0x00050041,0x0000000d,0x00000249,0x0000022c,0x0000004c,0x0004003d,0x00000006, + 0x0000024a,0x00000249,0x00050041,0x0000000d,0x0000024b,0x0000022c,0x00000051,0x0004003d, + 0x00000006,0x0000024c,0x0000024b,0x00090050,0x00000033,0x0000024d,0x00000242,0x00000244, + 0x00000246,0x00000248,0x0000024a,0x0000024c,0x0003003e,0x00000240,0x0000024d,0x0003003e, + 0x0000024e,0x000000a5,0x0003003e,0x0000024f,0x0000015c,0x000200f9,0x00000250,0x000200f8, + 0x00000250,0x000400f6,0x00000252,0x00000253,0x00000000,0x000200f9,0x00000254,0x000200f8, + 0x00000254,0x0004003d,0x00000025,0x00000255,0x0000024f,0x000500b1,0x000000a6,0x00000257, + 0x00000255,0x00000256,0x000400fa,0x00000257,0x00000251,0x00000252,0x000200f8,0x00000251, + 0x0003003e,0x00000258,0x000000a5,0x0003003e,0x00000259,0x0000015c,0x000200f9,0x0000025a, + 0x000200f8,0x0000025a,0x000400f6,0x0000025c,0x0000025d,0x00000000,0x000200f9,0x0000025e, + 0x000200f8,0x0000025e,0x0004003d,0x00000025,0x0000025f,0x00000259,0x000500b1,0x000000a6, + 0x00000260,0x0000025f,0x00000256,0x000400fa,0x00000260,0x0000025b,0x0000025c,0x000200f8, + 0x0000025b,0x0004003d,0x00000025,0x00000261,0x00000259,0x0004003d,0x00000025,0x00000262, + 0x0000024f,0x00060041,0x0000000d,0x00000263,0x0000003d,0x00000261,0x00000262,0x0004003d, + 0x00000006,0x00000264,0x00000263,0x0004003d,0x00000025,0x00000265,0x00000259,0x00050041, + 0x0000000d,0x00000266,0x00000232,0x00000265,0x0004003d,0x00000006,0x00000267,0x00000266, + 0x00050085,0x00000006,0x00000268,0x00000264,0x00000267,0x0004003d,0x00000006,0x00000269, + 0x00000258,0x00050081,0x00000006,0x0000026a,0x00000269,0x00000268,0x0003003e,0x00000258, + 0x0000026a,0x000200f9,0x0000025d,0x000200f8,0x0000025d,0x0004003d,0x00000025,0x0000026b, + 0x00000259,0x00050080,0x00000025,0x0000026c,0x0000026b,0x0000016f,0x0003003e,0x00000259, + 0x0000026c,0x000200f9,0x0000025a,0x000200f8,0x0000025c,0x0004003d,0x00000006,0x0000026d, + 0x00000258,0x0004003d,0x00000025,0x0000026e,0x0000024f,0x00050041,0x0000000d,0x0000026f, + 0x00000240,0x0000026e,0x0004003d,0x00000006,0x00000270,0x0000026f,0x00050085,0x00000006, + 0x00000271,0x0000026d,0x00000270,0x0004003d,0x00000006,0x00000272,0x0000024e,0x00050081, + 0x00000006,0x00000273,0x00000272,0x00000271,0x0003003e,0x0000024e,0x00000273,0x000200f9, + 0x00000253,0x000200f8,0x00000253,0x0004003d,0x00000025,0x00000274,0x0000024f,0x00050080, + 0x00000025,0x00000275,0x00000274,0x0000016f,0x0003003e,0x0000024f,0x00000275,0x000200f9, + 0x00000250,0x000200f8,0x00000252,0x0004003d,0x00000006,0x00000276,0x0000024e,0x000200fe, + 0x00000276,0x00010038,0x00050036,0x00000006,0x00000049,0x00000000,0x00000042,0x00030037, + 0x0000003b,0x00000043,0x00030037,0x0000000d,0x00000044,0x00030037,0x0000000d,0x00000045, + 0x00030037,0x00000026,0x00000046,0x00030037,0x00000026,0x00000047,0x00030037,0x0000001b, + 0x00000048,0x000200f8,0x0000004a,0x0004003b,0x0000000d,0x00000279,0x00000007,0x0004003b, + 0x00000026,0x0000027f,0x00000007,0x0004003b,0x00000034,0x00000287,0x00000007,0x0004003b, + 0x00000034,0x00000294,0x00000007,0x0004003b,0x00000026,0x00000296,0x00000007,0x0004003b, + 0x00000026,0x000002a3,0x00000007,0x0004003b,0x00000034,0x000002ab,0x00000007,0x0004003b, + 0x00000034,0x000002b8,0x00000007,0x0004003b,0x00000026,0x000002ba,0x00000007,0x0004003b, + 0x0000000d,0x000002c7,0x00000007,0x0004003b,0x000002d0,0x000002d1,0x00000007,0x0004003b, + 0x0000000d,0x000002e9,0x00000007,0x0004003b,0x0000000d,0x000002ec,0x00000007,0x0004003b, + 0x0000000d,0x000002f5,0x00000007,0x0004003b,0x0000000d,0x000002f8,0x00000007,0x0004003b, + 0x0000000d,0x00000301,0x00000007,0x0004003b,0x0000000d,0x00000304,0x00000007,0x0004003b, + 0x0000000d,0x0000030d,0x00000007,0x0004003b,0x0000000d,0x00000310,0x00000007,0x0004003b, + 0x0000000d,0x00000335,0x00000007,0x0004003b,0x00000026,0x0000033d,0x00000007,0x0004003b, + 0x00000034,0x00000345,0x00000007,0x0004003b,0x00000026,0x00000351,0x00000007,0x0004003b, + 0x00000034,0x00000364,0x00000007,0x0004003b,0x00000026,0x00000366,0x00000007,0x0004003b, + 0x0000000d,0x00000372,0x00000007,0x0004003b,0x000002d0,0x00000377,0x00000007,0x0004003b, + 0x0000000d,0x0000038f,0x00000007,0x0004003b,0x0000000d,0x00000392,0x00000007,0x0004003b, + 0x0000000d,0x0000039b,0x00000007,0x0004003b,0x0000000d,0x0000039e,0x00000007,0x0004003b, + 0x0000000d,0x000003a7,0x00000007,0x0004003b,0x0000000d,0x000003aa,0x00000007,0x0004003b, + 0x0000000d,0x000003b3,0x00000007,0x0004003b,0x0000000d,0x000003b6,0x00000007,0x0004003b, + 0x0000000d,0x000003db,0x00000007,0x0004003b,0x00000026,0x000003e4,0x00000007,0x0004003b, + 0x00000034,0x000003ec,0x00000007,0x0004003b,0x00000026,0x000003f8,0x00000007,0x0004003b, + 0x00000034,0x0000040a,0x00000007,0x0004003b,0x00000026,0x0000040c,0x00000007,0x0003003e, + 0x00000279,0x000000a5,0x00050041,0x0000000d,0x0000027a,0x00000048,0x0000004c,0x0004003d, + 0x00000006,0x0000027b,0x0000027a,0x000500ba,0x000000a6,0x0000027c,0x0000027b,0x000000a5, + 0x000300f7,0x0000027e,0x00000000,0x000400fa,0x0000027c,0x0000027d,0x0000027e,0x000200f8, + 0x0000027d,0x0003003e,0x0000027f,0x0000015c,0x000200f9,0x00000280,0x000200f8,0x00000280, + 0x000400f6,0x00000282,0x00000283,0x00000000,0x000200f9,0x00000284,0x000200f8,0x00000284, + 0x0004003d,0x00000025,0x00000285,0x0000027f,0x000500b1,0x000000a6,0x00000286,0x00000285, + 0x00000256,0x000400fa,0x00000286,0x00000281,0x00000282,0x000200f8,0x00000281,0x0004003d, + 0x00000025,0x00000288,0x0000027f,0x0004003d,0x00000025,0x00000289,0x0000027f,0x00060041, + 0x0000000d,0x0000028a,0x00000043,0x00000289,0x00000167,0x0004003d,0x00000006,0x0000028b, + 0x0000028a,0x0004003d,0x00000025,0x0000028c,0x0000027f,0x00060041,0x0000000d,0x0000028d, + 0x00000043,0x0000028c,0x00000197,0x0004003d,0x00000006,0x0000028e,0x0000028d,0x0004003d, + 0x00000006,0x0000028f,0x00000044,0x0008000c,0x00000006,0x00000290,0x00000001,0x0000002e, + 0x0000028b,0x0000028e,0x0000028f,0x00050041,0x0000000d,0x00000291,0x00000287,0x00000288, + 0x0003003e,0x00000291,0x00000290,0x000200f9,0x00000283,0x000200f8,0x00000283,0x0004003d, + 0x00000025,0x00000292,0x0000027f,0x00050080,0x00000025,0x00000293,0x00000292,0x0000016f, + 0x0003003e,0x0000027f,0x00000293,0x000200f9,0x00000280,0x000200f8,0x00000282,0x0004003d, + 0x00000033,0x00000295,0x00000287,0x0003003e,0x00000294,0x00000295,0x0004003d,0x00000025, + 0x00000297,0x00000047,0x0003003e,0x00000296,0x00000297,0x00060039,0x00000006,0x00000298, + 0x00000038,0x00000294,0x00000296,0x00050041,0x0000000d,0x00000299,0x00000048,0x0000004c, + 0x0004003d,0x00000006,0x0000029a,0x00000299,0x00050085,0x00000006,0x0000029b,0x00000298, + 0x0000029a,0x0004003d,0x00000006,0x0000029c,0x00000279,0x00050081,0x00000006,0x0000029d, + 0x0000029c,0x0000029b,0x0003003e,0x00000279,0x0000029d,0x000200f9,0x0000027e,0x000200f8, + 0x0000027e,0x00050041,0x0000000d,0x0000029e,0x00000048,0x00000051,0x0004003d,0x00000006, + 0x0000029f,0x0000029e,0x000500ba,0x000000a6,0x000002a0,0x0000029f,0x000000a5,0x000300f7, + 0x000002a2,0x00000000,0x000400fa,0x000002a0,0x000002a1,0x000002a2,0x000200f8,0x000002a1, + 0x0003003e,0x000002a3,0x0000015c,0x000200f9,0x000002a4,0x000200f8,0x000002a4,0x000400f6, + 0x000002a6,0x000002a7,0x00000000,0x000200f9,0x000002a8,0x000200f8,0x000002a8,0x0004003d, + 0x00000025,0x000002a9,0x000002a3,0x000500b1,0x000000a6,0x000002aa,0x000002a9,0x00000256, + 0x000400fa,0x000002aa,0x000002a5,0x000002a6,0x000200f8,0x000002a5,0x0004003d,0x00000025, + 0x000002ac,0x000002a3,0x0004003d,0x00000025,0x000002ad,0x000002a3,0x00060041,0x0000000d, + 0x000002ae,0x00000043,0x00000167,0x000002ad,0x0004003d,0x00000006,0x000002af,0x000002ae, + 0x0004003d,0x00000025,0x000002b0,0x000002a3,0x00060041,0x0000000d,0x000002b1,0x00000043, + 0x00000197,0x000002b0,0x0004003d,0x00000006,0x000002b2,0x000002b1,0x0004003d,0x00000006, + 0x000002b3,0x00000045,0x0008000c,0x00000006,0x000002b4,0x00000001,0x0000002e,0x000002af, + 0x000002b2,0x000002b3,0x00050041,0x0000000d,0x000002b5,0x000002ab,0x000002ac,0x0003003e, + 0x000002b5,0x000002b4,0x000200f9,0x000002a7,0x000200f8,0x000002a7,0x0004003d,0x00000025, + 0x000002b6,0x000002a3,0x00050080,0x00000025,0x000002b7,0x000002b6,0x0000016f,0x0003003e, + 0x000002a3,0x000002b7,0x000200f9,0x000002a4,0x000200f8,0x000002a6,0x0004003d,0x00000033, + 0x000002b9,0x000002ab,0x0003003e,0x000002b8,0x000002b9,0x0004003d,0x00000025,0x000002bb, + 0x00000046,0x0003003e,0x000002ba,0x000002bb,0x00060039,0x00000006,0x000002bc,0x00000038, + 0x000002b8,0x000002ba,0x00050041,0x0000000d,0x000002bd,0x00000048,0x00000051,0x0004003d, + 0x00000006,0x000002be,0x000002bd,0x00050085,0x00000006,0x000002bf,0x000002bc,0x000002be, + 0x0004003d,0x00000006,0x000002c0,0x00000279,0x00050081,0x00000006,0x000002c1,0x000002c0, + 0x000002bf,0x0003003e,0x00000279,0x000002c1,0x000200f9,0x000002a2,0x000200f8,0x000002a2, + 0x00050041,0x0000000d,0x000002c2,0x00000048,0x00000057,0x0004003d,0x00000006,0x000002c3, + 0x000002c2,0x000500ba,0x000000a6,0x000002c4,0x000002c3,0x000000a5,0x000300f7,0x000002c6, + 0x00000000,0x000400fa,0x000002c4,0x000002c5,0x000002c6,0x000200f8,0x000002c5,0x0004003d, + 0x00000006,0x000002c9,0x00000044,0x0004003d,0x00000006,0x000002ca,0x00000045,0x00050083, + 0x00000006,0x000002cb,0x000002c9,0x000002ca,0x00050085,0x00000006,0x000002cc,0x000002c8, + 0x000002cb,0x00050081,0x00000006,0x000002cd,0x000002c8,0x000002cc,0x0003003e,0x000002c7, + 0x000002cd,0x00060041,0x0000000d,0x000002d2,0x00000043,0x00000167,0x0000016f,0x0004003d, + 0x00000006,0x000002d3,0x000002d2,0x00060041,0x0000000d,0x000002d4,0x00000043,0x0000016f, + 0x00000167,0x0004003d,0x00000006,0x000002d5,0x000002d4,0x0004003d,0x00000006,0x000002d6, + 0x000002c7,0x0008000c,0x00000006,0x000002d7,0x00000001,0x0000002e,0x000002d3,0x000002d5, + 0x000002d6,0x00050041,0x0000000d,0x000002d8,0x000002d1,0x0000016f,0x0003003e,0x000002d8, + 0x000002d7,0x00060041,0x0000000d,0x000002d9,0x00000043,0x00000197,0x00000167,0x0004003d, + 0x00000006,0x000002da,0x000002d9,0x00060041,0x0000000d,0x000002db,0x00000043,0x00000167, + 0x00000197,0x0004003d,0x00000006,0x000002dc,0x000002db,0x0004003d,0x00000006,0x000002dd, + 0x000002c7,0x0008000c,0x00000006,0x000002de,0x00000001,0x0000002e,0x000002da,0x000002dc, + 0x000002dd,0x00050041,0x0000000d,0x000002df,0x000002d1,0x00000197,0x0003003e,0x000002df, + 0x000002de,0x00060041,0x0000000d,0x000002e0,0x00000043,0x0000019f,0x00000197,0x0004003d, + 0x00000006,0x000002e1,0x000002e0,0x00060041,0x0000000d,0x000002e2,0x00000043,0x00000197, + 0x0000019f,0x0004003d,0x00000006,0x000002e3,0x000002e2,0x0004003d,0x00000006,0x000002e4, + 0x000002c7,0x0008000c,0x00000006,0x000002e5,0x00000001,0x0000002e,0x000002e1,0x000002e3, + 0x000002e4,0x00050041,0x0000000d,0x000002e6,0x000002d1,0x000001a7,0x0003003e,0x000002e6, + 0x000002e5,0x0004003d,0x00000006,0x000002e7,0x000002c7,0x00050083,0x00000006,0x000002e8, + 0x000002e7,0x000002c8,0x0003003e,0x000002c7,0x000002e8,0x0004003d,0x00000006,0x000002ea, + 0x000002c7,0x000500be,0x000000a6,0x000002eb,0x000002ea,0x000000a5,0x000300f7,0x000002ee, + 0x00000000,0x000400fa,0x000002eb,0x000002ed,0x000002f1,0x000200f8,0x000002ed,0x00060041, + 0x0000000d,0x000002ef,0x00000043,0x0000015c,0x00000167,0x0004003d,0x00000006,0x000002f0, + 0x000002ef,0x0003003e,0x000002ec,0x000002f0,0x000200f9,0x000002ee,0x000200f8,0x000002f1, + 0x00060041,0x0000000d,0x000002f2,0x00000043,0x00000167,0x0000015c,0x0004003d,0x00000006, + 0x000002f3,0x000002f2,0x0003003e,0x000002ec,0x000002f3,0x000200f9,0x000002ee,0x000200f8, + 0x000002ee,0x0004003d,0x00000006,0x000002f4,0x000002ec,0x0003003e,0x000002e9,0x000002f4, + 0x0004003d,0x00000006,0x000002f6,0x000002c7,0x000500be,0x000000a6,0x000002f7,0x000002f6, + 0x000000a5,0x000300f7,0x000002fa,0x00000000,0x000400fa,0x000002f7,0x000002f9,0x000002fd, + 0x000200f8,0x000002f9,0x00060041,0x0000000d,0x000002fb,0x00000043,0x0000016f,0x00000197, + 0x0004003d,0x00000006,0x000002fc,0x000002fb,0x0003003e,0x000002f8,0x000002fc,0x000200f9, + 0x000002fa,0x000200f8,0x000002fd,0x00060041,0x0000000d,0x000002fe,0x00000043,0x00000197, + 0x0000016f,0x0004003d,0x00000006,0x000002ff,0x000002fe,0x0003003e,0x000002f8,0x000002ff, + 0x000200f9,0x000002fa,0x000200f8,0x000002fa,0x0004003d,0x00000006,0x00000300,0x000002f8, + 0x0003003e,0x000002f5,0x00000300,0x0004003d,0x00000006,0x00000302,0x000002c7,0x000500be, + 0x000000a6,0x00000303,0x00000302,0x000000a5,0x000300f7,0x00000306,0x00000000,0x000400fa, + 0x00000303,0x00000305,0x00000309,0x000200f8,0x00000305,0x00060041,0x0000000d,0x00000307, + 0x00000043,0x00000167,0x0000019f,0x0004003d,0x00000006,0x00000308,0x00000307,0x0003003e, + 0x00000304,0x00000308,0x000200f9,0x00000306,0x000200f8,0x00000309,0x00060041,0x0000000d, + 0x0000030a,0x00000043,0x0000019f,0x00000167,0x0004003d,0x00000006,0x0000030b,0x0000030a, + 0x0003003e,0x00000304,0x0000030b,0x000200f9,0x00000306,0x000200f8,0x00000306,0x0004003d, + 0x00000006,0x0000030c,0x00000304,0x0003003e,0x00000301,0x0000030c,0x0004003d,0x00000006, + 0x0000030e,0x000002c7,0x000500be,0x000000a6,0x0000030f,0x0000030e,0x000000a5,0x000300f7, + 0x00000312,0x00000000,0x000400fa,0x0000030f,0x00000311,0x00000315,0x000200f8,0x00000311, + 0x00060041,0x0000000d,0x00000313,0x00000043,0x00000197,0x000001a7,0x0004003d,0x00000006, + 0x00000314,0x00000313,0x0003003e,0x00000310,0x00000314,0x000200f9,0x00000312,0x000200f8, + 0x00000315,0x00060041,0x0000000d,0x00000316,0x00000043,0x000001a7,0x00000197,0x0004003d, + 0x00000006,0x00000317,0x00000316,0x0003003e,0x00000310,0x00000317,0x000200f9,0x00000312, + 0x000200f8,0x00000312,0x0004003d,0x00000006,0x00000318,0x00000310,0x0003003e,0x0000030d, + 0x00000318,0x00060041,0x0000000d,0x00000319,0x00000043,0x0000016f,0x0000016f,0x0004003d, + 0x00000006,0x0000031a,0x00000319,0x0004003d,0x00000006,0x0000031b,0x000002e9,0x0004003d, + 0x00000006,0x0000031c,0x000002c7,0x0006000c,0x00000006,0x0000031d,0x00000001,0x00000004, + 0x0000031c,0x0008000c,0x00000006,0x0000031e,0x00000001,0x0000002e,0x0000031a,0x0000031b, + 0x0000031d,0x00050041,0x0000000d,0x0000031f,0x000002d1,0x0000015c,0x0003003e,0x0000031f, + 0x0000031e,0x00060041,0x0000000d,0x00000320,0x00000043,0x00000167,0x00000167,0x0004003d, + 0x00000006,0x00000321,0x00000320,0x0004003d,0x00000006,0x00000322,0x000002f5,0x0004003d, + 0x00000006,0x00000323,0x000002c7,0x0006000c,0x00000006,0x00000324,0x00000001,0x00000004, + 0x00000323,0x0008000c,0x00000006,0x00000325,0x00000001,0x0000002e,0x00000321,0x00000322, + 0x00000324,0x00050041,0x0000000d,0x00000326,0x000002d1,0x00000167,0x0003003e,0x00000326, + 0x00000325,0x00060041,0x0000000d,0x00000327,0x00000043,0x00000197,0x00000197,0x0004003d, + 0x00000006,0x00000328,0x00000327,0x0004003d,0x00000006,0x00000329,0x00000301,0x0004003d, + 0x00000006,0x0000032a,0x000002c7,0x0006000c,0x00000006,0x0000032b,0x00000001,0x00000004, + 0x0000032a,0x0008000c,0x00000006,0x0000032c,0x00000001,0x0000002e,0x00000328,0x00000329, + 0x0000032b,0x00050041,0x0000000d,0x0000032d,0x000002d1,0x0000019f,0x0003003e,0x0000032d, + 0x0000032c,0x00060041,0x0000000d,0x0000032e,0x00000043,0x0000019f,0x0000019f,0x0004003d, + 0x00000006,0x0000032f,0x0000032e,0x0004003d,0x00000006,0x00000330,0x0000030d,0x0004003d, + 0x00000006,0x00000331,0x000002c7,0x0006000c,0x00000006,0x00000332,0x00000001,0x00000004, + 0x00000331,0x0008000c,0x00000006,0x00000333,0x00000001,0x0000002e,0x0000032f,0x00000330, + 0x00000332,0x00050041,0x0000000d,0x00000334,0x000002d1,0x00000256,0x0003003e,0x00000334, + 0x00000333,0x0004003d,0x00000006,0x00000336,0x00000044,0x0004003d,0x00000006,0x00000337, + 0x00000045,0x00050081,0x00000006,0x00000338,0x00000336,0x00000337,0x0003003e,0x00000335, + 0x00000338,0x0004003d,0x00000006,0x00000339,0x00000335,0x000500be,0x000000a6,0x0000033a, + 0x00000339,0x000000b2,0x000300f7,0x0000033c,0x00000000,0x000400fa,0x0000033a,0x0000033b, + 0x00000350,0x000200f8,0x0000033b,0x0003003e,0x0000033d,0x0000015c,0x000200f9,0x0000033e, + 0x000200f8,0x0000033e,0x000400f6,0x00000340,0x00000341,0x00000000,0x000200f9,0x00000342, + 0x000200f8,0x00000342,0x0004003d,0x00000025,0x00000343,0x0000033d,0x000500b1,0x000000a6, + 0x00000344,0x00000343,0x00000256,0x000400fa,0x00000344,0x0000033f,0x00000340,0x000200f8, + 0x0000033f,0x0004003d,0x00000025,0x00000346,0x0000033d,0x0004003d,0x00000025,0x00000347, + 0x0000033d,0x00050080,0x00000025,0x00000348,0x00000347,0x0000016f,0x00050041,0x0000000d, + 0x00000349,0x000002d1,0x00000348,0x0004003d,0x00000006,0x0000034a,0x00000349,0x00050041, + 0x0000000d,0x0000034b,0x00000345,0x00000346,0x0003003e,0x0000034b,0x0000034a,0x000200f9, + 0x00000341,0x000200f8,0x00000341,0x0004003d,0x00000025,0x0000034c,0x0000033d,0x00050080, + 0x00000025,0x0000034d,0x0000034c,0x0000016f,0x0003003e,0x0000033d,0x0000034d,0x000200f9, + 0x0000033e,0x000200f8,0x00000340,0x0004003d,0x00000006,0x0000034e,0x00000335,0x00050083, + 0x00000006,0x0000034f,0x0000034e,0x000000b2,0x0003003e,0x00000335,0x0000034f,0x000200f9, + 0x0000033c,0x000200f8,0x00000350,0x0003003e,0x00000351,0x0000015c,0x000200f9,0x00000352, + 0x000200f8,0x00000352,0x000400f6,0x00000354,0x00000355,0x00000000,0x000200f9,0x00000356, + 0x000200f8,0x00000356,0x0004003d,0x00000025,0x00000357,0x00000351,0x000500b1,0x000000a6, + 0x00000358,0x00000357,0x00000256,0x000400fa,0x00000358,0x00000353,0x00000354,0x000200f8, + 0x00000353,0x0004003d,0x00000025,0x00000359,0x00000351,0x0004003d,0x00000025,0x0000035a, + 0x00000351,0x00050041,0x0000000d,0x0000035b,0x000002d1,0x0000035a,0x0004003d,0x00000006, + 0x0000035c,0x0000035b,0x00050041,0x0000000d,0x0000035d,0x00000345,0x00000359,0x0003003e, + 0x0000035d,0x0000035c,0x000200f9,0x00000355,0x000200f8,0x00000355,0x0004003d,0x00000025, + 0x0000035e,0x00000351,0x00050080,0x00000025,0x0000035f,0x0000035e,0x0000016f,0x0003003e, + 0x00000351,0x0000035f,0x000200f9,0x00000352,0x000200f8,0x00000354,0x000200f9,0x0000033c, + 0x000200f8,0x0000033c,0x0004003d,0x00000006,0x00000360,0x00000335,0x00050085,0x00000006, + 0x00000362,0x00000360,0x00000361,0x0004006e,0x00000025,0x00000363,0x00000362,0x0004003d, + 0x00000033,0x00000365,0x00000345,0x0003003e,0x00000364,0x00000365,0x0003003e,0x00000366, + 0x00000363,0x00060039,0x00000006,0x00000367,0x00000038,0x00000364,0x00000366,0x00050041, + 0x0000000d,0x00000368,0x00000048,0x00000057,0x0004003d,0x00000006,0x00000369,0x00000368, + 0x00050085,0x00000006,0x0000036a,0x00000367,0x00000369,0x0004003d,0x00000006,0x0000036b, + 0x00000279,0x00050081,0x00000006,0x0000036c,0x0000036b,0x0000036a,0x0003003e,0x00000279, + 0x0000036c,0x000200f9,0x000002c6,0x000200f8,0x000002c6,0x00050041,0x0000000d,0x0000036d, + 0x00000048,0x00000194,0x0004003d,0x00000006,0x0000036e,0x0000036d,0x000500ba,0x000000a6, + 0x0000036f,0x0000036e,0x000000a5,0x000300f7,0x00000371,0x00000000,0x000400fa,0x0000036f, + 0x00000370,0x00000371,0x000200f8,0x00000370,0x0004003d,0x00000006,0x00000373,0x00000044, + 0x0004003d,0x00000006,0x00000374,0x00000045,0x00050081,0x00000006,0x00000375,0x00000373, + 0x00000374,0x00050085,0x00000006,0x00000376,0x000002c8,0x00000375,0x0003003e,0x00000372, + 0x00000376,0x00060041,0x0000000d,0x00000378,0x00000043,0x00000197,0x0000016f,0x0004003d, + 0x00000006,0x00000379,0x00000378,0x00060041,0x0000000d,0x0000037a,0x00000043,0x0000019f, + 0x00000167,0x0004003d,0x00000006,0x0000037b,0x0000037a,0x0004003d,0x00000006,0x0000037c, + 0x00000372,0x0008000c,0x00000006,0x0000037d,0x00000001,0x0000002e,0x00000379,0x0000037b, + 0x0000037c,0x00050041,0x0000000d,0x0000037e,0x00000377,0x0000016f,0x0003003e,0x0000037e, + 0x0000037d,0x00060041,0x0000000d,0x0000037f,0x00000043,0x00000167,0x00000167,0x0004003d, + 0x00000006,0x00000380,0x0000037f,0x00060041,0x0000000d,0x00000381,0x00000043,0x00000197, + 0x00000197,0x0004003d,0x00000006,0x00000382,0x00000381,0x0004003d,0x00000006,0x00000383, + 0x00000372,0x0008000c,0x00000006,0x00000384,0x00000001,0x0000002e,0x00000380,0x00000382, + 0x00000383,0x00050041,0x0000000d,0x00000385,0x00000377,0x00000197,0x0003003e,0x00000385, + 0x00000384,0x00060041,0x0000000d,0x00000386,0x00000043,0x0000016f,0x00000197,0x0004003d, + 0x00000006,0x00000387,0x00000386,0x00060041,0x0000000d,0x00000388,0x00000043,0x00000167, + 0x0000019f,0x0004003d,0x00000006,0x00000389,0x00000388,0x0004003d,0x00000006,0x0000038a, + 0x00000372,0x0008000c,0x00000006,0x0000038b,0x00000001,0x0000002e,0x00000387,0x00000389, + 0x0000038a,0x00050041,0x0000000d,0x0000038c,0x00000377,0x000001a7,0x0003003e,0x0000038c, + 0x0000038b,0x0004003d,0x00000006,0x0000038d,0x00000372,0x00050083,0x00000006,0x0000038e, + 0x0000038d,0x000002c8,0x0003003e,0x00000372,0x0000038e,0x0004003d,0x00000006,0x00000390, + 0x00000372,0x000500be,0x000000a6,0x00000391,0x00000390,0x000000a5,0x000300f7,0x00000394, + 0x00000000,0x000400fa,0x00000391,0x00000393,0x00000397,0x000200f8,0x00000393,0x00060041, + 0x0000000d,0x00000395,0x00000043,0x000001a7,0x00000167,0x0004003d,0x00000006,0x00000396, + 0x00000395,0x0003003e,0x00000392,0x00000396,0x000200f9,0x00000394,0x000200f8,0x00000397, + 0x00060041,0x0000000d,0x00000398,0x00000043,0x00000197,0x0000015c,0x0004003d,0x00000006, + 0x00000399,0x00000398,0x0003003e,0x00000392,0x00000399,0x000200f9,0x00000394,0x000200f8, + 0x00000394,0x0004003d,0x00000006,0x0000039a,0x00000392,0x0003003e,0x0000038f,0x0000039a, + 0x0004003d,0x00000006,0x0000039c,0x00000372,0x000500be,0x000000a6,0x0000039d,0x0000039c, + 0x000000a5,0x000300f7,0x000003a0,0x00000000,0x000400fa,0x0000039d,0x0000039f,0x000003a3, + 0x000200f8,0x0000039f,0x00060041,0x0000000d,0x000003a1,0x00000043,0x0000019f,0x00000197, + 0x0004003d,0x00000006,0x000003a2,0x000003a1,0x0003003e,0x0000039e,0x000003a2,0x000200f9, + 0x000003a0,0x000200f8,0x000003a3,0x00060041,0x0000000d,0x000003a4,0x00000043,0x00000167, + 0x0000016f,0x0004003d,0x00000006,0x000003a5,0x000003a4,0x0003003e,0x0000039e,0x000003a5, + 0x000200f9,0x000003a0,0x000200f8,0x000003a0,0x0004003d,0x00000006,0x000003a6,0x0000039e, + 0x0003003e,0x0000039b,0x000003a6,0x0004003d,0x00000006,0x000003a8,0x00000372,0x000500be, + 0x000000a6,0x000003a9,0x000003a8,0x000000a5,0x000300f7,0x000003ac,0x00000000,0x000400fa, + 0x000003a9,0x000003ab,0x000003af,0x000200f8,0x000003ab,0x00060041,0x0000000d,0x000003ad, + 0x00000043,0x00000197,0x0000019f,0x0004003d,0x00000006,0x000003ae,0x000003ad,0x0003003e, + 0x000003aa,0x000003ae,0x000200f9,0x000003ac,0x000200f8,0x000003af,0x00060041,0x0000000d, + 0x000003b0,0x00000043,0x0000016f,0x00000167,0x0004003d,0x00000006,0x000003b1,0x000003b0, + 0x0003003e,0x000003aa,0x000003b1,0x000200f9,0x000003ac,0x000200f8,0x000003ac,0x0004003d, + 0x00000006,0x000003b2,0x000003aa,0x0003003e,0x000003a7,0x000003b2,0x0004003d,0x00000006, + 0x000003b4,0x00000372,0x000500be,0x000000a6,0x000003b5,0x000003b4,0x000000a5,0x000300f7, + 0x000003b8,0x00000000,0x000400fa,0x000003b5,0x000003b7,0x000003bb,0x000200f8,0x000003b7, + 0x00060041,0x0000000d,0x000003b9,0x00000043,0x00000167,0x000001a7,0x0004003d,0x00000006, + 0x000003ba,0x000003b9,0x0003003e,0x000003b6,0x000003ba,0x000200f9,0x000003b8,0x000200f8, + 0x000003bb,0x00060041,0x0000000d,0x000003bc,0x00000043,0x0000015c,0x00000197,0x0004003d, + 0x00000006,0x000003bd,0x000003bc,0x0003003e,0x000003b6,0x000003bd,0x000200f9,0x000003b8, + 0x000200f8,0x000003b8,0x0004003d,0x00000006,0x000003be,0x000003b6,0x0003003e,0x000003b3, + 0x000003be,0x00060041,0x0000000d,0x000003bf,0x00000043,0x0000019f,0x0000016f,0x0004003d, + 0x00000006,0x000003c0,0x000003bf,0x0004003d,0x00000006,0x000003c1,0x0000038f,0x0004003d, + 0x00000006,0x000003c2,0x00000372,0x0006000c,0x00000006,0x000003c3,0x00000001,0x00000004, + 0x000003c2,0x0008000c,0x00000006,0x000003c4,0x00000001,0x0000002e,0x000003c0,0x000003c1, + 0x000003c3,0x00050041,0x0000000d,0x000003c5,0x00000377,0x0000015c,0x0003003e,0x000003c5, + 0x000003c4,0x00060041,0x0000000d,0x000003c6,0x00000043,0x00000197,0x00000167,0x0004003d, + 0x00000006,0x000003c7,0x000003c6,0x0004003d,0x00000006,0x000003c8,0x0000039b,0x0004003d, + 0x00000006,0x000003c9,0x00000372,0x0006000c,0x00000006,0x000003ca,0x00000001,0x00000004, + 0x000003c9,0x0008000c,0x00000006,0x000003cb,0x00000001,0x0000002e,0x000003c7,0x000003c8, + 0x000003ca,0x00050041,0x0000000d,0x000003cc,0x00000377,0x00000167,0x0003003e,0x000003cc, + 0x000003cb,0x00060041,0x0000000d,0x000003cd,0x00000043,0x00000167,0x00000197,0x0004003d, + 0x00000006,0x000003ce,0x000003cd,0x0004003d,0x00000006,0x000003cf,0x000003a7,0x0004003d, + 0x00000006,0x000003d0,0x00000372,0x0006000c,0x00000006,0x000003d1,0x00000001,0x00000004, + 0x000003d0,0x0008000c,0x00000006,0x000003d2,0x00000001,0x0000002e,0x000003ce,0x000003cf, + 0x000003d1,0x00050041,0x0000000d,0x000003d3,0x00000377,0x0000019f,0x0003003e,0x000003d3, + 0x000003d2,0x00060041,0x0000000d,0x000003d4,0x00000043,0x0000016f,0x0000019f,0x0004003d, + 0x00000006,0x000003d5,0x000003d4,0x0004003d,0x00000006,0x000003d6,0x000003b3,0x0004003d, + 0x00000006,0x000003d7,0x00000372,0x0006000c,0x00000006,0x000003d8,0x00000001,0x00000004, + 0x000003d7,0x0008000c,0x00000006,0x000003d9,0x00000001,0x0000002e,0x000003d5,0x000003d6, + 0x000003d8,0x00050041,0x0000000d,0x000003da,0x00000377,0x00000256,0x0003003e,0x000003da, + 0x000003d9,0x0004003d,0x00000006,0x000003dc,0x00000044,0x0004003d,0x00000006,0x000003dd, + 0x00000045,0x00050083,0x00000006,0x000003de,0x000003dc,0x000003dd,0x00050081,0x00000006, + 0x000003df,0x000000b2,0x000003de,0x0003003e,0x000003db,0x000003df,0x0004003d,0x00000006, + 0x000003e0,0x000003db,0x000500be,0x000000a6,0x000003e1,0x000003e0,0x000000b2,0x000300f7, + 0x000003e3,0x00000000,0x000400fa,0x000003e1,0x000003e2,0x000003f7,0x000200f8,0x000003e2, + 0x0003003e,0x000003e4,0x0000015c,0x000200f9,0x000003e5,0x000200f8,0x000003e5,0x000400f6, + 0x000003e7,0x000003e8,0x00000000,0x000200f9,0x000003e9,0x000200f8,0x000003e9,0x0004003d, + 0x00000025,0x000003ea,0x000003e4,0x000500b1,0x000000a6,0x000003eb,0x000003ea,0x00000256, + 0x000400fa,0x000003eb,0x000003e6,0x000003e7,0x000200f8,0x000003e6,0x0004003d,0x00000025, + 0x000003ed,0x000003e4,0x0004003d,0x00000025,0x000003ee,0x000003e4,0x00050080,0x00000025, + 0x000003ef,0x000003ee,0x0000016f,0x00050041,0x0000000d,0x000003f0,0x00000377,0x000003ef, + 0x0004003d,0x00000006,0x000003f1,0x000003f0,0x00050041,0x0000000d,0x000003f2,0x000003ec, + 0x000003ed,0x0003003e,0x000003f2,0x000003f1,0x000200f9,0x000003e8,0x000200f8,0x000003e8, + 0x0004003d,0x00000025,0x000003f3,0x000003e4,0x00050080,0x00000025,0x000003f4,0x000003f3, + 0x0000016f,0x0003003e,0x000003e4,0x000003f4,0x000200f9,0x000003e5,0x000200f8,0x000003e7, + 0x0004003d,0x00000006,0x000003f5,0x000003db,0x00050083,0x00000006,0x000003f6,0x000003f5, + 0x000000b2,0x0003003e,0x000003db,0x000003f6,0x000200f9,0x000003e3,0x000200f8,0x000003f7, + 0x0003003e,0x000003f8,0x0000015c,0x000200f9,0x000003f9,0x000200f8,0x000003f9,0x000400f6, + 0x000003fb,0x000003fc,0x00000000,0x000200f9,0x000003fd,0x000200f8,0x000003fd,0x0004003d, + 0x00000025,0x000003fe,0x000003f8,0x000500b1,0x000000a6,0x000003ff,0x000003fe,0x00000256, + 0x000400fa,0x000003ff,0x000003fa,0x000003fb,0x000200f8,0x000003fa,0x0004003d,0x00000025, + 0x00000400,0x000003f8,0x0004003d,0x00000025,0x00000401,0x000003f8,0x00050041,0x0000000d, + 0x00000402,0x00000377,0x00000401,0x0004003d,0x00000006,0x00000403,0x00000402,0x00050041, + 0x0000000d,0x00000404,0x000003ec,0x00000400,0x0003003e,0x00000404,0x00000403,0x000200f9, + 0x000003fc,0x000200f8,0x000003fc,0x0004003d,0x00000025,0x00000405,0x000003f8,0x00050080, + 0x00000025,0x00000406,0x00000405,0x0000016f,0x0003003e,0x000003f8,0x00000406,0x000200f9, + 0x000003f9,0x000200f8,0x000003fb,0x000200f9,0x000003e3,0x000200f8,0x000003e3,0x0004003d, + 0x00000006,0x00000407,0x000003db,0x00050085,0x00000006,0x00000408,0x00000407,0x00000361, + 0x0004006e,0x00000025,0x00000409,0x00000408,0x0004003d,0x00000033,0x0000040b,0x000003ec, + 0x0003003e,0x0000040a,0x0000040b,0x0003003e,0x0000040c,0x00000409,0x00060039,0x00000006, + 0x0000040d,0x00000038,0x0000040a,0x0000040c,0x00050041,0x0000000d,0x0000040e,0x00000048, + 0x00000194,0x0004003d,0x00000006,0x0000040f,0x0000040e,0x00050085,0x00000006,0x00000410, + 0x0000040d,0x0000040f,0x0004003d,0x00000006,0x00000411,0x00000279,0x00050081,0x00000006, + 0x00000412,0x00000411,0x00000410,0x0003003e,0x00000279,0x00000412,0x000200f9,0x00000371, + 0x000200f8,0x00000371,0x0004003d,0x00000006,0x00000413,0x00000279,0x000200fe,0x00000413, + 0x00010038 +}; diff --git a/app/src/main/cpp/shaders/nis_coef.h b/app/src/main/cpp/shaders/nis_coef.h new file mode 100644 index 0000000000..77252c738e --- /dev/null +++ b/app/src/main/cpp/shaders/nis_coef.h @@ -0,0 +1,156 @@ +// NVIDIA Image Scaling coefficient banks for nis3.frag (uniform buffer, set 1, binding 0): +// coef_scale and coef_usm, 64 phases x 6 taps, laid out as two vec4 per phase (taps 0-3, taps 4-5 +// + two zeros) to match the shader's std140 vec4[128] arrays. Values = nis.frag's baked tables. +// +// The MIT License (MIT) +// Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of 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. +// +// 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. +#pragma once + +static const float kNisCoefScale[64 * 8] = { + 0.0000f, 0.0000f, 1.0000f, 0.0000f, 0.0000f, 0.0000f, 0.0000f, 0.0000f, // phase 0 + 0.0029f, -0.0127f, 1.0000f, 0.0132f, -0.0034f, 0.0000f, 0.0000f, 0.0000f, // phase 1 + 0.0063f, -0.0249f, 0.9985f, 0.0269f, -0.0068f, 0.0000f, 0.0000f, 0.0000f, // phase 2 + 0.0088f, -0.0361f, 0.9956f, 0.0415f, -0.0103f, 0.0005f, 0.0000f, 0.0000f, // phase 3 + 0.0117f, -0.0474f, 0.9932f, 0.0562f, -0.0142f, 0.0005f, 0.0000f, 0.0000f, // phase 4 + 0.0142f, -0.0576f, 0.9897f, 0.0713f, -0.0181f, 0.0005f, 0.0000f, 0.0000f, // phase 5 + 0.0166f, -0.0674f, 0.9844f, 0.0874f, -0.0220f, 0.0010f, 0.0000f, 0.0000f, // phase 6 + 0.0186f, -0.0762f, 0.9785f, 0.1040f, -0.0264f, 0.0015f, 0.0000f, 0.0000f, // phase 7 + 0.0205f, -0.0850f, 0.9727f, 0.1206f, -0.0308f, 0.0020f, 0.0000f, 0.0000f, // phase 8 + 0.0225f, -0.0928f, 0.9648f, 0.1382f, -0.0352f, 0.0024f, 0.0000f, 0.0000f, // phase 9 + 0.0239f, -0.1006f, 0.9575f, 0.1558f, -0.0396f, 0.0029f, 0.0000f, 0.0000f, // phase 10 + 0.0254f, -0.1074f, 0.9487f, 0.1738f, -0.0439f, 0.0034f, 0.0000f, 0.0000f, // phase 11 + 0.0264f, -0.1138f, 0.9390f, 0.1929f, -0.0488f, 0.0044f, 0.0000f, 0.0000f, // phase 12 + 0.0278f, -0.1191f, 0.9282f, 0.2119f, -0.0537f, 0.0049f, 0.0000f, 0.0000f, // phase 13 + 0.0288f, -0.1245f, 0.9170f, 0.2310f, -0.0581f, 0.0059f, 0.0000f, 0.0000f, // phase 14 + 0.0293f, -0.1294f, 0.9058f, 0.2510f, -0.0630f, 0.0063f, 0.0000f, 0.0000f, // phase 15 + 0.0303f, -0.1333f, 0.8926f, 0.2710f, -0.0679f, 0.0073f, 0.0000f, 0.0000f, // phase 16 + 0.0308f, -0.1367f, 0.8789f, 0.2915f, -0.0728f, 0.0083f, 0.0000f, 0.0000f, // phase 17 + 0.0308f, -0.1401f, 0.8657f, 0.3120f, -0.0776f, 0.0093f, 0.0000f, 0.0000f, // phase 18 + 0.0313f, -0.1426f, 0.8506f, 0.3330f, -0.0825f, 0.0103f, 0.0000f, 0.0000f, // phase 19 + 0.0313f, -0.1445f, 0.8354f, 0.3540f, -0.0874f, 0.0112f, 0.0000f, 0.0000f, // phase 20 + 0.0313f, -0.1460f, 0.8193f, 0.3755f, -0.0923f, 0.0122f, 0.0000f, 0.0000f, // phase 21 + 0.0313f, -0.1470f, 0.8022f, 0.3965f, -0.0967f, 0.0137f, 0.0000f, 0.0000f, // phase 22 + 0.0308f, -0.1479f, 0.7856f, 0.4185f, -0.1016f, 0.0146f, 0.0000f, 0.0000f, // phase 23 + 0.0303f, -0.1479f, 0.7681f, 0.4399f, -0.1060f, 0.0156f, 0.0000f, 0.0000f, // phase 24 + 0.0298f, -0.1479f, 0.7505f, 0.4614f, -0.1104f, 0.0166f, 0.0000f, 0.0000f, // phase 25 + 0.0293f, -0.1470f, 0.7314f, 0.4829f, -0.1147f, 0.0181f, 0.0000f, 0.0000f, // phase 26 + 0.0288f, -0.1460f, 0.7119f, 0.5049f, -0.1187f, 0.0190f, 0.0000f, 0.0000f, // phase 27 + 0.0278f, -0.1445f, 0.6929f, 0.5264f, -0.1226f, 0.0200f, 0.0000f, 0.0000f, // phase 28 + 0.0273f, -0.1431f, 0.6724f, 0.5479f, -0.1260f, 0.0215f, 0.0000f, 0.0000f, // phase 29 + 0.0264f, -0.1411f, 0.6528f, 0.5693f, -0.1299f, 0.0225f, 0.0000f, 0.0000f, // phase 30 + 0.0254f, -0.1387f, 0.6323f, 0.5903f, -0.1328f, 0.0234f, 0.0000f, 0.0000f, // phase 31 + 0.0244f, -0.1357f, 0.6113f, 0.6113f, -0.1357f, 0.0244f, 0.0000f, 0.0000f, // phase 32 + 0.0234f, -0.1328f, 0.5903f, 0.6323f, -0.1387f, 0.0254f, 0.0000f, 0.0000f, // phase 33 + 0.0225f, -0.1299f, 0.5693f, 0.6528f, -0.1411f, 0.0264f, 0.0000f, 0.0000f, // phase 34 + 0.0215f, -0.1260f, 0.5479f, 0.6724f, -0.1431f, 0.0273f, 0.0000f, 0.0000f, // phase 35 + 0.0200f, -0.1226f, 0.5264f, 0.6929f, -0.1445f, 0.0278f, 0.0000f, 0.0000f, // phase 36 + 0.0190f, -0.1187f, 0.5049f, 0.7119f, -0.1460f, 0.0288f, 0.0000f, 0.0000f, // phase 37 + 0.0181f, -0.1147f, 0.4829f, 0.7314f, -0.1470f, 0.0293f, 0.0000f, 0.0000f, // phase 38 + 0.0166f, -0.1104f, 0.4614f, 0.7505f, -0.1479f, 0.0298f, 0.0000f, 0.0000f, // phase 39 + 0.0156f, -0.1060f, 0.4399f, 0.7681f, -0.1479f, 0.0303f, 0.0000f, 0.0000f, // phase 40 + 0.0146f, -0.1016f, 0.4185f, 0.7856f, -0.1479f, 0.0308f, 0.0000f, 0.0000f, // phase 41 + 0.0137f, -0.0967f, 0.3965f, 0.8022f, -0.1470f, 0.0313f, 0.0000f, 0.0000f, // phase 42 + 0.0122f, -0.0923f, 0.3755f, 0.8193f, -0.1460f, 0.0313f, 0.0000f, 0.0000f, // phase 43 + 0.0112f, -0.0874f, 0.3540f, 0.8354f, -0.1445f, 0.0313f, 0.0000f, 0.0000f, // phase 44 + 0.0103f, -0.0825f, 0.3330f, 0.8506f, -0.1426f, 0.0313f, 0.0000f, 0.0000f, // phase 45 + 0.0093f, -0.0776f, 0.3120f, 0.8657f, -0.1401f, 0.0308f, 0.0000f, 0.0000f, // phase 46 + 0.0083f, -0.0728f, 0.2915f, 0.8789f, -0.1367f, 0.0308f, 0.0000f, 0.0000f, // phase 47 + 0.0073f, -0.0679f, 0.2710f, 0.8926f, -0.1333f, 0.0303f, 0.0000f, 0.0000f, // phase 48 + 0.0063f, -0.0630f, 0.2510f, 0.9058f, -0.1294f, 0.0293f, 0.0000f, 0.0000f, // phase 49 + 0.0059f, -0.0581f, 0.2310f, 0.9170f, -0.1245f, 0.0288f, 0.0000f, 0.0000f, // phase 50 + 0.0049f, -0.0537f, 0.2119f, 0.9282f, -0.1191f, 0.0278f, 0.0000f, 0.0000f, // phase 51 + 0.0044f, -0.0488f, 0.1929f, 0.9390f, -0.1138f, 0.0264f, 0.0000f, 0.0000f, // phase 52 + 0.0034f, -0.0439f, 0.1738f, 0.9487f, -0.1074f, 0.0254f, 0.0000f, 0.0000f, // phase 53 + 0.0029f, -0.0396f, 0.1558f, 0.9575f, -0.1006f, 0.0239f, 0.0000f, 0.0000f, // phase 54 + 0.0024f, -0.0352f, 0.1382f, 0.9648f, -0.0928f, 0.0225f, 0.0000f, 0.0000f, // phase 55 + 0.0020f, -0.0308f, 0.1206f, 0.9727f, -0.0850f, 0.0205f, 0.0000f, 0.0000f, // phase 56 + 0.0015f, -0.0264f, 0.1040f, 0.9785f, -0.0762f, 0.0186f, 0.0000f, 0.0000f, // phase 57 + 0.0010f, -0.0220f, 0.0874f, 0.9844f, -0.0674f, 0.0166f, 0.0000f, 0.0000f, // phase 58 + 0.0005f, -0.0181f, 0.0713f, 0.9897f, -0.0576f, 0.0142f, 0.0000f, 0.0000f, // phase 59 + 0.0005f, -0.0142f, 0.0562f, 0.9932f, -0.0474f, 0.0117f, 0.0000f, 0.0000f, // phase 60 + 0.0005f, -0.0103f, 0.0415f, 0.9956f, -0.0361f, 0.0088f, 0.0000f, 0.0000f, // phase 61 + 0.0000f, -0.0068f, 0.0269f, 0.9985f, -0.0249f, 0.0063f, 0.0000f, 0.0000f, // phase 62 + 0.0000f, -0.0034f, 0.0132f, 1.0000f, -0.0127f, 0.0029f, 0.0000f, 0.0000f, // phase 63 +}; + +static const float kNisCoefUsm[64 * 8] = { + 0.0000f, -0.6001f, 1.2002f, -0.6001f, 0.0000f, 0.0000f, 0.0000f, 0.0000f, // phase 0 + 0.0029f, -0.6084f, 1.1987f, -0.5903f, -0.0029f, 0.0000f, 0.0000f, 0.0000f, // phase 1 + 0.0049f, -0.6147f, 1.1958f, -0.5791f, -0.0068f, 0.0005f, 0.0000f, 0.0000f, // phase 2 + 0.0073f, -0.6196f, 1.1890f, -0.5659f, -0.0103f, 0.0000f, 0.0000f, 0.0000f, // phase 3 + 0.0093f, -0.6235f, 1.1802f, -0.5513f, -0.0151f, 0.0000f, 0.0000f, 0.0000f, // phase 4 + 0.0112f, -0.6265f, 1.1699f, -0.5352f, -0.0195f, 0.0005f, 0.0000f, 0.0000f, // phase 5 + 0.0122f, -0.6270f, 1.1582f, -0.5181f, -0.0259f, 0.0005f, 0.0000f, 0.0000f, // phase 6 + 0.0142f, -0.6284f, 1.1455f, -0.5005f, -0.0317f, 0.0005f, 0.0000f, 0.0000f, // phase 7 + 0.0156f, -0.6265f, 1.1274f, -0.4790f, -0.0386f, 0.0005f, 0.0000f, 0.0000f, // phase 8 + 0.0166f, -0.6235f, 1.1089f, -0.4570f, -0.0454f, 0.0010f, 0.0000f, 0.0000f, // phase 9 + 0.0176f, -0.6187f, 1.0879f, -0.4346f, -0.0532f, 0.0010f, 0.0000f, 0.0000f, // phase 10 + 0.0181f, -0.6138f, 1.0659f, -0.4102f, -0.0615f, 0.0015f, 0.0000f, 0.0000f, // phase 11 + 0.0190f, -0.6069f, 1.0405f, -0.3843f, -0.0698f, 0.0015f, 0.0000f, 0.0000f, // phase 12 + 0.0195f, -0.6006f, 1.0161f, -0.3574f, -0.0796f, 0.0020f, 0.0000f, 0.0000f, // phase 13 + 0.0200f, -0.5928f, 0.9893f, -0.3286f, -0.0898f, 0.0024f, 0.0000f, 0.0000f, // phase 14 + 0.0200f, -0.5820f, 0.9580f, -0.2988f, -0.1001f, 0.0029f, 0.0000f, 0.0000f, // phase 15 + 0.0200f, -0.5728f, 0.9292f, -0.2690f, -0.1104f, 0.0034f, 0.0000f, 0.0000f, // phase 16 + 0.0200f, -0.5620f, 0.8975f, -0.2368f, -0.1226f, 0.0039f, 0.0000f, 0.0000f, // phase 17 + 0.0205f, -0.5498f, 0.8643f, -0.2046f, -0.1343f, 0.0044f, 0.0000f, 0.0000f, // phase 18 + 0.0200f, -0.5371f, 0.8301f, -0.1709f, -0.1465f, 0.0049f, 0.0000f, 0.0000f, // phase 19 + 0.0195f, -0.5239f, 0.7944f, -0.1367f, -0.1587f, 0.0054f, 0.0000f, 0.0000f, // phase 20 + 0.0195f, -0.5107f, 0.7598f, -0.1021f, -0.1724f, 0.0059f, 0.0000f, 0.0000f, // phase 21 + 0.0190f, -0.4966f, 0.7231f, -0.0649f, -0.1865f, 0.0063f, 0.0000f, 0.0000f, // phase 22 + 0.0186f, -0.4819f, 0.6846f, -0.0288f, -0.1997f, 0.0068f, 0.0000f, 0.0000f, // phase 23 + 0.0186f, -0.4668f, 0.6460f, 0.0093f, -0.2144f, 0.0073f, 0.0000f, 0.0000f, // phase 24 + 0.0176f, -0.4507f, 0.6055f, 0.0479f, -0.2290f, 0.0083f, 0.0000f, 0.0000f, // phase 25 + 0.0171f, -0.4370f, 0.5693f, 0.0859f, -0.2446f, 0.0088f, 0.0000f, 0.0000f, // phase 26 + 0.0161f, -0.4199f, 0.5283f, 0.1255f, -0.2598f, 0.0098f, 0.0000f, 0.0000f, // phase 27 + 0.0161f, -0.4048f, 0.4883f, 0.1655f, -0.2754f, 0.0103f, 0.0000f, 0.0000f, // phase 28 + 0.0151f, -0.3887f, 0.4497f, 0.2041f, -0.2910f, 0.0107f, 0.0000f, 0.0000f, // phase 29 + 0.0142f, -0.3711f, 0.4072f, 0.2446f, -0.3066f, 0.0117f, 0.0000f, 0.0000f, // phase 30 + 0.0137f, -0.3555f, 0.3672f, 0.2852f, -0.3228f, 0.0122f, 0.0000f, 0.0000f, // phase 31 + 0.0132f, -0.3394f, 0.3262f, 0.3262f, -0.3394f, 0.0132f, 0.0000f, 0.0000f, // phase 32 + 0.0122f, -0.3228f, 0.2852f, 0.3672f, -0.3555f, 0.0137f, 0.0000f, 0.0000f, // phase 33 + 0.0117f, -0.3066f, 0.2446f, 0.4072f, -0.3711f, 0.0142f, 0.0000f, 0.0000f, // phase 34 + 0.0107f, -0.2910f, 0.2041f, 0.4497f, -0.3887f, 0.0151f, 0.0000f, 0.0000f, // phase 35 + 0.0103f, -0.2754f, 0.1655f, 0.4883f, -0.4048f, 0.0161f, 0.0000f, 0.0000f, // phase 36 + 0.0098f, -0.2598f, 0.1255f, 0.5283f, -0.4199f, 0.0161f, 0.0000f, 0.0000f, // phase 37 + 0.0088f, -0.2446f, 0.0859f, 0.5693f, -0.4370f, 0.0171f, 0.0000f, 0.0000f, // phase 38 + 0.0083f, -0.2290f, 0.0479f, 0.6055f, -0.4507f, 0.0176f, 0.0000f, 0.0000f, // phase 39 + 0.0073f, -0.2144f, 0.0093f, 0.6460f, -0.4668f, 0.0186f, 0.0000f, 0.0000f, // phase 40 + 0.0068f, -0.1997f, -0.0288f, 0.6846f, -0.4819f, 0.0186f, 0.0000f, 0.0000f, // phase 41 + 0.0063f, -0.1865f, -0.0649f, 0.7231f, -0.4966f, 0.0190f, 0.0000f, 0.0000f, // phase 42 + 0.0059f, -0.1724f, -0.1021f, 0.7598f, -0.5107f, 0.0195f, 0.0000f, 0.0000f, // phase 43 + 0.0054f, -0.1587f, -0.1367f, 0.7944f, -0.5239f, 0.0195f, 0.0000f, 0.0000f, // phase 44 + 0.0049f, -0.1465f, -0.1709f, 0.8301f, -0.5371f, 0.0200f, 0.0000f, 0.0000f, // phase 45 + 0.0044f, -0.1343f, -0.2046f, 0.8643f, -0.5498f, 0.0205f, 0.0000f, 0.0000f, // phase 46 + 0.0039f, -0.1226f, -0.2368f, 0.8975f, -0.5620f, 0.0200f, 0.0000f, 0.0000f, // phase 47 + 0.0034f, -0.1104f, -0.2690f, 0.9292f, -0.5728f, 0.0200f, 0.0000f, 0.0000f, // phase 48 + 0.0029f, -0.1001f, -0.2988f, 0.9580f, -0.5820f, 0.0200f, 0.0000f, 0.0000f, // phase 49 + 0.0024f, -0.0898f, -0.3286f, 0.9893f, -0.5928f, 0.0200f, 0.0000f, 0.0000f, // phase 50 + 0.0020f, -0.0796f, -0.3574f, 1.0161f, -0.6006f, 0.0195f, 0.0000f, 0.0000f, // phase 51 + 0.0015f, -0.0698f, -0.3843f, 1.0405f, -0.6069f, 0.0190f, 0.0000f, 0.0000f, // phase 52 + 0.0015f, -0.0615f, -0.4102f, 1.0659f, -0.6138f, 0.0181f, 0.0000f, 0.0000f, // phase 53 + 0.0010f, -0.0532f, -0.4346f, 1.0879f, -0.6187f, 0.0176f, 0.0000f, 0.0000f, // phase 54 + 0.0010f, -0.0454f, -0.4570f, 1.1089f, -0.6235f, 0.0166f, 0.0000f, 0.0000f, // phase 55 + 0.0005f, -0.0386f, -0.4790f, 1.1274f, -0.6265f, 0.0156f, 0.0000f, 0.0000f, // phase 56 + 0.0005f, -0.0317f, -0.5005f, 1.1455f, -0.6284f, 0.0142f, 0.0000f, 0.0000f, // phase 57 + 0.0005f, -0.0259f, -0.5181f, 1.1582f, -0.6270f, 0.0122f, 0.0000f, 0.0000f, // phase 58 + 0.0005f, -0.0195f, -0.5352f, 1.1699f, -0.6265f, 0.0112f, 0.0000f, 0.0000f, // phase 59 + 0.0000f, -0.0151f, -0.5513f, 1.1802f, -0.6235f, 0.0093f, 0.0000f, 0.0000f, // phase 60 + 0.0000f, -0.0103f, -0.5659f, 1.1890f, -0.6196f, 0.0073f, 0.0000f, 0.0000f, // phase 61 + 0.0005f, -0.0068f, -0.5791f, 1.1958f, -0.6147f, 0.0049f, 0.0000f, 0.0000f, // phase 62 + 0.0000f, -0.0029f, -0.5903f, 1.1987f, -0.6084f, 0.0029f, 0.0000f, 0.0000f, // phase 63 +}; diff --git a/app/src/main/cpp/shaders/nis_frag.h b/app/src/main/cpp/shaders/nis_frag.h index b20294eae8..8946f147c9 100644 --- a/app/src/main/cpp/shaders/nis_frag.h +++ b/app/src/main/cpp/shaders/nis_frag.h @@ -1,8 +1,9 @@ + // 1116.3.0 #pragma once const uint32_t nis_code[] = { - 0x07230203,0x00010000,0x0008000b,0x00000644,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x07230203,0x00010000,0x0008000b,0x0000062f,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000051f,0x00000637,0x00030010, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000050a,0x00000622,0x00030010, 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00050005,0x0000000b,0x59746567,0x33667628,0x0000003b,0x00030005,0x0000000a, 0x00626772,0x000b0005,0x00000019,0x65676465,0x66287441,0x31663b31,0x3b31663b,0x663b3166, @@ -28,1194 +29,1180 @@ const uint32_t nis_code[] = { 0x00000000,0x00060005,0x00000045,0x73616870,0x5f795f65,0x63617266,0x00000000,0x00070005, 0x00000046,0x73616870,0x5f785f65,0x63617266,0x746e695f,0x00000000,0x00070005,0x00000047, 0x73616870,0x5f795f65,0x63617266,0x746e695f,0x00000000,0x00030005,0x00000048,0x00000077, - 0x00030005,0x0000005e,0x00305f67,0x00040005,0x0000006b,0x35345f67,0x00000000,0x00040005, - 0x00000078,0x30395f67,0x00000000,0x00040005,0x00000085,0x33315f67,0x00000035,0x00050005, - 0x00000092,0x5f305f67,0x6d5f3039,0x00007861,0x00050005,0x00000096,0x5f305f67,0x6d5f3039, - 0x00006e69,0x00060005,0x0000009a,0x35345f67,0x3533315f,0x78616d5f,0x00000000,0x00060005, - 0x0000009e,0x35345f67,0x3533315f,0x6e696d5f,0x00000000,0x00040005,0x000000ac,0x5f305f65, - 0x00003039,0x00050005,0x000000b4,0x35345f65,0x3533315f,0x00000000,0x00040005,0x000000b8, - 0x5f305f63,0x00003039,0x00050005,0x000000c6,0x35345f63,0x3533315f,0x00000000,0x00050005, - 0x000000d2,0x5f675f63,0x30395f30,0x00000000,0x00050005,0x000000d6,0x5f675f63,0x315f3534, - 0x00003533,0x00050005,0x000000da,0x5f655f66,0x30395f30,0x00000000,0x00050005,0x000000e0, - 0x5f655f66,0x315f3534,0x00003533,0x00030005,0x000000e6,0x00003077,0x00030005,0x000000ec, - 0x00303977,0x00030005,0x000000f3,0x00353477,0x00040005,0x000000f9,0x35333177,0x00000000, - 0x00030005,0x00000107,0x00003068,0x00030005,0x0000010d,0x00003168,0x00050005,0x0000011a, - 0x656c6573,0x726f7463,0x00000000,0x00030005,0x0000011e,0x006c6573,0x00040005,0x00000123, - 0x696d5f61,0x0000006e,0x00040005,0x00000129,0x616d5f61,0x00000078,0x00040005,0x00000133, - 0x696d5f62,0x0000006e,0x00040005,0x00000139,0x616d5f62,0x00000078,0x00040005,0x0000013f, - 0x6f635f61,0x0000746e,0x00040005,0x00000143,0x6f635f62,0x0000746e,0x00050005,0x00000147, - 0x746e6f63,0x7461725f,0x00006f69,0x00030005,0x0000015f,0x00000079,0x00030005,0x00000160, - 0x00000069,0x00050005,0x00000215,0x65646e69,0x6c626178,0x00000065,0x00040005,0x00000221, - 0x73755f79,0x0000006d,0x00030005,0x00000222,0x00000069,0x00050005,0x000002b0,0x65646e69, - 0x6c626178,0x00000065,0x00040005,0x000002bb,0x63735f79,0x00656c61,0x00050005,0x000002c3, - 0x68735f79,0x6e707261,0x00737365,0x00070005,0x000002c6,0x61685367,0x74537072,0x676e6572, - 0x63536874,0x00656c61,0x00070005,0x000002c9,0x61685367,0x74537072,0x676e6572,0x694d6874, - 0x0000006e,0x00070005,0x000002cf,0x68735f79,0x6e707261,0x5f737365,0x696d696c,0x00000074, - 0x00070005,0x000002d1,0x61685367,0x694c7072,0x5374696d,0x656c6163,0x00000000,0x00060005, - 0x000002d4,0x61685367,0x694c7072,0x4d74696d,0x00006e69,0x00040005,0x000002e3,0x61726170, - 0x0000006d,0x00040005,0x000002e6,0x61726170,0x0000006d,0x00040005,0x000002e9,0x61726170, - 0x0000006d,0x00040005,0x000002ec,0x61726170,0x0000006d,0x00040005,0x000002ef,0x61726170, - 0x0000006d,0x00040005,0x000002f2,0x61726170,0x0000006d,0x00040005,0x000002f5,0x61726170, - 0x0000006d,0x00040005,0x00000303,0x63615f68,0x00000063,0x00030005,0x00000304,0x0000006a, - 0x00040005,0x0000030c,0x63615f76,0x00000063,0x00030005,0x0000030d,0x00000069,0x00050005, - 0x0000031d,0x65646e69,0x6c626178,0x00000065,0x00050005,0x0000032a,0x65646e69,0x6c626178, - 0x00000065,0x00030005,0x00000335,0x00000066,0x00030005,0x0000033b,0x00000069,0x00050005, - 0x00000343,0x65746e69,0x44307072,0x00006765,0x00040005,0x00000350,0x61726170,0x0000006d, - 0x00040005,0x00000352,0x61726170,0x0000006d,0x00030005,0x0000035f,0x00000069,0x00050005, - 0x00000367,0x65746e69,0x30397072,0x00676544,0x00040005,0x00000374,0x61726170,0x0000006d, - 0x00040005,0x00000376,0x61726170,0x0000006d,0x00050005,0x00000383,0x61687070,0x625f6573, - 0x00003534,0x00070005,0x0000038d,0x706d6574,0x746e695f,0x34707265,0x67654435,0x00000000, - 0x00030005,0x000003a5,0x00000061,0x00030005,0x000003b1,0x00000062,0x00030005,0x000003bd, - 0x00000063,0x00030005,0x000003c9,0x00000064,0x00050005,0x000003f1,0x61687070,0x705f6573, - 0x00003534,0x00030005,0x000003f9,0x00000069,0x00050005,0x00000401,0x65746e69,0x35347072, - 0x00676544,0x00030005,0x0000040d,0x00000069,0x00040005,0x00000420,0x61726170,0x0000006d, - 0x00040005,0x00000422,0x61726170,0x0000006d,0x00050005,0x0000042f,0x61687070,0x625f6573, - 0x00353331,0x00070005,0x00000434,0x706d6574,0x746e695f,0x31707265,0x65443533,0x00000067, - 0x00030005,0x0000044c,0x00000061,0x00030005,0x00000458,0x00000062,0x00030005,0x00000464, - 0x00000063,0x00030005,0x00000470,0x00000064,0x00050005,0x00000498,0x61687070,0x705f6573, - 0x00353331,0x00030005,0x000004a1,0x00000069,0x00060005,0x000004a9,0x65746e69,0x33317072, - 0x67654435,0x00000000,0x00030005,0x000004b5,0x00000069,0x00040005,0x000004c7,0x61726170, - 0x0000006d,0x00040005,0x000004c9,0x61726170,0x0000006d,0x00050005,0x000004d3,0x72616873, - 0x73656e70,0x00000073,0x00030005,0x000004d4,0x00004350,0x00040006,0x000004d4,0x00000000, - 0x0063646e,0x00070006,0x000004d4,0x00000001,0x77656956,0x74726f70,0x6f666e49,0x00000000, - 0x00060006,0x000004d4,0x00000002,0x72616873,0x73656e70,0x00000073,0x00030005,0x000004d6, - 0x00006370,0x00060005,0x000004db,0x72616873,0x5f6e6570,0x64696c73,0x00007265,0x00050005, - 0x000004de,0x5378614d,0x656c6163,0x00000000,0x00050005,0x000004e4,0x536e694d,0x656c6163, - 0x00000000,0x00050005,0x000004e8,0x696d694c,0x61635374,0x0000656c,0x00070005,0x000004f4, - 0x72616873,0x72745370,0x74676e65,0x78614d68,0x00000000,0x00060005,0x00000508,0x72616873, - 0x6d694c70,0x614d7469,0x00000078,0x00040005,0x00000514,0x69536e69,0x0000657a,0x00040005, - 0x00000519,0x49766e69,0x0000006e,0x00040005,0x0000051d,0x58637273,0x00000000,0x00060005, - 0x0000051f,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00040005,0x00000527,0x59637273, - 0x00000000,0x00030005,0x0000052e,0x00787366,0x00030005,0x00000531,0x00797366,0x00030005, - 0x00000534,0x00007866,0x00030005,0x00000538,0x00007966,0x00040005,0x0000053c,0x695f7866, - 0x0000746e,0x00040005,0x00000540,0x695f7966,0x0000746e,0x00030005,0x00000544,0x00000069, - 0x00030005,0x0000054c,0x0000006a,0x00030005,0x00000554,0x00006374,0x00030005,0x00000564, - 0x00000070,0x00060005,0x0000056a,0x75706e49,0x78655474,0x65727574,0x00000000,0x00040005, - 0x0000056e,0x61726170,0x0000006d,0x00030005,0x00000576,0x00303065,0x00040005,0x00000577, - 0x61726170,0x0000006d,0x00040005,0x0000057a,0x61726170,0x0000006d,0x00040005,0x0000057d, - 0x61726170,0x0000006d,0x00040005,0x00000580,0x61726170,0x0000006d,0x00040005,0x00000583, - 0x61726170,0x0000006d,0x00040005,0x00000586,0x61726170,0x0000006d,0x00040005,0x00000589, - 0x61726170,0x0000006d,0x00040005,0x0000058c,0x61726170,0x0000006d,0x00040005,0x0000058f, - 0x61726170,0x0000006d,0x00030005,0x00000593,0x00313065,0x00040005,0x00000594,0x61726170, - 0x0000006d,0x00040005,0x00000597,0x61726170,0x0000006d,0x00040005,0x0000059a,0x61726170, - 0x0000006d,0x00040005,0x0000059d,0x61726170,0x0000006d,0x00040005,0x000005a0,0x61726170, - 0x0000006d,0x00040005,0x000005a3,0x61726170,0x0000006d,0x00040005,0x000005a6,0x61726170, - 0x0000006d,0x00040005,0x000005a9,0x61726170,0x0000006d,0x00040005,0x000005ac,0x61726170, - 0x0000006d,0x00030005,0x000005b0,0x00303165,0x00040005,0x000005b1,0x61726170,0x0000006d, - 0x00040005,0x000005b4,0x61726170,0x0000006d,0x00040005,0x000005b7,0x61726170,0x0000006d, - 0x00040005,0x000005ba,0x61726170,0x0000006d,0x00040005,0x000005bd,0x61726170,0x0000006d, - 0x00040005,0x000005c0,0x61726170,0x0000006d,0x00040005,0x000005c3,0x61726170,0x0000006d, - 0x00040005,0x000005c6,0x61726170,0x0000006d,0x00040005,0x000005c9,0x61726170,0x0000006d, - 0x00030005,0x000005cd,0x00313165,0x00040005,0x000005ce,0x61726170,0x0000006d,0x00040005, - 0x000005d1,0x61726170,0x0000006d,0x00040005,0x000005d4,0x61726170,0x0000006d,0x00040005, - 0x000005d7,0x61726170,0x0000006d,0x00040005,0x000005da,0x61726170,0x0000006d,0x00040005, - 0x000005dd,0x61726170,0x0000006d,0x00040005,0x000005e0,0x61726170,0x0000006d,0x00040005, - 0x000005e3,0x61726170,0x0000006d,0x00040005,0x000005e6,0x61726170,0x0000006d,0x00030005, - 0x000005ea,0x00000077,0x00040005,0x000005eb,0x61726170,0x0000006d,0x00040005,0x000005ed, - 0x61726170,0x0000006d,0x00040005,0x000005ef,0x61726170,0x0000006d,0x00040005,0x000005f1, - 0x61726170,0x0000006d,0x00040005,0x000005f3,0x61726170,0x0000006d,0x00040005,0x000005f5, - 0x61726170,0x0000006d,0x00050005,0x000005f8,0x65736162,0x67696557,0x00007468,0x00030005, - 0x00000605,0x0059706f,0x00040005,0x00000606,0x61726170,0x0000006d,0x00040005,0x00000608, - 0x61726170,0x0000006d,0x00040005,0x0000060a,0x61726170,0x0000006d,0x00040005,0x0000060f, - 0x61726170,0x0000006d,0x00040005,0x00000611,0x61726170,0x0000006d,0x00040005,0x00000613, - 0x61726170,0x0000006d,0x00040005,0x00000615,0x61726170,0x0000006d,0x00040005,0x00000617, - 0x61726170,0x0000006d,0x00040005,0x00000619,0x61726170,0x0000006d,0x00030005,0x0000061e, - 0x0000706f,0x00030005,0x00000622,0x00000079,0x00040005,0x00000623,0x61726170,0x0000006d, - 0x00040005,0x00000627,0x72726f63,0x00000000,0x00050005,0x00000637,0x4374756f,0x726f6c6f, - 0x00000000,0x00030047,0x000004d4,0x00000002,0x00050048,0x000004d4,0x00000000,0x00000023, - 0x00000000,0x00050048,0x000004d4,0x00000001,0x00000023,0x00000010,0x00050048,0x000004d4, - 0x00000002,0x00000023,0x00000020,0x00040047,0x0000051f,0x0000001e,0x00000000,0x00040047, - 0x0000056a,0x00000021,0x00000000,0x00040047,0x0000056a,0x00000022,0x00000000,0x00040047, - 0x00000637,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002, - 0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000003,0x00040020, - 0x00000008,0x00000007,0x00000007,0x00040021,0x00000009,0x00000006,0x00000008,0x00040020, - 0x0000000d,0x00000007,0x00000006,0x00040017,0x0000000e,0x00000006,0x00000004,0x000c0021, - 0x0000000f,0x0000000e,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d, - 0x0000000d,0x0000000d,0x0000000d,0x00040020,0x0000001b,0x00000007,0x0000000e,0x00090021, - 0x0000001c,0x0000000e,0x0000001b,0x0000001b,0x0000001b,0x0000001b,0x0000000d,0x0000000d, - 0x00040015,0x00000025,0x00000020,0x00000001,0x00040020,0x00000026,0x00000007,0x00000025, - 0x000a0021,0x00000027,0x00000006,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d, - 0x0000000d,0x00000026,0x00040015,0x00000031,0x00000020,0x00000000,0x0004002b,0x00000031, - 0x00000032,0x00000006,0x0004001c,0x00000033,0x00000006,0x00000032,0x00040020,0x00000034, - 0x00000007,0x00000033,0x00050021,0x00000035,0x00000006,0x00000034,0x00000026,0x0004001c, - 0x0000003a,0x00000033,0x00000032,0x00040020,0x0000003b,0x00000007,0x0000003a,0x00060021, - 0x0000003c,0x00000006,0x0000003b,0x00000026,0x00000026,0x00090021,0x00000042,0x00000006, - 0x0000003b,0x0000000d,0x0000000d,0x00000026,0x00000026,0x0000001b,0x0004002b,0x00000006, - 0x0000004b,0x3e59b3d0,0x0004002b,0x00000031,0x0000004c,0x00000000,0x0004002b,0x00000006, - 0x00000050,0x3f371759,0x0004002b,0x00000031,0x00000051,0x00000001,0x0004002b,0x00000006, - 0x00000056,0x3d93dd98,0x0004002b,0x00000031,0x00000057,0x00000002,0x0004002b,0x00000006, - 0x000000a5,0x00000000,0x00020014,0x000000a6,0x0007002c,0x0000000e,0x000000aa,0x000000a5, - 0x000000a5,0x000000a5,0x000000a5,0x0004002b,0x00000006,0x000000b2,0x3f800000,0x00040020, - 0x000000b7,0x00000007,0x000000a6,0x0004002b,0x00000006,0x000000bb,0x400ce000,0x0004002b, - 0x00000006,0x000000bf,0x3d800000,0x0004002b,0x00000025,0x0000011c,0x00000020,0x0004002b, - 0x00000006,0x0000014e,0x3b808081,0x0004002b,0x00000006,0x00000152,0x40000000,0x0004002b, - 0x00000006,0x00000154,0x3e000000,0x0004002b,0x00000025,0x0000015c,0x00000000,0x0004002b, - 0x00000025,0x0000015d,0x0000003f,0x0004002b,0x00000025,0x00000167,0x00000006,0x0004002b, - 0x00000031,0x00000169,0x00000180,0x0004001c,0x0000016a,0x00000006,0x00000169,0x0004002b, - 0x00000006,0x0000016b,0x3b3e0ded,0x0004002b,0x00000006,0x0000016c,0xbc5013a9,0x0004002b, - 0x00000006,0x0000016d,0x3c5844d0,0x0004002b,0x00000006,0x0000016e,0xbb5ed289,0x0004002b, - 0x00000006,0x0000016f,0x3bce703b,0x0004002b,0x00000006,0x00000170,0xbccbfb16,0x0004002b, - 0x00000006,0x00000171,0x3f7f9db2,0x0004002b,0x00000006,0x00000172,0x3cdc5d64,0x0004002b, - 0x00000006,0x00000173,0xbbded289,0x0004002b,0x00000006,0x00000174,0x3c102de0,0x0004002b, - 0x00000006,0x00000175,0xbd13dd98,0x0004002b,0x00000006,0x00000176,0x3f7edfa4,0x0004002b, - 0x00000006,0x00000177,0x3d29fbe7,0x0004002b,0x00000006,0x00000178,0xbc28c155,0x0004002b, - 0x00000006,0x00000179,0x3a03126f,0x0004002b,0x00000006,0x0000017a,0x3c3fb15b,0x0004002b, - 0x00000006,0x0000017b,0xbd422681,0x0004002b,0x00000006,0x0000017c,0x3f7e425b,0x0004002b, - 0x00000006,0x0000017d,0x3d6631f9,0x0004002b,0x00000006,0x0000017e,0xbc68a71e,0x0004002b, - 0x00000006,0x0000017f,0x3c68a71e,0x0004002b,0x00000006,0x00000180,0xbd6bedfa,0x0004002b, - 0x00000006,0x00000181,0x3f7d5cfb,0x0004002b,0x00000006,0x00000182,0x3d9205bc,0x0004002b, - 0x00000006,0x00000183,0xbc944674,0x0004002b,0x00000006,0x00000184,0x3c87fcb9,0x0004002b, - 0x00000006,0x00000185,0xbd8a0903,0x0004002b,0x00000006,0x00000186,0x3f7c01a3,0x0004002b, - 0x00000006,0x00000187,0x3db2fec5,0x0004002b,0x00000006,0x00000188,0xbcb43958,0x0004002b, - 0x00000006,0x00000189,0x3a83126f,0x0004002b,0x00000006,0x0000018a,0x3c985f07,0x0004002b, - 0x00000006,0x0000018b,0xbd9c0ebf,0x0004002b,0x00000006,0x0000018c,0x3f7a7efa,0x0004002b, - 0x00000006,0x0000018d,0x3dd4fdf4,0x0004002b,0x00000006,0x0000018e,0xbcd844d0,0x0004002b, - 0x00000006,0x0000018f,0x3ac49ba6,0x0004002b,0x00000006,0x00000190,0x3ca7ef9e,0x0004002b, - 0x00000006,0x00000191,0xbdae147b,0x0004002b,0x00000006,0x00000192,0x3f7902de,0x0004002b, - 0x00000006,0x00000193,0x3df6fd22,0x0004002b,0x00000006,0x00000194,0xbcfc5048,0x0004002b, - 0x00000006,0x00000195,0x3b03126f,0x0004002b,0x00000006,0x00000196,0x3cb851ec,0x0004002b, - 0x00000006,0x00000197,0xbdbe0ded,0x0004002b,0x00000006,0x00000198,0x3f76fd22,0x0004002b, - 0x00000006,0x00000199,0x3e0d844d,0x0004002b,0x00000006,0x0000019a,0xbd102de0,0x0004002b, - 0x00000006,0x0000019b,0x3b1d4952,0x0004002b,0x00000006,0x0000019c,0x3cc3c9ef,0x0004002b, - 0x00000006,0x0000019d,0xbdce075f,0x0004002b,0x00000006,0x0000019e,0x3f751eb8,0x0004002b, - 0x00000006,0x0000019f,0x3e1f8a09,0x0004002b,0x00000006,0x000001a0,0xbd22339c,0x0004002b, - 0x00000006,0x000001a1,0x3cd013a9,0x0004002b,0x00000006,0x000001a2,0xbddbf488,0x0004002b, - 0x00000006,0x000001a3,0x3f72de01,0x0004002b,0x00000006,0x000001a4,0x3e31f8a1,0x0004002b, - 0x00000006,0x000001a5,0xbd33d07d,0x0004002b,0x00000006,0x000001a6,0x3b5ed289,0x0004002b, - 0x00000006,0x000001a7,0x3cd844d0,0x0004002b,0x00000006,0x000001a8,0xbde90ff9,0x0004002b, - 0x00000006,0x000001a9,0x3f70624e,0x0004002b,0x00000006,0x000001aa,0x3e458794,0x0004002b, - 0x00000006,0x000001ab,0xbd47e282,0x0004002b,0x00000006,0x000001ac,0x3b902de0,0x0004002b, - 0x00000006,0x000001ad,0x3ce3bcd3,0x0004002b,0x00000006,0x000001ae,0xbdf3eab3,0x0004002b, - 0x00000006,0x000001af,0x3f6d9e84,0x0004002b,0x00000006,0x000001b0,0x3e58fc50,0x0004002b, - 0x00000006,0x000001b1,0xbd5bf488,0x0004002b,0x00000006,0x000001b2,0x3ba0902e,0x0004002b, - 0x00000006,0x000001b3,0x3cebedfa,0x0004002b,0x00000006,0x000001b4,0xbdfef9db,0x0004002b, - 0x00000006,0x000001b5,0x3f6ac083,0x0004002b,0x00000006,0x000001b6,0x3e6c8b44,0x0004002b, - 0x00000006,0x000001b7,0xbd6dfa44,0x0004002b,0x00000006,0x000001b8,0x3bc154ca,0x0004002b, - 0x00000006,0x000001b9,0x3cf0068e,0x0004002b,0x00000006,0x000001ba,0xbe04816f,0x0004002b, - 0x00000006,0x000001bb,0x3f67e282,0x0004002b,0x00000006,0x000001bc,0x3e808312,0x0004002b, - 0x00000006,0x000001bd,0xbd810625,0x0004002b,0x00000006,0x000001be,0x3cf837b5,0x0004002b, - 0x00000006,0x000001bf,0xbe087fcc,0x0004002b,0x00000006,0x000001c0,0x3f64816f,0x0004002b, - 0x00000006,0x000001c1,0x3e8ac083,0x0004002b,0x00000006,0x000001c2,0xbd8b0f28,0x0004002b, - 0x00000006,0x000001c3,0x3bef34d7,0x0004002b,0x00000006,0x000001c4,0x3cfc5048,0x0004002b, - 0x00000006,0x000001c5,0xbe0bfb16,0x0004002b,0x00000006,0x000001c6,0x3f60ff97,0x0004002b, - 0x00000006,0x000001c7,0x3e953f7d,0x0004002b,0x00000006,0x000001c8,0xbd95182b,0x0004002b, - 0x00000006,0x000001c9,0x3c07fcb9,0x0004002b,0x00000006,0x000001ca,0xbe0f7660,0x0004002b, - 0x00000006,0x000001cb,0x3f5d9e84,0x0004002b,0x00000006,0x000001cc,0x3e9fbe77,0x0004002b, - 0x00000006,0x000001cd,0xbd9eecc0,0x0004002b,0x00000006,0x000001ce,0x3c185f07,0x0004002b, - 0x00000006,0x000001cf,0x3d00346e,0x0004002b,0x00000006,0x000001d0,0xbe1205bc,0x0004002b, - 0x00000006,0x000001d1,0x3f59c0ec,0x0004002b,0x00000006,0x000001d2,0x3eaa7efa,0x0004002b, - 0x00000006,0x000001d3,0xbda8f5c3,0x0004002b,0x00000006,0x000001d4,0x3c28c155,0x0004002b, - 0x00000006,0x000001d5,0xbe13f7cf,0x0004002b,0x00000006,0x000001d6,0x3f55dcc6,0x0004002b, - 0x00000006,0x000001d7,0x3eb53f7d,0x0004002b,0x00000006,0x000001d8,0xbdb2fec5,0x0004002b, - 0x00000006,0x000001d9,0x3c378034,0x0004002b,0x00000006,0x000001da,0xbe158106,0x0004002b, - 0x00000006,0x000001db,0x3f51bda5,0x0004002b,0x00000006,0x000001dc,0x3ec04189,0x0004002b, - 0x00000006,0x000001dd,0xbdbd07c8,0x0004002b,0x00000006,0x000001de,0x3c47e282,0x0004002b, - 0x00000006,0x000001df,0xbe16872b,0x0004002b,0x00000006,0x000001e0,0x3f4d5cfb,0x0004002b, - 0x00000006,0x000001e1,0x3ecb020c,0x0004002b,0x00000006,0x000001e2,0xbdc60aa6,0x0004002b, - 0x00000006,0x000001e3,0x3c6075f7,0x0004002b,0x00000006,0x000001e4,0xbe177319,0x0004002b, - 0x00000006,0x000001e5,0x3f491d15,0x0004002b,0x00000006,0x000001e6,0x3ed645a2,0x0004002b, - 0x00000006,0x000001e7,0xbdd013a9,0x0004002b,0x00000006,0x000001e8,0x3c6f34d7,0x0004002b, - 0x00000006,0x000001e9,0x3f44a234,0x0004002b,0x00000006,0x000001ea,0x3ee13a93,0x0004002b, - 0x00000006,0x000001eb,0xbdd91687,0x0004002b,0x00000006,0x000001ec,0x3c7f9724,0x0004002b, - 0x00000006,0x000001ed,0x3cf41f21,0x0004002b,0x00000006,0x000001ee,0x3f4020c5,0x0004002b, - 0x00000006,0x000001ef,0x3eec3c9f,0x0004002b,0x00000006,0x000001f0,0xbde21965,0x0004002b, - 0x00000006,0x000001f1,0x3f3b3d08,0x0004002b,0x00000006,0x000001f2,0x3ef73eab,0x0004002b, - 0x00000006,0x000001f3,0xbdeae7d5,0x0004002b,0x00000006,0x000001f4,0x3c944674,0x0004002b, - 0x00000006,0x000001f5,0x3f363f14,0x0004002b,0x00000006,0x000001f6,0x3f014120,0x0004002b, - 0x00000006,0x000001f7,0xbdf318fc,0x0004002b,0x00000006,0x000001f8,0x3c9ba5e3,0x0004002b, - 0x00000006,0x000001f9,0x3f3161e5,0x0004002b,0x00000006,0x000001fa,0x3f06c227,0x0004002b, - 0x00000006,0x000001fb,0xbdfb15b5,0x0004002b,0x00000006,0x000001fc,0x3ca3d70a,0x0004002b, - 0x00000006,0x000001fd,0x3cdfa440,0x0004002b,0x00000006,0x000001fe,0xbe1288ce,0x0004002b, - 0x00000006,0x000001ff,0x3f2c2268,0x0004002b,0x00000006,0x00000200,0x3f0c432d,0x0004002b, - 0x00000006,0x00000201,0xbe010625,0x0004002b,0x00000006,0x00000202,0x3cb020c5,0x0004002b, - 0x00000006,0x00000203,0xbe107c85,0x0004002b,0x00000006,0x00000204,0x3f271de7,0x0004002b, - 0x00000006,0x00000205,0x3f11bda5,0x0004002b,0x00000006,0x00000206,0xbe050481,0x0004002b, - 0x00000006,0x00000207,0xbe0e075f,0x0004002b,0x00000006,0x00000208,0x3f21de6a,0x0004002b, - 0x00000006,0x00000209,0x3f171de7,0x0004002b,0x00000006,0x0000020a,0xbe07fcb9,0x0004002b, - 0x00000006,0x0000020b,0x3cbfb15b,0x0004002b,0x00000006,0x0000020c,0x3cc7e282,0x0004002b, - 0x00000006,0x0000020d,0xbe0af4f1,0x0004002b,0x00000006,0x0000020e,0x3f1c7e28,0x0183002c, - 0x0000016a,0x0000020f,0x000000a5,0x000000a5,0x000000b2,0x000000a5,0x000000a5,0x000000a5, - 0x0000016b,0x0000016c,0x000000b2,0x0000016d,0x0000016e,0x000000a5,0x0000016f,0x00000170, - 0x00000171,0x00000172,0x00000173,0x000000a5,0x00000174,0x00000175,0x00000176,0x00000177, - 0x00000178,0x00000179,0x0000017a,0x0000017b,0x0000017c,0x0000017d,0x0000017e,0x00000179, - 0x0000017f,0x00000180,0x00000181,0x00000182,0x00000183,0x00000179,0x00000184,0x00000185, - 0x00000186,0x00000187,0x00000188,0x00000189,0x0000018a,0x0000018b,0x0000018c,0x0000018d, - 0x0000018e,0x0000018f,0x00000190,0x00000191,0x00000192,0x00000193,0x00000194,0x00000195, - 0x00000196,0x00000197,0x00000198,0x00000199,0x0000019a,0x0000019b,0x0000019c,0x0000019d, - 0x0000019e,0x0000019f,0x000001a0,0x0000016b,0x000001a1,0x000001a2,0x000001a3,0x000001a4, - 0x000001a5,0x000001a6,0x000001a7,0x000001a8,0x000001a9,0x000001aa,0x000001ab,0x000001ac, - 0x000001ad,0x000001ae,0x000001af,0x000001b0,0x000001b1,0x000001b2,0x000001b3,0x000001b4, - 0x000001b5,0x000001b6,0x000001b7,0x000001b8,0x000001b9,0x000001ba,0x000001bb,0x000001bc, - 0x000001bd,0x0000016f,0x000001be,0x000001bf,0x000001c0,0x000001c1,0x000001c2,0x000001c3, - 0x000001c4,0x000001c5,0x000001c6,0x000001c7,0x000001c8,0x000001c9,0x000001c4,0x000001ca, - 0x000001cb,0x000001cc,0x000001cd,0x000001ce,0x000001cf,0x000001d0,0x000001d1,0x000001d2, - 0x000001d3,0x000001d4,0x000001cf,0x000001d5,0x000001d6,0x000001d7,0x000001d8,0x000001d9, - 0x000001cf,0x000001da,0x000001db,0x000001dc,0x000001dd,0x000001de,0x000001cf,0x000001df, - 0x000001e0,0x000001e1,0x000001e2,0x000001e3,0x000001c4,0x000001e4,0x000001e5,0x000001e6, - 0x000001e7,0x000001e8,0x000001be,0x000001e4,0x000001e9,0x000001ea,0x000001eb,0x000001ec, - 0x000001ed,0x000001e4,0x000001ee,0x000001ef,0x000001f0,0x00000184,0x000001b9,0x000001df, - 0x000001f1,0x000001f2,0x000001f3,0x000001f4,0x000001b3,0x000001da,0x000001f5,0x000001f6, - 0x000001f7,0x000001f8,0x000001ad,0x000001d5,0x000001f9,0x000001fa,0x000001fb,0x000001fc, - 0x000001fd,0x000001fe,0x000001ff,0x00000200,0x00000201,0x00000202,0x000001a7,0x00000203, - 0x00000204,0x00000205,0x00000206,0x00000196,0x000001a1,0x00000207,0x00000208,0x00000209, - 0x0000020a,0x0000020b,0x0000020c,0x0000020d,0x0000020e,0x0000020e,0x0000020d,0x0000020c, - 0x0000020b,0x0000020a,0x00000209,0x00000208,0x00000207,0x000001a1,0x00000196,0x00000206, - 0x00000205,0x00000204,0x00000203,0x000001a7,0x00000202,0x00000201,0x00000200,0x000001ff, - 0x000001fe,0x000001fd,0x000001fc,0x000001fb,0x000001fa,0x000001f9,0x000001d5,0x000001ad, - 0x000001f8,0x000001f7,0x000001f6,0x000001f5,0x000001da,0x000001b3,0x000001f4,0x000001f3, - 0x000001f2,0x000001f1,0x000001df,0x000001b9,0x00000184,0x000001f0,0x000001ef,0x000001ee, - 0x000001e4,0x000001ed,0x000001ec,0x000001eb,0x000001ea,0x000001e9,0x000001e4,0x000001be, - 0x000001e8,0x000001e7,0x000001e6,0x000001e5,0x000001e4,0x000001c4,0x000001e3,0x000001e2, - 0x000001e1,0x000001e0,0x000001df,0x000001cf,0x000001de,0x000001dd,0x000001dc,0x000001db, - 0x000001da,0x000001cf,0x000001d9,0x000001d8,0x000001d7,0x000001d6,0x000001d5,0x000001cf, - 0x000001d4,0x000001d3,0x000001d2,0x000001d1,0x000001d0,0x000001cf,0x000001ce,0x000001cd, - 0x000001cc,0x000001cb,0x000001ca,0x000001c4,0x000001c9,0x000001c8,0x000001c7,0x000001c6, - 0x000001c5,0x000001c4,0x000001c3,0x000001c2,0x000001c1,0x000001c0,0x000001bf,0x000001be, - 0x0000016f,0x000001bd,0x000001bc,0x000001bb,0x000001ba,0x000001b9,0x000001b8,0x000001b7, - 0x000001b6,0x000001b5,0x000001b4,0x000001b3,0x000001b2,0x000001b1,0x000001b0,0x000001af, - 0x000001ae,0x000001ad,0x000001ac,0x000001ab,0x000001aa,0x000001a9,0x000001a8,0x000001a7, - 0x000001a6,0x000001a5,0x000001a4,0x000001a3,0x000001a2,0x000001a1,0x0000016b,0x000001a0, - 0x0000019f,0x0000019e,0x0000019d,0x0000019c,0x0000019b,0x0000019a,0x00000199,0x00000198, - 0x00000197,0x00000196,0x00000195,0x00000194,0x00000193,0x00000192,0x00000191,0x00000190, - 0x0000018f,0x0000018e,0x0000018d,0x0000018c,0x0000018b,0x0000018a,0x00000189,0x00000188, - 0x00000187,0x00000186,0x00000185,0x00000184,0x00000179,0x00000183,0x00000182,0x00000181, - 0x00000180,0x0000017f,0x00000179,0x0000017e,0x0000017d,0x0000017c,0x0000017b,0x0000017a, - 0x00000179,0x00000178,0x00000177,0x00000176,0x00000175,0x00000174,0x000000a5,0x00000173, - 0x00000172,0x00000171,0x00000170,0x0000016f,0x000000a5,0x0000016e,0x0000016d,0x000000b2, - 0x0000016c,0x0000016b,0x00040020,0x00000214,0x00000007,0x0000016a,0x0004002b,0x00000025, - 0x0000021f,0x00000001,0x0004002b,0x00000006,0x0000022a,0xbf19a027,0x0004002b,0x00000006, - 0x0000022b,0x3f99a027,0x0004002b,0x00000006,0x0000022c,0xbf1bc01a,0x0004002b,0x00000006, - 0x0000022d,0x3f996f00,0x0004002b,0x00000006,0x0000022e,0xbf171de7,0x0004002b,0x00000006, - 0x0000022f,0xbb3e0ded,0x0004002b,0x00000006,0x00000230,0xbf1d5cfb,0x0004002b,0x00000006, - 0x00000231,0x3f990ff9,0x0004002b,0x00000006,0x00000232,0xbf143fe6,0x0004002b,0x00000006, - 0x00000233,0xbf1e9e1b,0x0004002b,0x00000006,0x00000234,0x3f983127,0x0004002b,0x00000006, - 0x00000235,0xbf10ded3,0x0004002b,0x00000006,0x00000236,0xbf1f9db2,0x0004002b,0x00000006, - 0x00000237,0x3f9710cb,0x0004002b,0x00000006,0x00000238,0xbf0d21ff,0x0004002b,0x00000006, - 0x00000239,0xbc7765fe,0x0004002b,0x00000006,0x0000023a,0xbf20624e,0x0004002b,0x00000006, - 0x0000023b,0x3f95bf48,0x0004002b,0x00000006,0x0000023c,0xbf0902de,0x0004002b,0x00000006, - 0x0000023d,0xbc9fbe77,0x0004002b,0x00000006,0x0000023e,0xbf208312,0x0004002b,0x00000006, - 0x0000023f,0x3f943fe6,0x0004002b,0x00000006,0x00000240,0xbf04a234,0x0004002b,0x00000006, - 0x00000241,0xbcd42c3d,0x0004002b,0x00000006,0x00000242,0xbf20ded3,0x0004002b,0x00000006, - 0x00000243,0x3f929fbe,0x0004002b,0x00000006,0x00000244,0xbf0020c5,0x0004002b,0x00000006, - 0x00000245,0xbd01d7dc,0x0004002b,0x00000006,0x00000246,0x3f904ea5,0x0004002b,0x00000006, - 0x00000247,0xbef53f7d,0x0004002b,0x00000006,0x00000248,0xbd1e1b09,0x0004002b,0x00000006, - 0x00000249,0x3f8df06f,0x0004002b,0x00000006,0x0000024a,0xbee9fbe7,0x0004002b,0x00000006, - 0x0000024b,0xbd39f55a,0x0004002b,0x00000006,0x0000024c,0x3c902de0,0x0004002b,0x00000006, - 0x0000024d,0xbf1e6320,0x0004002b,0x00000006,0x0000024e,0x3f8b404f,0x0004002b,0x00000006, - 0x0000024f,0xbede83e4,0x0004002b,0x00000006,0x00000250,0xbd59e83e,0x0004002b,0x00000006, - 0x00000251,0xbf1d21ff,0x0004002b,0x00000006,0x00000252,0x3f886f69,0x0004002b,0x00000006, - 0x00000253,0xbed205bc,0x0004002b,0x00000006,0x00000254,0xbd7be76d,0x0004002b,0x00000006, - 0x00000255,0xbf1b5dcc,0x0004002b,0x00000006,0x00000256,0x3f852f1b,0x0004002b,0x00000006, - 0x00000257,0xbec4c2f8,0x0004002b,0x00000006,0x00000258,0xbd8ef34d,0x0004002b,0x00000006, - 0x00000259,0x3c9fbe77,0x0004002b,0x00000006,0x0000025a,0xbf19c0ec,0x0004002b,0x00000006, - 0x0000025b,0x3f820f91,0x0004002b,0x00000006,0x0000025c,0xbeb6fd22,0x0004002b,0x00000006, - 0x0000025d,0xbda30553,0x0004002b,0x00000006,0x0000025e,0xbf17c1be,0x0004002b,0x00000006, - 0x0000025f,0x3f7d42c4,0x0004002b,0x00000006,0x00000260,0xbea83e42,0x0004002b,0x00000006, - 0x00000261,0xbdb7e910,0x0004002b,0x00000006,0x00000262,0xbf14fdf4,0x0004002b,0x00000006, - 0x00000263,0x3f753f7d,0x0004002b,0x00000006,0x00000264,0xbe98fc50,0x0004002b,0x00000006, - 0x00000265,0xbdcd013b,0x0004002b,0x00000006,0x00000266,0xbf12a305,0x0004002b,0x00000006, - 0x00000267,0x3f6de00d,0x0004002b,0x00000006,0x00000268,0xbe89ba5e,0x0004002b,0x00000006, - 0x00000269,0xbf0fdf3b,0x0004002b,0x00000006,0x0000026a,0x3f65c28f,0x0004002b,0x00000006, - 0x0000026b,0xbe727bb3,0x0004002b,0x00000006,0x0000026c,0x3b7f9724,0x0004002b,0x00000006, - 0x0000026d,0xbf0cbfb1,0x0004002b,0x00000006,0x0000026e,0x3f5d42c4,0x0004002b,0x00000006, - 0x0000026f,0xbe5182aa,0x0004002b,0x00000006,0x00000270,0xbe0985f0,0x0004002b,0x00000006, - 0x00000271,0xbf097f63,0x0004002b,0x00000006,0x00000272,0x3f54816f,0x0004002b,0x00000006, - 0x00000273,0xbe2f0069,0x0004002b,0x00000006,0x00000274,0xbe160419,0x0004002b,0x00000006, - 0x00000275,0xbf061e4f,0x0004002b,0x00000006,0x00000276,0x3f4b5dcc,0x0004002b,0x00000006, - 0x00000277,0xbe228241,0x0004002b,0x00000006,0x00000278,0x3bb0f27c,0x0004002b,0x00000006, - 0x00000279,0xbf02bd3c,0x0004002b,0x00000006,0x0000027a,0x3f428241,0x0004002b,0x00000006, - 0x0000027b,0xbdd119ce,0x0004002b,0x00000006,0x0000027c,0xbe3089a0,0x0004002b,0x00000006, - 0x0000027d,0xbefe425b,0x0004002b,0x00000006,0x0000027e,0x3f391d15,0x0004002b,0x00000006, - 0x0000027f,0xbd84ea4b,0x0004002b,0x00000006,0x00000280,0xbe3ef9db,0x0004002b,0x00000006, - 0x00000281,0xbef6bb99,0x0004002b,0x00000006,0x00000282,0x3f2f41f2,0x0004002b,0x00000006, - 0x00000283,0xbcebedfa,0x0004002b,0x00000006,0x00000284,0xbe4c7e28,0x0004002b,0x00000006, - 0x00000285,0x3bded289,0x0004002b,0x00000006,0x00000286,0xbeef0069,0x0004002b,0x00000006, - 0x00000287,0x3f256042,0x0004002b,0x00000006,0x00000288,0xbe5b8bac,0x0004002b,0x00000006, - 0x00000289,0xbee6c227,0x0004002b,0x00000006,0x0000028a,0x3f1b020c,0x0004002b,0x00000006, - 0x0000028b,0x3d4432ca,0x0004002b,0x00000006,0x0000028c,0xbe6a7efa,0x0004002b,0x00000006, - 0x0000028d,0x3c8c154d,0x0004002b,0x00000006,0x0000028e,0xbedfbe77,0x0004002b,0x00000006, - 0x0000028f,0x3dafec57,0x0004002b,0x00000006,0x00000290,0xbe7a786c,0x0004002b,0x00000006, - 0x00000291,0x3c83e426,0x0004002b,0x00000006,0x00000292,0xbed6fd22,0x0004002b,0x00000006, - 0x00000293,0x3f073eab,0x0004002b,0x00000006,0x00000294,0x3e008312,0x0004002b,0x00000006, - 0x00000295,0xbe850481,0x0004002b,0x00000006,0x00000296,0x3c20902e,0x0004002b,0x00000006, - 0x00000297,0xbecf41f2,0x0004002b,0x00000006,0x00000298,0x3efa0275,0x0004002b,0x00000006, - 0x00000299,0x3e2978d5,0x0004002b,0x00000006,0x0000029a,0xbe8d013b,0x0004002b,0x00000006, - 0x0000029b,0x3c7765fe,0x0004002b,0x00000006,0x0000029c,0xbec703b0,0x0004002b,0x00000006, - 0x0000029d,0x3ee63f14,0x0004002b,0x00000006,0x0000029e,0x3e50ff97,0x0004002b,0x00000006, - 0x0000029f,0xbe94fdf4,0x0004002b,0x00000006,0x000002a0,0x3c2f4f0e,0x0004002b,0x00000006, - 0x000002a1,0xbebe00d2,0x0004002b,0x00000006,0x000002a2,0x3ed07c85,0x0004002b,0x00000006, - 0x000002a3,0x3e7a786c,0x0004002b,0x00000006,0x000002a4,0xbe9cfaad,0x0004002b,0x00000006, - 0x000002a5,0xbeb60419,0x0004002b,0x00000006,0x000002a6,0x3ebc01a3,0x0004002b,0x00000006, - 0x000002a7,0x3e9205bc,0x0004002b,0x00000006,0x000002a8,0xbea5460b,0x0004002b,0x00000006, - 0x000002a9,0xbeadc5d6,0x0004002b,0x00000006,0x000002aa,0x3ea703b0,0x0183002c,0x0000016a, - 0x000002ab,0x000000a5,0x0000022a,0x0000022b,0x0000022a,0x000000a5,0x000000a5,0x0000016b, - 0x0000022c,0x0000022d,0x0000022e,0x0000022f,0x000000a5,0x000001b2,0x00000230,0x00000231, - 0x00000232,0x00000173,0x00000179,0x000001c3,0x00000233,0x00000234,0x00000235,0x00000178, - 0x000000a5,0x000001ce,0x00000236,0x00000237,0x00000238,0x00000239,0x000000a5,0x000001d9, - 0x0000023a,0x0000023b,0x0000023c,0x0000023d,0x00000179,0x000001de,0x0000023e,0x0000023f, - 0x00000240,0x00000241,0x00000179,0x0000017f,0x00000242,0x00000243,0x00000244,0x00000245, - 0x00000179,0x000001ec,0x0000023a,0x00000246,0x00000247,0x00000248,0x00000179,0x00000184, - 0x00000236,0x00000249,0x0000024a,0x0000024b,0x00000189,0x0000024c,0x0000024d,0x0000024e, - 0x0000024f,0x00000250,0x00000189,0x000001f4,0x00000251,0x00000252,0x00000253,0x00000254, - 0x0000018f,0x000001f8,0x00000255,0x00000256,0x00000257,0x00000258,0x0000018f,0x00000259, - 0x0000025a,0x0000025b,0x0000025c,0x0000025d,0x00000195,0x000001fc,0x0000025e,0x0000025f, - 0x00000260,0x00000261,0x0000019b,0x000001fc,0x00000262,0x00000263,0x00000264,0x00000265, - 0x0000016b,0x000001fc,0x00000266,0x00000267,0x00000268,0x000001f0,0x000001a6,0x000001fc, - 0x00000269,0x0000026a,0x0000026b,0x000001fb,0x0000026c,0x00000190,0x0000026d,0x0000026e, - 0x0000026f,0x00000270,0x000001ac,0x000001fc,0x00000271,0x00000272,0x00000273,0x00000274, - 0x000001b2,0x00000259,0x00000275,0x00000276,0x000001c5,0x00000277,0x00000278,0x00000259, - 0x00000279,0x0000027a,0x0000027b,0x0000027c,0x000001b8,0x000001f8,0x0000027d,0x0000027e, - 0x0000027f,0x00000280,0x0000016f,0x0000018a,0x00000281,0x00000282,0x00000283,0x00000284, - 0x00000285,0x0000018a,0x00000286,0x00000287,0x000001ce,0x00000288,0x000001c3,0x0000024c, - 0x00000289,0x0000028a,0x0000028b,0x0000028c,0x000001c9,0x0000028d,0x0000028e,0x00000205, - 0x0000028f,0x00000290,0x00000174,0x00000291,0x00000292,0x00000293,0x00000294,0x00000295, - 0x00000296,0x00000291,0x00000297,0x00000298,0x00000299,0x0000029a,0x000001d4,0x0000029b, - 0x0000029c,0x0000029d,0x0000029e,0x0000029f,0x000002a0,0x0000017f,0x000002a1,0x000002a2, - 0x000002a3,0x000002a4,0x0000017a,0x000001e3,0x000002a5,0x000002a6,0x000002a7,0x000002a8, - 0x000001de,0x0000016d,0x000002a9,0x000002aa,0x000002aa,0x000002a9,0x0000016d,0x000001de, - 0x000002a8,0x000002a7,0x000002a6,0x000002a5,0x000001e3,0x0000017a,0x000002a4,0x000002a3, - 0x000002a2,0x000002a1,0x0000017f,0x000002a0,0x0000029f,0x0000029e,0x0000029d,0x0000029c, - 0x0000029b,0x000001d4,0x0000029a,0x00000299,0x00000298,0x00000297,0x00000291,0x00000296, - 0x00000295,0x00000294,0x00000293,0x00000292,0x00000291,0x00000174,0x00000290,0x0000028f, - 0x00000205,0x0000028e,0x0000028d,0x000001c9,0x0000028c,0x0000028b,0x0000028a,0x00000289, - 0x0000024c,0x000001c3,0x00000288,0x000001ce,0x00000287,0x00000286,0x0000018a,0x00000285, - 0x00000284,0x00000283,0x00000282,0x00000281,0x0000018a,0x0000016f,0x00000280,0x0000027f, - 0x0000027e,0x0000027d,0x000001f8,0x000001b8,0x0000027c,0x0000027b,0x0000027a,0x00000279, - 0x00000259,0x00000278,0x00000277,0x000001c5,0x00000276,0x00000275,0x00000259,0x000001b2, - 0x00000274,0x00000273,0x00000272,0x00000271,0x000001fc,0x000001ac,0x00000270,0x0000026f, - 0x0000026e,0x0000026d,0x00000190,0x0000026c,0x000001fb,0x0000026b,0x0000026a,0x00000269, - 0x000001fc,0x000001a6,0x000001f0,0x00000268,0x00000267,0x00000266,0x000001fc,0x0000016b, - 0x00000265,0x00000264,0x00000263,0x00000262,0x000001fc,0x0000019b,0x00000261,0x00000260, - 0x0000025f,0x0000025e,0x000001fc,0x00000195,0x0000025d,0x0000025c,0x0000025b,0x0000025a, - 0x00000259,0x0000018f,0x00000258,0x00000257,0x00000256,0x00000255,0x000001f8,0x0000018f, - 0x00000254,0x00000253,0x00000252,0x00000251,0x000001f4,0x00000189,0x00000250,0x0000024f, - 0x0000024e,0x0000024d,0x0000024c,0x00000189,0x0000024b,0x0000024a,0x00000249,0x00000236, - 0x00000184,0x00000179,0x00000248,0x00000247,0x00000246,0x0000023a,0x000001ec,0x00000179, - 0x00000245,0x00000244,0x00000243,0x00000242,0x0000017f,0x00000179,0x00000241,0x00000240, - 0x0000023f,0x0000023e,0x000001de,0x00000179,0x0000023d,0x0000023c,0x0000023b,0x0000023a, - 0x000001d9,0x000000a5,0x00000239,0x00000238,0x00000237,0x00000236,0x000001ce,0x000000a5, - 0x00000178,0x00000235,0x00000234,0x00000233,0x000001c3,0x00000179,0x00000173,0x00000232, - 0x00000231,0x00000230,0x000001b2,0x000000a5,0x0000022f,0x0000022e,0x0000022d,0x0000022c, - 0x0000016b,0x0004002b,0x00000006,0x000002bd,0x3ee66666,0x0004002b,0x00000006,0x000002bf, - 0x400e38e4,0x00040020,0x000002c5,0x00000006,0x00000006,0x0004003b,0x000002c5,0x000002c6, - 0x00000006,0x0004003b,0x000002c5,0x000002c9,0x00000006,0x0004003b,0x000002c5,0x000002d1, - 0x00000006,0x0004003b,0x000002c5,0x000002d4,0x00000006,0x0004002b,0x00000025,0x000002df, - 0x00000002,0x0004002b,0x00000025,0x000002e0,0x00000003,0x0004002b,0x00000025,0x000002e1, - 0x00000004,0x0004002b,0x00000025,0x000002e2,0x00000005,0x0004002b,0x00000006,0x00000384, - 0x3f000000,0x0004002b,0x00000031,0x0000038a,0x00000007,0x0004001c,0x0000038b,0x00000006, - 0x0000038a,0x00040020,0x0000038c,0x00000007,0x0000038b,0x0004002b,0x00000006,0x0000041d, - 0x42800000,0x0004002b,0x00000031,0x00000429,0x00000003,0x0005001e,0x000004d4,0x0000000e, - 0x0000000e,0x00000006,0x00040020,0x000004d5,0x00000009,0x000004d4,0x0004003b,0x000004d5, - 0x000004d6,0x00000009,0x00040020,0x000004d7,0x00000009,0x00000006,0x0004002b,0x00000006, - 0x000004e1,0x3fa00000,0x0004002b,0x00000006,0x000004e2,0x3fe00000,0x0004002b,0x00000006, - 0x000004ec,0x3ecccccd,0x0004002b,0x00000006,0x000004f0,0x3f99999a,0x0004002b,0x00000006, - 0x000004f5,0x3fcccccd,0x0004002b,0x00000006,0x000004f9,0x3fe66666,0x0004002b,0x00000006, - 0x000004ff,0x3dcccccd,0x0004002b,0x00000006,0x00000500,0x3e0f5c29,0x0004002b,0x00000006, - 0x00000504,0x3ea3d70a,0x0004002b,0x00000006,0x0000050c,0x3f19999a,0x00040017,0x00000512, - 0x00000006,0x00000002,0x00040020,0x00000513,0x00000007,0x00000512,0x00040020,0x00000515, - 0x00000009,0x0000000e,0x00040020,0x0000051e,0x00000001,0x00000512,0x0004003b,0x0000051e, - 0x0000051f,0x00000001,0x00040020,0x00000520,0x00000001,0x00000006,0x00090019,0x00000567, - 0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b, - 0x00000568,0x00000567,0x00040020,0x00000569,0x00000000,0x00000568,0x0004003b,0x00000569, - 0x0000056a,0x00000000,0x00040020,0x00000636,0x00000003,0x0000000e,0x0004003b,0x00000636, - 0x00000637,0x00000003,0x0004002b,0x00000006,0x00000641,0x41200000,0x0004002b,0x00000006, - 0x00000642,0x3f666666,0x0004002b,0x00000025,0x00000643,0x00000040,0x00050036,0x00000002, - 0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x0000000d,0x000004d3, - 0x00000007,0x0004003b,0x0000000d,0x000004db,0x00000007,0x0004003b,0x0000000d,0x000004de, - 0x00000007,0x0004003b,0x0000000d,0x000004e4,0x00000007,0x0004003b,0x0000000d,0x000004e8, - 0x00000007,0x0004003b,0x0000000d,0x000004f4,0x00000007,0x0004003b,0x0000000d,0x00000508, - 0x00000007,0x0004003b,0x00000513,0x00000514,0x00000007,0x0004003b,0x00000513,0x00000519, - 0x00000007,0x0004003b,0x0000000d,0x0000051d,0x00000007,0x0004003b,0x0000000d,0x00000527, - 0x00000007,0x0004003b,0x0000000d,0x0000052e,0x00000007,0x0004003b,0x0000000d,0x00000531, - 0x00000007,0x0004003b,0x0000000d,0x00000534,0x00000007,0x0004003b,0x0000000d,0x00000538, - 0x00000007,0x0004003b,0x00000026,0x0000053c,0x00000007,0x0004003b,0x00000026,0x00000540, - 0x00000007,0x0004003b,0x00000026,0x00000544,0x00000007,0x0004003b,0x00000026,0x0000054c, - 0x00000007,0x0004003b,0x00000513,0x00000554,0x00000007,0x0004003b,0x0000003b,0x00000564, - 0x00000007,0x0004003b,0x00000008,0x0000056e,0x00000007,0x0004003b,0x0000001b,0x00000576, - 0x00000007,0x0004003b,0x0000000d,0x00000577,0x00000007,0x0004003b,0x0000000d,0x0000057a, - 0x00000007,0x0004003b,0x0000000d,0x0000057d,0x00000007,0x0004003b,0x0000000d,0x00000580, - 0x00000007,0x0004003b,0x0000000d,0x00000583,0x00000007,0x0004003b,0x0000000d,0x00000586, - 0x00000007,0x0004003b,0x0000000d,0x00000589,0x00000007,0x0004003b,0x0000000d,0x0000058c, - 0x00000007,0x0004003b,0x0000000d,0x0000058f,0x00000007,0x0004003b,0x0000001b,0x00000593, - 0x00000007,0x0004003b,0x0000000d,0x00000594,0x00000007,0x0004003b,0x0000000d,0x00000597, - 0x00000007,0x0004003b,0x0000000d,0x0000059a,0x00000007,0x0004003b,0x0000000d,0x0000059d, - 0x00000007,0x0004003b,0x0000000d,0x000005a0,0x00000007,0x0004003b,0x0000000d,0x000005a3, - 0x00000007,0x0004003b,0x0000000d,0x000005a6,0x00000007,0x0004003b,0x0000000d,0x000005a9, - 0x00000007,0x0004003b,0x0000000d,0x000005ac,0x00000007,0x0004003b,0x0000001b,0x000005b0, - 0x00000007,0x0004003b,0x0000000d,0x000005b1,0x00000007,0x0004003b,0x0000000d,0x000005b4, - 0x00000007,0x0004003b,0x0000000d,0x000005b7,0x00000007,0x0004003b,0x0000000d,0x000005ba, - 0x00000007,0x0004003b,0x0000000d,0x000005bd,0x00000007,0x0004003b,0x0000000d,0x000005c0, - 0x00000007,0x0004003b,0x0000000d,0x000005c3,0x00000007,0x0004003b,0x0000000d,0x000005c6, - 0x00000007,0x0004003b,0x0000000d,0x000005c9,0x00000007,0x0004003b,0x0000001b,0x000005cd, - 0x00000007,0x0004003b,0x0000000d,0x000005ce,0x00000007,0x0004003b,0x0000000d,0x000005d1, - 0x00000007,0x0004003b,0x0000000d,0x000005d4,0x00000007,0x0004003b,0x0000000d,0x000005d7, - 0x00000007,0x0004003b,0x0000000d,0x000005da,0x00000007,0x0004003b,0x0000000d,0x000005dd, - 0x00000007,0x0004003b,0x0000000d,0x000005e0,0x00000007,0x0004003b,0x0000000d,0x000005e3, - 0x00000007,0x0004003b,0x0000000d,0x000005e6,0x00000007,0x0004003b,0x0000001b,0x000005ea, - 0x00000007,0x0004003b,0x0000001b,0x000005eb,0x00000007,0x0004003b,0x0000001b,0x000005ed, - 0x00000007,0x0004003b,0x0000001b,0x000005ef,0x00000007,0x0004003b,0x0000001b,0x000005f1, - 0x00000007,0x0004003b,0x0000000d,0x000005f3,0x00000007,0x0004003b,0x0000000d,0x000005f5, - 0x00000007,0x0004003b,0x0000000d,0x000005f8,0x00000007,0x0004003b,0x0000000d,0x00000605, - 0x00000007,0x0004003b,0x0000003b,0x00000606,0x00000007,0x0004003b,0x00000026,0x00000608, - 0x00000007,0x0004003b,0x00000026,0x0000060a,0x00000007,0x0004003b,0x0000003b,0x0000060f, - 0x00000007,0x0004003b,0x0000000d,0x00000611,0x00000007,0x0004003b,0x0000000d,0x00000613, - 0x00000007,0x0004003b,0x00000026,0x00000615,0x00000007,0x0004003b,0x00000026,0x00000617, - 0x00000007,0x0004003b,0x0000001b,0x00000619,0x00000007,0x0004003b,0x0000001b,0x0000061e, - 0x00000007,0x0004003b,0x0000000d,0x00000622,0x00000007,0x0004003b,0x00000008,0x00000623, - 0x00000007,0x0004003b,0x0000000d,0x00000627,0x00000007,0x00050041,0x000004d7,0x000004d8, - 0x000004d6,0x000002df,0x0004003d,0x00000006,0x000004d9,0x000004d8,0x0008000c,0x00000006, - 0x000004da,0x00000001,0x0000002b,0x000004d9,0x000000a5,0x000000b2,0x0003003e,0x000004d3, - 0x000004da,0x0004003d,0x00000006,0x000004dc,0x000004d3,0x00050083,0x00000006,0x000004dd, - 0x000004dc,0x00000384,0x0003003e,0x000004db,0x000004dd,0x0004003d,0x00000006,0x000004df, - 0x000004db,0x000500be,0x000000a6,0x000004e0,0x000004df,0x000000a5,0x000600a9,0x00000006, - 0x000004e3,0x000004e0,0x000004e1,0x000004e2,0x0003003e,0x000004de,0x000004e3,0x0004003d, - 0x00000006,0x000004e5,0x000004db,0x000500be,0x000000a6,0x000004e6,0x000004e5,0x000000a5, - 0x000600a9,0x00000006,0x000004e7,0x000004e6,0x000004e1,0x000000b2,0x0003003e,0x000004e4, - 0x000004e7,0x0004003d,0x00000006,0x000004e9,0x000004db,0x000500be,0x000000a6,0x000004ea, - 0x000004e9,0x000000a5,0x000600a9,0x00000006,0x000004eb,0x000004ea,0x000004e1,0x000000b2, - 0x0003003e,0x000004e8,0x000004eb,0x0004003d,0x00000006,0x000004ed,0x000004db,0x0004003d, - 0x00000006,0x000004ee,0x000004e4,0x00050085,0x00000006,0x000004ef,0x000004ed,0x000004ee, - 0x00050085,0x00000006,0x000004f1,0x000004ef,0x000004f0,0x00050081,0x00000006,0x000004f2, - 0x000004ec,0x000004f1,0x0007000c,0x00000006,0x000004f3,0x00000001,0x00000028,0x000000a5, - 0x000004f2,0x0003003e,0x000002c9,0x000004f3,0x0004003d,0x00000006,0x000004f6,0x000004db, - 0x0004003d,0x00000006,0x000004f7,0x000004de,0x00050085,0x00000006,0x000004f8,0x000004f6, - 0x000004f7,0x00050085,0x00000006,0x000004fa,0x000004f8,0x000004f9,0x00050081,0x00000006, - 0x000004fb,0x000004f5,0x000004fa,0x0003003e,0x000004f4,0x000004fb,0x0004003d,0x00000006, - 0x000004fc,0x000004f4,0x0004003d,0x00000006,0x000004fd,0x000002c9,0x00050083,0x00000006, - 0x000004fe,0x000004fc,0x000004fd,0x0003003e,0x000002c6,0x000004fe,0x0004003d,0x00000006, - 0x00000501,0x000004db,0x0004003d,0x00000006,0x00000502,0x000004e8,0x00050085,0x00000006, - 0x00000503,0x00000501,0x00000502,0x00050085,0x00000006,0x00000505,0x00000503,0x00000504, - 0x00050081,0x00000006,0x00000506,0x00000500,0x00000505,0x0007000c,0x00000006,0x00000507, - 0x00000001,0x00000028,0x000004ff,0x00000506,0x0003003e,0x000002d4,0x00000507,0x0004003d, - 0x00000006,0x00000509,0x000004db,0x0004003d,0x00000006,0x0000050a,0x000004e8,0x00050085, - 0x00000006,0x0000050b,0x00000509,0x0000050a,0x00050085,0x00000006,0x0000050d,0x0000050b, - 0x0000050c,0x00050081,0x00000006,0x0000050e,0x00000384,0x0000050d,0x0003003e,0x00000508, - 0x0000050e,0x0004003d,0x00000006,0x0000050f,0x00000508,0x0004003d,0x00000006,0x00000510, - 0x000002d4,0x00050083,0x00000006,0x00000511,0x0000050f,0x00000510,0x0003003e,0x000002d1, - 0x00000511,0x00050041,0x00000515,0x00000516,0x000004d6,0x0000021f,0x0004003d,0x0000000e, - 0x00000517,0x00000516,0x0007004f,0x00000512,0x00000518,0x00000517,0x00000517,0x00000002, - 0x00000003,0x0003003e,0x00000514,0x00000518,0x00050041,0x00000515,0x0000051a,0x000004d6, - 0x0000021f,0x0004003d,0x0000000e,0x0000051b,0x0000051a,0x0007004f,0x00000512,0x0000051c, - 0x0000051b,0x0000051b,0x00000000,0x00000001,0x0003003e,0x00000519,0x0000051c,0x00050041, - 0x00000520,0x00000521,0x0000051f,0x0000004c,0x0004003d,0x00000006,0x00000522,0x00000521, - 0x00050041,0x0000000d,0x00000523,0x00000514,0x0000004c,0x0004003d,0x00000006,0x00000524, - 0x00000523,0x00050085,0x00000006,0x00000525,0x00000522,0x00000524,0x00050083,0x00000006, - 0x00000526,0x00000525,0x00000384,0x0003003e,0x0000051d,0x00000526,0x00050041,0x00000520, - 0x00000528,0x0000051f,0x00000051,0x0004003d,0x00000006,0x00000529,0x00000528,0x00050041, - 0x0000000d,0x0000052a,0x00000514,0x00000051,0x0004003d,0x00000006,0x0000052b,0x0000052a, - 0x00050085,0x00000006,0x0000052c,0x00000529,0x0000052b,0x00050083,0x00000006,0x0000052d, - 0x0000052c,0x00000384,0x0003003e,0x00000527,0x0000052d,0x0004003d,0x00000006,0x0000052f, - 0x0000051d,0x0006000c,0x00000006,0x00000530,0x00000001,0x00000008,0x0000052f,0x0003003e, - 0x0000052e,0x00000530,0x0004003d,0x00000006,0x00000532,0x00000527,0x0006000c,0x00000006, - 0x00000533,0x00000001,0x00000008,0x00000532,0x0003003e,0x00000531,0x00000533,0x0004003d, - 0x00000006,0x00000535,0x0000051d,0x0004003d,0x00000006,0x00000536,0x0000052e,0x00050083, - 0x00000006,0x00000537,0x00000535,0x00000536,0x0003003e,0x00000534,0x00000537,0x0004003d, - 0x00000006,0x00000539,0x00000527,0x0004003d,0x00000006,0x0000053a,0x00000531,0x00050083, - 0x00000006,0x0000053b,0x00000539,0x0000053a,0x0003003e,0x00000538,0x0000053b,0x0004003d, - 0x00000006,0x0000053d,0x00000534,0x00050085,0x00000006,0x0000053e,0x0000053d,0x0000041d, - 0x0004006e,0x00000025,0x0000053f,0x0000053e,0x0003003e,0x0000053c,0x0000053f,0x0004003d, - 0x00000006,0x00000541,0x00000538,0x00050085,0x00000006,0x00000542,0x00000541,0x0000041d, - 0x0004006e,0x00000025,0x00000543,0x00000542,0x0003003e,0x00000540,0x00000543,0x0003003e, - 0x00000544,0x0000015c,0x000200f9,0x00000545,0x000200f8,0x00000545,0x000400f6,0x00000547, - 0x00000548,0x00000000,0x000200f9,0x00000549,0x000200f8,0x00000549,0x0004003d,0x00000025, - 0x0000054a,0x00000544,0x000500b1,0x000000a6,0x0000054b,0x0000054a,0x00000167,0x000400fa, - 0x0000054b,0x00000546,0x00000547,0x000200f8,0x00000546,0x0003003e,0x0000054c,0x0000015c, - 0x000200f9,0x0000054d,0x000200f8,0x0000054d,0x000400f6,0x0000054f,0x00000550,0x00000000, - 0x000200f9,0x00000551,0x000200f8,0x00000551,0x0004003d,0x00000025,0x00000552,0x0000054c, - 0x000500b1,0x000000a6,0x00000553,0x00000552,0x00000167,0x000400fa,0x00000553,0x0000054e, - 0x0000054f,0x000200f8,0x0000054e,0x0004003d,0x00000006,0x00000555,0x0000052e,0x0004003d, - 0x00000025,0x00000556,0x0000054c,0x0004006f,0x00000006,0x00000557,0x00000556,0x00050081, - 0x00000006,0x00000558,0x00000555,0x00000557,0x00050083,0x00000006,0x00000559,0x00000558, - 0x00000152,0x0004003d,0x00000006,0x0000055a,0x00000531,0x0004003d,0x00000025,0x0000055b, - 0x00000544,0x0004006f,0x00000006,0x0000055c,0x0000055b,0x00050081,0x00000006,0x0000055d, - 0x0000055a,0x0000055c,0x00050083,0x00000006,0x0000055e,0x0000055d,0x00000152,0x00050050, - 0x00000512,0x0000055f,0x00000559,0x0000055e,0x00050050,0x00000512,0x00000560,0x00000384, - 0x00000384,0x00050081,0x00000512,0x00000561,0x0000055f,0x00000560,0x0004003d,0x00000512, - 0x00000562,0x00000519,0x00050085,0x00000512,0x00000563,0x00000561,0x00000562,0x0003003e, - 0x00000554,0x00000563,0x0004003d,0x00000025,0x00000565,0x00000544,0x0004003d,0x00000025, - 0x00000566,0x0000054c,0x0004003d,0x00000568,0x0000056b,0x0000056a,0x0004003d,0x00000512, - 0x0000056c,0x00000554,0x00070058,0x0000000e,0x0000056d,0x0000056b,0x0000056c,0x00000002, - 0x000000a5,0x0008004f,0x00000007,0x0000056f,0x0000056d,0x0000056d,0x00000000,0x00000001, - 0x00000002,0x0003003e,0x0000056e,0x0000056f,0x00050039,0x00000006,0x00000570,0x0000000b, - 0x0000056e,0x00060041,0x0000000d,0x00000571,0x00000564,0x00000565,0x00000566,0x0003003e, - 0x00000571,0x00000570,0x000200f9,0x00000550,0x000200f8,0x00000550,0x0004003d,0x00000025, - 0x00000572,0x0000054c,0x00050080,0x00000025,0x00000573,0x00000572,0x0000021f,0x0003003e, - 0x0000054c,0x00000573,0x000200f9,0x0000054d,0x000200f8,0x0000054f,0x000200f9,0x00000548, - 0x000200f8,0x00000548,0x0004003d,0x00000025,0x00000574,0x00000544,0x00050080,0x00000025, - 0x00000575,0x00000574,0x0000021f,0x0003003e,0x00000544,0x00000575,0x000200f9,0x00000545, - 0x000200f8,0x00000547,0x00060041,0x0000000d,0x00000578,0x00000564,0x0000021f,0x0000021f, - 0x0004003d,0x00000006,0x00000579,0x00000578,0x0003003e,0x00000577,0x00000579,0x00060041, - 0x0000000d,0x0000057b,0x00000564,0x0000021f,0x000002df,0x0004003d,0x00000006,0x0000057c, - 0x0000057b,0x0003003e,0x0000057a,0x0000057c,0x00060041,0x0000000d,0x0000057e,0x00000564, - 0x0000021f,0x000002e0,0x0004003d,0x00000006,0x0000057f,0x0000057e,0x0003003e,0x0000057d, - 0x0000057f,0x00060041,0x0000000d,0x00000581,0x00000564,0x000002df,0x0000021f,0x0004003d, - 0x00000006,0x00000582,0x00000581,0x0003003e,0x00000580,0x00000582,0x00060041,0x0000000d, - 0x00000584,0x00000564,0x000002df,0x000002df,0x0004003d,0x00000006,0x00000585,0x00000584, - 0x0003003e,0x00000583,0x00000585,0x00060041,0x0000000d,0x00000587,0x00000564,0x000002df, - 0x000002e0,0x0004003d,0x00000006,0x00000588,0x00000587,0x0003003e,0x00000586,0x00000588, - 0x00060041,0x0000000d,0x0000058a,0x00000564,0x000002e0,0x0000021f,0x0004003d,0x00000006, - 0x0000058b,0x0000058a,0x0003003e,0x00000589,0x0000058b,0x00060041,0x0000000d,0x0000058d, - 0x00000564,0x000002e0,0x000002df,0x0004003d,0x00000006,0x0000058e,0x0000058d,0x0003003e, - 0x0000058c,0x0000058e,0x00060041,0x0000000d,0x00000590,0x00000564,0x000002e0,0x000002e0, - 0x0004003d,0x00000006,0x00000591,0x00000590,0x0003003e,0x0000058f,0x00000591,0x000d0039, - 0x0000000e,0x00000592,0x00000019,0x00000577,0x0000057a,0x0000057d,0x00000580,0x00000583, - 0x00000586,0x00000589,0x0000058c,0x0000058f,0x0003003e,0x00000576,0x00000592,0x00060041, - 0x0000000d,0x00000595,0x00000564,0x0000021f,0x000002df,0x0004003d,0x00000006,0x00000596, - 0x00000595,0x0003003e,0x00000594,0x00000596,0x00060041,0x0000000d,0x00000598,0x00000564, - 0x0000021f,0x000002e0,0x0004003d,0x00000006,0x00000599,0x00000598,0x0003003e,0x00000597, - 0x00000599,0x00060041,0x0000000d,0x0000059b,0x00000564,0x0000021f,0x000002e1,0x0004003d, - 0x00000006,0x0000059c,0x0000059b,0x0003003e,0x0000059a,0x0000059c,0x00060041,0x0000000d, - 0x0000059e,0x00000564,0x000002df,0x000002df,0x0004003d,0x00000006,0x0000059f,0x0000059e, - 0x0003003e,0x0000059d,0x0000059f,0x00060041,0x0000000d,0x000005a1,0x00000564,0x000002df, - 0x000002e0,0x0004003d,0x00000006,0x000005a2,0x000005a1,0x0003003e,0x000005a0,0x000005a2, - 0x00060041,0x0000000d,0x000005a4,0x00000564,0x000002df,0x000002e1,0x0004003d,0x00000006, - 0x000005a5,0x000005a4,0x0003003e,0x000005a3,0x000005a5,0x00060041,0x0000000d,0x000005a7, - 0x00000564,0x000002e0,0x000002df,0x0004003d,0x00000006,0x000005a8,0x000005a7,0x0003003e, - 0x000005a6,0x000005a8,0x00060041,0x0000000d,0x000005aa,0x00000564,0x000002e0,0x000002e0, - 0x0004003d,0x00000006,0x000005ab,0x000005aa,0x0003003e,0x000005a9,0x000005ab,0x00060041, - 0x0000000d,0x000005ad,0x00000564,0x000002e0,0x000002e1,0x0004003d,0x00000006,0x000005ae, - 0x000005ad,0x0003003e,0x000005ac,0x000005ae,0x000d0039,0x0000000e,0x000005af,0x00000019, - 0x00000594,0x00000597,0x0000059a,0x0000059d,0x000005a0,0x000005a3,0x000005a6,0x000005a9, - 0x000005ac,0x0003003e,0x00000593,0x000005af,0x00060041,0x0000000d,0x000005b2,0x00000564, - 0x000002df,0x0000021f,0x0004003d,0x00000006,0x000005b3,0x000005b2,0x0003003e,0x000005b1, - 0x000005b3,0x00060041,0x0000000d,0x000005b5,0x00000564,0x000002df,0x000002df,0x0004003d, - 0x00000006,0x000005b6,0x000005b5,0x0003003e,0x000005b4,0x000005b6,0x00060041,0x0000000d, - 0x000005b8,0x00000564,0x000002df,0x000002e0,0x0004003d,0x00000006,0x000005b9,0x000005b8, - 0x0003003e,0x000005b7,0x000005b9,0x00060041,0x0000000d,0x000005bb,0x00000564,0x000002e0, - 0x0000021f,0x0004003d,0x00000006,0x000005bc,0x000005bb,0x0003003e,0x000005ba,0x000005bc, - 0x00060041,0x0000000d,0x000005be,0x00000564,0x000002e0,0x000002df,0x0004003d,0x00000006, - 0x000005bf,0x000005be,0x0003003e,0x000005bd,0x000005bf,0x00060041,0x0000000d,0x000005c1, - 0x00000564,0x000002e0,0x000002e0,0x0004003d,0x00000006,0x000005c2,0x000005c1,0x0003003e, - 0x000005c0,0x000005c2,0x00060041,0x0000000d,0x000005c4,0x00000564,0x000002e1,0x0000021f, - 0x0004003d,0x00000006,0x000005c5,0x000005c4,0x0003003e,0x000005c3,0x000005c5,0x00060041, - 0x0000000d,0x000005c7,0x00000564,0x000002e1,0x000002df,0x0004003d,0x00000006,0x000005c8, - 0x000005c7,0x0003003e,0x000005c6,0x000005c8,0x00060041,0x0000000d,0x000005ca,0x00000564, - 0x000002e1,0x000002e0,0x0004003d,0x00000006,0x000005cb,0x000005ca,0x0003003e,0x000005c9, - 0x000005cb,0x000d0039,0x0000000e,0x000005cc,0x00000019,0x000005b1,0x000005b4,0x000005b7, - 0x000005ba,0x000005bd,0x000005c0,0x000005c3,0x000005c6,0x000005c9,0x0003003e,0x000005b0, - 0x000005cc,0x00060041,0x0000000d,0x000005cf,0x00000564,0x000002df,0x000002df,0x0004003d, - 0x00000006,0x000005d0,0x000005cf,0x0003003e,0x000005ce,0x000005d0,0x00060041,0x0000000d, - 0x000005d2,0x00000564,0x000002df,0x000002e0,0x0004003d,0x00000006,0x000005d3,0x000005d2, - 0x0003003e,0x000005d1,0x000005d3,0x00060041,0x0000000d,0x000005d5,0x00000564,0x000002df, - 0x000002e1,0x0004003d,0x00000006,0x000005d6,0x000005d5,0x0003003e,0x000005d4,0x000005d6, - 0x00060041,0x0000000d,0x000005d8,0x00000564,0x000002e0,0x000002df,0x0004003d,0x00000006, - 0x000005d9,0x000005d8,0x0003003e,0x000005d7,0x000005d9,0x00060041,0x0000000d,0x000005db, - 0x00000564,0x000002e0,0x000002e0,0x0004003d,0x00000006,0x000005dc,0x000005db,0x0003003e, - 0x000005da,0x000005dc,0x00060041,0x0000000d,0x000005de,0x00000564,0x000002e0,0x000002e1, - 0x0004003d,0x00000006,0x000005df,0x000005de,0x0003003e,0x000005dd,0x000005df,0x00060041, - 0x0000000d,0x000005e1,0x00000564,0x000002e1,0x000002df,0x0004003d,0x00000006,0x000005e2, - 0x000005e1,0x0003003e,0x000005e0,0x000005e2,0x00060041,0x0000000d,0x000005e4,0x00000564, - 0x000002e1,0x000002e0,0x0004003d,0x00000006,0x000005e5,0x000005e4,0x0003003e,0x000005e3, - 0x000005e5,0x00060041,0x0000000d,0x000005e7,0x00000564,0x000002e1,0x000002e1,0x0004003d, - 0x00000006,0x000005e8,0x000005e7,0x0003003e,0x000005e6,0x000005e8,0x000d0039,0x0000000e, - 0x000005e9,0x00000019,0x000005ce,0x000005d1,0x000005d4,0x000005d7,0x000005da,0x000005dd, - 0x000005e0,0x000005e3,0x000005e6,0x0003003e,0x000005cd,0x000005e9,0x0004003d,0x0000000e, - 0x000005ec,0x00000576,0x0003003e,0x000005eb,0x000005ec,0x0004003d,0x0000000e,0x000005ee, - 0x00000593,0x0003003e,0x000005ed,0x000005ee,0x0004003d,0x0000000e,0x000005f0,0x000005b0, - 0x0003003e,0x000005ef,0x000005f0,0x0004003d,0x0000000e,0x000005f2,0x000005cd,0x0003003e, - 0x000005f1,0x000005f2,0x0004003d,0x00000006,0x000005f4,0x00000534,0x0003003e,0x000005f3, - 0x000005f4,0x0004003d,0x00000006,0x000005f6,0x00000538,0x0003003e,0x000005f5,0x000005f6, - 0x000a0039,0x0000000e,0x000005f7,0x00000023,0x000005eb,0x000005ed,0x000005ef,0x000005f1, - 0x000005f3,0x000005f5,0x0003003e,0x000005ea,0x000005f7,0x00050041,0x0000000d,0x000005f9, - 0x000005ea,0x0000004c,0x0004003d,0x00000006,0x000005fa,0x000005f9,0x00050083,0x00000006, - 0x000005fb,0x000000b2,0x000005fa,0x00050041,0x0000000d,0x000005fc,0x000005ea,0x00000051, - 0x0004003d,0x00000006,0x000005fd,0x000005fc,0x00050083,0x00000006,0x000005fe,0x000005fb, - 0x000005fd,0x00050041,0x0000000d,0x000005ff,0x000005ea,0x00000057,0x0004003d,0x00000006, - 0x00000600,0x000005ff,0x00050083,0x00000006,0x00000601,0x000005fe,0x00000600,0x00050041, - 0x0000000d,0x00000602,0x000005ea,0x00000429,0x0004003d,0x00000006,0x00000603,0x00000602, - 0x00050083,0x00000006,0x00000604,0x00000601,0x00000603,0x0003003e,0x000005f8,0x00000604, - 0x0004003d,0x0000003a,0x00000607,0x00000564,0x0003003e,0x00000606,0x00000607,0x0004003d, - 0x00000025,0x00000609,0x0000053c,0x0003003e,0x00000608,0x00000609,0x0004003d,0x00000025, - 0x0000060b,0x00000540,0x0003003e,0x0000060a,0x0000060b,0x00070039,0x00000006,0x0000060c, - 0x00000040,0x00000606,0x00000608,0x0000060a,0x0004003d,0x00000006,0x0000060d,0x000005f8, - 0x00050085,0x00000006,0x0000060e,0x0000060c,0x0000060d,0x0003003e,0x00000605,0x0000060e, - 0x0004003d,0x0000003a,0x00000610,0x00000564,0x0003003e,0x0000060f,0x00000610,0x0004003d, - 0x00000006,0x00000612,0x00000534,0x0003003e,0x00000611,0x00000612,0x0004003d,0x00000006, - 0x00000614,0x00000538,0x0003003e,0x00000613,0x00000614,0x0004003d,0x00000025,0x00000616, - 0x0000053c,0x0003003e,0x00000615,0x00000616,0x0004003d,0x00000025,0x00000618,0x00000540, - 0x0003003e,0x00000617,0x00000618,0x0004003d,0x0000000e,0x0000061a,0x000005ea,0x0003003e, - 0x00000619,0x0000061a,0x000a0039,0x00000006,0x0000061b,0x00000049,0x0000060f,0x00000611, - 0x00000613,0x00000615,0x00000617,0x00000619,0x0004003d,0x00000006,0x0000061c,0x00000605, - 0x00050081,0x00000006,0x0000061d,0x0000061c,0x0000061b,0x0003003e,0x00000605,0x0000061d, - 0x0004003d,0x00000568,0x0000061f,0x0000056a,0x0004003d,0x00000512,0x00000620,0x0000051f, - 0x00050057,0x0000000e,0x00000621,0x0000061f,0x00000620,0x0003003e,0x0000061e,0x00000621, - 0x0004003d,0x0000000e,0x00000624,0x0000061e,0x0008004f,0x00000007,0x00000625,0x00000624, - 0x00000624,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000623,0x00000625,0x00050039, - 0x00000006,0x00000626,0x0000000b,0x00000623,0x0003003e,0x00000622,0x00000626,0x0004003d, - 0x00000006,0x00000628,0x00000605,0x0004003d,0x00000006,0x00000629,0x00000622,0x00050083, - 0x00000006,0x0000062a,0x00000628,0x00000629,0x0003003e,0x00000627,0x0000062a,0x0004003d, - 0x00000006,0x0000062b,0x00000627,0x00060050,0x00000007,0x0000062c,0x0000062b,0x0000062b, - 0x0000062b,0x0004003d,0x0000000e,0x0000062d,0x0000061e,0x0008004f,0x00000007,0x0000062e, - 0x0000062d,0x0000062d,0x00000000,0x00000001,0x00000002,0x00050081,0x00000007,0x0000062f, - 0x0000062e,0x0000062c,0x00050041,0x0000000d,0x00000630,0x0000061e,0x0000004c,0x00050051, - 0x00000006,0x00000631,0x0000062f,0x00000000,0x0003003e,0x00000630,0x00000631,0x00050041, - 0x0000000d,0x00000632,0x0000061e,0x00000051,0x00050051,0x00000006,0x00000633,0x0000062f, - 0x00000001,0x0003003e,0x00000632,0x00000633,0x00050041,0x0000000d,0x00000634,0x0000061e, - 0x00000057,0x00050051,0x00000006,0x00000635,0x0000062f,0x00000002,0x0003003e,0x00000634, - 0x00000635,0x0004003d,0x0000000e,0x00000638,0x0000061e,0x0008004f,0x00000007,0x00000639, - 0x00000638,0x00000638,0x00000000,0x00000001,0x00000002,0x00060050,0x00000007,0x0000063a, - 0x000000a5,0x000000a5,0x000000a5,0x00060050,0x00000007,0x0000063b,0x000000b2,0x000000b2, - 0x000000b2,0x0008000c,0x00000007,0x0000063c,0x00000001,0x0000002b,0x00000639,0x0000063a, - 0x0000063b,0x00050051,0x00000006,0x0000063d,0x0000063c,0x00000000,0x00050051,0x00000006, - 0x0000063e,0x0000063c,0x00000001,0x00050051,0x00000006,0x0000063f,0x0000063c,0x00000002, - 0x00070050,0x0000000e,0x00000640,0x0000063d,0x0000063e,0x0000063f,0x000000b2,0x0003003e, - 0x00000637,0x00000640,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000b,0x00000000, - 0x00000009,0x00030037,0x00000008,0x0000000a,0x000200f8,0x0000000c,0x00050041,0x0000000d, - 0x0000004d,0x0000000a,0x0000004c,0x0004003d,0x00000006,0x0000004e,0x0000004d,0x00050085, - 0x00000006,0x0000004f,0x0000004b,0x0000004e,0x00050041,0x0000000d,0x00000052,0x0000000a, - 0x00000051,0x0004003d,0x00000006,0x00000053,0x00000052,0x00050085,0x00000006,0x00000054, - 0x00000050,0x00000053,0x00050081,0x00000006,0x00000055,0x0000004f,0x00000054,0x00050041, - 0x0000000d,0x00000058,0x0000000a,0x00000057,0x0004003d,0x00000006,0x00000059,0x00000058, - 0x00050085,0x00000006,0x0000005a,0x00000056,0x00000059,0x00050081,0x00000006,0x0000005b, - 0x00000055,0x0000005a,0x000200fe,0x0000005b,0x00010038,0x00050036,0x0000000e,0x00000019, - 0x00000000,0x0000000f,0x00030037,0x0000000d,0x00000010,0x00030037,0x0000000d,0x00000011, - 0x00030037,0x0000000d,0x00000012,0x00030037,0x0000000d,0x00000013,0x00030037,0x0000000d, - 0x00000014,0x00030037,0x0000000d,0x00000015,0x00030037,0x0000000d,0x00000016,0x00030037, - 0x0000000d,0x00000017,0x00030037,0x0000000d,0x00000018,0x000200f8,0x0000001a,0x0004003b, - 0x0000000d,0x0000005e,0x00000007,0x0004003b,0x0000000d,0x0000006b,0x00000007,0x0004003b, - 0x0000000d,0x00000078,0x00000007,0x0004003b,0x0000000d,0x00000085,0x00000007,0x0004003b, - 0x0000000d,0x00000092,0x00000007,0x0004003b,0x0000000d,0x00000096,0x00000007,0x0004003b, - 0x0000000d,0x0000009a,0x00000007,0x0004003b,0x0000000d,0x0000009e,0x00000007,0x0004003b, - 0x0000000d,0x000000ac,0x00000007,0x0004003b,0x0000000d,0x000000b4,0x00000007,0x0004003b, - 0x000000b7,0x000000b8,0x00000007,0x0004003b,0x000000b7,0x000000c6,0x00000007,0x0004003b, - 0x000000b7,0x000000d2,0x00000007,0x0004003b,0x000000b7,0x000000d6,0x00000007,0x0004003b, - 0x0000000d,0x000000da,0x00000007,0x0004003b,0x0000000d,0x000000e0,0x00000007,0x0004003b, - 0x0000000d,0x000000e6,0x00000007,0x0004003b,0x0000000d,0x000000ec,0x00000007,0x0004003b, - 0x0000000d,0x000000f3,0x00000007,0x0004003b,0x0000000d,0x000000f9,0x00000007,0x0004003d, - 0x00000006,0x0000005f,0x00000010,0x0004003d,0x00000006,0x00000060,0x00000011,0x00050081, - 0x00000006,0x00000061,0x0000005f,0x00000060,0x0004003d,0x00000006,0x00000062,0x00000012, - 0x00050081,0x00000006,0x00000063,0x00000061,0x00000062,0x0004003d,0x00000006,0x00000064, - 0x00000016,0x00050083,0x00000006,0x00000065,0x00000063,0x00000064,0x0004003d,0x00000006, - 0x00000066,0x00000017,0x00050083,0x00000006,0x00000067,0x00000065,0x00000066,0x0004003d, - 0x00000006,0x00000068,0x00000018,0x00050083,0x00000006,0x00000069,0x00000067,0x00000068, - 0x0006000c,0x00000006,0x0000006a,0x00000001,0x00000004,0x00000069,0x0003003e,0x0000005e, - 0x0000006a,0x0004003d,0x00000006,0x0000006c,0x00000013,0x0004003d,0x00000006,0x0000006d, - 0x00000010,0x00050081,0x00000006,0x0000006e,0x0000006c,0x0000006d,0x0004003d,0x00000006, - 0x0000006f,0x00000011,0x00050081,0x00000006,0x00000070,0x0000006e,0x0000006f,0x0004003d, - 0x00000006,0x00000071,0x00000017,0x00050083,0x00000006,0x00000072,0x00000070,0x00000071, - 0x0004003d,0x00000006,0x00000073,0x00000018,0x00050083,0x00000006,0x00000074,0x00000072, - 0x00000073,0x0004003d,0x00000006,0x00000075,0x00000015,0x00050083,0x00000006,0x00000076, - 0x00000074,0x00000075,0x0006000c,0x00000006,0x00000077,0x00000001,0x00000004,0x00000076, - 0x0003003e,0x0000006b,0x00000077,0x0004003d,0x00000006,0x00000079,0x00000010,0x0004003d, - 0x00000006,0x0000007a,0x00000013,0x00050081,0x00000006,0x0000007b,0x00000079,0x0000007a, - 0x0004003d,0x00000006,0x0000007c,0x00000016,0x00050081,0x00000006,0x0000007d,0x0000007b, - 0x0000007c,0x0004003d,0x00000006,0x0000007e,0x00000012,0x00050083,0x00000006,0x0000007f, - 0x0000007d,0x0000007e,0x0004003d,0x00000006,0x00000080,0x00000015,0x00050083,0x00000006, - 0x00000081,0x0000007f,0x00000080,0x0004003d,0x00000006,0x00000082,0x00000018,0x00050083, - 0x00000006,0x00000083,0x00000081,0x00000082,0x0006000c,0x00000006,0x00000084,0x00000001, - 0x00000004,0x00000083,0x0003003e,0x00000078,0x00000084,0x0004003d,0x00000006,0x00000086, - 0x00000013,0x0004003d,0x00000006,0x00000087,0x00000016,0x00050081,0x00000006,0x00000088, - 0x00000086,0x00000087,0x0004003d,0x00000006,0x00000089,0x00000017,0x00050081,0x00000006, - 0x0000008a,0x00000088,0x00000089,0x0004003d,0x00000006,0x0000008b,0x00000011,0x00050083, - 0x00000006,0x0000008c,0x0000008a,0x0000008b,0x0004003d,0x00000006,0x0000008d,0x00000012, - 0x00050083,0x00000006,0x0000008e,0x0000008c,0x0000008d,0x0004003d,0x00000006,0x0000008f, - 0x00000015,0x00050083,0x00000006,0x00000090,0x0000008e,0x0000008f,0x0006000c,0x00000006, - 0x00000091,0x00000001,0x00000004,0x00000090,0x0003003e,0x00000085,0x00000091,0x0004003d, - 0x00000006,0x00000093,0x0000005e,0x0004003d,0x00000006,0x00000094,0x00000078,0x0007000c, - 0x00000006,0x00000095,0x00000001,0x00000028,0x00000093,0x00000094,0x0003003e,0x00000092, - 0x00000095,0x0004003d,0x00000006,0x00000097,0x0000005e,0x0004003d,0x00000006,0x00000098, - 0x00000078,0x0007000c,0x00000006,0x00000099,0x00000001,0x00000025,0x00000097,0x00000098, - 0x0003003e,0x00000096,0x00000099,0x0004003d,0x00000006,0x0000009b,0x0000006b,0x0004003d, - 0x00000006,0x0000009c,0x00000085,0x0007000c,0x00000006,0x0000009d,0x00000001,0x00000028, - 0x0000009b,0x0000009c,0x0003003e,0x0000009a,0x0000009d,0x0004003d,0x00000006,0x0000009f, - 0x0000006b,0x0004003d,0x00000006,0x000000a0,0x00000085,0x0007000c,0x00000006,0x000000a1, - 0x00000001,0x00000025,0x0000009f,0x000000a0,0x0003003e,0x0000009e,0x000000a1,0x0004003d, - 0x00000006,0x000000a2,0x00000092,0x0004003d,0x00000006,0x000000a3,0x0000009a,0x00050081, - 0x00000006,0x000000a4,0x000000a2,0x000000a3,0x000500b4,0x000000a6,0x000000a7,0x000000a4, - 0x000000a5,0x000300f7,0x000000a9,0x00000000,0x000400fa,0x000000a7,0x000000a8,0x000000a9, - 0x000200f8,0x000000a8,0x000200fe,0x000000aa,0x000200f8,0x000000a9,0x0004003d,0x00000006, - 0x000000ad,0x00000092,0x0004003d,0x00000006,0x000000ae,0x00000092,0x0004003d,0x00000006, - 0x000000af,0x0000009a,0x00050081,0x00000006,0x000000b0,0x000000ae,0x000000af,0x00050088, - 0x00000006,0x000000b1,0x000000ad,0x000000b0,0x0007000c,0x00000006,0x000000b3,0x00000001, - 0x00000025,0x000000b1,0x000000b2,0x0003003e,0x000000ac,0x000000b3,0x0004003d,0x00000006, - 0x000000b5,0x000000ac,0x00050083,0x00000006,0x000000b6,0x000000b2,0x000000b5,0x0003003e, - 0x000000b4,0x000000b6,0x0004003d,0x00000006,0x000000b9,0x00000092,0x0004003d,0x00000006, - 0x000000ba,0x00000096,0x00050085,0x00000006,0x000000bc,0x000000ba,0x000000bb,0x000500ba, - 0x000000a6,0x000000bd,0x000000b9,0x000000bc,0x0004003d,0x00000006,0x000000be,0x00000092, - 0x000500ba,0x000000a6,0x000000c0,0x000000be,0x000000bf,0x000500a7,0x000000a6,0x000000c1, - 0x000000bd,0x000000c0,0x0004003d,0x00000006,0x000000c2,0x00000092,0x0004003d,0x00000006, - 0x000000c3,0x0000009e,0x000500ba,0x000000a6,0x000000c4,0x000000c2,0x000000c3,0x000500a7, - 0x000000a6,0x000000c5,0x000000c1,0x000000c4,0x0003003e,0x000000b8,0x000000c5,0x0004003d, - 0x00000006,0x000000c7,0x0000009a,0x0004003d,0x00000006,0x000000c8,0x0000009e,0x00050085, - 0x00000006,0x000000c9,0x000000c8,0x000000bb,0x000500ba,0x000000a6,0x000000ca,0x000000c7, - 0x000000c9,0x0004003d,0x00000006,0x000000cb,0x0000009a,0x000500ba,0x000000a6,0x000000cc, - 0x000000cb,0x000000bf,0x000500a7,0x000000a6,0x000000cd,0x000000ca,0x000000cc,0x0004003d, - 0x00000006,0x000000ce,0x0000009a,0x0004003d,0x00000006,0x000000cf,0x00000096,0x000500ba, - 0x000000a6,0x000000d0,0x000000ce,0x000000cf,0x000500a7,0x000000a6,0x000000d1,0x000000cd, - 0x000000d0,0x0003003e,0x000000c6,0x000000d1,0x0004003d,0x00000006,0x000000d3,0x00000092, - 0x0004003d,0x00000006,0x000000d4,0x0000005e,0x000500b4,0x000000a6,0x000000d5,0x000000d3, - 0x000000d4,0x0003003e,0x000000d2,0x000000d5,0x0004003d,0x00000006,0x000000d7,0x0000009a, - 0x0004003d,0x00000006,0x000000d8,0x0000006b,0x000500b4,0x000000a6,0x000000d9,0x000000d7, - 0x000000d8,0x0003003e,0x000000d6,0x000000d9,0x0004003d,0x000000a6,0x000000db,0x000000b8, - 0x0004003d,0x000000a6,0x000000dc,0x000000c6,0x000500a7,0x000000a6,0x000000dd,0x000000db, - 0x000000dc,0x0004003d,0x00000006,0x000000de,0x000000ac,0x000600a9,0x00000006,0x000000df, - 0x000000dd,0x000000de,0x000000b2,0x0003003e,0x000000da,0x000000df,0x0004003d,0x000000a6, - 0x000000e1,0x000000b8,0x0004003d,0x000000a6,0x000000e2,0x000000c6,0x000500a7,0x000000a6, - 0x000000e3,0x000000e1,0x000000e2,0x0004003d,0x00000006,0x000000e4,0x000000b4,0x000600a9, - 0x00000006,0x000000e5,0x000000e3,0x000000e4,0x000000b2,0x0003003e,0x000000e0,0x000000e5, - 0x0004003d,0x000000a6,0x000000e7,0x000000b8,0x0004003d,0x000000a6,0x000000e8,0x000000d2, - 0x000500a7,0x000000a6,0x000000e9,0x000000e7,0x000000e8,0x0004003d,0x00000006,0x000000ea, - 0x000000da,0x000600a9,0x00000006,0x000000eb,0x000000e9,0x000000ea,0x000000a5,0x0003003e, - 0x000000e6,0x000000eb,0x0004003d,0x000000a6,0x000000ed,0x000000b8,0x0004003d,0x000000a6, - 0x000000ee,0x000000d2,0x000400a8,0x000000a6,0x000000ef,0x000000ee,0x000500a7,0x000000a6, - 0x000000f0,0x000000ed,0x000000ef,0x0004003d,0x00000006,0x000000f1,0x000000da,0x000600a9, - 0x00000006,0x000000f2,0x000000f0,0x000000f1,0x000000a5,0x0003003e,0x000000ec,0x000000f2, - 0x0004003d,0x000000a6,0x000000f4,0x000000c6,0x0004003d,0x000000a6,0x000000f5,0x000000d6, - 0x000500a7,0x000000a6,0x000000f6,0x000000f4,0x000000f5,0x0004003d,0x00000006,0x000000f7, - 0x000000e0,0x000600a9,0x00000006,0x000000f8,0x000000f6,0x000000f7,0x000000a5,0x0003003e, - 0x000000f3,0x000000f8,0x0004003d,0x000000a6,0x000000fa,0x000000c6,0x0004003d,0x000000a6, - 0x000000fb,0x000000d6,0x000400a8,0x000000a6,0x000000fc,0x000000fb,0x000500a7,0x000000a6, - 0x000000fd,0x000000fa,0x000000fc,0x0004003d,0x00000006,0x000000fe,0x000000e0,0x000600a9, - 0x00000006,0x000000ff,0x000000fd,0x000000fe,0x000000a5,0x0003003e,0x000000f9,0x000000ff, - 0x0004003d,0x00000006,0x00000100,0x000000e6,0x0004003d,0x00000006,0x00000101,0x000000ec, - 0x0004003d,0x00000006,0x00000102,0x000000f3,0x0004003d,0x00000006,0x00000103,0x000000f9, - 0x00070050,0x0000000e,0x00000104,0x00000100,0x00000101,0x00000102,0x00000103,0x000200fe, - 0x00000104,0x00010038,0x00050036,0x0000000e,0x00000023,0x00000000,0x0000001c,0x00030037, - 0x0000001b,0x0000001d,0x00030037,0x0000001b,0x0000001e,0x00030037,0x0000001b,0x0000001f, - 0x00030037,0x0000001b,0x00000020,0x00030037,0x0000000d,0x00000021,0x00030037,0x0000000d, - 0x00000022,0x000200f8,0x00000024,0x0004003b,0x0000001b,0x00000107,0x00000007,0x0004003b, - 0x0000001b,0x0000010d,0x00000007,0x0004003d,0x0000000e,0x00000108,0x0000001d,0x0004003d, - 0x0000000e,0x00000109,0x0000001e,0x0004003d,0x00000006,0x0000010a,0x00000021,0x00070050, - 0x0000000e,0x0000010b,0x0000010a,0x0000010a,0x0000010a,0x0000010a,0x0008000c,0x0000000e, - 0x0000010c,0x00000001,0x0000002e,0x00000108,0x00000109,0x0000010b,0x0003003e,0x00000107, - 0x0000010c,0x0004003d,0x0000000e,0x0000010e,0x0000001f,0x0004003d,0x0000000e,0x0000010f, - 0x00000020,0x0004003d,0x00000006,0x00000110,0x00000021,0x00070050,0x0000000e,0x00000111, - 0x00000110,0x00000110,0x00000110,0x00000110,0x0008000c,0x0000000e,0x00000112,0x00000001, - 0x0000002e,0x0000010e,0x0000010f,0x00000111,0x0003003e,0x0000010d,0x00000112,0x0004003d, - 0x0000000e,0x00000113,0x00000107,0x0004003d,0x0000000e,0x00000114,0x0000010d,0x0004003d, - 0x00000006,0x00000115,0x00000022,0x00070050,0x0000000e,0x00000116,0x00000115,0x00000115, - 0x00000115,0x00000115,0x0008000c,0x0000000e,0x00000117,0x00000001,0x0000002e,0x00000113, - 0x00000114,0x00000116,0x000200fe,0x00000117,0x00010038,0x00050036,0x00000006,0x0000002f, - 0x00000000,0x00000027,0x00030037,0x0000000d,0x00000028,0x00030037,0x0000000d,0x00000029, - 0x00030037,0x0000000d,0x0000002a,0x00030037,0x0000000d,0x0000002b,0x00030037,0x0000000d, - 0x0000002c,0x00030037,0x0000000d,0x0000002d,0x00030037,0x00000026,0x0000002e,0x000200f8, - 0x00000030,0x0004003b,0x000000b7,0x0000011a,0x00000007,0x0004003b,0x0000000d,0x0000011e, - 0x00000007,0x0004003b,0x0000000d,0x00000123,0x00000007,0x0004003b,0x0000000d,0x00000129, - 0x00000007,0x0004003b,0x0000000d,0x00000133,0x00000007,0x0004003b,0x0000000d,0x00000139, - 0x00000007,0x0004003b,0x0000000d,0x0000013f,0x00000007,0x0004003b,0x0000000d,0x00000143, - 0x00000007,0x0004003b,0x0000000d,0x00000147,0x00000007,0x0004003d,0x00000025,0x0000011b, - 0x0000002e,0x000500b3,0x000000a6,0x0000011d,0x0000011b,0x0000011c,0x0003003e,0x0000011a, - 0x0000011d,0x0004003d,0x000000a6,0x0000011f,0x0000011a,0x0004003d,0x00000006,0x00000120, - 0x00000028,0x0004003d,0x00000006,0x00000121,0x0000002b,0x000600a9,0x00000006,0x00000122, - 0x0000011f,0x00000120,0x00000121,0x0003003e,0x0000011e,0x00000122,0x0004003d,0x00000006, - 0x00000124,0x00000029,0x0004003d,0x00000006,0x00000125,0x0000002a,0x0007000c,0x00000006, - 0x00000126,0x00000001,0x00000025,0x00000124,0x00000125,0x0004003d,0x00000006,0x00000127, - 0x0000011e,0x0007000c,0x00000006,0x00000128,0x00000001,0x00000025,0x00000126,0x00000127, - 0x0003003e,0x00000123,0x00000128,0x0004003d,0x00000006,0x0000012a,0x00000029,0x0004003d, - 0x00000006,0x0000012b,0x0000002a,0x0007000c,0x00000006,0x0000012c,0x00000001,0x00000028, - 0x0000012a,0x0000012b,0x0004003d,0x00000006,0x0000012d,0x0000011e,0x0007000c,0x00000006, - 0x0000012e,0x00000001,0x00000028,0x0000012c,0x0000012d,0x0003003e,0x00000129,0x0000012e, - 0x0004003d,0x000000a6,0x0000012f,0x0000011a,0x0004003d,0x00000006,0x00000130,0x0000002a, - 0x0004003d,0x00000006,0x00000131,0x0000002d,0x000600a9,0x00000006,0x00000132,0x0000012f, - 0x00000130,0x00000131,0x0003003e,0x0000011e,0x00000132,0x0004003d,0x00000006,0x00000134, - 0x0000002b,0x0004003d,0x00000006,0x00000135,0x0000002c,0x0007000c,0x00000006,0x00000136, - 0x00000001,0x00000025,0x00000134,0x00000135,0x0004003d,0x00000006,0x00000137,0x0000011e, - 0x0007000c,0x00000006,0x00000138,0x00000001,0x00000025,0x00000136,0x00000137,0x0003003e, - 0x00000133,0x00000138,0x0004003d,0x00000006,0x0000013a,0x0000002b,0x0004003d,0x00000006, - 0x0000013b,0x0000002c,0x0007000c,0x00000006,0x0000013c,0x00000001,0x00000028,0x0000013a, - 0x0000013b,0x0004003d,0x00000006,0x0000013d,0x0000011e,0x0007000c,0x00000006,0x0000013e, - 0x00000001,0x00000028,0x0000013c,0x0000013d,0x0003003e,0x00000139,0x0000013e,0x0004003d, - 0x00000006,0x00000140,0x00000129,0x0004003d,0x00000006,0x00000141,0x00000123,0x00050083, - 0x00000006,0x00000142,0x00000140,0x00000141,0x0003003e,0x0000013f,0x00000142,0x0004003d, - 0x00000006,0x00000144,0x00000139,0x0004003d,0x00000006,0x00000145,0x00000133,0x00050083, - 0x00000006,0x00000146,0x00000144,0x00000145,0x0003003e,0x00000143,0x00000146,0x0004003d, - 0x00000006,0x00000148,0x0000013f,0x0004003d,0x00000006,0x00000149,0x00000143,0x0007000c, - 0x00000006,0x0000014a,0x00000001,0x00000028,0x00000148,0x00000149,0x0004003d,0x00000006, - 0x0000014b,0x0000013f,0x0004003d,0x00000006,0x0000014c,0x00000143,0x0007000c,0x00000006, - 0x0000014d,0x00000001,0x00000025,0x0000014b,0x0000014c,0x00050081,0x00000006,0x0000014f, - 0x0000014d,0x0000014e,0x00050088,0x00000006,0x00000150,0x0000014a,0x0000014f,0x0003003e, - 0x00000147,0x00000150,0x0004003d,0x00000006,0x00000151,0x00000147,0x00050083,0x00000006, - 0x00000153,0x00000151,0x00000152,0x00050085,0x00000006,0x00000155,0x00000153,0x00000154, - 0x0008000c,0x00000006,0x00000156,0x00000001,0x0000002b,0x00000155,0x000000a5,0x000000b2, - 0x00050083,0x00000006,0x00000157,0x000000b2,0x00000156,0x00050085,0x00000006,0x00000158, - 0x00000157,0x000000b2,0x000200fe,0x00000158,0x00010038,0x00050036,0x00000006,0x00000038, - 0x00000000,0x00000035,0x00030037,0x00000034,0x00000036,0x00030037,0x00000026,0x00000037, - 0x000200f8,0x00000039,0x0004003b,0x0000000d,0x0000015f,0x00000007,0x0004003b,0x00000026, - 0x00000160,0x00000007,0x0004003b,0x00000214,0x00000215,0x00000007,0x0004003b,0x0000000d, - 0x00000221,0x00000007,0x0004003b,0x00000026,0x00000222,0x00000007,0x0004003b,0x00000214, - 0x000002b0,0x00000007,0x0004003b,0x0000000d,0x000002bb,0x00000007,0x0004003b,0x0000000d, - 0x000002c3,0x00000007,0x0004003b,0x0000000d,0x000002cf,0x00000007,0x0004003b,0x0000000d, - 0x000002e3,0x00000007,0x0004003b,0x0000000d,0x000002e6,0x00000007,0x0004003b,0x0000000d, - 0x000002e9,0x00000007,0x0004003b,0x0000000d,0x000002ec,0x00000007,0x0004003b,0x0000000d, - 0x000002ef,0x00000007,0x0004003b,0x0000000d,0x000002f2,0x00000007,0x0004003b,0x00000026, - 0x000002f5,0x00000007,0x0004003d,0x00000025,0x0000015b,0x00000037,0x0008000c,0x00000025, - 0x0000015e,0x00000001,0x0000002d,0x0000015b,0x0000015c,0x0000015d,0x0003003e,0x00000037, - 0x0000015e,0x0003003e,0x0000015f,0x000000a5,0x0003003e,0x00000160,0x0000015c,0x000200f9, - 0x00000161,0x000200f8,0x00000161,0x000400f6,0x00000163,0x00000164,0x00000000,0x000200f9, - 0x00000165,0x000200f8,0x00000165,0x0004003d,0x00000025,0x00000166,0x00000160,0x000500b1, - 0x000000a6,0x00000168,0x00000166,0x00000167,0x000400fa,0x00000168,0x00000162,0x00000163, - 0x000200f8,0x00000162,0x0004003d,0x00000025,0x00000210,0x00000037,0x00050084,0x00000025, - 0x00000211,0x00000210,0x00000167,0x0004003d,0x00000025,0x00000212,0x00000160,0x00050080, - 0x00000025,0x00000213,0x00000211,0x00000212,0x0003003e,0x00000215,0x0000020f,0x00050041, - 0x0000000d,0x00000216,0x00000215,0x00000213,0x0004003d,0x00000006,0x00000217,0x00000216, - 0x0004003d,0x00000025,0x00000218,0x00000160,0x00050041,0x0000000d,0x00000219,0x00000036, - 0x00000218,0x0004003d,0x00000006,0x0000021a,0x00000219,0x00050085,0x00000006,0x0000021b, - 0x00000217,0x0000021a,0x0004003d,0x00000006,0x0000021c,0x0000015f,0x00050081,0x00000006, - 0x0000021d,0x0000021c,0x0000021b,0x0003003e,0x0000015f,0x0000021d,0x000200f9,0x00000164, - 0x000200f8,0x00000164,0x0004003d,0x00000025,0x0000021e,0x00000160,0x00050080,0x00000025, - 0x00000220,0x0000021e,0x0000021f,0x0003003e,0x00000160,0x00000220,0x000200f9,0x00000161, - 0x000200f8,0x00000163,0x0003003e,0x00000221,0x000000a5,0x0003003e,0x00000222,0x0000015c, - 0x000200f9,0x00000223,0x000200f8,0x00000223,0x000400f6,0x00000225,0x00000226,0x00000000, - 0x000200f9,0x00000227,0x000200f8,0x00000227,0x0004003d,0x00000025,0x00000228,0x00000222, - 0x000500b1,0x000000a6,0x00000229,0x00000228,0x00000167,0x000400fa,0x00000229,0x00000224, - 0x00000225,0x000200f8,0x00000224,0x0004003d,0x00000025,0x000002ac,0x00000037,0x00050084, - 0x00000025,0x000002ad,0x000002ac,0x00000167,0x0004003d,0x00000025,0x000002ae,0x00000222, - 0x00050080,0x00000025,0x000002af,0x000002ad,0x000002ae,0x0003003e,0x000002b0,0x000002ab, - 0x00050041,0x0000000d,0x000002b1,0x000002b0,0x000002af,0x0004003d,0x00000006,0x000002b2, - 0x000002b1,0x0004003d,0x00000025,0x000002b3,0x00000222,0x00050041,0x0000000d,0x000002b4, - 0x00000036,0x000002b3,0x0004003d,0x00000006,0x000002b5,0x000002b4,0x00050085,0x00000006, - 0x000002b6,0x000002b2,0x000002b5,0x0004003d,0x00000006,0x000002b7,0x00000221,0x00050081, - 0x00000006,0x000002b8,0x000002b7,0x000002b6,0x0003003e,0x00000221,0x000002b8,0x000200f9, - 0x00000226,0x000200f8,0x00000226,0x0004003d,0x00000025,0x000002b9,0x00000222,0x00050080, - 0x00000025,0x000002ba,0x000002b9,0x0000021f,0x0003003e,0x00000222,0x000002ba,0x000200f9, - 0x00000223,0x000200f8,0x00000225,0x0004003d,0x00000006,0x000002bc,0x0000015f,0x00050083, - 0x00000006,0x000002be,0x000002bc,0x000002bd,0x00050085,0x00000006,0x000002c0,0x000002be, - 0x000002bf,0x0008000c,0x00000006,0x000002c1,0x00000001,0x0000002b,0x000002c0,0x000000a5, - 0x000000b2,0x00050083,0x00000006,0x000002c2,0x000000b2,0x000002c1,0x0003003e,0x000002bb, - 0x000002c2,0x0004003d,0x00000006,0x000002c4,0x000002bb,0x0004003d,0x00000006,0x000002c7, - 0x000002c6,0x00050085,0x00000006,0x000002c8,0x000002c4,0x000002c7,0x0004003d,0x00000006, - 0x000002ca,0x000002c9,0x00050081,0x00000006,0x000002cb,0x000002c8,0x000002ca,0x0003003e, - 0x000002c3,0x000002cb,0x0004003d,0x00000006,0x000002cc,0x000002c3,0x0004003d,0x00000006, - 0x000002cd,0x00000221,0x00050085,0x00000006,0x000002ce,0x000002cd,0x000002cc,0x0003003e, - 0x00000221,0x000002ce,0x0004003d,0x00000006,0x000002d0,0x000002bb,0x0004003d,0x00000006, - 0x000002d2,0x000002d1,0x00050085,0x00000006,0x000002d3,0x000002d0,0x000002d2,0x0004003d, - 0x00000006,0x000002d5,0x000002d4,0x00050081,0x00000006,0x000002d6,0x000002d3,0x000002d5, - 0x0004003d,0x00000006,0x000002d7,0x0000015f,0x00050085,0x00000006,0x000002d8,0x000002d6, - 0x000002d7,0x0003003e,0x000002cf,0x000002d8,0x0004003d,0x00000006,0x000002d9,0x000002cf, - 0x0004003d,0x00000006,0x000002da,0x000002cf,0x0004007f,0x00000006,0x000002db,0x000002da, - 0x0004003d,0x00000006,0x000002dc,0x00000221,0x0007000c,0x00000006,0x000002dd,0x00000001, - 0x00000028,0x000002db,0x000002dc,0x0007000c,0x00000006,0x000002de,0x00000001,0x00000025, - 0x000002d9,0x000002dd,0x0003003e,0x00000221,0x000002de,0x00050041,0x0000000d,0x000002e4, - 0x00000036,0x0000015c,0x0004003d,0x00000006,0x000002e5,0x000002e4,0x0003003e,0x000002e3, - 0x000002e5,0x00050041,0x0000000d,0x000002e7,0x00000036,0x0000021f,0x0004003d,0x00000006, - 0x000002e8,0x000002e7,0x0003003e,0x000002e6,0x000002e8,0x00050041,0x0000000d,0x000002ea, - 0x00000036,0x000002df,0x0004003d,0x00000006,0x000002eb,0x000002ea,0x0003003e,0x000002e9, - 0x000002eb,0x00050041,0x0000000d,0x000002ed,0x00000036,0x000002e0,0x0004003d,0x00000006, - 0x000002ee,0x000002ed,0x0003003e,0x000002ec,0x000002ee,0x00050041,0x0000000d,0x000002f0, - 0x00000036,0x000002e1,0x0004003d,0x00000006,0x000002f1,0x000002f0,0x0003003e,0x000002ef, - 0x000002f1,0x00050041,0x0000000d,0x000002f3,0x00000036,0x000002e2,0x0004003d,0x00000006, - 0x000002f4,0x000002f3,0x0003003e,0x000002f2,0x000002f4,0x0004003d,0x00000025,0x000002f6, - 0x00000037,0x0003003e,0x000002f5,0x000002f6,0x000b0039,0x00000006,0x000002f7,0x0000002f, - 0x000002e3,0x000002e6,0x000002e9,0x000002ec,0x000002ef,0x000002f2,0x000002f5,0x0004003d, - 0x00000006,0x000002f8,0x00000221,0x00050085,0x00000006,0x000002f9,0x000002f8,0x000002f7, - 0x0003003e,0x00000221,0x000002f9,0x0004003d,0x00000006,0x000002fa,0x0000015f,0x0004003d, - 0x00000006,0x000002fb,0x00000221,0x00050081,0x00000006,0x000002fc,0x000002fa,0x000002fb, - 0x000200fe,0x000002fc,0x00010038,0x00050036,0x00000006,0x00000040,0x00000000,0x0000003c, + 0x00030005,0x00000053,0x00305f67,0x00040005,0x00000060,0x35345f67,0x00000000,0x00040005, + 0x0000006d,0x30395f67,0x00000000,0x00040005,0x0000007a,0x33315f67,0x00000035,0x00050005, + 0x00000087,0x5f305f67,0x6d5f3039,0x00007861,0x00050005,0x0000008b,0x5f305f67,0x6d5f3039, + 0x00006e69,0x00060005,0x0000008f,0x35345f67,0x3533315f,0x78616d5f,0x00000000,0x00060005, + 0x00000093,0x35345f67,0x3533315f,0x6e696d5f,0x00000000,0x00040005,0x000000a1,0x5f305f65, + 0x00003039,0x00050005,0x000000a7,0x35345f65,0x3533315f,0x00000000,0x00040005,0x000000ac, + 0x5f305f63,0x00003039,0x00050005,0x000000ba,0x35345f63,0x3533315f,0x00000000,0x00050005, + 0x000000c6,0x5f675f63,0x30395f30,0x00000000,0x00050005,0x000000ca,0x5f675f63,0x315f3534, + 0x00003533,0x00050005,0x000000ce,0x5f655f66,0x30395f30,0x00000000,0x00050005,0x000000d4, + 0x5f655f66,0x315f3534,0x00003533,0x00030005,0x000000da,0x00003077,0x00030005,0x000000e0, + 0x00303977,0x00030005,0x000000e7,0x00353477,0x00040005,0x000000ed,0x35333177,0x00000000, + 0x00030005,0x000000fb,0x00003068,0x00030005,0x00000101,0x00003168,0x00050005,0x0000010e, + 0x656c6573,0x726f7463,0x00000000,0x00030005,0x00000112,0x006c6573,0x00040005,0x00000117, + 0x696d5f61,0x0000006e,0x00040005,0x0000011d,0x616d5f61,0x00000078,0x00040005,0x00000127, + 0x696d5f62,0x0000006e,0x00040005,0x0000012d,0x616d5f62,0x00000078,0x00040005,0x00000133, + 0x6f635f61,0x0000746e,0x00040005,0x00000137,0x6f635f62,0x0000746e,0x00050005,0x0000013b, + 0x746e6f63,0x7461725f,0x00006f69,0x00030005,0x00000153,0x00000079,0x00040005,0x00000154, + 0x73755f79,0x0000006d,0x00030005,0x00000155,0x00000069,0x00050005,0x0000020a,0x65646e69, + 0x6c626178,0x00000065,0x00050005,0x00000299,0x65646e69,0x6c626178,0x00000065,0x00040005, + 0x000002a5,0x63735f79,0x00656c61,0x00050005,0x000002ad,0x68735f79,0x6e707261,0x00737365, + 0x00070005,0x000002b0,0x61685367,0x74537072,0x676e6572,0x63536874,0x00656c61,0x00070005, + 0x000002b3,0x61685367,0x74537072,0x676e6572,0x694d6874,0x0000006e,0x00070005,0x000002b9, + 0x68735f79,0x6e707261,0x5f737365,0x696d696c,0x00000074,0x00070005,0x000002bb,0x61685367, + 0x694c7072,0x5374696d,0x656c6163,0x00000000,0x00060005,0x000002be,0x61685367,0x694c7072, + 0x4d74696d,0x00006e69,0x00040005,0x000002cd,0x61726170,0x0000006d,0x00040005,0x000002d0, + 0x61726170,0x0000006d,0x00040005,0x000002d3,0x61726170,0x0000006d,0x00040005,0x000002d6, + 0x61726170,0x0000006d,0x00040005,0x000002d9,0x61726170,0x0000006d,0x00040005,0x000002dc, + 0x61726170,0x0000006d,0x00040005,0x000002df,0x61726170,0x0000006d,0x00040005,0x000002ed, + 0x63615f68,0x00000063,0x00030005,0x000002ee,0x0000006a,0x00040005,0x000002f6,0x63615f76, + 0x00000063,0x00030005,0x000002f7,0x00000069,0x00050005,0x00000307,0x65646e69,0x6c626178, + 0x00000065,0x00050005,0x00000314,0x65646e69,0x6c626178,0x00000065,0x00030005,0x0000031f, + 0x00000066,0x00030005,0x00000326,0x00000069,0x00050005,0x0000032e,0x65746e69,0x44307072, + 0x00006765,0x00040005,0x0000033b,0x61726170,0x0000006d,0x00040005,0x0000033d,0x61726170, + 0x0000006d,0x00030005,0x0000034b,0x00000069,0x00050005,0x00000353,0x65746e69,0x30397072, + 0x00676544,0x00040005,0x00000360,0x61726170,0x0000006d,0x00040005,0x00000362,0x61726170, + 0x0000006d,0x00050005,0x00000370,0x61687070,0x625f6573,0x00003534,0x00070005,0x0000037a, + 0x706d6574,0x746e695f,0x34707265,0x67654435,0x00000000,0x00030005,0x00000392,0x00000061, + 0x00030005,0x0000039e,0x00000062,0x00030005,0x000003aa,0x00000063,0x00030005,0x000003b6, + 0x00000064,0x00050005,0x000003de,0x61687070,0x705f6573,0x00003534,0x00030005,0x000003e6, + 0x00000069,0x00050005,0x000003ee,0x65746e69,0x35347072,0x00676544,0x00030005,0x000003fa, + 0x00000069,0x00040005,0x0000040d,0x61726170,0x0000006d,0x00040005,0x0000040f,0x61726170, + 0x0000006d,0x00050005,0x0000041c,0x61687070,0x625f6573,0x00353331,0x00070005,0x00000421, + 0x706d6574,0x746e695f,0x31707265,0x65443533,0x00000067,0x00030005,0x00000439,0x00000061, + 0x00030005,0x00000445,0x00000062,0x00030005,0x00000451,0x00000063,0x00030005,0x0000045d, + 0x00000064,0x00050005,0x00000485,0x61687070,0x705f6573,0x00353331,0x00030005,0x0000048e, + 0x00000069,0x00060005,0x00000496,0x65746e69,0x33317072,0x67654435,0x00000000,0x00030005, + 0x000004a2,0x00000069,0x00040005,0x000004b4,0x61726170,0x0000006d,0x00040005,0x000004b6, + 0x61726170,0x0000006d,0x00050005,0x000004c0,0x72616873,0x73656e70,0x00000073,0x00030005, + 0x000004c1,0x00004350,0x00040006,0x000004c1,0x00000000,0x0063646e,0x00070006,0x000004c1, + 0x00000001,0x77656956,0x74726f70,0x6f666e49,0x00000000,0x00060006,0x000004c1,0x00000002, + 0x72616873,0x73656e70,0x00000073,0x00030005,0x000004c3,0x00006370,0x00060005,0x000004c8, + 0x72616873,0x5f6e6570,0x64696c73,0x00007265,0x00050005,0x000004cb,0x5378614d,0x656c6163, + 0x00000000,0x00050005,0x000004d1,0x536e694d,0x656c6163,0x00000000,0x00050005,0x000004d5, + 0x696d694c,0x61635374,0x0000656c,0x00070005,0x000004df,0x72616873,0x72745370,0x74676e65, + 0x78614d68,0x00000000,0x00060005,0x000004f3,0x72616873,0x6d694c70,0x614d7469,0x00000078, + 0x00040005,0x000004ff,0x69536e69,0x0000657a,0x00040005,0x00000504,0x49766e69,0x0000006e, + 0x00040005,0x00000508,0x58637273,0x00000000,0x00060005,0x0000050a,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00040005,0x00000512,0x59637273,0x00000000,0x00030005,0x00000519, + 0x00787366,0x00030005,0x0000051c,0x00797366,0x00030005,0x0000051f,0x00007866,0x00030005, + 0x00000523,0x00007966,0x00040005,0x00000527,0x695f7866,0x0000746e,0x00040005,0x0000052b, + 0x695f7966,0x0000746e,0x00030005,0x0000052f,0x00000069,0x00030005,0x00000537,0x0000006a, + 0x00030005,0x0000053f,0x00006374,0x00030005,0x0000054f,0x00000070,0x00060005,0x00000555, + 0x75706e49,0x78655474,0x65727574,0x00000000,0x00040005,0x00000559,0x61726170,0x0000006d, + 0x00030005,0x00000561,0x00303065,0x00040005,0x00000562,0x61726170,0x0000006d,0x00040005, + 0x00000565,0x61726170,0x0000006d,0x00040005,0x00000568,0x61726170,0x0000006d,0x00040005, + 0x0000056b,0x61726170,0x0000006d,0x00040005,0x0000056e,0x61726170,0x0000006d,0x00040005, + 0x00000571,0x61726170,0x0000006d,0x00040005,0x00000574,0x61726170,0x0000006d,0x00040005, + 0x00000577,0x61726170,0x0000006d,0x00040005,0x0000057a,0x61726170,0x0000006d,0x00030005, + 0x0000057e,0x00313065,0x00040005,0x0000057f,0x61726170,0x0000006d,0x00040005,0x00000582, + 0x61726170,0x0000006d,0x00040005,0x00000585,0x61726170,0x0000006d,0x00040005,0x00000588, + 0x61726170,0x0000006d,0x00040005,0x0000058b,0x61726170,0x0000006d,0x00040005,0x0000058e, + 0x61726170,0x0000006d,0x00040005,0x00000591,0x61726170,0x0000006d,0x00040005,0x00000594, + 0x61726170,0x0000006d,0x00040005,0x00000597,0x61726170,0x0000006d,0x00030005,0x0000059b, + 0x00303165,0x00040005,0x0000059c,0x61726170,0x0000006d,0x00040005,0x0000059f,0x61726170, + 0x0000006d,0x00040005,0x000005a2,0x61726170,0x0000006d,0x00040005,0x000005a5,0x61726170, + 0x0000006d,0x00040005,0x000005a8,0x61726170,0x0000006d,0x00040005,0x000005ab,0x61726170, + 0x0000006d,0x00040005,0x000005ae,0x61726170,0x0000006d,0x00040005,0x000005b1,0x61726170, + 0x0000006d,0x00040005,0x000005b4,0x61726170,0x0000006d,0x00030005,0x000005b8,0x00313165, + 0x00040005,0x000005b9,0x61726170,0x0000006d,0x00040005,0x000005bc,0x61726170,0x0000006d, + 0x00040005,0x000005bf,0x61726170,0x0000006d,0x00040005,0x000005c2,0x61726170,0x0000006d, + 0x00040005,0x000005c5,0x61726170,0x0000006d,0x00040005,0x000005c8,0x61726170,0x0000006d, + 0x00040005,0x000005cb,0x61726170,0x0000006d,0x00040005,0x000005ce,0x61726170,0x0000006d, + 0x00040005,0x000005d1,0x61726170,0x0000006d,0x00030005,0x000005d5,0x00000077,0x00040005, + 0x000005d6,0x61726170,0x0000006d,0x00040005,0x000005d8,0x61726170,0x0000006d,0x00040005, + 0x000005da,0x61726170,0x0000006d,0x00040005,0x000005dc,0x61726170,0x0000006d,0x00040005, + 0x000005de,0x61726170,0x0000006d,0x00040005,0x000005e0,0x61726170,0x0000006d,0x00050005, + 0x000005e3,0x65736162,0x67696557,0x00007468,0x00030005,0x000005f0,0x0059706f,0x00040005, + 0x000005f1,0x61726170,0x0000006d,0x00040005,0x000005f3,0x61726170,0x0000006d,0x00040005, + 0x000005f5,0x61726170,0x0000006d,0x00040005,0x000005fa,0x61726170,0x0000006d,0x00040005, + 0x000005fc,0x61726170,0x0000006d,0x00040005,0x000005fe,0x61726170,0x0000006d,0x00040005, + 0x00000600,0x61726170,0x0000006d,0x00040005,0x00000602,0x61726170,0x0000006d,0x00040005, + 0x00000604,0x61726170,0x0000006d,0x00030005,0x00000609,0x0000706f,0x00030005,0x0000060d, + 0x00000079,0x00040005,0x0000060e,0x61726170,0x0000006d,0x00040005,0x00000612,0x72726f63, + 0x00000000,0x00050005,0x00000622,0x4374756f,0x726f6c6f,0x00000000,0x00030047,0x000004c1, + 0x00000002,0x00050048,0x000004c1,0x00000000,0x00000023,0x00000000,0x00050048,0x000004c1, + 0x00000001,0x00000023,0x00000010,0x00050048,0x000004c1,0x00000002,0x00000023,0x00000020, + 0x00040047,0x0000050a,0x0000001e,0x00000000,0x00040047,0x00000555,0x00000021,0x00000000, + 0x00040047,0x00000555,0x00000022,0x00000000,0x00040047,0x00000622,0x0000001e,0x00000000, + 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, + 0x00040017,0x00000007,0x00000006,0x00000003,0x00040020,0x00000008,0x00000007,0x00000007, + 0x00040021,0x00000009,0x00000006,0x00000008,0x00040020,0x0000000d,0x00000007,0x00000006, + 0x00040017,0x0000000e,0x00000006,0x00000004,0x000c0021,0x0000000f,0x0000000e,0x0000000d, + 0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d, + 0x00040020,0x0000001b,0x00000007,0x0000000e,0x00090021,0x0000001c,0x0000000e,0x0000001b, + 0x0000001b,0x0000001b,0x0000001b,0x0000000d,0x0000000d,0x00040015,0x00000025,0x00000020, + 0x00000001,0x00040020,0x00000026,0x00000007,0x00000025,0x000a0021,0x00000027,0x00000006, + 0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x00000026,0x00040015, + 0x00000031,0x00000020,0x00000000,0x0004002b,0x00000031,0x00000032,0x00000006,0x0004001c, + 0x00000033,0x00000006,0x00000032,0x00040020,0x00000034,0x00000007,0x00000033,0x00050021, + 0x00000035,0x00000006,0x00000034,0x00000026,0x0004001c,0x0000003a,0x00000033,0x00000032, + 0x00040020,0x0000003b,0x00000007,0x0000003a,0x00060021,0x0000003c,0x00000006,0x0000003b, + 0x00000026,0x00000026,0x00090021,0x00000042,0x00000006,0x0000003b,0x0000000d,0x0000000d, + 0x00000026,0x00000026,0x0000001b,0x0004002b,0x00000006,0x0000004c,0x3e59b3d0,0x0004002b, + 0x00000006,0x0000004d,0x3f371759,0x0004002b,0x00000006,0x0000004e,0x3d93dd98,0x0006002c, + 0x00000007,0x0000004f,0x0000004c,0x0000004d,0x0000004e,0x0004002b,0x00000006,0x0000009a, + 0x00000000,0x00020014,0x0000009b,0x0007002c,0x0000000e,0x0000009f,0x0000009a,0x0000009a, + 0x0000009a,0x0000009a,0x0004002b,0x00000006,0x000000a8,0x3f800000,0x00040020,0x000000ab, + 0x00000007,0x0000009b,0x0004002b,0x00000006,0x000000af,0x400ce000,0x0004002b,0x00000006, + 0x000000b3,0x3d800000,0x0004002b,0x00000025,0x00000110,0x00000020,0x0004002b,0x00000006, + 0x00000142,0x3b808081,0x0004002b,0x00000006,0x00000146,0x40000000,0x0004002b,0x00000006, + 0x00000148,0x3e000000,0x0004002b,0x00000025,0x00000150,0x00000000,0x0004002b,0x00000025, + 0x00000151,0x0000003f,0x0004002b,0x00000025,0x0000015c,0x00000006,0x0004002b,0x00000031, + 0x0000015e,0x00000180,0x0004001c,0x0000015f,0x00000006,0x0000015e,0x0004002b,0x00000006, + 0x00000160,0x3b3e0ded,0x0004002b,0x00000006,0x00000161,0xbc5013a9,0x0004002b,0x00000006, + 0x00000162,0x3c5844d0,0x0004002b,0x00000006,0x00000163,0xbb5ed289,0x0004002b,0x00000006, + 0x00000164,0x3bce703b,0x0004002b,0x00000006,0x00000165,0xbccbfb16,0x0004002b,0x00000006, + 0x00000166,0x3f7f9db2,0x0004002b,0x00000006,0x00000167,0x3cdc5d64,0x0004002b,0x00000006, + 0x00000168,0xbbded289,0x0004002b,0x00000006,0x00000169,0x3c102de0,0x0004002b,0x00000006, + 0x0000016a,0xbd13dd98,0x0004002b,0x00000006,0x0000016b,0x3f7edfa4,0x0004002b,0x00000006, + 0x0000016c,0x3d29fbe7,0x0004002b,0x00000006,0x0000016d,0xbc28c155,0x0004002b,0x00000006, + 0x0000016e,0x3a03126f,0x0004002b,0x00000006,0x0000016f,0x3c3fb15b,0x0004002b,0x00000006, + 0x00000170,0xbd422681,0x0004002b,0x00000006,0x00000171,0x3f7e425b,0x0004002b,0x00000006, + 0x00000172,0x3d6631f9,0x0004002b,0x00000006,0x00000173,0xbc68a71e,0x0004002b,0x00000006, + 0x00000174,0x3c68a71e,0x0004002b,0x00000006,0x00000175,0xbd6bedfa,0x0004002b,0x00000006, + 0x00000176,0x3f7d5cfb,0x0004002b,0x00000006,0x00000177,0x3d9205bc,0x0004002b,0x00000006, + 0x00000178,0xbc944674,0x0004002b,0x00000006,0x00000179,0x3c87fcb9,0x0004002b,0x00000006, + 0x0000017a,0xbd8a0903,0x0004002b,0x00000006,0x0000017b,0x3f7c01a3,0x0004002b,0x00000006, + 0x0000017c,0x3db2fec5,0x0004002b,0x00000006,0x0000017d,0xbcb43958,0x0004002b,0x00000006, + 0x0000017e,0x3a83126f,0x0004002b,0x00000006,0x0000017f,0x3c985f07,0x0004002b,0x00000006, + 0x00000180,0xbd9c0ebf,0x0004002b,0x00000006,0x00000181,0x3f7a7efa,0x0004002b,0x00000006, + 0x00000182,0x3dd4fdf4,0x0004002b,0x00000006,0x00000183,0xbcd844d0,0x0004002b,0x00000006, + 0x00000184,0x3ac49ba6,0x0004002b,0x00000006,0x00000185,0x3ca7ef9e,0x0004002b,0x00000006, + 0x00000186,0xbdae147b,0x0004002b,0x00000006,0x00000187,0x3f7902de,0x0004002b,0x00000006, + 0x00000188,0x3df6fd22,0x0004002b,0x00000006,0x00000189,0xbcfc5048,0x0004002b,0x00000006, + 0x0000018a,0x3b03126f,0x0004002b,0x00000006,0x0000018b,0x3cb851ec,0x0004002b,0x00000006, + 0x0000018c,0xbdbe0ded,0x0004002b,0x00000006,0x0000018d,0x3f76fd22,0x0004002b,0x00000006, + 0x0000018e,0x3e0d844d,0x0004002b,0x00000006,0x0000018f,0xbd102de0,0x0004002b,0x00000006, + 0x00000190,0x3b1d4952,0x0004002b,0x00000006,0x00000191,0x3cc3c9ef,0x0004002b,0x00000006, + 0x00000192,0xbdce075f,0x0004002b,0x00000006,0x00000193,0x3f751eb8,0x0004002b,0x00000006, + 0x00000194,0x3e1f8a09,0x0004002b,0x00000006,0x00000195,0xbd22339c,0x0004002b,0x00000006, + 0x00000196,0x3cd013a9,0x0004002b,0x00000006,0x00000197,0xbddbf488,0x0004002b,0x00000006, + 0x00000198,0x3f72de01,0x0004002b,0x00000006,0x00000199,0x3e31f8a1,0x0004002b,0x00000006, + 0x0000019a,0xbd33d07d,0x0004002b,0x00000006,0x0000019b,0x3b5ed289,0x0004002b,0x00000006, + 0x0000019c,0x3cd844d0,0x0004002b,0x00000006,0x0000019d,0xbde90ff9,0x0004002b,0x00000006, + 0x0000019e,0x3f70624e,0x0004002b,0x00000006,0x0000019f,0x3e458794,0x0004002b,0x00000006, + 0x000001a0,0xbd47e282,0x0004002b,0x00000006,0x000001a1,0x3b902de0,0x0004002b,0x00000006, + 0x000001a2,0x3ce3bcd3,0x0004002b,0x00000006,0x000001a3,0xbdf3eab3,0x0004002b,0x00000006, + 0x000001a4,0x3f6d9e84,0x0004002b,0x00000006,0x000001a5,0x3e58fc50,0x0004002b,0x00000006, + 0x000001a6,0xbd5bf488,0x0004002b,0x00000006,0x000001a7,0x3ba0902e,0x0004002b,0x00000006, + 0x000001a8,0x3cebedfa,0x0004002b,0x00000006,0x000001a9,0xbdfef9db,0x0004002b,0x00000006, + 0x000001aa,0x3f6ac083,0x0004002b,0x00000006,0x000001ab,0x3e6c8b44,0x0004002b,0x00000006, + 0x000001ac,0xbd6dfa44,0x0004002b,0x00000006,0x000001ad,0x3bc154ca,0x0004002b,0x00000006, + 0x000001ae,0x3cf0068e,0x0004002b,0x00000006,0x000001af,0xbe04816f,0x0004002b,0x00000006, + 0x000001b0,0x3f67e282,0x0004002b,0x00000006,0x000001b1,0x3e808312,0x0004002b,0x00000006, + 0x000001b2,0xbd810625,0x0004002b,0x00000006,0x000001b3,0x3cf837b5,0x0004002b,0x00000006, + 0x000001b4,0xbe087fcc,0x0004002b,0x00000006,0x000001b5,0x3f64816f,0x0004002b,0x00000006, + 0x000001b6,0x3e8ac083,0x0004002b,0x00000006,0x000001b7,0xbd8b0f28,0x0004002b,0x00000006, + 0x000001b8,0x3bef34d7,0x0004002b,0x00000006,0x000001b9,0x3cfc5048,0x0004002b,0x00000006, + 0x000001ba,0xbe0bfb16,0x0004002b,0x00000006,0x000001bb,0x3f60ff97,0x0004002b,0x00000006, + 0x000001bc,0x3e953f7d,0x0004002b,0x00000006,0x000001bd,0xbd95182b,0x0004002b,0x00000006, + 0x000001be,0x3c07fcb9,0x0004002b,0x00000006,0x000001bf,0xbe0f7660,0x0004002b,0x00000006, + 0x000001c0,0x3f5d9e84,0x0004002b,0x00000006,0x000001c1,0x3e9fbe77,0x0004002b,0x00000006, + 0x000001c2,0xbd9eecc0,0x0004002b,0x00000006,0x000001c3,0x3c185f07,0x0004002b,0x00000006, + 0x000001c4,0x3d00346e,0x0004002b,0x00000006,0x000001c5,0xbe1205bc,0x0004002b,0x00000006, + 0x000001c6,0x3f59c0ec,0x0004002b,0x00000006,0x000001c7,0x3eaa7efa,0x0004002b,0x00000006, + 0x000001c8,0xbda8f5c3,0x0004002b,0x00000006,0x000001c9,0x3c28c155,0x0004002b,0x00000006, + 0x000001ca,0xbe13f7cf,0x0004002b,0x00000006,0x000001cb,0x3f55dcc6,0x0004002b,0x00000006, + 0x000001cc,0x3eb53f7d,0x0004002b,0x00000006,0x000001cd,0xbdb2fec5,0x0004002b,0x00000006, + 0x000001ce,0x3c378034,0x0004002b,0x00000006,0x000001cf,0xbe158106,0x0004002b,0x00000006, + 0x000001d0,0x3f51bda5,0x0004002b,0x00000006,0x000001d1,0x3ec04189,0x0004002b,0x00000006, + 0x000001d2,0xbdbd07c8,0x0004002b,0x00000006,0x000001d3,0x3c47e282,0x0004002b,0x00000006, + 0x000001d4,0xbe16872b,0x0004002b,0x00000006,0x000001d5,0x3f4d5cfb,0x0004002b,0x00000006, + 0x000001d6,0x3ecb020c,0x0004002b,0x00000006,0x000001d7,0xbdc60aa6,0x0004002b,0x00000006, + 0x000001d8,0x3c6075f7,0x0004002b,0x00000006,0x000001d9,0xbe177319,0x0004002b,0x00000006, + 0x000001da,0x3f491d15,0x0004002b,0x00000006,0x000001db,0x3ed645a2,0x0004002b,0x00000006, + 0x000001dc,0xbdd013a9,0x0004002b,0x00000006,0x000001dd,0x3c6f34d7,0x0004002b,0x00000006, + 0x000001de,0x3f44a234,0x0004002b,0x00000006,0x000001df,0x3ee13a93,0x0004002b,0x00000006, + 0x000001e0,0xbdd91687,0x0004002b,0x00000006,0x000001e1,0x3c7f9724,0x0004002b,0x00000006, + 0x000001e2,0x3cf41f21,0x0004002b,0x00000006,0x000001e3,0x3f4020c5,0x0004002b,0x00000006, + 0x000001e4,0x3eec3c9f,0x0004002b,0x00000006,0x000001e5,0xbde21965,0x0004002b,0x00000006, + 0x000001e6,0x3f3b3d08,0x0004002b,0x00000006,0x000001e7,0x3ef73eab,0x0004002b,0x00000006, + 0x000001e8,0xbdeae7d5,0x0004002b,0x00000006,0x000001e9,0x3c944674,0x0004002b,0x00000006, + 0x000001ea,0x3f363f14,0x0004002b,0x00000006,0x000001eb,0x3f014120,0x0004002b,0x00000006, + 0x000001ec,0xbdf318fc,0x0004002b,0x00000006,0x000001ed,0x3c9ba5e3,0x0004002b,0x00000006, + 0x000001ee,0x3f3161e5,0x0004002b,0x00000006,0x000001ef,0x3f06c227,0x0004002b,0x00000006, + 0x000001f0,0xbdfb15b5,0x0004002b,0x00000006,0x000001f1,0x3ca3d70a,0x0004002b,0x00000006, + 0x000001f2,0x3cdfa440,0x0004002b,0x00000006,0x000001f3,0xbe1288ce,0x0004002b,0x00000006, + 0x000001f4,0x3f2c2268,0x0004002b,0x00000006,0x000001f5,0x3f0c432d,0x0004002b,0x00000006, + 0x000001f6,0xbe010625,0x0004002b,0x00000006,0x000001f7,0x3cb020c5,0x0004002b,0x00000006, + 0x000001f8,0xbe107c85,0x0004002b,0x00000006,0x000001f9,0x3f271de7,0x0004002b,0x00000006, + 0x000001fa,0x3f11bda5,0x0004002b,0x00000006,0x000001fb,0xbe050481,0x0004002b,0x00000006, + 0x000001fc,0xbe0e075f,0x0004002b,0x00000006,0x000001fd,0x3f21de6a,0x0004002b,0x00000006, + 0x000001fe,0x3f171de7,0x0004002b,0x00000006,0x000001ff,0xbe07fcb9,0x0004002b,0x00000006, + 0x00000200,0x3cbfb15b,0x0004002b,0x00000006,0x00000201,0x3cc7e282,0x0004002b,0x00000006, + 0x00000202,0xbe0af4f1,0x0004002b,0x00000006,0x00000203,0x3f1c7e28,0x0183002c,0x0000015f, + 0x00000204,0x0000009a,0x0000009a,0x000000a8,0x0000009a,0x0000009a,0x0000009a,0x00000160, + 0x00000161,0x000000a8,0x00000162,0x00000163,0x0000009a,0x00000164,0x00000165,0x00000166, + 0x00000167,0x00000168,0x0000009a,0x00000169,0x0000016a,0x0000016b,0x0000016c,0x0000016d, + 0x0000016e,0x0000016f,0x00000170,0x00000171,0x00000172,0x00000173,0x0000016e,0x00000174, + 0x00000175,0x00000176,0x00000177,0x00000178,0x0000016e,0x00000179,0x0000017a,0x0000017b, + 0x0000017c,0x0000017d,0x0000017e,0x0000017f,0x00000180,0x00000181,0x00000182,0x00000183, + 0x00000184,0x00000185,0x00000186,0x00000187,0x00000188,0x00000189,0x0000018a,0x0000018b, + 0x0000018c,0x0000018d,0x0000018e,0x0000018f,0x00000190,0x00000191,0x00000192,0x00000193, + 0x00000194,0x00000195,0x00000160,0x00000196,0x00000197,0x00000198,0x00000199,0x0000019a, + 0x0000019b,0x0000019c,0x0000019d,0x0000019e,0x0000019f,0x000001a0,0x000001a1,0x000001a2, + 0x000001a3,0x000001a4,0x000001a5,0x000001a6,0x000001a7,0x000001a8,0x000001a9,0x000001aa, + 0x000001ab,0x000001ac,0x000001ad,0x000001ae,0x000001af,0x000001b0,0x000001b1,0x000001b2, + 0x00000164,0x000001b3,0x000001b4,0x000001b5,0x000001b6,0x000001b7,0x000001b8,0x000001b9, + 0x000001ba,0x000001bb,0x000001bc,0x000001bd,0x000001be,0x000001b9,0x000001bf,0x000001c0, + 0x000001c1,0x000001c2,0x000001c3,0x000001c4,0x000001c5,0x000001c6,0x000001c7,0x000001c8, + 0x000001c9,0x000001c4,0x000001ca,0x000001cb,0x000001cc,0x000001cd,0x000001ce,0x000001c4, + 0x000001cf,0x000001d0,0x000001d1,0x000001d2,0x000001d3,0x000001c4,0x000001d4,0x000001d5, + 0x000001d6,0x000001d7,0x000001d8,0x000001b9,0x000001d9,0x000001da,0x000001db,0x000001dc, + 0x000001dd,0x000001b3,0x000001d9,0x000001de,0x000001df,0x000001e0,0x000001e1,0x000001e2, + 0x000001d9,0x000001e3,0x000001e4,0x000001e5,0x00000179,0x000001ae,0x000001d4,0x000001e6, + 0x000001e7,0x000001e8,0x000001e9,0x000001a8,0x000001cf,0x000001ea,0x000001eb,0x000001ec, + 0x000001ed,0x000001a2,0x000001ca,0x000001ee,0x000001ef,0x000001f0,0x000001f1,0x000001f2, + 0x000001f3,0x000001f4,0x000001f5,0x000001f6,0x000001f7,0x0000019c,0x000001f8,0x000001f9, + 0x000001fa,0x000001fb,0x0000018b,0x00000196,0x000001fc,0x000001fd,0x000001fe,0x000001ff, + 0x00000200,0x00000201,0x00000202,0x00000203,0x00000203,0x00000202,0x00000201,0x00000200, + 0x000001ff,0x000001fe,0x000001fd,0x000001fc,0x00000196,0x0000018b,0x000001fb,0x000001fa, + 0x000001f9,0x000001f8,0x0000019c,0x000001f7,0x000001f6,0x000001f5,0x000001f4,0x000001f3, + 0x000001f2,0x000001f1,0x000001f0,0x000001ef,0x000001ee,0x000001ca,0x000001a2,0x000001ed, + 0x000001ec,0x000001eb,0x000001ea,0x000001cf,0x000001a8,0x000001e9,0x000001e8,0x000001e7, + 0x000001e6,0x000001d4,0x000001ae,0x00000179,0x000001e5,0x000001e4,0x000001e3,0x000001d9, + 0x000001e2,0x000001e1,0x000001e0,0x000001df,0x000001de,0x000001d9,0x000001b3,0x000001dd, + 0x000001dc,0x000001db,0x000001da,0x000001d9,0x000001b9,0x000001d8,0x000001d7,0x000001d6, + 0x000001d5,0x000001d4,0x000001c4,0x000001d3,0x000001d2,0x000001d1,0x000001d0,0x000001cf, + 0x000001c4,0x000001ce,0x000001cd,0x000001cc,0x000001cb,0x000001ca,0x000001c4,0x000001c9, + 0x000001c8,0x000001c7,0x000001c6,0x000001c5,0x000001c4,0x000001c3,0x000001c2,0x000001c1, + 0x000001c0,0x000001bf,0x000001b9,0x000001be,0x000001bd,0x000001bc,0x000001bb,0x000001ba, + 0x000001b9,0x000001b8,0x000001b7,0x000001b6,0x000001b5,0x000001b4,0x000001b3,0x00000164, + 0x000001b2,0x000001b1,0x000001b0,0x000001af,0x000001ae,0x000001ad,0x000001ac,0x000001ab, + 0x000001aa,0x000001a9,0x000001a8,0x000001a7,0x000001a6,0x000001a5,0x000001a4,0x000001a3, + 0x000001a2,0x000001a1,0x000001a0,0x0000019f,0x0000019e,0x0000019d,0x0000019c,0x0000019b, + 0x0000019a,0x00000199,0x00000198,0x00000197,0x00000196,0x00000160,0x00000195,0x00000194, + 0x00000193,0x00000192,0x00000191,0x00000190,0x0000018f,0x0000018e,0x0000018d,0x0000018c, + 0x0000018b,0x0000018a,0x00000189,0x00000188,0x00000187,0x00000186,0x00000185,0x00000184, + 0x00000183,0x00000182,0x00000181,0x00000180,0x0000017f,0x0000017e,0x0000017d,0x0000017c, + 0x0000017b,0x0000017a,0x00000179,0x0000016e,0x00000178,0x00000177,0x00000176,0x00000175, + 0x00000174,0x0000016e,0x00000173,0x00000172,0x00000171,0x00000170,0x0000016f,0x0000016e, + 0x0000016d,0x0000016c,0x0000016b,0x0000016a,0x00000169,0x0000009a,0x00000168,0x00000167, + 0x00000166,0x00000165,0x00000164,0x0000009a,0x00000163,0x00000162,0x000000a8,0x00000161, + 0x00000160,0x00040020,0x00000209,0x00000007,0x0000015f,0x0004002b,0x00000006,0x00000213, + 0xbf19a027,0x0004002b,0x00000006,0x00000214,0x3f99a027,0x0004002b,0x00000006,0x00000215, + 0xbf1bc01a,0x0004002b,0x00000006,0x00000216,0x3f996f00,0x0004002b,0x00000006,0x00000217, + 0xbf171de7,0x0004002b,0x00000006,0x00000218,0xbb3e0ded,0x0004002b,0x00000006,0x00000219, + 0xbf1d5cfb,0x0004002b,0x00000006,0x0000021a,0x3f990ff9,0x0004002b,0x00000006,0x0000021b, + 0xbf143fe6,0x0004002b,0x00000006,0x0000021c,0xbf1e9e1b,0x0004002b,0x00000006,0x0000021d, + 0x3f983127,0x0004002b,0x00000006,0x0000021e,0xbf10ded3,0x0004002b,0x00000006,0x0000021f, + 0xbf1f9db2,0x0004002b,0x00000006,0x00000220,0x3f9710cb,0x0004002b,0x00000006,0x00000221, + 0xbf0d21ff,0x0004002b,0x00000006,0x00000222,0xbc7765fe,0x0004002b,0x00000006,0x00000223, + 0xbf20624e,0x0004002b,0x00000006,0x00000224,0x3f95bf48,0x0004002b,0x00000006,0x00000225, + 0xbf0902de,0x0004002b,0x00000006,0x00000226,0xbc9fbe77,0x0004002b,0x00000006,0x00000227, + 0xbf208312,0x0004002b,0x00000006,0x00000228,0x3f943fe6,0x0004002b,0x00000006,0x00000229, + 0xbf04a234,0x0004002b,0x00000006,0x0000022a,0xbcd42c3d,0x0004002b,0x00000006,0x0000022b, + 0xbf20ded3,0x0004002b,0x00000006,0x0000022c,0x3f929fbe,0x0004002b,0x00000006,0x0000022d, + 0xbf0020c5,0x0004002b,0x00000006,0x0000022e,0xbd01d7dc,0x0004002b,0x00000006,0x0000022f, + 0x3f904ea5,0x0004002b,0x00000006,0x00000230,0xbef53f7d,0x0004002b,0x00000006,0x00000231, + 0xbd1e1b09,0x0004002b,0x00000006,0x00000232,0x3f8df06f,0x0004002b,0x00000006,0x00000233, + 0xbee9fbe7,0x0004002b,0x00000006,0x00000234,0xbd39f55a,0x0004002b,0x00000006,0x00000235, + 0x3c902de0,0x0004002b,0x00000006,0x00000236,0xbf1e6320,0x0004002b,0x00000006,0x00000237, + 0x3f8b404f,0x0004002b,0x00000006,0x00000238,0xbede83e4,0x0004002b,0x00000006,0x00000239, + 0xbd59e83e,0x0004002b,0x00000006,0x0000023a,0xbf1d21ff,0x0004002b,0x00000006,0x0000023b, + 0x3f886f69,0x0004002b,0x00000006,0x0000023c,0xbed205bc,0x0004002b,0x00000006,0x0000023d, + 0xbd7be76d,0x0004002b,0x00000006,0x0000023e,0xbf1b5dcc,0x0004002b,0x00000006,0x0000023f, + 0x3f852f1b,0x0004002b,0x00000006,0x00000240,0xbec4c2f8,0x0004002b,0x00000006,0x00000241, + 0xbd8ef34d,0x0004002b,0x00000006,0x00000242,0x3c9fbe77,0x0004002b,0x00000006,0x00000243, + 0xbf19c0ec,0x0004002b,0x00000006,0x00000244,0x3f820f91,0x0004002b,0x00000006,0x00000245, + 0xbeb6fd22,0x0004002b,0x00000006,0x00000246,0xbda30553,0x0004002b,0x00000006,0x00000247, + 0xbf17c1be,0x0004002b,0x00000006,0x00000248,0x3f7d42c4,0x0004002b,0x00000006,0x00000249, + 0xbea83e42,0x0004002b,0x00000006,0x0000024a,0xbdb7e910,0x0004002b,0x00000006,0x0000024b, + 0xbf14fdf4,0x0004002b,0x00000006,0x0000024c,0x3f753f7d,0x0004002b,0x00000006,0x0000024d, + 0xbe98fc50,0x0004002b,0x00000006,0x0000024e,0xbdcd013b,0x0004002b,0x00000006,0x0000024f, + 0xbf12a305,0x0004002b,0x00000006,0x00000250,0x3f6de00d,0x0004002b,0x00000006,0x00000251, + 0xbe89ba5e,0x0004002b,0x00000006,0x00000252,0xbf0fdf3b,0x0004002b,0x00000006,0x00000253, + 0x3f65c28f,0x0004002b,0x00000006,0x00000254,0xbe727bb3,0x0004002b,0x00000006,0x00000255, + 0x3b7f9724,0x0004002b,0x00000006,0x00000256,0xbf0cbfb1,0x0004002b,0x00000006,0x00000257, + 0x3f5d42c4,0x0004002b,0x00000006,0x00000258,0xbe5182aa,0x0004002b,0x00000006,0x00000259, + 0xbe0985f0,0x0004002b,0x00000006,0x0000025a,0xbf097f63,0x0004002b,0x00000006,0x0000025b, + 0x3f54816f,0x0004002b,0x00000006,0x0000025c,0xbe2f0069,0x0004002b,0x00000006,0x0000025d, + 0xbe160419,0x0004002b,0x00000006,0x0000025e,0xbf061e4f,0x0004002b,0x00000006,0x0000025f, + 0x3f4b5dcc,0x0004002b,0x00000006,0x00000260,0xbe228241,0x0004002b,0x00000006,0x00000261, + 0x3bb0f27c,0x0004002b,0x00000006,0x00000262,0xbf02bd3c,0x0004002b,0x00000006,0x00000263, + 0x3f428241,0x0004002b,0x00000006,0x00000264,0xbdd119ce,0x0004002b,0x00000006,0x00000265, + 0xbe3089a0,0x0004002b,0x00000006,0x00000266,0xbefe425b,0x0004002b,0x00000006,0x00000267, + 0x3f391d15,0x0004002b,0x00000006,0x00000268,0xbd84ea4b,0x0004002b,0x00000006,0x00000269, + 0xbe3ef9db,0x0004002b,0x00000006,0x0000026a,0xbef6bb99,0x0004002b,0x00000006,0x0000026b, + 0x3f2f41f2,0x0004002b,0x00000006,0x0000026c,0xbcebedfa,0x0004002b,0x00000006,0x0000026d, + 0xbe4c7e28,0x0004002b,0x00000006,0x0000026e,0x3bded289,0x0004002b,0x00000006,0x0000026f, + 0xbeef0069,0x0004002b,0x00000006,0x00000270,0x3f256042,0x0004002b,0x00000006,0x00000271, + 0xbe5b8bac,0x0004002b,0x00000006,0x00000272,0xbee6c227,0x0004002b,0x00000006,0x00000273, + 0x3f1b020c,0x0004002b,0x00000006,0x00000274,0x3d4432ca,0x0004002b,0x00000006,0x00000275, + 0xbe6a7efa,0x0004002b,0x00000006,0x00000276,0x3c8c154d,0x0004002b,0x00000006,0x00000277, + 0xbedfbe77,0x0004002b,0x00000006,0x00000278,0x3dafec57,0x0004002b,0x00000006,0x00000279, + 0xbe7a786c,0x0004002b,0x00000006,0x0000027a,0x3c83e426,0x0004002b,0x00000006,0x0000027b, + 0xbed6fd22,0x0004002b,0x00000006,0x0000027c,0x3f073eab,0x0004002b,0x00000006,0x0000027d, + 0x3e008312,0x0004002b,0x00000006,0x0000027e,0xbe850481,0x0004002b,0x00000006,0x0000027f, + 0x3c20902e,0x0004002b,0x00000006,0x00000280,0xbecf41f2,0x0004002b,0x00000006,0x00000281, + 0x3efa0275,0x0004002b,0x00000006,0x00000282,0x3e2978d5,0x0004002b,0x00000006,0x00000283, + 0xbe8d013b,0x0004002b,0x00000006,0x00000284,0x3c7765fe,0x0004002b,0x00000006,0x00000285, + 0xbec703b0,0x0004002b,0x00000006,0x00000286,0x3ee63f14,0x0004002b,0x00000006,0x00000287, + 0x3e50ff97,0x0004002b,0x00000006,0x00000288,0xbe94fdf4,0x0004002b,0x00000006,0x00000289, + 0x3c2f4f0e,0x0004002b,0x00000006,0x0000028a,0xbebe00d2,0x0004002b,0x00000006,0x0000028b, + 0x3ed07c85,0x0004002b,0x00000006,0x0000028c,0x3e7a786c,0x0004002b,0x00000006,0x0000028d, + 0xbe9cfaad,0x0004002b,0x00000006,0x0000028e,0xbeb60419,0x0004002b,0x00000006,0x0000028f, + 0x3ebc01a3,0x0004002b,0x00000006,0x00000290,0x3e9205bc,0x0004002b,0x00000006,0x00000291, + 0xbea5460b,0x0004002b,0x00000006,0x00000292,0xbeadc5d6,0x0004002b,0x00000006,0x00000293, + 0x3ea703b0,0x0183002c,0x0000015f,0x00000294,0x0000009a,0x00000213,0x00000214,0x00000213, + 0x0000009a,0x0000009a,0x00000160,0x00000215,0x00000216,0x00000217,0x00000218,0x0000009a, + 0x000001a7,0x00000219,0x0000021a,0x0000021b,0x00000168,0x0000016e,0x000001b8,0x0000021c, + 0x0000021d,0x0000021e,0x0000016d,0x0000009a,0x000001c3,0x0000021f,0x00000220,0x00000221, + 0x00000222,0x0000009a,0x000001ce,0x00000223,0x00000224,0x00000225,0x00000226,0x0000016e, + 0x000001d3,0x00000227,0x00000228,0x00000229,0x0000022a,0x0000016e,0x00000174,0x0000022b, + 0x0000022c,0x0000022d,0x0000022e,0x0000016e,0x000001e1,0x00000223,0x0000022f,0x00000230, + 0x00000231,0x0000016e,0x00000179,0x0000021f,0x00000232,0x00000233,0x00000234,0x0000017e, + 0x00000235,0x00000236,0x00000237,0x00000238,0x00000239,0x0000017e,0x000001e9,0x0000023a, + 0x0000023b,0x0000023c,0x0000023d,0x00000184,0x000001ed,0x0000023e,0x0000023f,0x00000240, + 0x00000241,0x00000184,0x00000242,0x00000243,0x00000244,0x00000245,0x00000246,0x0000018a, + 0x000001f1,0x00000247,0x00000248,0x00000249,0x0000024a,0x00000190,0x000001f1,0x0000024b, + 0x0000024c,0x0000024d,0x0000024e,0x00000160,0x000001f1,0x0000024f,0x00000250,0x00000251, + 0x000001e5,0x0000019b,0x000001f1,0x00000252,0x00000253,0x00000254,0x000001f0,0x00000255, + 0x00000185,0x00000256,0x00000257,0x00000258,0x00000259,0x000001a1,0x000001f1,0x0000025a, + 0x0000025b,0x0000025c,0x0000025d,0x000001a7,0x00000242,0x0000025e,0x0000025f,0x000001ba, + 0x00000260,0x00000261,0x00000242,0x00000262,0x00000263,0x00000264,0x00000265,0x000001ad, + 0x000001ed,0x00000266,0x00000267,0x00000268,0x00000269,0x00000164,0x0000017f,0x0000026a, + 0x0000026b,0x0000026c,0x0000026d,0x0000026e,0x0000017f,0x0000026f,0x00000270,0x000001c3, + 0x00000271,0x000001b8,0x00000235,0x00000272,0x00000273,0x00000274,0x00000275,0x000001be, + 0x00000276,0x00000277,0x000001fa,0x00000278,0x00000279,0x00000169,0x0000027a,0x0000027b, + 0x0000027c,0x0000027d,0x0000027e,0x0000027f,0x0000027a,0x00000280,0x00000281,0x00000282, + 0x00000283,0x000001c9,0x00000284,0x00000285,0x00000286,0x00000287,0x00000288,0x00000289, + 0x00000174,0x0000028a,0x0000028b,0x0000028c,0x0000028d,0x0000016f,0x000001d8,0x0000028e, + 0x0000028f,0x00000290,0x00000291,0x000001d3,0x00000162,0x00000292,0x00000293,0x00000293, + 0x00000292,0x00000162,0x000001d3,0x00000291,0x00000290,0x0000028f,0x0000028e,0x000001d8, + 0x0000016f,0x0000028d,0x0000028c,0x0000028b,0x0000028a,0x00000174,0x00000289,0x00000288, + 0x00000287,0x00000286,0x00000285,0x00000284,0x000001c9,0x00000283,0x00000282,0x00000281, + 0x00000280,0x0000027a,0x0000027f,0x0000027e,0x0000027d,0x0000027c,0x0000027b,0x0000027a, + 0x00000169,0x00000279,0x00000278,0x000001fa,0x00000277,0x00000276,0x000001be,0x00000275, + 0x00000274,0x00000273,0x00000272,0x00000235,0x000001b8,0x00000271,0x000001c3,0x00000270, + 0x0000026f,0x0000017f,0x0000026e,0x0000026d,0x0000026c,0x0000026b,0x0000026a,0x0000017f, + 0x00000164,0x00000269,0x00000268,0x00000267,0x00000266,0x000001ed,0x000001ad,0x00000265, + 0x00000264,0x00000263,0x00000262,0x00000242,0x00000261,0x00000260,0x000001ba,0x0000025f, + 0x0000025e,0x00000242,0x000001a7,0x0000025d,0x0000025c,0x0000025b,0x0000025a,0x000001f1, + 0x000001a1,0x00000259,0x00000258,0x00000257,0x00000256,0x00000185,0x00000255,0x000001f0, + 0x00000254,0x00000253,0x00000252,0x000001f1,0x0000019b,0x000001e5,0x00000251,0x00000250, + 0x0000024f,0x000001f1,0x00000160,0x0000024e,0x0000024d,0x0000024c,0x0000024b,0x000001f1, + 0x00000190,0x0000024a,0x00000249,0x00000248,0x00000247,0x000001f1,0x0000018a,0x00000246, + 0x00000245,0x00000244,0x00000243,0x00000242,0x00000184,0x00000241,0x00000240,0x0000023f, + 0x0000023e,0x000001ed,0x00000184,0x0000023d,0x0000023c,0x0000023b,0x0000023a,0x000001e9, + 0x0000017e,0x00000239,0x00000238,0x00000237,0x00000236,0x00000235,0x0000017e,0x00000234, + 0x00000233,0x00000232,0x0000021f,0x00000179,0x0000016e,0x00000231,0x00000230,0x0000022f, + 0x00000223,0x000001e1,0x0000016e,0x0000022e,0x0000022d,0x0000022c,0x0000022b,0x00000174, + 0x0000016e,0x0000022a,0x00000229,0x00000228,0x00000227,0x000001d3,0x0000016e,0x00000226, + 0x00000225,0x00000224,0x00000223,0x000001ce,0x0000009a,0x00000222,0x00000221,0x00000220, + 0x0000021f,0x000001c3,0x0000009a,0x0000016d,0x0000021e,0x0000021d,0x0000021c,0x000001b8, + 0x0000016e,0x00000168,0x0000021b,0x0000021a,0x00000219,0x000001a7,0x0000009a,0x00000218, + 0x00000217,0x00000216,0x00000215,0x00000160,0x0004002b,0x00000025,0x000002a3,0x00000001, + 0x0004002b,0x00000006,0x000002a7,0x3ee66666,0x0004002b,0x00000006,0x000002a9,0x400e38e4, + 0x00040020,0x000002af,0x00000006,0x00000006,0x0004003b,0x000002af,0x000002b0,0x00000006, + 0x0004003b,0x000002af,0x000002b3,0x00000006,0x0004003b,0x000002af,0x000002bb,0x00000006, + 0x0004003b,0x000002af,0x000002be,0x00000006,0x0004002b,0x00000025,0x000002c9,0x00000002, + 0x0004002b,0x00000025,0x000002ca,0x00000003,0x0004002b,0x00000025,0x000002cb,0x00000004, + 0x0004002b,0x00000025,0x000002cc,0x00000005,0x0004002b,0x00000031,0x00000320,0x00000000, + 0x0004002b,0x00000031,0x00000345,0x00000001,0x0004002b,0x00000031,0x0000036a,0x00000002, + 0x0004002b,0x00000006,0x00000371,0x3f000000,0x0004002b,0x00000031,0x00000377,0x00000007, + 0x0004001c,0x00000378,0x00000006,0x00000377,0x00040020,0x00000379,0x00000007,0x00000378, + 0x0004002b,0x00000006,0x0000040a,0x42800000,0x0004002b,0x00000031,0x00000416,0x00000003, + 0x0005001e,0x000004c1,0x0000000e,0x0000000e,0x00000006,0x00040020,0x000004c2,0x00000009, + 0x000004c1,0x0004003b,0x000004c2,0x000004c3,0x00000009,0x00040020,0x000004c4,0x00000009, + 0x00000006,0x0004002b,0x00000006,0x000004ce,0x3fa00000,0x0004002b,0x00000006,0x000004cf, + 0x3fe00000,0x0004002b,0x00000006,0x000004d7,0x3ecccccd,0x0004002b,0x00000006,0x000004db, + 0x3f99999a,0x0004002b,0x00000006,0x000004e0,0x3fcccccd,0x0004002b,0x00000006,0x000004e4, + 0x3fe66666,0x0004002b,0x00000006,0x000004ea,0x3dcccccd,0x0004002b,0x00000006,0x000004eb, + 0x3e0f5c29,0x0004002b,0x00000006,0x000004ef,0x3ea3d70a,0x0004002b,0x00000006,0x000004f7, + 0x3f19999a,0x00040017,0x000004fd,0x00000006,0x00000002,0x00040020,0x000004fe,0x00000007, + 0x000004fd,0x00040020,0x00000500,0x00000009,0x0000000e,0x00040020,0x00000509,0x00000001, + 0x000004fd,0x0004003b,0x00000509,0x0000050a,0x00000001,0x00040020,0x0000050b,0x00000001, + 0x00000006,0x00090019,0x00000552,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000, + 0x00000001,0x00000000,0x0003001b,0x00000553,0x00000552,0x00040020,0x00000554,0x00000000, + 0x00000553,0x0004003b,0x00000554,0x00000555,0x00000000,0x00040020,0x00000621,0x00000003, + 0x0000000e,0x0004003b,0x00000621,0x00000622,0x00000003,0x0004002b,0x00000006,0x0000062c, + 0x41200000,0x0004002b,0x00000006,0x0000062d,0x3f666666,0x0004002b,0x00000025,0x0000062e, + 0x00000040,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, + 0x0004003b,0x0000000d,0x000004c0,0x00000007,0x0004003b,0x0000000d,0x000004c8,0x00000007, + 0x0004003b,0x0000000d,0x000004cb,0x00000007,0x0004003b,0x0000000d,0x000004d1,0x00000007, + 0x0004003b,0x0000000d,0x000004d5,0x00000007,0x0004003b,0x0000000d,0x000004df,0x00000007, + 0x0004003b,0x0000000d,0x000004f3,0x00000007,0x0004003b,0x000004fe,0x000004ff,0x00000007, + 0x0004003b,0x000004fe,0x00000504,0x00000007,0x0004003b,0x0000000d,0x00000508,0x00000007, + 0x0004003b,0x0000000d,0x00000512,0x00000007,0x0004003b,0x0000000d,0x00000519,0x00000007, + 0x0004003b,0x0000000d,0x0000051c,0x00000007,0x0004003b,0x0000000d,0x0000051f,0x00000007, + 0x0004003b,0x0000000d,0x00000523,0x00000007,0x0004003b,0x00000026,0x00000527,0x00000007, + 0x0004003b,0x00000026,0x0000052b,0x00000007,0x0004003b,0x00000026,0x0000052f,0x00000007, + 0x0004003b,0x00000026,0x00000537,0x00000007,0x0004003b,0x000004fe,0x0000053f,0x00000007, + 0x0004003b,0x0000003b,0x0000054f,0x00000007,0x0004003b,0x00000008,0x00000559,0x00000007, + 0x0004003b,0x0000001b,0x00000561,0x00000007,0x0004003b,0x0000000d,0x00000562,0x00000007, + 0x0004003b,0x0000000d,0x00000565,0x00000007,0x0004003b,0x0000000d,0x00000568,0x00000007, + 0x0004003b,0x0000000d,0x0000056b,0x00000007,0x0004003b,0x0000000d,0x0000056e,0x00000007, + 0x0004003b,0x0000000d,0x00000571,0x00000007,0x0004003b,0x0000000d,0x00000574,0x00000007, + 0x0004003b,0x0000000d,0x00000577,0x00000007,0x0004003b,0x0000000d,0x0000057a,0x00000007, + 0x0004003b,0x0000001b,0x0000057e,0x00000007,0x0004003b,0x0000000d,0x0000057f,0x00000007, + 0x0004003b,0x0000000d,0x00000582,0x00000007,0x0004003b,0x0000000d,0x00000585,0x00000007, + 0x0004003b,0x0000000d,0x00000588,0x00000007,0x0004003b,0x0000000d,0x0000058b,0x00000007, + 0x0004003b,0x0000000d,0x0000058e,0x00000007,0x0004003b,0x0000000d,0x00000591,0x00000007, + 0x0004003b,0x0000000d,0x00000594,0x00000007,0x0004003b,0x0000000d,0x00000597,0x00000007, + 0x0004003b,0x0000001b,0x0000059b,0x00000007,0x0004003b,0x0000000d,0x0000059c,0x00000007, + 0x0004003b,0x0000000d,0x0000059f,0x00000007,0x0004003b,0x0000000d,0x000005a2,0x00000007, + 0x0004003b,0x0000000d,0x000005a5,0x00000007,0x0004003b,0x0000000d,0x000005a8,0x00000007, + 0x0004003b,0x0000000d,0x000005ab,0x00000007,0x0004003b,0x0000000d,0x000005ae,0x00000007, + 0x0004003b,0x0000000d,0x000005b1,0x00000007,0x0004003b,0x0000000d,0x000005b4,0x00000007, + 0x0004003b,0x0000001b,0x000005b8,0x00000007,0x0004003b,0x0000000d,0x000005b9,0x00000007, + 0x0004003b,0x0000000d,0x000005bc,0x00000007,0x0004003b,0x0000000d,0x000005bf,0x00000007, + 0x0004003b,0x0000000d,0x000005c2,0x00000007,0x0004003b,0x0000000d,0x000005c5,0x00000007, + 0x0004003b,0x0000000d,0x000005c8,0x00000007,0x0004003b,0x0000000d,0x000005cb,0x00000007, + 0x0004003b,0x0000000d,0x000005ce,0x00000007,0x0004003b,0x0000000d,0x000005d1,0x00000007, + 0x0004003b,0x0000001b,0x000005d5,0x00000007,0x0004003b,0x0000001b,0x000005d6,0x00000007, + 0x0004003b,0x0000001b,0x000005d8,0x00000007,0x0004003b,0x0000001b,0x000005da,0x00000007, + 0x0004003b,0x0000001b,0x000005dc,0x00000007,0x0004003b,0x0000000d,0x000005de,0x00000007, + 0x0004003b,0x0000000d,0x000005e0,0x00000007,0x0004003b,0x0000000d,0x000005e3,0x00000007, + 0x0004003b,0x0000000d,0x000005f0,0x00000007,0x0004003b,0x0000003b,0x000005f1,0x00000007, + 0x0004003b,0x00000026,0x000005f3,0x00000007,0x0004003b,0x00000026,0x000005f5,0x00000007, + 0x0004003b,0x0000003b,0x000005fa,0x00000007,0x0004003b,0x0000000d,0x000005fc,0x00000007, + 0x0004003b,0x0000000d,0x000005fe,0x00000007,0x0004003b,0x00000026,0x00000600,0x00000007, + 0x0004003b,0x00000026,0x00000602,0x00000007,0x0004003b,0x0000001b,0x00000604,0x00000007, + 0x0004003b,0x0000001b,0x00000609,0x00000007,0x0004003b,0x0000000d,0x0000060d,0x00000007, + 0x0004003b,0x00000008,0x0000060e,0x00000007,0x0004003b,0x0000000d,0x00000612,0x00000007, + 0x00050041,0x000004c4,0x000004c5,0x000004c3,0x000002c9,0x0004003d,0x00000006,0x000004c6, + 0x000004c5,0x0008000c,0x00000006,0x000004c7,0x00000001,0x0000002b,0x000004c6,0x0000009a, + 0x000000a8,0x0003003e,0x000004c0,0x000004c7,0x0004003d,0x00000006,0x000004c9,0x000004c0, + 0x00050083,0x00000006,0x000004ca,0x000004c9,0x00000371,0x0003003e,0x000004c8,0x000004ca, + 0x0004003d,0x00000006,0x000004cc,0x000004c8,0x000500be,0x0000009b,0x000004cd,0x000004cc, + 0x0000009a,0x000600a9,0x00000006,0x000004d0,0x000004cd,0x000004ce,0x000004cf,0x0003003e, + 0x000004cb,0x000004d0,0x0004003d,0x00000006,0x000004d2,0x000004c8,0x000500be,0x0000009b, + 0x000004d3,0x000004d2,0x0000009a,0x000600a9,0x00000006,0x000004d4,0x000004d3,0x000004ce, + 0x000000a8,0x0003003e,0x000004d1,0x000004d4,0x0004003d,0x00000006,0x000004d6,0x000004d1, + 0x0003003e,0x000004d5,0x000004d6,0x0004003d,0x00000006,0x000004d8,0x000004c8,0x0004003d, + 0x00000006,0x000004d9,0x000004d1,0x00050085,0x00000006,0x000004da,0x000004d8,0x000004d9, + 0x00050085,0x00000006,0x000004dc,0x000004da,0x000004db,0x00050081,0x00000006,0x000004dd, + 0x000004d7,0x000004dc,0x0007000c,0x00000006,0x000004de,0x00000001,0x00000028,0x0000009a, + 0x000004dd,0x0003003e,0x000002b3,0x000004de,0x0004003d,0x00000006,0x000004e1,0x000004c8, + 0x0004003d,0x00000006,0x000004e2,0x000004cb,0x00050085,0x00000006,0x000004e3,0x000004e1, + 0x000004e2,0x00050085,0x00000006,0x000004e5,0x000004e3,0x000004e4,0x00050081,0x00000006, + 0x000004e6,0x000004e0,0x000004e5,0x0003003e,0x000004df,0x000004e6,0x0004003d,0x00000006, + 0x000004e7,0x000004df,0x0004003d,0x00000006,0x000004e8,0x000002b3,0x00050083,0x00000006, + 0x000004e9,0x000004e7,0x000004e8,0x0003003e,0x000002b0,0x000004e9,0x0004003d,0x00000006, + 0x000004ec,0x000004c8,0x0004003d,0x00000006,0x000004ed,0x000004d5,0x00050085,0x00000006, + 0x000004ee,0x000004ec,0x000004ed,0x00050085,0x00000006,0x000004f0,0x000004ee,0x000004ef, + 0x00050081,0x00000006,0x000004f1,0x000004eb,0x000004f0,0x0007000c,0x00000006,0x000004f2, + 0x00000001,0x00000028,0x000004ea,0x000004f1,0x0003003e,0x000002be,0x000004f2,0x0004003d, + 0x00000006,0x000004f4,0x000004c8,0x0004003d,0x00000006,0x000004f5,0x000004d5,0x00050085, + 0x00000006,0x000004f6,0x000004f4,0x000004f5,0x00050085,0x00000006,0x000004f8,0x000004f6, + 0x000004f7,0x00050081,0x00000006,0x000004f9,0x00000371,0x000004f8,0x0003003e,0x000004f3, + 0x000004f9,0x0004003d,0x00000006,0x000004fa,0x000004f3,0x0004003d,0x00000006,0x000004fb, + 0x000002be,0x00050083,0x00000006,0x000004fc,0x000004fa,0x000004fb,0x0003003e,0x000002bb, + 0x000004fc,0x00050041,0x00000500,0x00000501,0x000004c3,0x000002a3,0x0004003d,0x0000000e, + 0x00000502,0x00000501,0x0007004f,0x000004fd,0x00000503,0x00000502,0x00000502,0x00000002, + 0x00000003,0x0003003e,0x000004ff,0x00000503,0x00050041,0x00000500,0x00000505,0x000004c3, + 0x000002a3,0x0004003d,0x0000000e,0x00000506,0x00000505,0x0007004f,0x000004fd,0x00000507, + 0x00000506,0x00000506,0x00000000,0x00000001,0x0003003e,0x00000504,0x00000507,0x00050041, + 0x0000050b,0x0000050c,0x0000050a,0x00000320,0x0004003d,0x00000006,0x0000050d,0x0000050c, + 0x00050041,0x0000000d,0x0000050e,0x000004ff,0x00000320,0x0004003d,0x00000006,0x0000050f, + 0x0000050e,0x00050085,0x00000006,0x00000510,0x0000050d,0x0000050f,0x00050083,0x00000006, + 0x00000511,0x00000510,0x00000371,0x0003003e,0x00000508,0x00000511,0x00050041,0x0000050b, + 0x00000513,0x0000050a,0x00000345,0x0004003d,0x00000006,0x00000514,0x00000513,0x00050041, + 0x0000000d,0x00000515,0x000004ff,0x00000345,0x0004003d,0x00000006,0x00000516,0x00000515, + 0x00050085,0x00000006,0x00000517,0x00000514,0x00000516,0x00050083,0x00000006,0x00000518, + 0x00000517,0x00000371,0x0003003e,0x00000512,0x00000518,0x0004003d,0x00000006,0x0000051a, + 0x00000508,0x0006000c,0x00000006,0x0000051b,0x00000001,0x00000008,0x0000051a,0x0003003e, + 0x00000519,0x0000051b,0x0004003d,0x00000006,0x0000051d,0x00000512,0x0006000c,0x00000006, + 0x0000051e,0x00000001,0x00000008,0x0000051d,0x0003003e,0x0000051c,0x0000051e,0x0004003d, + 0x00000006,0x00000520,0x00000508,0x0004003d,0x00000006,0x00000521,0x00000519,0x00050083, + 0x00000006,0x00000522,0x00000520,0x00000521,0x0003003e,0x0000051f,0x00000522,0x0004003d, + 0x00000006,0x00000524,0x00000512,0x0004003d,0x00000006,0x00000525,0x0000051c,0x00050083, + 0x00000006,0x00000526,0x00000524,0x00000525,0x0003003e,0x00000523,0x00000526,0x0004003d, + 0x00000006,0x00000528,0x0000051f,0x00050085,0x00000006,0x00000529,0x00000528,0x0000040a, + 0x0004006e,0x00000025,0x0000052a,0x00000529,0x0003003e,0x00000527,0x0000052a,0x0004003d, + 0x00000006,0x0000052c,0x00000523,0x00050085,0x00000006,0x0000052d,0x0000052c,0x0000040a, + 0x0004006e,0x00000025,0x0000052e,0x0000052d,0x0003003e,0x0000052b,0x0000052e,0x0003003e, + 0x0000052f,0x00000150,0x000200f9,0x00000530,0x000200f8,0x00000530,0x000400f6,0x00000532, + 0x00000533,0x00000000,0x000200f9,0x00000534,0x000200f8,0x00000534,0x0004003d,0x00000025, + 0x00000535,0x0000052f,0x000500b1,0x0000009b,0x00000536,0x00000535,0x0000015c,0x000400fa, + 0x00000536,0x00000531,0x00000532,0x000200f8,0x00000531,0x0003003e,0x00000537,0x00000150, + 0x000200f9,0x00000538,0x000200f8,0x00000538,0x000400f6,0x0000053a,0x0000053b,0x00000000, + 0x000200f9,0x0000053c,0x000200f8,0x0000053c,0x0004003d,0x00000025,0x0000053d,0x00000537, + 0x000500b1,0x0000009b,0x0000053e,0x0000053d,0x0000015c,0x000400fa,0x0000053e,0x00000539, + 0x0000053a,0x000200f8,0x00000539,0x0004003d,0x00000006,0x00000540,0x00000519,0x0004003d, + 0x00000025,0x00000541,0x00000537,0x0004006f,0x00000006,0x00000542,0x00000541,0x00050081, + 0x00000006,0x00000543,0x00000540,0x00000542,0x00050083,0x00000006,0x00000544,0x00000543, + 0x00000146,0x0004003d,0x00000006,0x00000545,0x0000051c,0x0004003d,0x00000025,0x00000546, + 0x0000052f,0x0004006f,0x00000006,0x00000547,0x00000546,0x00050081,0x00000006,0x00000548, + 0x00000545,0x00000547,0x00050083,0x00000006,0x00000549,0x00000548,0x00000146,0x00050050, + 0x000004fd,0x0000054a,0x00000544,0x00000549,0x00050050,0x000004fd,0x0000054b,0x00000371, + 0x00000371,0x00050081,0x000004fd,0x0000054c,0x0000054a,0x0000054b,0x0004003d,0x000004fd, + 0x0000054d,0x00000504,0x00050085,0x000004fd,0x0000054e,0x0000054c,0x0000054d,0x0003003e, + 0x0000053f,0x0000054e,0x0004003d,0x00000025,0x00000550,0x0000052f,0x0004003d,0x00000025, + 0x00000551,0x00000537,0x0004003d,0x00000553,0x00000556,0x00000555,0x0004003d,0x000004fd, + 0x00000557,0x0000053f,0x00070058,0x0000000e,0x00000558,0x00000556,0x00000557,0x00000002, + 0x0000009a,0x0008004f,0x00000007,0x0000055a,0x00000558,0x00000558,0x00000000,0x00000001, + 0x00000002,0x0003003e,0x00000559,0x0000055a,0x00050039,0x00000006,0x0000055b,0x0000000b, + 0x00000559,0x00060041,0x0000000d,0x0000055c,0x0000054f,0x00000550,0x00000551,0x0003003e, + 0x0000055c,0x0000055b,0x000200f9,0x0000053b,0x000200f8,0x0000053b,0x0004003d,0x00000025, + 0x0000055d,0x00000537,0x00050080,0x00000025,0x0000055e,0x0000055d,0x000002a3,0x0003003e, + 0x00000537,0x0000055e,0x000200f9,0x00000538,0x000200f8,0x0000053a,0x000200f9,0x00000533, + 0x000200f8,0x00000533,0x0004003d,0x00000025,0x0000055f,0x0000052f,0x00050080,0x00000025, + 0x00000560,0x0000055f,0x000002a3,0x0003003e,0x0000052f,0x00000560,0x000200f9,0x00000530, + 0x000200f8,0x00000532,0x00060041,0x0000000d,0x00000563,0x0000054f,0x000002a3,0x000002a3, + 0x0004003d,0x00000006,0x00000564,0x00000563,0x0003003e,0x00000562,0x00000564,0x00060041, + 0x0000000d,0x00000566,0x0000054f,0x000002a3,0x000002c9,0x0004003d,0x00000006,0x00000567, + 0x00000566,0x0003003e,0x00000565,0x00000567,0x00060041,0x0000000d,0x00000569,0x0000054f, + 0x000002a3,0x000002ca,0x0004003d,0x00000006,0x0000056a,0x00000569,0x0003003e,0x00000568, + 0x0000056a,0x00060041,0x0000000d,0x0000056c,0x0000054f,0x000002c9,0x000002a3,0x0004003d, + 0x00000006,0x0000056d,0x0000056c,0x0003003e,0x0000056b,0x0000056d,0x00060041,0x0000000d, + 0x0000056f,0x0000054f,0x000002c9,0x000002c9,0x0004003d,0x00000006,0x00000570,0x0000056f, + 0x0003003e,0x0000056e,0x00000570,0x00060041,0x0000000d,0x00000572,0x0000054f,0x000002c9, + 0x000002ca,0x0004003d,0x00000006,0x00000573,0x00000572,0x0003003e,0x00000571,0x00000573, + 0x00060041,0x0000000d,0x00000575,0x0000054f,0x000002ca,0x000002a3,0x0004003d,0x00000006, + 0x00000576,0x00000575,0x0003003e,0x00000574,0x00000576,0x00060041,0x0000000d,0x00000578, + 0x0000054f,0x000002ca,0x000002c9,0x0004003d,0x00000006,0x00000579,0x00000578,0x0003003e, + 0x00000577,0x00000579,0x00060041,0x0000000d,0x0000057b,0x0000054f,0x000002ca,0x000002ca, + 0x0004003d,0x00000006,0x0000057c,0x0000057b,0x0003003e,0x0000057a,0x0000057c,0x000d0039, + 0x0000000e,0x0000057d,0x00000019,0x00000562,0x00000565,0x00000568,0x0000056b,0x0000056e, + 0x00000571,0x00000574,0x00000577,0x0000057a,0x0003003e,0x00000561,0x0000057d,0x00060041, + 0x0000000d,0x00000580,0x0000054f,0x000002a3,0x000002c9,0x0004003d,0x00000006,0x00000581, + 0x00000580,0x0003003e,0x0000057f,0x00000581,0x00060041,0x0000000d,0x00000583,0x0000054f, + 0x000002a3,0x000002ca,0x0004003d,0x00000006,0x00000584,0x00000583,0x0003003e,0x00000582, + 0x00000584,0x00060041,0x0000000d,0x00000586,0x0000054f,0x000002a3,0x000002cb,0x0004003d, + 0x00000006,0x00000587,0x00000586,0x0003003e,0x00000585,0x00000587,0x00060041,0x0000000d, + 0x00000589,0x0000054f,0x000002c9,0x000002c9,0x0004003d,0x00000006,0x0000058a,0x00000589, + 0x0003003e,0x00000588,0x0000058a,0x00060041,0x0000000d,0x0000058c,0x0000054f,0x000002c9, + 0x000002ca,0x0004003d,0x00000006,0x0000058d,0x0000058c,0x0003003e,0x0000058b,0x0000058d, + 0x00060041,0x0000000d,0x0000058f,0x0000054f,0x000002c9,0x000002cb,0x0004003d,0x00000006, + 0x00000590,0x0000058f,0x0003003e,0x0000058e,0x00000590,0x00060041,0x0000000d,0x00000592, + 0x0000054f,0x000002ca,0x000002c9,0x0004003d,0x00000006,0x00000593,0x00000592,0x0003003e, + 0x00000591,0x00000593,0x00060041,0x0000000d,0x00000595,0x0000054f,0x000002ca,0x000002ca, + 0x0004003d,0x00000006,0x00000596,0x00000595,0x0003003e,0x00000594,0x00000596,0x00060041, + 0x0000000d,0x00000598,0x0000054f,0x000002ca,0x000002cb,0x0004003d,0x00000006,0x00000599, + 0x00000598,0x0003003e,0x00000597,0x00000599,0x000d0039,0x0000000e,0x0000059a,0x00000019, + 0x0000057f,0x00000582,0x00000585,0x00000588,0x0000058b,0x0000058e,0x00000591,0x00000594, + 0x00000597,0x0003003e,0x0000057e,0x0000059a,0x00060041,0x0000000d,0x0000059d,0x0000054f, + 0x000002c9,0x000002a3,0x0004003d,0x00000006,0x0000059e,0x0000059d,0x0003003e,0x0000059c, + 0x0000059e,0x00060041,0x0000000d,0x000005a0,0x0000054f,0x000002c9,0x000002c9,0x0004003d, + 0x00000006,0x000005a1,0x000005a0,0x0003003e,0x0000059f,0x000005a1,0x00060041,0x0000000d, + 0x000005a3,0x0000054f,0x000002c9,0x000002ca,0x0004003d,0x00000006,0x000005a4,0x000005a3, + 0x0003003e,0x000005a2,0x000005a4,0x00060041,0x0000000d,0x000005a6,0x0000054f,0x000002ca, + 0x000002a3,0x0004003d,0x00000006,0x000005a7,0x000005a6,0x0003003e,0x000005a5,0x000005a7, + 0x00060041,0x0000000d,0x000005a9,0x0000054f,0x000002ca,0x000002c9,0x0004003d,0x00000006, + 0x000005aa,0x000005a9,0x0003003e,0x000005a8,0x000005aa,0x00060041,0x0000000d,0x000005ac, + 0x0000054f,0x000002ca,0x000002ca,0x0004003d,0x00000006,0x000005ad,0x000005ac,0x0003003e, + 0x000005ab,0x000005ad,0x00060041,0x0000000d,0x000005af,0x0000054f,0x000002cb,0x000002a3, + 0x0004003d,0x00000006,0x000005b0,0x000005af,0x0003003e,0x000005ae,0x000005b0,0x00060041, + 0x0000000d,0x000005b2,0x0000054f,0x000002cb,0x000002c9,0x0004003d,0x00000006,0x000005b3, + 0x000005b2,0x0003003e,0x000005b1,0x000005b3,0x00060041,0x0000000d,0x000005b5,0x0000054f, + 0x000002cb,0x000002ca,0x0004003d,0x00000006,0x000005b6,0x000005b5,0x0003003e,0x000005b4, + 0x000005b6,0x000d0039,0x0000000e,0x000005b7,0x00000019,0x0000059c,0x0000059f,0x000005a2, + 0x000005a5,0x000005a8,0x000005ab,0x000005ae,0x000005b1,0x000005b4,0x0003003e,0x0000059b, + 0x000005b7,0x00060041,0x0000000d,0x000005ba,0x0000054f,0x000002c9,0x000002c9,0x0004003d, + 0x00000006,0x000005bb,0x000005ba,0x0003003e,0x000005b9,0x000005bb,0x00060041,0x0000000d, + 0x000005bd,0x0000054f,0x000002c9,0x000002ca,0x0004003d,0x00000006,0x000005be,0x000005bd, + 0x0003003e,0x000005bc,0x000005be,0x00060041,0x0000000d,0x000005c0,0x0000054f,0x000002c9, + 0x000002cb,0x0004003d,0x00000006,0x000005c1,0x000005c0,0x0003003e,0x000005bf,0x000005c1, + 0x00060041,0x0000000d,0x000005c3,0x0000054f,0x000002ca,0x000002c9,0x0004003d,0x00000006, + 0x000005c4,0x000005c3,0x0003003e,0x000005c2,0x000005c4,0x00060041,0x0000000d,0x000005c6, + 0x0000054f,0x000002ca,0x000002ca,0x0004003d,0x00000006,0x000005c7,0x000005c6,0x0003003e, + 0x000005c5,0x000005c7,0x00060041,0x0000000d,0x000005c9,0x0000054f,0x000002ca,0x000002cb, + 0x0004003d,0x00000006,0x000005ca,0x000005c9,0x0003003e,0x000005c8,0x000005ca,0x00060041, + 0x0000000d,0x000005cc,0x0000054f,0x000002cb,0x000002c9,0x0004003d,0x00000006,0x000005cd, + 0x000005cc,0x0003003e,0x000005cb,0x000005cd,0x00060041,0x0000000d,0x000005cf,0x0000054f, + 0x000002cb,0x000002ca,0x0004003d,0x00000006,0x000005d0,0x000005cf,0x0003003e,0x000005ce, + 0x000005d0,0x00060041,0x0000000d,0x000005d2,0x0000054f,0x000002cb,0x000002cb,0x0004003d, + 0x00000006,0x000005d3,0x000005d2,0x0003003e,0x000005d1,0x000005d3,0x000d0039,0x0000000e, + 0x000005d4,0x00000019,0x000005b9,0x000005bc,0x000005bf,0x000005c2,0x000005c5,0x000005c8, + 0x000005cb,0x000005ce,0x000005d1,0x0003003e,0x000005b8,0x000005d4,0x0004003d,0x0000000e, + 0x000005d7,0x00000561,0x0003003e,0x000005d6,0x000005d7,0x0004003d,0x0000000e,0x000005d9, + 0x0000057e,0x0003003e,0x000005d8,0x000005d9,0x0004003d,0x0000000e,0x000005db,0x0000059b, + 0x0003003e,0x000005da,0x000005db,0x0004003d,0x0000000e,0x000005dd,0x000005b8,0x0003003e, + 0x000005dc,0x000005dd,0x0004003d,0x00000006,0x000005df,0x0000051f,0x0003003e,0x000005de, + 0x000005df,0x0004003d,0x00000006,0x000005e1,0x00000523,0x0003003e,0x000005e0,0x000005e1, + 0x000a0039,0x0000000e,0x000005e2,0x00000023,0x000005d6,0x000005d8,0x000005da,0x000005dc, + 0x000005de,0x000005e0,0x0003003e,0x000005d5,0x000005e2,0x00050041,0x0000000d,0x000005e4, + 0x000005d5,0x00000320,0x0004003d,0x00000006,0x000005e5,0x000005e4,0x00050083,0x00000006, + 0x000005e6,0x000000a8,0x000005e5,0x00050041,0x0000000d,0x000005e7,0x000005d5,0x00000345, + 0x0004003d,0x00000006,0x000005e8,0x000005e7,0x00050083,0x00000006,0x000005e9,0x000005e6, + 0x000005e8,0x00050041,0x0000000d,0x000005ea,0x000005d5,0x0000036a,0x0004003d,0x00000006, + 0x000005eb,0x000005ea,0x00050083,0x00000006,0x000005ec,0x000005e9,0x000005eb,0x00050041, + 0x0000000d,0x000005ed,0x000005d5,0x00000416,0x0004003d,0x00000006,0x000005ee,0x000005ed, + 0x00050083,0x00000006,0x000005ef,0x000005ec,0x000005ee,0x0003003e,0x000005e3,0x000005ef, + 0x0004003d,0x0000003a,0x000005f2,0x0000054f,0x0003003e,0x000005f1,0x000005f2,0x0004003d, + 0x00000025,0x000005f4,0x00000527,0x0003003e,0x000005f3,0x000005f4,0x0004003d,0x00000025, + 0x000005f6,0x0000052b,0x0003003e,0x000005f5,0x000005f6,0x00070039,0x00000006,0x000005f7, + 0x00000040,0x000005f1,0x000005f3,0x000005f5,0x0004003d,0x00000006,0x000005f8,0x000005e3, + 0x00050085,0x00000006,0x000005f9,0x000005f7,0x000005f8,0x0003003e,0x000005f0,0x000005f9, + 0x0004003d,0x0000003a,0x000005fb,0x0000054f,0x0003003e,0x000005fa,0x000005fb,0x0004003d, + 0x00000006,0x000005fd,0x0000051f,0x0003003e,0x000005fc,0x000005fd,0x0004003d,0x00000006, + 0x000005ff,0x00000523,0x0003003e,0x000005fe,0x000005ff,0x0004003d,0x00000025,0x00000601, + 0x00000527,0x0003003e,0x00000600,0x00000601,0x0004003d,0x00000025,0x00000603,0x0000052b, + 0x0003003e,0x00000602,0x00000603,0x0004003d,0x0000000e,0x00000605,0x000005d5,0x0003003e, + 0x00000604,0x00000605,0x000a0039,0x00000006,0x00000606,0x00000049,0x000005fa,0x000005fc, + 0x000005fe,0x00000600,0x00000602,0x00000604,0x0004003d,0x00000006,0x00000607,0x000005f0, + 0x00050081,0x00000006,0x00000608,0x00000607,0x00000606,0x0003003e,0x000005f0,0x00000608, + 0x0004003d,0x00000553,0x0000060a,0x00000555,0x0004003d,0x000004fd,0x0000060b,0x0000050a, + 0x00050057,0x0000000e,0x0000060c,0x0000060a,0x0000060b,0x0003003e,0x00000609,0x0000060c, + 0x0004003d,0x0000000e,0x0000060f,0x00000609,0x0008004f,0x00000007,0x00000610,0x0000060f, + 0x0000060f,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000060e,0x00000610,0x00050039, + 0x00000006,0x00000611,0x0000000b,0x0000060e,0x0003003e,0x0000060d,0x00000611,0x0004003d, + 0x00000006,0x00000613,0x000005f0,0x0004003d,0x00000006,0x00000614,0x0000060d,0x00050083, + 0x00000006,0x00000615,0x00000613,0x00000614,0x0003003e,0x00000612,0x00000615,0x0004003d, + 0x00000006,0x00000616,0x00000612,0x00060050,0x00000007,0x00000617,0x00000616,0x00000616, + 0x00000616,0x0004003d,0x0000000e,0x00000618,0x00000609,0x0008004f,0x00000007,0x00000619, + 0x00000618,0x00000618,0x00000000,0x00000001,0x00000002,0x00050081,0x00000007,0x0000061a, + 0x00000619,0x00000617,0x00050041,0x0000000d,0x0000061b,0x00000609,0x00000320,0x00050051, + 0x00000006,0x0000061c,0x0000061a,0x00000000,0x0003003e,0x0000061b,0x0000061c,0x00050041, + 0x0000000d,0x0000061d,0x00000609,0x00000345,0x00050051,0x00000006,0x0000061e,0x0000061a, + 0x00000001,0x0003003e,0x0000061d,0x0000061e,0x00050041,0x0000000d,0x0000061f,0x00000609, + 0x0000036a,0x00050051,0x00000006,0x00000620,0x0000061a,0x00000002,0x0003003e,0x0000061f, + 0x00000620,0x0004003d,0x0000000e,0x00000623,0x00000609,0x0008004f,0x00000007,0x00000624, + 0x00000623,0x00000623,0x00000000,0x00000001,0x00000002,0x00060050,0x00000007,0x00000625, + 0x0000009a,0x0000009a,0x0000009a,0x00060050,0x00000007,0x00000626,0x000000a8,0x000000a8, + 0x000000a8,0x0008000c,0x00000007,0x00000627,0x00000001,0x0000002b,0x00000624,0x00000625, + 0x00000626,0x00050051,0x00000006,0x00000628,0x00000627,0x00000000,0x00050051,0x00000006, + 0x00000629,0x00000627,0x00000001,0x00050051,0x00000006,0x0000062a,0x00000627,0x00000002, + 0x00070050,0x0000000e,0x0000062b,0x00000628,0x00000629,0x0000062a,0x000000a8,0x0003003e, + 0x00000622,0x0000062b,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000b,0x00000000, + 0x00000009,0x00030037,0x00000008,0x0000000a,0x000200f8,0x0000000c,0x0004003d,0x00000007, + 0x0000004b,0x0000000a,0x00050094,0x00000006,0x00000050,0x0000004b,0x0000004f,0x000200fe, + 0x00000050,0x00010038,0x00050036,0x0000000e,0x00000019,0x00000000,0x0000000f,0x00030037, + 0x0000000d,0x00000010,0x00030037,0x0000000d,0x00000011,0x00030037,0x0000000d,0x00000012, + 0x00030037,0x0000000d,0x00000013,0x00030037,0x0000000d,0x00000014,0x00030037,0x0000000d, + 0x00000015,0x00030037,0x0000000d,0x00000016,0x00030037,0x0000000d,0x00000017,0x00030037, + 0x0000000d,0x00000018,0x000200f8,0x0000001a,0x0004003b,0x0000000d,0x00000053,0x00000007, + 0x0004003b,0x0000000d,0x00000060,0x00000007,0x0004003b,0x0000000d,0x0000006d,0x00000007, + 0x0004003b,0x0000000d,0x0000007a,0x00000007,0x0004003b,0x0000000d,0x00000087,0x00000007, + 0x0004003b,0x0000000d,0x0000008b,0x00000007,0x0004003b,0x0000000d,0x0000008f,0x00000007, + 0x0004003b,0x0000000d,0x00000093,0x00000007,0x0004003b,0x0000000d,0x000000a1,0x00000007, + 0x0004003b,0x0000000d,0x000000a7,0x00000007,0x0004003b,0x000000ab,0x000000ac,0x00000007, + 0x0004003b,0x000000ab,0x000000ba,0x00000007,0x0004003b,0x000000ab,0x000000c6,0x00000007, + 0x0004003b,0x000000ab,0x000000ca,0x00000007,0x0004003b,0x0000000d,0x000000ce,0x00000007, + 0x0004003b,0x0000000d,0x000000d4,0x00000007,0x0004003b,0x0000000d,0x000000da,0x00000007, + 0x0004003b,0x0000000d,0x000000e0,0x00000007,0x0004003b,0x0000000d,0x000000e7,0x00000007, + 0x0004003b,0x0000000d,0x000000ed,0x00000007,0x0004003d,0x00000006,0x00000054,0x00000010, + 0x0004003d,0x00000006,0x00000055,0x00000011,0x00050081,0x00000006,0x00000056,0x00000054, + 0x00000055,0x0004003d,0x00000006,0x00000057,0x00000012,0x00050081,0x00000006,0x00000058, + 0x00000056,0x00000057,0x0004003d,0x00000006,0x00000059,0x00000016,0x00050083,0x00000006, + 0x0000005a,0x00000058,0x00000059,0x0004003d,0x00000006,0x0000005b,0x00000017,0x00050083, + 0x00000006,0x0000005c,0x0000005a,0x0000005b,0x0004003d,0x00000006,0x0000005d,0x00000018, + 0x00050083,0x00000006,0x0000005e,0x0000005c,0x0000005d,0x0006000c,0x00000006,0x0000005f, + 0x00000001,0x00000004,0x0000005e,0x0003003e,0x00000053,0x0000005f,0x0004003d,0x00000006, + 0x00000061,0x00000013,0x0004003d,0x00000006,0x00000062,0x00000010,0x00050081,0x00000006, + 0x00000063,0x00000061,0x00000062,0x0004003d,0x00000006,0x00000064,0x00000011,0x00050081, + 0x00000006,0x00000065,0x00000063,0x00000064,0x0004003d,0x00000006,0x00000066,0x00000017, + 0x00050083,0x00000006,0x00000067,0x00000065,0x00000066,0x0004003d,0x00000006,0x00000068, + 0x00000018,0x00050083,0x00000006,0x00000069,0x00000067,0x00000068,0x0004003d,0x00000006, + 0x0000006a,0x00000015,0x00050083,0x00000006,0x0000006b,0x00000069,0x0000006a,0x0006000c, + 0x00000006,0x0000006c,0x00000001,0x00000004,0x0000006b,0x0003003e,0x00000060,0x0000006c, + 0x0004003d,0x00000006,0x0000006e,0x00000010,0x0004003d,0x00000006,0x0000006f,0x00000013, + 0x00050081,0x00000006,0x00000070,0x0000006e,0x0000006f,0x0004003d,0x00000006,0x00000071, + 0x00000016,0x00050081,0x00000006,0x00000072,0x00000070,0x00000071,0x0004003d,0x00000006, + 0x00000073,0x00000012,0x00050083,0x00000006,0x00000074,0x00000072,0x00000073,0x0004003d, + 0x00000006,0x00000075,0x00000015,0x00050083,0x00000006,0x00000076,0x00000074,0x00000075, + 0x0004003d,0x00000006,0x00000077,0x00000018,0x00050083,0x00000006,0x00000078,0x00000076, + 0x00000077,0x0006000c,0x00000006,0x00000079,0x00000001,0x00000004,0x00000078,0x0003003e, + 0x0000006d,0x00000079,0x0004003d,0x00000006,0x0000007b,0x00000013,0x0004003d,0x00000006, + 0x0000007c,0x00000016,0x00050081,0x00000006,0x0000007d,0x0000007b,0x0000007c,0x0004003d, + 0x00000006,0x0000007e,0x00000017,0x00050081,0x00000006,0x0000007f,0x0000007d,0x0000007e, + 0x0004003d,0x00000006,0x00000080,0x00000011,0x00050083,0x00000006,0x00000081,0x0000007f, + 0x00000080,0x0004003d,0x00000006,0x00000082,0x00000012,0x00050083,0x00000006,0x00000083, + 0x00000081,0x00000082,0x0004003d,0x00000006,0x00000084,0x00000015,0x00050083,0x00000006, + 0x00000085,0x00000083,0x00000084,0x0006000c,0x00000006,0x00000086,0x00000001,0x00000004, + 0x00000085,0x0003003e,0x0000007a,0x00000086,0x0004003d,0x00000006,0x00000088,0x00000053, + 0x0004003d,0x00000006,0x00000089,0x0000006d,0x0007000c,0x00000006,0x0000008a,0x00000001, + 0x00000028,0x00000088,0x00000089,0x0003003e,0x00000087,0x0000008a,0x0004003d,0x00000006, + 0x0000008c,0x00000053,0x0004003d,0x00000006,0x0000008d,0x0000006d,0x0007000c,0x00000006, + 0x0000008e,0x00000001,0x00000025,0x0000008c,0x0000008d,0x0003003e,0x0000008b,0x0000008e, + 0x0004003d,0x00000006,0x00000090,0x00000060,0x0004003d,0x00000006,0x00000091,0x0000007a, + 0x0007000c,0x00000006,0x00000092,0x00000001,0x00000028,0x00000090,0x00000091,0x0003003e, + 0x0000008f,0x00000092,0x0004003d,0x00000006,0x00000094,0x00000060,0x0004003d,0x00000006, + 0x00000095,0x0000007a,0x0007000c,0x00000006,0x00000096,0x00000001,0x00000025,0x00000094, + 0x00000095,0x0003003e,0x00000093,0x00000096,0x0004003d,0x00000006,0x00000097,0x00000087, + 0x0004003d,0x00000006,0x00000098,0x0000008f,0x00050081,0x00000006,0x00000099,0x00000097, + 0x00000098,0x000500b4,0x0000009b,0x0000009c,0x00000099,0x0000009a,0x000300f7,0x0000009e, + 0x00000000,0x000400fa,0x0000009c,0x0000009d,0x0000009e,0x000200f8,0x0000009d,0x000200fe, + 0x0000009f,0x000200f8,0x0000009e,0x0004003d,0x00000006,0x000000a2,0x00000087,0x0004003d, + 0x00000006,0x000000a3,0x00000087,0x0004003d,0x00000006,0x000000a4,0x0000008f,0x00050081, + 0x00000006,0x000000a5,0x000000a3,0x000000a4,0x00050088,0x00000006,0x000000a6,0x000000a2, + 0x000000a5,0x0003003e,0x000000a1,0x000000a6,0x0004003d,0x00000006,0x000000a9,0x000000a1, + 0x00050083,0x00000006,0x000000aa,0x000000a8,0x000000a9,0x0003003e,0x000000a7,0x000000aa, + 0x0004003d,0x00000006,0x000000ad,0x00000087,0x0004003d,0x00000006,0x000000ae,0x0000008b, + 0x00050085,0x00000006,0x000000b0,0x000000ae,0x000000af,0x000500ba,0x0000009b,0x000000b1, + 0x000000ad,0x000000b0,0x0004003d,0x00000006,0x000000b2,0x00000087,0x000500ba,0x0000009b, + 0x000000b4,0x000000b2,0x000000b3,0x000500a7,0x0000009b,0x000000b5,0x000000b1,0x000000b4, + 0x0004003d,0x00000006,0x000000b6,0x00000087,0x0004003d,0x00000006,0x000000b7,0x00000093, + 0x000500ba,0x0000009b,0x000000b8,0x000000b6,0x000000b7,0x000500a7,0x0000009b,0x000000b9, + 0x000000b5,0x000000b8,0x0003003e,0x000000ac,0x000000b9,0x0004003d,0x00000006,0x000000bb, + 0x0000008f,0x0004003d,0x00000006,0x000000bc,0x00000093,0x00050085,0x00000006,0x000000bd, + 0x000000bc,0x000000af,0x000500ba,0x0000009b,0x000000be,0x000000bb,0x000000bd,0x0004003d, + 0x00000006,0x000000bf,0x0000008f,0x000500ba,0x0000009b,0x000000c0,0x000000bf,0x000000b3, + 0x000500a7,0x0000009b,0x000000c1,0x000000be,0x000000c0,0x0004003d,0x00000006,0x000000c2, + 0x0000008f,0x0004003d,0x00000006,0x000000c3,0x0000008b,0x000500ba,0x0000009b,0x000000c4, + 0x000000c2,0x000000c3,0x000500a7,0x0000009b,0x000000c5,0x000000c1,0x000000c4,0x0003003e, + 0x000000ba,0x000000c5,0x0004003d,0x00000006,0x000000c7,0x00000087,0x0004003d,0x00000006, + 0x000000c8,0x00000053,0x000500b4,0x0000009b,0x000000c9,0x000000c7,0x000000c8,0x0003003e, + 0x000000c6,0x000000c9,0x0004003d,0x00000006,0x000000cb,0x0000008f,0x0004003d,0x00000006, + 0x000000cc,0x00000060,0x000500b4,0x0000009b,0x000000cd,0x000000cb,0x000000cc,0x0003003e, + 0x000000ca,0x000000cd,0x0004003d,0x0000009b,0x000000cf,0x000000ac,0x0004003d,0x0000009b, + 0x000000d0,0x000000ba,0x000500a7,0x0000009b,0x000000d1,0x000000cf,0x000000d0,0x0004003d, + 0x00000006,0x000000d2,0x000000a1,0x000600a9,0x00000006,0x000000d3,0x000000d1,0x000000d2, + 0x000000a8,0x0003003e,0x000000ce,0x000000d3,0x0004003d,0x0000009b,0x000000d5,0x000000ac, + 0x0004003d,0x0000009b,0x000000d6,0x000000ba,0x000500a7,0x0000009b,0x000000d7,0x000000d5, + 0x000000d6,0x0004003d,0x00000006,0x000000d8,0x000000a7,0x000600a9,0x00000006,0x000000d9, + 0x000000d7,0x000000d8,0x000000a8,0x0003003e,0x000000d4,0x000000d9,0x0004003d,0x0000009b, + 0x000000db,0x000000ac,0x0004003d,0x0000009b,0x000000dc,0x000000c6,0x000500a7,0x0000009b, + 0x000000dd,0x000000db,0x000000dc,0x0004003d,0x00000006,0x000000de,0x000000ce,0x000600a9, + 0x00000006,0x000000df,0x000000dd,0x000000de,0x0000009a,0x0003003e,0x000000da,0x000000df, + 0x0004003d,0x0000009b,0x000000e1,0x000000ac,0x0004003d,0x0000009b,0x000000e2,0x000000c6, + 0x000400a8,0x0000009b,0x000000e3,0x000000e2,0x000500a7,0x0000009b,0x000000e4,0x000000e1, + 0x000000e3,0x0004003d,0x00000006,0x000000e5,0x000000ce,0x000600a9,0x00000006,0x000000e6, + 0x000000e4,0x000000e5,0x0000009a,0x0003003e,0x000000e0,0x000000e6,0x0004003d,0x0000009b, + 0x000000e8,0x000000ba,0x0004003d,0x0000009b,0x000000e9,0x000000ca,0x000500a7,0x0000009b, + 0x000000ea,0x000000e8,0x000000e9,0x0004003d,0x00000006,0x000000eb,0x000000d4,0x000600a9, + 0x00000006,0x000000ec,0x000000ea,0x000000eb,0x0000009a,0x0003003e,0x000000e7,0x000000ec, + 0x0004003d,0x0000009b,0x000000ee,0x000000ba,0x0004003d,0x0000009b,0x000000ef,0x000000ca, + 0x000400a8,0x0000009b,0x000000f0,0x000000ef,0x000500a7,0x0000009b,0x000000f1,0x000000ee, + 0x000000f0,0x0004003d,0x00000006,0x000000f2,0x000000d4,0x000600a9,0x00000006,0x000000f3, + 0x000000f1,0x000000f2,0x0000009a,0x0003003e,0x000000ed,0x000000f3,0x0004003d,0x00000006, + 0x000000f4,0x000000da,0x0004003d,0x00000006,0x000000f5,0x000000e0,0x0004003d,0x00000006, + 0x000000f6,0x000000e7,0x0004003d,0x00000006,0x000000f7,0x000000ed,0x00070050,0x0000000e, + 0x000000f8,0x000000f4,0x000000f5,0x000000f6,0x000000f7,0x000200fe,0x000000f8,0x00010038, + 0x00050036,0x0000000e,0x00000023,0x00000000,0x0000001c,0x00030037,0x0000001b,0x0000001d, + 0x00030037,0x0000001b,0x0000001e,0x00030037,0x0000001b,0x0000001f,0x00030037,0x0000001b, + 0x00000020,0x00030037,0x0000000d,0x00000021,0x00030037,0x0000000d,0x00000022,0x000200f8, + 0x00000024,0x0004003b,0x0000001b,0x000000fb,0x00000007,0x0004003b,0x0000001b,0x00000101, + 0x00000007,0x0004003d,0x0000000e,0x000000fc,0x0000001d,0x0004003d,0x0000000e,0x000000fd, + 0x0000001e,0x0004003d,0x00000006,0x000000fe,0x00000021,0x00070050,0x0000000e,0x000000ff, + 0x000000fe,0x000000fe,0x000000fe,0x000000fe,0x0008000c,0x0000000e,0x00000100,0x00000001, + 0x0000002e,0x000000fc,0x000000fd,0x000000ff,0x0003003e,0x000000fb,0x00000100,0x0004003d, + 0x0000000e,0x00000102,0x0000001f,0x0004003d,0x0000000e,0x00000103,0x00000020,0x0004003d, + 0x00000006,0x00000104,0x00000021,0x00070050,0x0000000e,0x00000105,0x00000104,0x00000104, + 0x00000104,0x00000104,0x0008000c,0x0000000e,0x00000106,0x00000001,0x0000002e,0x00000102, + 0x00000103,0x00000105,0x0003003e,0x00000101,0x00000106,0x0004003d,0x0000000e,0x00000107, + 0x000000fb,0x0004003d,0x0000000e,0x00000108,0x00000101,0x0004003d,0x00000006,0x00000109, + 0x00000022,0x00070050,0x0000000e,0x0000010a,0x00000109,0x00000109,0x00000109,0x00000109, + 0x0008000c,0x0000000e,0x0000010b,0x00000001,0x0000002e,0x00000107,0x00000108,0x0000010a, + 0x000200fe,0x0000010b,0x00010038,0x00050036,0x00000006,0x0000002f,0x00000000,0x00000027, + 0x00030037,0x0000000d,0x00000028,0x00030037,0x0000000d,0x00000029,0x00030037,0x0000000d, + 0x0000002a,0x00030037,0x0000000d,0x0000002b,0x00030037,0x0000000d,0x0000002c,0x00030037, + 0x0000000d,0x0000002d,0x00030037,0x00000026,0x0000002e,0x000200f8,0x00000030,0x0004003b, + 0x000000ab,0x0000010e,0x00000007,0x0004003b,0x0000000d,0x00000112,0x00000007,0x0004003b, + 0x0000000d,0x00000117,0x00000007,0x0004003b,0x0000000d,0x0000011d,0x00000007,0x0004003b, + 0x0000000d,0x00000127,0x00000007,0x0004003b,0x0000000d,0x0000012d,0x00000007,0x0004003b, + 0x0000000d,0x00000133,0x00000007,0x0004003b,0x0000000d,0x00000137,0x00000007,0x0004003b, + 0x0000000d,0x0000013b,0x00000007,0x0004003d,0x00000025,0x0000010f,0x0000002e,0x000500b3, + 0x0000009b,0x00000111,0x0000010f,0x00000110,0x0003003e,0x0000010e,0x00000111,0x0004003d, + 0x0000009b,0x00000113,0x0000010e,0x0004003d,0x00000006,0x00000114,0x00000028,0x0004003d, + 0x00000006,0x00000115,0x0000002b,0x000600a9,0x00000006,0x00000116,0x00000113,0x00000114, + 0x00000115,0x0003003e,0x00000112,0x00000116,0x0004003d,0x00000006,0x00000118,0x00000029, + 0x0004003d,0x00000006,0x00000119,0x0000002a,0x0007000c,0x00000006,0x0000011a,0x00000001, + 0x00000025,0x00000118,0x00000119,0x0004003d,0x00000006,0x0000011b,0x00000112,0x0007000c, + 0x00000006,0x0000011c,0x00000001,0x00000025,0x0000011a,0x0000011b,0x0003003e,0x00000117, + 0x0000011c,0x0004003d,0x00000006,0x0000011e,0x00000029,0x0004003d,0x00000006,0x0000011f, + 0x0000002a,0x0007000c,0x00000006,0x00000120,0x00000001,0x00000028,0x0000011e,0x0000011f, + 0x0004003d,0x00000006,0x00000121,0x00000112,0x0007000c,0x00000006,0x00000122,0x00000001, + 0x00000028,0x00000120,0x00000121,0x0003003e,0x0000011d,0x00000122,0x0004003d,0x0000009b, + 0x00000123,0x0000010e,0x0004003d,0x00000006,0x00000124,0x0000002a,0x0004003d,0x00000006, + 0x00000125,0x0000002d,0x000600a9,0x00000006,0x00000126,0x00000123,0x00000124,0x00000125, + 0x0003003e,0x00000112,0x00000126,0x0004003d,0x00000006,0x00000128,0x0000002b,0x0004003d, + 0x00000006,0x00000129,0x0000002c,0x0007000c,0x00000006,0x0000012a,0x00000001,0x00000025, + 0x00000128,0x00000129,0x0004003d,0x00000006,0x0000012b,0x00000112,0x0007000c,0x00000006, + 0x0000012c,0x00000001,0x00000025,0x0000012a,0x0000012b,0x0003003e,0x00000127,0x0000012c, + 0x0004003d,0x00000006,0x0000012e,0x0000002b,0x0004003d,0x00000006,0x0000012f,0x0000002c, + 0x0007000c,0x00000006,0x00000130,0x00000001,0x00000028,0x0000012e,0x0000012f,0x0004003d, + 0x00000006,0x00000131,0x00000112,0x0007000c,0x00000006,0x00000132,0x00000001,0x00000028, + 0x00000130,0x00000131,0x0003003e,0x0000012d,0x00000132,0x0004003d,0x00000006,0x00000134, + 0x0000011d,0x0004003d,0x00000006,0x00000135,0x00000117,0x00050083,0x00000006,0x00000136, + 0x00000134,0x00000135,0x0003003e,0x00000133,0x00000136,0x0004003d,0x00000006,0x00000138, + 0x0000012d,0x0004003d,0x00000006,0x00000139,0x00000127,0x00050083,0x00000006,0x0000013a, + 0x00000138,0x00000139,0x0003003e,0x00000137,0x0000013a,0x0004003d,0x00000006,0x0000013c, + 0x00000133,0x0004003d,0x00000006,0x0000013d,0x00000137,0x0007000c,0x00000006,0x0000013e, + 0x00000001,0x00000028,0x0000013c,0x0000013d,0x0004003d,0x00000006,0x0000013f,0x00000133, + 0x0004003d,0x00000006,0x00000140,0x00000137,0x0007000c,0x00000006,0x00000141,0x00000001, + 0x00000025,0x0000013f,0x00000140,0x00050081,0x00000006,0x00000143,0x00000141,0x00000142, + 0x00050088,0x00000006,0x00000144,0x0000013e,0x00000143,0x0003003e,0x0000013b,0x00000144, + 0x0004003d,0x00000006,0x00000145,0x0000013b,0x00050083,0x00000006,0x00000147,0x00000145, + 0x00000146,0x00050085,0x00000006,0x00000149,0x00000147,0x00000148,0x0008000c,0x00000006, + 0x0000014a,0x00000001,0x0000002b,0x00000149,0x0000009a,0x000000a8,0x00050083,0x00000006, + 0x0000014b,0x000000a8,0x0000014a,0x00050085,0x00000006,0x0000014c,0x0000014b,0x000000a8, + 0x000200fe,0x0000014c,0x00010038,0x00050036,0x00000006,0x00000038,0x00000000,0x00000035, + 0x00030037,0x00000034,0x00000036,0x00030037,0x00000026,0x00000037,0x000200f8,0x00000039, + 0x0004003b,0x0000000d,0x00000153,0x00000007,0x0004003b,0x0000000d,0x00000154,0x00000007, + 0x0004003b,0x00000026,0x00000155,0x00000007,0x0004003b,0x00000209,0x0000020a,0x00000007, + 0x0004003b,0x00000209,0x00000299,0x00000007,0x0004003b,0x0000000d,0x000002a5,0x00000007, + 0x0004003b,0x0000000d,0x000002ad,0x00000007,0x0004003b,0x0000000d,0x000002b9,0x00000007, + 0x0004003b,0x0000000d,0x000002cd,0x00000007,0x0004003b,0x0000000d,0x000002d0,0x00000007, + 0x0004003b,0x0000000d,0x000002d3,0x00000007,0x0004003b,0x0000000d,0x000002d6,0x00000007, + 0x0004003b,0x0000000d,0x000002d9,0x00000007,0x0004003b,0x0000000d,0x000002dc,0x00000007, + 0x0004003b,0x00000026,0x000002df,0x00000007,0x0004003d,0x00000025,0x0000014f,0x00000037, + 0x0008000c,0x00000025,0x00000152,0x00000001,0x0000002d,0x0000014f,0x00000150,0x00000151, + 0x0003003e,0x00000037,0x00000152,0x0003003e,0x00000153,0x0000009a,0x0003003e,0x00000154, + 0x0000009a,0x0003003e,0x00000155,0x00000150,0x000200f9,0x00000156,0x000200f8,0x00000156, + 0x000400f6,0x00000158,0x00000159,0x00000000,0x000200f9,0x0000015a,0x000200f8,0x0000015a, + 0x0004003d,0x00000025,0x0000015b,0x00000155,0x000500b1,0x0000009b,0x0000015d,0x0000015b, + 0x0000015c,0x000400fa,0x0000015d,0x00000157,0x00000158,0x000200f8,0x00000157,0x0004003d, + 0x00000025,0x00000205,0x00000037,0x00050084,0x00000025,0x00000206,0x00000205,0x0000015c, + 0x0004003d,0x00000025,0x00000207,0x00000155,0x00050080,0x00000025,0x00000208,0x00000206, + 0x00000207,0x0003003e,0x0000020a,0x00000204,0x00050041,0x0000000d,0x0000020b,0x0000020a, + 0x00000208,0x0004003d,0x00000006,0x0000020c,0x0000020b,0x0004003d,0x00000025,0x0000020d, + 0x00000155,0x00050041,0x0000000d,0x0000020e,0x00000036,0x0000020d,0x0004003d,0x00000006, + 0x0000020f,0x0000020e,0x00050085,0x00000006,0x00000210,0x0000020c,0x0000020f,0x0004003d, + 0x00000006,0x00000211,0x00000153,0x00050081,0x00000006,0x00000212,0x00000211,0x00000210, + 0x0003003e,0x00000153,0x00000212,0x0004003d,0x00000025,0x00000295,0x00000037,0x00050084, + 0x00000025,0x00000296,0x00000295,0x0000015c,0x0004003d,0x00000025,0x00000297,0x00000155, + 0x00050080,0x00000025,0x00000298,0x00000296,0x00000297,0x0003003e,0x00000299,0x00000294, + 0x00050041,0x0000000d,0x0000029a,0x00000299,0x00000298,0x0004003d,0x00000006,0x0000029b, + 0x0000029a,0x0004003d,0x00000025,0x0000029c,0x00000155,0x00050041,0x0000000d,0x0000029d, + 0x00000036,0x0000029c,0x0004003d,0x00000006,0x0000029e,0x0000029d,0x00050085,0x00000006, + 0x0000029f,0x0000029b,0x0000029e,0x0004003d,0x00000006,0x000002a0,0x00000154,0x00050081, + 0x00000006,0x000002a1,0x000002a0,0x0000029f,0x0003003e,0x00000154,0x000002a1,0x000200f9, + 0x00000159,0x000200f8,0x00000159,0x0004003d,0x00000025,0x000002a2,0x00000155,0x00050080, + 0x00000025,0x000002a4,0x000002a2,0x000002a3,0x0003003e,0x00000155,0x000002a4,0x000200f9, + 0x00000156,0x000200f8,0x00000158,0x0004003d,0x00000006,0x000002a6,0x00000153,0x00050083, + 0x00000006,0x000002a8,0x000002a6,0x000002a7,0x00050085,0x00000006,0x000002aa,0x000002a8, + 0x000002a9,0x0008000c,0x00000006,0x000002ab,0x00000001,0x0000002b,0x000002aa,0x0000009a, + 0x000000a8,0x00050083,0x00000006,0x000002ac,0x000000a8,0x000002ab,0x0003003e,0x000002a5, + 0x000002ac,0x0004003d,0x00000006,0x000002ae,0x000002a5,0x0004003d,0x00000006,0x000002b1, + 0x000002b0,0x00050085,0x00000006,0x000002b2,0x000002ae,0x000002b1,0x0004003d,0x00000006, + 0x000002b4,0x000002b3,0x00050081,0x00000006,0x000002b5,0x000002b2,0x000002b4,0x0003003e, + 0x000002ad,0x000002b5,0x0004003d,0x00000006,0x000002b6,0x000002ad,0x0004003d,0x00000006, + 0x000002b7,0x00000154,0x00050085,0x00000006,0x000002b8,0x000002b7,0x000002b6,0x0003003e, + 0x00000154,0x000002b8,0x0004003d,0x00000006,0x000002ba,0x000002a5,0x0004003d,0x00000006, + 0x000002bc,0x000002bb,0x00050085,0x00000006,0x000002bd,0x000002ba,0x000002bc,0x0004003d, + 0x00000006,0x000002bf,0x000002be,0x00050081,0x00000006,0x000002c0,0x000002bd,0x000002bf, + 0x0004003d,0x00000006,0x000002c1,0x00000153,0x00050085,0x00000006,0x000002c2,0x000002c0, + 0x000002c1,0x0003003e,0x000002b9,0x000002c2,0x0004003d,0x00000006,0x000002c3,0x000002b9, + 0x0004003d,0x00000006,0x000002c4,0x000002b9,0x0004007f,0x00000006,0x000002c5,0x000002c4, + 0x0004003d,0x00000006,0x000002c6,0x00000154,0x0007000c,0x00000006,0x000002c7,0x00000001, + 0x00000028,0x000002c5,0x000002c6,0x0007000c,0x00000006,0x000002c8,0x00000001,0x00000025, + 0x000002c3,0x000002c7,0x0003003e,0x00000154,0x000002c8,0x00050041,0x0000000d,0x000002ce, + 0x00000036,0x00000150,0x0004003d,0x00000006,0x000002cf,0x000002ce,0x0003003e,0x000002cd, + 0x000002cf,0x00050041,0x0000000d,0x000002d1,0x00000036,0x000002a3,0x0004003d,0x00000006, + 0x000002d2,0x000002d1,0x0003003e,0x000002d0,0x000002d2,0x00050041,0x0000000d,0x000002d4, + 0x00000036,0x000002c9,0x0004003d,0x00000006,0x000002d5,0x000002d4,0x0003003e,0x000002d3, + 0x000002d5,0x00050041,0x0000000d,0x000002d7,0x00000036,0x000002ca,0x0004003d,0x00000006, + 0x000002d8,0x000002d7,0x0003003e,0x000002d6,0x000002d8,0x00050041,0x0000000d,0x000002da, + 0x00000036,0x000002cb,0x0004003d,0x00000006,0x000002db,0x000002da,0x0003003e,0x000002d9, + 0x000002db,0x00050041,0x0000000d,0x000002dd,0x00000036,0x000002cc,0x0004003d,0x00000006, + 0x000002de,0x000002dd,0x0003003e,0x000002dc,0x000002de,0x0004003d,0x00000025,0x000002e0, + 0x00000037,0x0003003e,0x000002df,0x000002e0,0x000b0039,0x00000006,0x000002e1,0x0000002f, + 0x000002cd,0x000002d0,0x000002d3,0x000002d6,0x000002d9,0x000002dc,0x000002df,0x0004003d, + 0x00000006,0x000002e2,0x00000154,0x00050085,0x00000006,0x000002e3,0x000002e2,0x000002e1, + 0x0003003e,0x00000154,0x000002e3,0x0004003d,0x00000006,0x000002e4,0x00000153,0x0004003d, + 0x00000006,0x000002e5,0x00000154,0x00050081,0x00000006,0x000002e6,0x000002e4,0x000002e5, + 0x000200fe,0x000002e6,0x00010038,0x00050036,0x00000006,0x00000040,0x00000000,0x0000003c, 0x00030037,0x0000003b,0x0000003d,0x00030037,0x00000026,0x0000003e,0x00030037,0x00000026, - 0x0000003f,0x000200f8,0x00000041,0x0004003b,0x0000000d,0x00000303,0x00000007,0x0004003b, - 0x00000026,0x00000304,0x00000007,0x0004003b,0x0000000d,0x0000030c,0x00000007,0x0004003b, - 0x00000026,0x0000030d,0x00000007,0x0004003b,0x00000214,0x0000031d,0x00000007,0x0004003b, - 0x00000214,0x0000032a,0x00000007,0x0004003d,0x00000025,0x000002ff,0x0000003e,0x0008000c, - 0x00000025,0x00000300,0x00000001,0x0000002d,0x000002ff,0x0000015c,0x0000015d,0x0003003e, - 0x0000003e,0x00000300,0x0004003d,0x00000025,0x00000301,0x0000003f,0x0008000c,0x00000025, - 0x00000302,0x00000001,0x0000002d,0x00000301,0x0000015c,0x0000015d,0x0003003e,0x0000003f, - 0x00000302,0x0003003e,0x00000303,0x000000a5,0x0003003e,0x00000304,0x0000015c,0x000200f9, - 0x00000305,0x000200f8,0x00000305,0x000400f6,0x00000307,0x00000308,0x00000000,0x000200f9, - 0x00000309,0x000200f8,0x00000309,0x0004003d,0x00000025,0x0000030a,0x00000304,0x000500b1, - 0x000000a6,0x0000030b,0x0000030a,0x00000167,0x000400fa,0x0000030b,0x00000306,0x00000307, - 0x000200f8,0x00000306,0x0003003e,0x0000030c,0x000000a5,0x0003003e,0x0000030d,0x0000015c, - 0x000200f9,0x0000030e,0x000200f8,0x0000030e,0x000400f6,0x00000310,0x00000311,0x00000000, - 0x000200f9,0x00000312,0x000200f8,0x00000312,0x0004003d,0x00000025,0x00000313,0x0000030d, - 0x000500b1,0x000000a6,0x00000314,0x00000313,0x00000167,0x000400fa,0x00000314,0x0000030f, - 0x00000310,0x000200f8,0x0000030f,0x0004003d,0x00000025,0x00000315,0x0000030d,0x0004003d, - 0x00000025,0x00000316,0x00000304,0x00060041,0x0000000d,0x00000317,0x0000003d,0x00000315, - 0x00000316,0x0004003d,0x00000006,0x00000318,0x00000317,0x0004003d,0x00000025,0x00000319, - 0x0000003f,0x00050084,0x00000025,0x0000031a,0x00000319,0x00000167,0x0004003d,0x00000025, - 0x0000031b,0x0000030d,0x00050080,0x00000025,0x0000031c,0x0000031a,0x0000031b,0x0003003e, - 0x0000031d,0x0000020f,0x00050041,0x0000000d,0x0000031e,0x0000031d,0x0000031c,0x0004003d, - 0x00000006,0x0000031f,0x0000031e,0x00050085,0x00000006,0x00000320,0x00000318,0x0000031f, - 0x0004003d,0x00000006,0x00000321,0x0000030c,0x00050081,0x00000006,0x00000322,0x00000321, - 0x00000320,0x0003003e,0x0000030c,0x00000322,0x000200f9,0x00000311,0x000200f8,0x00000311, - 0x0004003d,0x00000025,0x00000323,0x0000030d,0x00050080,0x00000025,0x00000324,0x00000323, - 0x0000021f,0x0003003e,0x0000030d,0x00000324,0x000200f9,0x0000030e,0x000200f8,0x00000310, - 0x0004003d,0x00000006,0x00000325,0x0000030c,0x0004003d,0x00000025,0x00000326,0x0000003e, - 0x00050084,0x00000025,0x00000327,0x00000326,0x00000167,0x0004003d,0x00000025,0x00000328, - 0x00000304,0x00050080,0x00000025,0x00000329,0x00000327,0x00000328,0x0003003e,0x0000032a, - 0x0000020f,0x00050041,0x0000000d,0x0000032b,0x0000032a,0x00000329,0x0004003d,0x00000006, - 0x0000032c,0x0000032b,0x00050085,0x00000006,0x0000032d,0x00000325,0x0000032c,0x0004003d, - 0x00000006,0x0000032e,0x00000303,0x00050081,0x00000006,0x0000032f,0x0000032e,0x0000032d, - 0x0003003e,0x00000303,0x0000032f,0x000200f9,0x00000308,0x000200f8,0x00000308,0x0004003d, - 0x00000025,0x00000330,0x00000304,0x00050080,0x00000025,0x00000331,0x00000330,0x0000021f, - 0x0003003e,0x00000304,0x00000331,0x000200f9,0x00000305,0x000200f8,0x00000307,0x0004003d, - 0x00000006,0x00000332,0x00000303,0x000200fe,0x00000332,0x00010038,0x00050036,0x00000006, + 0x0000003f,0x000200f8,0x00000041,0x0004003b,0x0000000d,0x000002ed,0x00000007,0x0004003b, + 0x00000026,0x000002ee,0x00000007,0x0004003b,0x0000000d,0x000002f6,0x00000007,0x0004003b, + 0x00000026,0x000002f7,0x00000007,0x0004003b,0x00000209,0x00000307,0x00000007,0x0004003b, + 0x00000209,0x00000314,0x00000007,0x0004003d,0x00000025,0x000002e9,0x0000003e,0x0008000c, + 0x00000025,0x000002ea,0x00000001,0x0000002d,0x000002e9,0x00000150,0x00000151,0x0003003e, + 0x0000003e,0x000002ea,0x0004003d,0x00000025,0x000002eb,0x0000003f,0x0008000c,0x00000025, + 0x000002ec,0x00000001,0x0000002d,0x000002eb,0x00000150,0x00000151,0x0003003e,0x0000003f, + 0x000002ec,0x0003003e,0x000002ed,0x0000009a,0x0003003e,0x000002ee,0x00000150,0x000200f9, + 0x000002ef,0x000200f8,0x000002ef,0x000400f6,0x000002f1,0x000002f2,0x00000000,0x000200f9, + 0x000002f3,0x000200f8,0x000002f3,0x0004003d,0x00000025,0x000002f4,0x000002ee,0x000500b1, + 0x0000009b,0x000002f5,0x000002f4,0x0000015c,0x000400fa,0x000002f5,0x000002f0,0x000002f1, + 0x000200f8,0x000002f0,0x0003003e,0x000002f6,0x0000009a,0x0003003e,0x000002f7,0x00000150, + 0x000200f9,0x000002f8,0x000200f8,0x000002f8,0x000400f6,0x000002fa,0x000002fb,0x00000000, + 0x000200f9,0x000002fc,0x000200f8,0x000002fc,0x0004003d,0x00000025,0x000002fd,0x000002f7, + 0x000500b1,0x0000009b,0x000002fe,0x000002fd,0x0000015c,0x000400fa,0x000002fe,0x000002f9, + 0x000002fa,0x000200f8,0x000002f9,0x0004003d,0x00000025,0x000002ff,0x000002f7,0x0004003d, + 0x00000025,0x00000300,0x000002ee,0x00060041,0x0000000d,0x00000301,0x0000003d,0x000002ff, + 0x00000300,0x0004003d,0x00000006,0x00000302,0x00000301,0x0004003d,0x00000025,0x00000303, + 0x0000003f,0x00050084,0x00000025,0x00000304,0x00000303,0x0000015c,0x0004003d,0x00000025, + 0x00000305,0x000002f7,0x00050080,0x00000025,0x00000306,0x00000304,0x00000305,0x0003003e, + 0x00000307,0x00000204,0x00050041,0x0000000d,0x00000308,0x00000307,0x00000306,0x0004003d, + 0x00000006,0x00000309,0x00000308,0x00050085,0x00000006,0x0000030a,0x00000302,0x00000309, + 0x0004003d,0x00000006,0x0000030b,0x000002f6,0x00050081,0x00000006,0x0000030c,0x0000030b, + 0x0000030a,0x0003003e,0x000002f6,0x0000030c,0x000200f9,0x000002fb,0x000200f8,0x000002fb, + 0x0004003d,0x00000025,0x0000030d,0x000002f7,0x00050080,0x00000025,0x0000030e,0x0000030d, + 0x000002a3,0x0003003e,0x000002f7,0x0000030e,0x000200f9,0x000002f8,0x000200f8,0x000002fa, + 0x0004003d,0x00000006,0x0000030f,0x000002f6,0x0004003d,0x00000025,0x00000310,0x0000003e, + 0x00050084,0x00000025,0x00000311,0x00000310,0x0000015c,0x0004003d,0x00000025,0x00000312, + 0x000002ee,0x00050080,0x00000025,0x00000313,0x00000311,0x00000312,0x0003003e,0x00000314, + 0x00000204,0x00050041,0x0000000d,0x00000315,0x00000314,0x00000313,0x0004003d,0x00000006, + 0x00000316,0x00000315,0x00050085,0x00000006,0x00000317,0x0000030f,0x00000316,0x0004003d, + 0x00000006,0x00000318,0x000002ed,0x00050081,0x00000006,0x00000319,0x00000318,0x00000317, + 0x0003003e,0x000002ed,0x00000319,0x000200f9,0x000002f2,0x000200f8,0x000002f2,0x0004003d, + 0x00000025,0x0000031a,0x000002ee,0x00050080,0x00000025,0x0000031b,0x0000031a,0x000002a3, + 0x0003003e,0x000002ee,0x0000031b,0x000200f9,0x000002ef,0x000200f8,0x000002f1,0x0004003d, + 0x00000006,0x0000031c,0x000002ed,0x000200fe,0x0000031c,0x00010038,0x00050036,0x00000006, 0x00000049,0x00000000,0x00000042,0x00030037,0x0000003b,0x00000043,0x00030037,0x0000000d, 0x00000044,0x00030037,0x0000000d,0x00000045,0x00030037,0x00000026,0x00000046,0x00030037, 0x00000026,0x00000047,0x00030037,0x0000001b,0x00000048,0x000200f8,0x0000004a,0x0004003b, - 0x0000000d,0x00000335,0x00000007,0x0004003b,0x00000026,0x0000033b,0x00000007,0x0004003b, - 0x00000034,0x00000343,0x00000007,0x0004003b,0x00000034,0x00000350,0x00000007,0x0004003b, - 0x00000026,0x00000352,0x00000007,0x0004003b,0x00000026,0x0000035f,0x00000007,0x0004003b, - 0x00000034,0x00000367,0x00000007,0x0004003b,0x00000034,0x00000374,0x00000007,0x0004003b, - 0x00000026,0x00000376,0x00000007,0x0004003b,0x0000000d,0x00000383,0x00000007,0x0004003b, - 0x0000038c,0x0000038d,0x00000007,0x0004003b,0x0000000d,0x000003a5,0x00000007,0x0004003b, - 0x0000000d,0x000003a8,0x00000007,0x0004003b,0x0000000d,0x000003b1,0x00000007,0x0004003b, - 0x0000000d,0x000003b4,0x00000007,0x0004003b,0x0000000d,0x000003bd,0x00000007,0x0004003b, - 0x0000000d,0x000003c0,0x00000007,0x0004003b,0x0000000d,0x000003c9,0x00000007,0x0004003b, - 0x0000000d,0x000003cc,0x00000007,0x0004003b,0x0000000d,0x000003f1,0x00000007,0x0004003b, - 0x00000026,0x000003f9,0x00000007,0x0004003b,0x00000034,0x00000401,0x00000007,0x0004003b, - 0x00000026,0x0000040d,0x00000007,0x0004003b,0x00000034,0x00000420,0x00000007,0x0004003b, - 0x00000026,0x00000422,0x00000007,0x0004003b,0x0000000d,0x0000042f,0x00000007,0x0004003b, - 0x0000038c,0x00000434,0x00000007,0x0004003b,0x0000000d,0x0000044c,0x00000007,0x0004003b, - 0x0000000d,0x0000044f,0x00000007,0x0004003b,0x0000000d,0x00000458,0x00000007,0x0004003b, - 0x0000000d,0x0000045b,0x00000007,0x0004003b,0x0000000d,0x00000464,0x00000007,0x0004003b, - 0x0000000d,0x00000467,0x00000007,0x0004003b,0x0000000d,0x00000470,0x00000007,0x0004003b, - 0x0000000d,0x00000473,0x00000007,0x0004003b,0x0000000d,0x00000498,0x00000007,0x0004003b, - 0x00000026,0x000004a1,0x00000007,0x0004003b,0x00000034,0x000004a9,0x00000007,0x0004003b, - 0x00000026,0x000004b5,0x00000007,0x0004003b,0x00000034,0x000004c7,0x00000007,0x0004003b, - 0x00000026,0x000004c9,0x00000007,0x0003003e,0x00000335,0x000000a5,0x00050041,0x0000000d, - 0x00000336,0x00000048,0x0000004c,0x0004003d,0x00000006,0x00000337,0x00000336,0x000500ba, - 0x000000a6,0x00000338,0x00000337,0x000000a5,0x000300f7,0x0000033a,0x00000000,0x000400fa, - 0x00000338,0x00000339,0x0000033a,0x000200f8,0x00000339,0x0003003e,0x0000033b,0x0000015c, - 0x000200f9,0x0000033c,0x000200f8,0x0000033c,0x000400f6,0x0000033e,0x0000033f,0x00000000, - 0x000200f9,0x00000340,0x000200f8,0x00000340,0x0004003d,0x00000025,0x00000341,0x0000033b, - 0x000500b1,0x000000a6,0x00000342,0x00000341,0x00000167,0x000400fa,0x00000342,0x0000033d, - 0x0000033e,0x000200f8,0x0000033d,0x0004003d,0x00000025,0x00000344,0x0000033b,0x0004003d, - 0x00000025,0x00000345,0x0000033b,0x00060041,0x0000000d,0x00000346,0x00000043,0x00000345, - 0x000002df,0x0004003d,0x00000006,0x00000347,0x00000346,0x0004003d,0x00000025,0x00000348, - 0x0000033b,0x00060041,0x0000000d,0x00000349,0x00000043,0x00000348,0x000002e0,0x0004003d, - 0x00000006,0x0000034a,0x00000349,0x0004003d,0x00000006,0x0000034b,0x00000044,0x0008000c, - 0x00000006,0x0000034c,0x00000001,0x0000002e,0x00000347,0x0000034a,0x0000034b,0x00050041, - 0x0000000d,0x0000034d,0x00000343,0x00000344,0x0003003e,0x0000034d,0x0000034c,0x000200f9, - 0x0000033f,0x000200f8,0x0000033f,0x0004003d,0x00000025,0x0000034e,0x0000033b,0x00050080, - 0x00000025,0x0000034f,0x0000034e,0x0000021f,0x0003003e,0x0000033b,0x0000034f,0x000200f9, - 0x0000033c,0x000200f8,0x0000033e,0x0004003d,0x00000033,0x00000351,0x00000343,0x0003003e, - 0x00000350,0x00000351,0x0004003d,0x00000025,0x00000353,0x00000047,0x0003003e,0x00000352, - 0x00000353,0x00060039,0x00000006,0x00000354,0x00000038,0x00000350,0x00000352,0x00050041, - 0x0000000d,0x00000355,0x00000048,0x0000004c,0x0004003d,0x00000006,0x00000356,0x00000355, - 0x00050085,0x00000006,0x00000357,0x00000354,0x00000356,0x0004003d,0x00000006,0x00000358, - 0x00000335,0x00050081,0x00000006,0x00000359,0x00000358,0x00000357,0x0003003e,0x00000335, - 0x00000359,0x000200f9,0x0000033a,0x000200f8,0x0000033a,0x00050041,0x0000000d,0x0000035a, - 0x00000048,0x00000051,0x0004003d,0x00000006,0x0000035b,0x0000035a,0x000500ba,0x000000a6, - 0x0000035c,0x0000035b,0x000000a5,0x000300f7,0x0000035e,0x00000000,0x000400fa,0x0000035c, - 0x0000035d,0x0000035e,0x000200f8,0x0000035d,0x0003003e,0x0000035f,0x0000015c,0x000200f9, - 0x00000360,0x000200f8,0x00000360,0x000400f6,0x00000362,0x00000363,0x00000000,0x000200f9, - 0x00000364,0x000200f8,0x00000364,0x0004003d,0x00000025,0x00000365,0x0000035f,0x000500b1, - 0x000000a6,0x00000366,0x00000365,0x00000167,0x000400fa,0x00000366,0x00000361,0x00000362, - 0x000200f8,0x00000361,0x0004003d,0x00000025,0x00000368,0x0000035f,0x0004003d,0x00000025, - 0x00000369,0x0000035f,0x00060041,0x0000000d,0x0000036a,0x00000043,0x000002df,0x00000369, - 0x0004003d,0x00000006,0x0000036b,0x0000036a,0x0004003d,0x00000025,0x0000036c,0x0000035f, - 0x00060041,0x0000000d,0x0000036d,0x00000043,0x000002e0,0x0000036c,0x0004003d,0x00000006, - 0x0000036e,0x0000036d,0x0004003d,0x00000006,0x0000036f,0x00000045,0x0008000c,0x00000006, - 0x00000370,0x00000001,0x0000002e,0x0000036b,0x0000036e,0x0000036f,0x00050041,0x0000000d, - 0x00000371,0x00000367,0x00000368,0x0003003e,0x00000371,0x00000370,0x000200f9,0x00000363, - 0x000200f8,0x00000363,0x0004003d,0x00000025,0x00000372,0x0000035f,0x00050080,0x00000025, - 0x00000373,0x00000372,0x0000021f,0x0003003e,0x0000035f,0x00000373,0x000200f9,0x00000360, - 0x000200f8,0x00000362,0x0004003d,0x00000033,0x00000375,0x00000367,0x0003003e,0x00000374, - 0x00000375,0x0004003d,0x00000025,0x00000377,0x00000046,0x0003003e,0x00000376,0x00000377, - 0x00060039,0x00000006,0x00000378,0x00000038,0x00000374,0x00000376,0x00050041,0x0000000d, - 0x00000379,0x00000048,0x00000051,0x0004003d,0x00000006,0x0000037a,0x00000379,0x00050085, - 0x00000006,0x0000037b,0x00000378,0x0000037a,0x0004003d,0x00000006,0x0000037c,0x00000335, - 0x00050081,0x00000006,0x0000037d,0x0000037c,0x0000037b,0x0003003e,0x00000335,0x0000037d, - 0x000200f9,0x0000035e,0x000200f8,0x0000035e,0x00050041,0x0000000d,0x0000037e,0x00000048, - 0x00000057,0x0004003d,0x00000006,0x0000037f,0x0000037e,0x000500ba,0x000000a6,0x00000380, - 0x0000037f,0x000000a5,0x000300f7,0x00000382,0x00000000,0x000400fa,0x00000380,0x00000381, - 0x00000382,0x000200f8,0x00000381,0x0004003d,0x00000006,0x00000385,0x00000044,0x0004003d, - 0x00000006,0x00000386,0x00000045,0x00050083,0x00000006,0x00000387,0x00000385,0x00000386, - 0x00050085,0x00000006,0x00000388,0x00000384,0x00000387,0x00050081,0x00000006,0x00000389, - 0x00000384,0x00000388,0x0003003e,0x00000383,0x00000389,0x00060041,0x0000000d,0x0000038e, - 0x00000043,0x000002df,0x0000021f,0x0004003d,0x00000006,0x0000038f,0x0000038e,0x00060041, - 0x0000000d,0x00000390,0x00000043,0x0000021f,0x000002df,0x0004003d,0x00000006,0x00000391, - 0x00000390,0x0004003d,0x00000006,0x00000392,0x00000383,0x0008000c,0x00000006,0x00000393, - 0x00000001,0x0000002e,0x0000038f,0x00000391,0x00000392,0x00050041,0x0000000d,0x00000394, - 0x0000038d,0x0000021f,0x0003003e,0x00000394,0x00000393,0x00060041,0x0000000d,0x00000395, - 0x00000043,0x000002e0,0x000002df,0x0004003d,0x00000006,0x00000396,0x00000395,0x00060041, - 0x0000000d,0x00000397,0x00000043,0x000002df,0x000002e0,0x0004003d,0x00000006,0x00000398, - 0x00000397,0x0004003d,0x00000006,0x00000399,0x00000383,0x0008000c,0x00000006,0x0000039a, - 0x00000001,0x0000002e,0x00000396,0x00000398,0x00000399,0x00050041,0x0000000d,0x0000039b, - 0x0000038d,0x000002e0,0x0003003e,0x0000039b,0x0000039a,0x00060041,0x0000000d,0x0000039c, - 0x00000043,0x000002e1,0x000002e0,0x0004003d,0x00000006,0x0000039d,0x0000039c,0x00060041, - 0x0000000d,0x0000039e,0x00000043,0x000002e0,0x000002e1,0x0004003d,0x00000006,0x0000039f, - 0x0000039e,0x0004003d,0x00000006,0x000003a0,0x00000383,0x0008000c,0x00000006,0x000003a1, - 0x00000001,0x0000002e,0x0000039d,0x0000039f,0x000003a0,0x00050041,0x0000000d,0x000003a2, - 0x0000038d,0x000002e2,0x0003003e,0x000003a2,0x000003a1,0x0004003d,0x00000006,0x000003a3, - 0x00000383,0x00050083,0x00000006,0x000003a4,0x000003a3,0x00000384,0x0003003e,0x00000383, - 0x000003a4,0x0004003d,0x00000006,0x000003a6,0x00000383,0x000500be,0x000000a6,0x000003a7, - 0x000003a6,0x000000a5,0x000300f7,0x000003aa,0x00000000,0x000400fa,0x000003a7,0x000003a9, - 0x000003ad,0x000200f8,0x000003a9,0x00060041,0x0000000d,0x000003ab,0x00000043,0x0000015c, - 0x000002df,0x0004003d,0x00000006,0x000003ac,0x000003ab,0x0003003e,0x000003a8,0x000003ac, - 0x000200f9,0x000003aa,0x000200f8,0x000003ad,0x00060041,0x0000000d,0x000003ae,0x00000043, - 0x000002df,0x0000015c,0x0004003d,0x00000006,0x000003af,0x000003ae,0x0003003e,0x000003a8, - 0x000003af,0x000200f9,0x000003aa,0x000200f8,0x000003aa,0x0004003d,0x00000006,0x000003b0, - 0x000003a8,0x0003003e,0x000003a5,0x000003b0,0x0004003d,0x00000006,0x000003b2,0x00000383, - 0x000500be,0x000000a6,0x000003b3,0x000003b2,0x000000a5,0x000300f7,0x000003b6,0x00000000, - 0x000400fa,0x000003b3,0x000003b5,0x000003b9,0x000200f8,0x000003b5,0x00060041,0x0000000d, - 0x000003b7,0x00000043,0x0000021f,0x000002e0,0x0004003d,0x00000006,0x000003b8,0x000003b7, - 0x0003003e,0x000003b4,0x000003b8,0x000200f9,0x000003b6,0x000200f8,0x000003b9,0x00060041, - 0x0000000d,0x000003ba,0x00000043,0x000002e0,0x0000021f,0x0004003d,0x00000006,0x000003bb, - 0x000003ba,0x0003003e,0x000003b4,0x000003bb,0x000200f9,0x000003b6,0x000200f8,0x000003b6, - 0x0004003d,0x00000006,0x000003bc,0x000003b4,0x0003003e,0x000003b1,0x000003bc,0x0004003d, - 0x00000006,0x000003be,0x00000383,0x000500be,0x000000a6,0x000003bf,0x000003be,0x000000a5, - 0x000300f7,0x000003c2,0x00000000,0x000400fa,0x000003bf,0x000003c1,0x000003c5,0x000200f8, - 0x000003c1,0x00060041,0x0000000d,0x000003c3,0x00000043,0x000002df,0x000002e1,0x0004003d, - 0x00000006,0x000003c4,0x000003c3,0x0003003e,0x000003c0,0x000003c4,0x000200f9,0x000003c2, - 0x000200f8,0x000003c5,0x00060041,0x0000000d,0x000003c6,0x00000043,0x000002e1,0x000002df, - 0x0004003d,0x00000006,0x000003c7,0x000003c6,0x0003003e,0x000003c0,0x000003c7,0x000200f9, - 0x000003c2,0x000200f8,0x000003c2,0x0004003d,0x00000006,0x000003c8,0x000003c0,0x0003003e, - 0x000003bd,0x000003c8,0x0004003d,0x00000006,0x000003ca,0x00000383,0x000500be,0x000000a6, - 0x000003cb,0x000003ca,0x000000a5,0x000300f7,0x000003ce,0x00000000,0x000400fa,0x000003cb, - 0x000003cd,0x000003d1,0x000200f8,0x000003cd,0x00060041,0x0000000d,0x000003cf,0x00000043, - 0x000002e0,0x000002e2,0x0004003d,0x00000006,0x000003d0,0x000003cf,0x0003003e,0x000003cc, - 0x000003d0,0x000200f9,0x000003ce,0x000200f8,0x000003d1,0x00060041,0x0000000d,0x000003d2, - 0x00000043,0x000002e2,0x000002e0,0x0004003d,0x00000006,0x000003d3,0x000003d2,0x0003003e, - 0x000003cc,0x000003d3,0x000200f9,0x000003ce,0x000200f8,0x000003ce,0x0004003d,0x00000006, - 0x000003d4,0x000003cc,0x0003003e,0x000003c9,0x000003d4,0x00060041,0x0000000d,0x000003d5, - 0x00000043,0x0000021f,0x0000021f,0x0004003d,0x00000006,0x000003d6,0x000003d5,0x0004003d, - 0x00000006,0x000003d7,0x000003a5,0x0004003d,0x00000006,0x000003d8,0x00000383,0x0006000c, - 0x00000006,0x000003d9,0x00000001,0x00000004,0x000003d8,0x0008000c,0x00000006,0x000003da, - 0x00000001,0x0000002e,0x000003d6,0x000003d7,0x000003d9,0x00050041,0x0000000d,0x000003db, - 0x0000038d,0x0000015c,0x0003003e,0x000003db,0x000003da,0x00060041,0x0000000d,0x000003dc, - 0x00000043,0x000002df,0x000002df,0x0004003d,0x00000006,0x000003dd,0x000003dc,0x0004003d, - 0x00000006,0x000003de,0x000003b1,0x0004003d,0x00000006,0x000003df,0x00000383,0x0006000c, - 0x00000006,0x000003e0,0x00000001,0x00000004,0x000003df,0x0008000c,0x00000006,0x000003e1, - 0x00000001,0x0000002e,0x000003dd,0x000003de,0x000003e0,0x00050041,0x0000000d,0x000003e2, - 0x0000038d,0x000002df,0x0003003e,0x000003e2,0x000003e1,0x00060041,0x0000000d,0x000003e3, - 0x00000043,0x000002e0,0x000002e0,0x0004003d,0x00000006,0x000003e4,0x000003e3,0x0004003d, - 0x00000006,0x000003e5,0x000003bd,0x0004003d,0x00000006,0x000003e6,0x00000383,0x0006000c, - 0x00000006,0x000003e7,0x00000001,0x00000004,0x000003e6,0x0008000c,0x00000006,0x000003e8, - 0x00000001,0x0000002e,0x000003e4,0x000003e5,0x000003e7,0x00050041,0x0000000d,0x000003e9, - 0x0000038d,0x000002e1,0x0003003e,0x000003e9,0x000003e8,0x00060041,0x0000000d,0x000003ea, - 0x00000043,0x000002e1,0x000002e1,0x0004003d,0x00000006,0x000003eb,0x000003ea,0x0004003d, - 0x00000006,0x000003ec,0x000003c9,0x0004003d,0x00000006,0x000003ed,0x00000383,0x0006000c, - 0x00000006,0x000003ee,0x00000001,0x00000004,0x000003ed,0x0008000c,0x00000006,0x000003ef, - 0x00000001,0x0000002e,0x000003eb,0x000003ec,0x000003ee,0x00050041,0x0000000d,0x000003f0, - 0x0000038d,0x00000167,0x0003003e,0x000003f0,0x000003ef,0x0004003d,0x00000006,0x000003f2, - 0x00000044,0x0004003d,0x00000006,0x000003f3,0x00000045,0x00050081,0x00000006,0x000003f4, - 0x000003f2,0x000003f3,0x0003003e,0x000003f1,0x000003f4,0x0004003d,0x00000006,0x000003f5, - 0x000003f1,0x000500be,0x000000a6,0x000003f6,0x000003f5,0x000000b2,0x000300f7,0x000003f8, - 0x00000000,0x000400fa,0x000003f6,0x000003f7,0x0000040c,0x000200f8,0x000003f7,0x0003003e, - 0x000003f9,0x0000015c,0x000200f9,0x000003fa,0x000200f8,0x000003fa,0x000400f6,0x000003fc, - 0x000003fd,0x00000000,0x000200f9,0x000003fe,0x000200f8,0x000003fe,0x0004003d,0x00000025, - 0x000003ff,0x000003f9,0x000500b1,0x000000a6,0x00000400,0x000003ff,0x00000167,0x000400fa, - 0x00000400,0x000003fb,0x000003fc,0x000200f8,0x000003fb,0x0004003d,0x00000025,0x00000402, - 0x000003f9,0x0004003d,0x00000025,0x00000403,0x000003f9,0x00050080,0x00000025,0x00000404, - 0x00000403,0x0000021f,0x00050041,0x0000000d,0x00000405,0x0000038d,0x00000404,0x0004003d, - 0x00000006,0x00000406,0x00000405,0x00050041,0x0000000d,0x00000407,0x00000401,0x00000402, - 0x0003003e,0x00000407,0x00000406,0x000200f9,0x000003fd,0x000200f8,0x000003fd,0x0004003d, - 0x00000025,0x00000408,0x000003f9,0x00050080,0x00000025,0x00000409,0x00000408,0x0000021f, - 0x0003003e,0x000003f9,0x00000409,0x000200f9,0x000003fa,0x000200f8,0x000003fc,0x0004003d, - 0x00000006,0x0000040a,0x000003f1,0x00050083,0x00000006,0x0000040b,0x0000040a,0x000000b2, - 0x0003003e,0x000003f1,0x0000040b,0x000200f9,0x000003f8,0x000200f8,0x0000040c,0x0003003e, - 0x0000040d,0x0000015c,0x000200f9,0x0000040e,0x000200f8,0x0000040e,0x000400f6,0x00000410, - 0x00000411,0x00000000,0x000200f9,0x00000412,0x000200f8,0x00000412,0x0004003d,0x00000025, - 0x00000413,0x0000040d,0x000500b1,0x000000a6,0x00000414,0x00000413,0x00000167,0x000400fa, - 0x00000414,0x0000040f,0x00000410,0x000200f8,0x0000040f,0x0004003d,0x00000025,0x00000415, - 0x0000040d,0x0004003d,0x00000025,0x00000416,0x0000040d,0x00050041,0x0000000d,0x00000417, - 0x0000038d,0x00000416,0x0004003d,0x00000006,0x00000418,0x00000417,0x00050041,0x0000000d, - 0x00000419,0x00000401,0x00000415,0x0003003e,0x00000419,0x00000418,0x000200f9,0x00000411, - 0x000200f8,0x00000411,0x0004003d,0x00000025,0x0000041a,0x0000040d,0x00050080,0x00000025, - 0x0000041b,0x0000041a,0x0000021f,0x0003003e,0x0000040d,0x0000041b,0x000200f9,0x0000040e, - 0x000200f8,0x00000410,0x000200f9,0x000003f8,0x000200f8,0x000003f8,0x0004003d,0x00000006, - 0x0000041c,0x000003f1,0x00050085,0x00000006,0x0000041e,0x0000041c,0x0000041d,0x0004006e, - 0x00000025,0x0000041f,0x0000041e,0x0004003d,0x00000033,0x00000421,0x00000401,0x0003003e, - 0x00000420,0x00000421,0x0003003e,0x00000422,0x0000041f,0x00060039,0x00000006,0x00000423, - 0x00000038,0x00000420,0x00000422,0x00050041,0x0000000d,0x00000424,0x00000048,0x00000057, - 0x0004003d,0x00000006,0x00000425,0x00000424,0x00050085,0x00000006,0x00000426,0x00000423, - 0x00000425,0x0004003d,0x00000006,0x00000427,0x00000335,0x00050081,0x00000006,0x00000428, - 0x00000427,0x00000426,0x0003003e,0x00000335,0x00000428,0x000200f9,0x00000382,0x000200f8, - 0x00000382,0x00050041,0x0000000d,0x0000042a,0x00000048,0x00000429,0x0004003d,0x00000006, - 0x0000042b,0x0000042a,0x000500ba,0x000000a6,0x0000042c,0x0000042b,0x000000a5,0x000300f7, - 0x0000042e,0x00000000,0x000400fa,0x0000042c,0x0000042d,0x0000042e,0x000200f8,0x0000042d, - 0x0004003d,0x00000006,0x00000430,0x00000044,0x0004003d,0x00000006,0x00000431,0x00000045, - 0x00050081,0x00000006,0x00000432,0x00000430,0x00000431,0x00050085,0x00000006,0x00000433, - 0x00000384,0x00000432,0x0003003e,0x0000042f,0x00000433,0x00060041,0x0000000d,0x00000435, - 0x00000043,0x000002e0,0x0000021f,0x0004003d,0x00000006,0x00000436,0x00000435,0x00060041, - 0x0000000d,0x00000437,0x00000043,0x000002e1,0x000002df,0x0004003d,0x00000006,0x00000438, - 0x00000437,0x0004003d,0x00000006,0x00000439,0x0000042f,0x0008000c,0x00000006,0x0000043a, - 0x00000001,0x0000002e,0x00000436,0x00000438,0x00000439,0x00050041,0x0000000d,0x0000043b, - 0x00000434,0x0000021f,0x0003003e,0x0000043b,0x0000043a,0x00060041,0x0000000d,0x0000043c, - 0x00000043,0x000002df,0x000002df,0x0004003d,0x00000006,0x0000043d,0x0000043c,0x00060041, - 0x0000000d,0x0000043e,0x00000043,0x000002e0,0x000002e0,0x0004003d,0x00000006,0x0000043f, - 0x0000043e,0x0004003d,0x00000006,0x00000440,0x0000042f,0x0008000c,0x00000006,0x00000441, - 0x00000001,0x0000002e,0x0000043d,0x0000043f,0x00000440,0x00050041,0x0000000d,0x00000442, - 0x00000434,0x000002e0,0x0003003e,0x00000442,0x00000441,0x00060041,0x0000000d,0x00000443, - 0x00000043,0x0000021f,0x000002e0,0x0004003d,0x00000006,0x00000444,0x00000443,0x00060041, - 0x0000000d,0x00000445,0x00000043,0x000002df,0x000002e1,0x0004003d,0x00000006,0x00000446, - 0x00000445,0x0004003d,0x00000006,0x00000447,0x0000042f,0x0008000c,0x00000006,0x00000448, - 0x00000001,0x0000002e,0x00000444,0x00000446,0x00000447,0x00050041,0x0000000d,0x00000449, - 0x00000434,0x000002e2,0x0003003e,0x00000449,0x00000448,0x0004003d,0x00000006,0x0000044a, - 0x0000042f,0x00050083,0x00000006,0x0000044b,0x0000044a,0x00000384,0x0003003e,0x0000042f, - 0x0000044b,0x0004003d,0x00000006,0x0000044d,0x0000042f,0x000500be,0x000000a6,0x0000044e, - 0x0000044d,0x000000a5,0x000300f7,0x00000451,0x00000000,0x000400fa,0x0000044e,0x00000450, - 0x00000454,0x000200f8,0x00000450,0x00060041,0x0000000d,0x00000452,0x00000043,0x000002e2, - 0x000002df,0x0004003d,0x00000006,0x00000453,0x00000452,0x0003003e,0x0000044f,0x00000453, - 0x000200f9,0x00000451,0x000200f8,0x00000454,0x00060041,0x0000000d,0x00000455,0x00000043, - 0x000002e0,0x0000015c,0x0004003d,0x00000006,0x00000456,0x00000455,0x0003003e,0x0000044f, - 0x00000456,0x000200f9,0x00000451,0x000200f8,0x00000451,0x0004003d,0x00000006,0x00000457, - 0x0000044f,0x0003003e,0x0000044c,0x00000457,0x0004003d,0x00000006,0x00000459,0x0000042f, - 0x000500be,0x000000a6,0x0000045a,0x00000459,0x000000a5,0x000300f7,0x0000045d,0x00000000, - 0x000400fa,0x0000045a,0x0000045c,0x00000460,0x000200f8,0x0000045c,0x00060041,0x0000000d, - 0x0000045e,0x00000043,0x000002e1,0x000002e0,0x0004003d,0x00000006,0x0000045f,0x0000045e, - 0x0003003e,0x0000045b,0x0000045f,0x000200f9,0x0000045d,0x000200f8,0x00000460,0x00060041, - 0x0000000d,0x00000461,0x00000043,0x000002df,0x0000021f,0x0004003d,0x00000006,0x00000462, - 0x00000461,0x0003003e,0x0000045b,0x00000462,0x000200f9,0x0000045d,0x000200f8,0x0000045d, - 0x0004003d,0x00000006,0x00000463,0x0000045b,0x0003003e,0x00000458,0x00000463,0x0004003d, - 0x00000006,0x00000465,0x0000042f,0x000500be,0x000000a6,0x00000466,0x00000465,0x000000a5, - 0x000300f7,0x00000469,0x00000000,0x000400fa,0x00000466,0x00000468,0x0000046c,0x000200f8, - 0x00000468,0x00060041,0x0000000d,0x0000046a,0x00000043,0x000002e0,0x000002e1,0x0004003d, - 0x00000006,0x0000046b,0x0000046a,0x0003003e,0x00000467,0x0000046b,0x000200f9,0x00000469, - 0x000200f8,0x0000046c,0x00060041,0x0000000d,0x0000046d,0x00000043,0x0000021f,0x000002df, - 0x0004003d,0x00000006,0x0000046e,0x0000046d,0x0003003e,0x00000467,0x0000046e,0x000200f9, - 0x00000469,0x000200f8,0x00000469,0x0004003d,0x00000006,0x0000046f,0x00000467,0x0003003e, - 0x00000464,0x0000046f,0x0004003d,0x00000006,0x00000471,0x0000042f,0x000500be,0x000000a6, - 0x00000472,0x00000471,0x000000a5,0x000300f7,0x00000475,0x00000000,0x000400fa,0x00000472, - 0x00000474,0x00000478,0x000200f8,0x00000474,0x00060041,0x0000000d,0x00000476,0x00000043, - 0x000002df,0x000002e2,0x0004003d,0x00000006,0x00000477,0x00000476,0x0003003e,0x00000473, - 0x00000477,0x000200f9,0x00000475,0x000200f8,0x00000478,0x00060041,0x0000000d,0x00000479, - 0x00000043,0x0000015c,0x000002e0,0x0004003d,0x00000006,0x0000047a,0x00000479,0x0003003e, - 0x00000473,0x0000047a,0x000200f9,0x00000475,0x000200f8,0x00000475,0x0004003d,0x00000006, - 0x0000047b,0x00000473,0x0003003e,0x00000470,0x0000047b,0x00060041,0x0000000d,0x0000047c, - 0x00000043,0x000002e1,0x0000021f,0x0004003d,0x00000006,0x0000047d,0x0000047c,0x0004003d, - 0x00000006,0x0000047e,0x0000044c,0x0004003d,0x00000006,0x0000047f,0x0000042f,0x0006000c, - 0x00000006,0x00000480,0x00000001,0x00000004,0x0000047f,0x0008000c,0x00000006,0x00000481, - 0x00000001,0x0000002e,0x0000047d,0x0000047e,0x00000480,0x00050041,0x0000000d,0x00000482, - 0x00000434,0x0000015c,0x0003003e,0x00000482,0x00000481,0x00060041,0x0000000d,0x00000483, - 0x00000043,0x000002e0,0x000002df,0x0004003d,0x00000006,0x00000484,0x00000483,0x0004003d, - 0x00000006,0x00000485,0x00000458,0x0004003d,0x00000006,0x00000486,0x0000042f,0x0006000c, - 0x00000006,0x00000487,0x00000001,0x00000004,0x00000486,0x0008000c,0x00000006,0x00000488, - 0x00000001,0x0000002e,0x00000484,0x00000485,0x00000487,0x00050041,0x0000000d,0x00000489, - 0x00000434,0x000002df,0x0003003e,0x00000489,0x00000488,0x00060041,0x0000000d,0x0000048a, - 0x00000043,0x000002df,0x000002e0,0x0004003d,0x00000006,0x0000048b,0x0000048a,0x0004003d, - 0x00000006,0x0000048c,0x00000464,0x0004003d,0x00000006,0x0000048d,0x0000042f,0x0006000c, - 0x00000006,0x0000048e,0x00000001,0x00000004,0x0000048d,0x0008000c,0x00000006,0x0000048f, - 0x00000001,0x0000002e,0x0000048b,0x0000048c,0x0000048e,0x00050041,0x0000000d,0x00000490, - 0x00000434,0x000002e1,0x0003003e,0x00000490,0x0000048f,0x00060041,0x0000000d,0x00000491, - 0x00000043,0x0000021f,0x000002e1,0x0004003d,0x00000006,0x00000492,0x00000491,0x0004003d, - 0x00000006,0x00000493,0x00000470,0x0004003d,0x00000006,0x00000494,0x0000042f,0x0006000c, - 0x00000006,0x00000495,0x00000001,0x00000004,0x00000494,0x0008000c,0x00000006,0x00000496, - 0x00000001,0x0000002e,0x00000492,0x00000493,0x00000495,0x00050041,0x0000000d,0x00000497, - 0x00000434,0x00000167,0x0003003e,0x00000497,0x00000496,0x0004003d,0x00000006,0x00000499, - 0x00000044,0x0004003d,0x00000006,0x0000049a,0x00000045,0x00050083,0x00000006,0x0000049b, - 0x00000499,0x0000049a,0x00050081,0x00000006,0x0000049c,0x000000b2,0x0000049b,0x0003003e, - 0x00000498,0x0000049c,0x0004003d,0x00000006,0x0000049d,0x00000498,0x000500be,0x000000a6, - 0x0000049e,0x0000049d,0x000000b2,0x000300f7,0x000004a0,0x00000000,0x000400fa,0x0000049e, - 0x0000049f,0x000004b4,0x000200f8,0x0000049f,0x0003003e,0x000004a1,0x0000015c,0x000200f9, - 0x000004a2,0x000200f8,0x000004a2,0x000400f6,0x000004a4,0x000004a5,0x00000000,0x000200f9, - 0x000004a6,0x000200f8,0x000004a6,0x0004003d,0x00000025,0x000004a7,0x000004a1,0x000500b1, - 0x000000a6,0x000004a8,0x000004a7,0x00000167,0x000400fa,0x000004a8,0x000004a3,0x000004a4, - 0x000200f8,0x000004a3,0x0004003d,0x00000025,0x000004aa,0x000004a1,0x0004003d,0x00000025, - 0x000004ab,0x000004a1,0x00050080,0x00000025,0x000004ac,0x000004ab,0x0000021f,0x00050041, - 0x0000000d,0x000004ad,0x00000434,0x000004ac,0x0004003d,0x00000006,0x000004ae,0x000004ad, - 0x00050041,0x0000000d,0x000004af,0x000004a9,0x000004aa,0x0003003e,0x000004af,0x000004ae, - 0x000200f9,0x000004a5,0x000200f8,0x000004a5,0x0004003d,0x00000025,0x000004b0,0x000004a1, - 0x00050080,0x00000025,0x000004b1,0x000004b0,0x0000021f,0x0003003e,0x000004a1,0x000004b1, - 0x000200f9,0x000004a2,0x000200f8,0x000004a4,0x0004003d,0x00000006,0x000004b2,0x00000498, - 0x00050083,0x00000006,0x000004b3,0x000004b2,0x000000b2,0x0003003e,0x00000498,0x000004b3, - 0x000200f9,0x000004a0,0x000200f8,0x000004b4,0x0003003e,0x000004b5,0x0000015c,0x000200f9, - 0x000004b6,0x000200f8,0x000004b6,0x000400f6,0x000004b8,0x000004b9,0x00000000,0x000200f9, - 0x000004ba,0x000200f8,0x000004ba,0x0004003d,0x00000025,0x000004bb,0x000004b5,0x000500b1, - 0x000000a6,0x000004bc,0x000004bb,0x00000167,0x000400fa,0x000004bc,0x000004b7,0x000004b8, - 0x000200f8,0x000004b7,0x0004003d,0x00000025,0x000004bd,0x000004b5,0x0004003d,0x00000025, - 0x000004be,0x000004b5,0x00050041,0x0000000d,0x000004bf,0x00000434,0x000004be,0x0004003d, - 0x00000006,0x000004c0,0x000004bf,0x00050041,0x0000000d,0x000004c1,0x000004a9,0x000004bd, - 0x0003003e,0x000004c1,0x000004c0,0x000200f9,0x000004b9,0x000200f8,0x000004b9,0x0004003d, - 0x00000025,0x000004c2,0x000004b5,0x00050080,0x00000025,0x000004c3,0x000004c2,0x0000021f, - 0x0003003e,0x000004b5,0x000004c3,0x000200f9,0x000004b6,0x000200f8,0x000004b8,0x000200f9, - 0x000004a0,0x000200f8,0x000004a0,0x0004003d,0x00000006,0x000004c4,0x00000498,0x00050085, - 0x00000006,0x000004c5,0x000004c4,0x0000041d,0x0004006e,0x00000025,0x000004c6,0x000004c5, - 0x0004003d,0x00000033,0x000004c8,0x000004a9,0x0003003e,0x000004c7,0x000004c8,0x0003003e, - 0x000004c9,0x000004c6,0x00060039,0x00000006,0x000004ca,0x00000038,0x000004c7,0x000004c9, - 0x00050041,0x0000000d,0x000004cb,0x00000048,0x00000429,0x0004003d,0x00000006,0x000004cc, - 0x000004cb,0x00050085,0x00000006,0x000004cd,0x000004ca,0x000004cc,0x0004003d,0x00000006, - 0x000004ce,0x00000335,0x00050081,0x00000006,0x000004cf,0x000004ce,0x000004cd,0x0003003e, - 0x00000335,0x000004cf,0x000200f9,0x0000042e,0x000200f8,0x0000042e,0x0004003d,0x00000006, - 0x000004d0,0x00000335,0x000200fe,0x000004d0,0x00010038 + 0x0000000d,0x0000031f,0x00000007,0x0004003b,0x00000026,0x00000326,0x00000007,0x0004003b, + 0x00000034,0x0000032e,0x00000007,0x0004003b,0x00000034,0x0000033b,0x00000007,0x0004003b, + 0x00000026,0x0000033d,0x00000007,0x0004003b,0x00000026,0x0000034b,0x00000007,0x0004003b, + 0x00000034,0x00000353,0x00000007,0x0004003b,0x00000034,0x00000360,0x00000007,0x0004003b, + 0x00000026,0x00000362,0x00000007,0x0004003b,0x0000000d,0x00000370,0x00000007,0x0004003b, + 0x00000379,0x0000037a,0x00000007,0x0004003b,0x0000000d,0x00000392,0x00000007,0x0004003b, + 0x0000000d,0x00000395,0x00000007,0x0004003b,0x0000000d,0x0000039e,0x00000007,0x0004003b, + 0x0000000d,0x000003a1,0x00000007,0x0004003b,0x0000000d,0x000003aa,0x00000007,0x0004003b, + 0x0000000d,0x000003ad,0x00000007,0x0004003b,0x0000000d,0x000003b6,0x00000007,0x0004003b, + 0x0000000d,0x000003b9,0x00000007,0x0004003b,0x0000000d,0x000003de,0x00000007,0x0004003b, + 0x00000026,0x000003e6,0x00000007,0x0004003b,0x00000034,0x000003ee,0x00000007,0x0004003b, + 0x00000026,0x000003fa,0x00000007,0x0004003b,0x00000034,0x0000040d,0x00000007,0x0004003b, + 0x00000026,0x0000040f,0x00000007,0x0004003b,0x0000000d,0x0000041c,0x00000007,0x0004003b, + 0x00000379,0x00000421,0x00000007,0x0004003b,0x0000000d,0x00000439,0x00000007,0x0004003b, + 0x0000000d,0x0000043c,0x00000007,0x0004003b,0x0000000d,0x00000445,0x00000007,0x0004003b, + 0x0000000d,0x00000448,0x00000007,0x0004003b,0x0000000d,0x00000451,0x00000007,0x0004003b, + 0x0000000d,0x00000454,0x00000007,0x0004003b,0x0000000d,0x0000045d,0x00000007,0x0004003b, + 0x0000000d,0x00000460,0x00000007,0x0004003b,0x0000000d,0x00000485,0x00000007,0x0004003b, + 0x00000026,0x0000048e,0x00000007,0x0004003b,0x00000034,0x00000496,0x00000007,0x0004003b, + 0x00000026,0x000004a2,0x00000007,0x0004003b,0x00000034,0x000004b4,0x00000007,0x0004003b, + 0x00000026,0x000004b6,0x00000007,0x0003003e,0x0000031f,0x0000009a,0x00050041,0x0000000d, + 0x00000321,0x00000048,0x00000320,0x0004003d,0x00000006,0x00000322,0x00000321,0x000500ba, + 0x0000009b,0x00000323,0x00000322,0x0000009a,0x000300f7,0x00000325,0x00000000,0x000400fa, + 0x00000323,0x00000324,0x00000325,0x000200f8,0x00000324,0x0003003e,0x00000326,0x00000150, + 0x000200f9,0x00000327,0x000200f8,0x00000327,0x000400f6,0x00000329,0x0000032a,0x00000000, + 0x000200f9,0x0000032b,0x000200f8,0x0000032b,0x0004003d,0x00000025,0x0000032c,0x00000326, + 0x000500b1,0x0000009b,0x0000032d,0x0000032c,0x0000015c,0x000400fa,0x0000032d,0x00000328, + 0x00000329,0x000200f8,0x00000328,0x0004003d,0x00000025,0x0000032f,0x00000326,0x0004003d, + 0x00000025,0x00000330,0x00000326,0x00060041,0x0000000d,0x00000331,0x00000043,0x00000330, + 0x000002c9,0x0004003d,0x00000006,0x00000332,0x00000331,0x0004003d,0x00000025,0x00000333, + 0x00000326,0x00060041,0x0000000d,0x00000334,0x00000043,0x00000333,0x000002ca,0x0004003d, + 0x00000006,0x00000335,0x00000334,0x0004003d,0x00000006,0x00000336,0x00000044,0x0008000c, + 0x00000006,0x00000337,0x00000001,0x0000002e,0x00000332,0x00000335,0x00000336,0x00050041, + 0x0000000d,0x00000338,0x0000032e,0x0000032f,0x0003003e,0x00000338,0x00000337,0x000200f9, + 0x0000032a,0x000200f8,0x0000032a,0x0004003d,0x00000025,0x00000339,0x00000326,0x00050080, + 0x00000025,0x0000033a,0x00000339,0x000002a3,0x0003003e,0x00000326,0x0000033a,0x000200f9, + 0x00000327,0x000200f8,0x00000329,0x0004003d,0x00000033,0x0000033c,0x0000032e,0x0003003e, + 0x0000033b,0x0000033c,0x0004003d,0x00000025,0x0000033e,0x00000047,0x0003003e,0x0000033d, + 0x0000033e,0x00060039,0x00000006,0x0000033f,0x00000038,0x0000033b,0x0000033d,0x00050041, + 0x0000000d,0x00000340,0x00000048,0x00000320,0x0004003d,0x00000006,0x00000341,0x00000340, + 0x00050085,0x00000006,0x00000342,0x0000033f,0x00000341,0x0004003d,0x00000006,0x00000343, + 0x0000031f,0x00050081,0x00000006,0x00000344,0x00000343,0x00000342,0x0003003e,0x0000031f, + 0x00000344,0x000200f9,0x00000325,0x000200f8,0x00000325,0x00050041,0x0000000d,0x00000346, + 0x00000048,0x00000345,0x0004003d,0x00000006,0x00000347,0x00000346,0x000500ba,0x0000009b, + 0x00000348,0x00000347,0x0000009a,0x000300f7,0x0000034a,0x00000000,0x000400fa,0x00000348, + 0x00000349,0x0000034a,0x000200f8,0x00000349,0x0003003e,0x0000034b,0x00000150,0x000200f9, + 0x0000034c,0x000200f8,0x0000034c,0x000400f6,0x0000034e,0x0000034f,0x00000000,0x000200f9, + 0x00000350,0x000200f8,0x00000350,0x0004003d,0x00000025,0x00000351,0x0000034b,0x000500b1, + 0x0000009b,0x00000352,0x00000351,0x0000015c,0x000400fa,0x00000352,0x0000034d,0x0000034e, + 0x000200f8,0x0000034d,0x0004003d,0x00000025,0x00000354,0x0000034b,0x0004003d,0x00000025, + 0x00000355,0x0000034b,0x00060041,0x0000000d,0x00000356,0x00000043,0x000002c9,0x00000355, + 0x0004003d,0x00000006,0x00000357,0x00000356,0x0004003d,0x00000025,0x00000358,0x0000034b, + 0x00060041,0x0000000d,0x00000359,0x00000043,0x000002ca,0x00000358,0x0004003d,0x00000006, + 0x0000035a,0x00000359,0x0004003d,0x00000006,0x0000035b,0x00000045,0x0008000c,0x00000006, + 0x0000035c,0x00000001,0x0000002e,0x00000357,0x0000035a,0x0000035b,0x00050041,0x0000000d, + 0x0000035d,0x00000353,0x00000354,0x0003003e,0x0000035d,0x0000035c,0x000200f9,0x0000034f, + 0x000200f8,0x0000034f,0x0004003d,0x00000025,0x0000035e,0x0000034b,0x00050080,0x00000025, + 0x0000035f,0x0000035e,0x000002a3,0x0003003e,0x0000034b,0x0000035f,0x000200f9,0x0000034c, + 0x000200f8,0x0000034e,0x0004003d,0x00000033,0x00000361,0x00000353,0x0003003e,0x00000360, + 0x00000361,0x0004003d,0x00000025,0x00000363,0x00000046,0x0003003e,0x00000362,0x00000363, + 0x00060039,0x00000006,0x00000364,0x00000038,0x00000360,0x00000362,0x00050041,0x0000000d, + 0x00000365,0x00000048,0x00000345,0x0004003d,0x00000006,0x00000366,0x00000365,0x00050085, + 0x00000006,0x00000367,0x00000364,0x00000366,0x0004003d,0x00000006,0x00000368,0x0000031f, + 0x00050081,0x00000006,0x00000369,0x00000368,0x00000367,0x0003003e,0x0000031f,0x00000369, + 0x000200f9,0x0000034a,0x000200f8,0x0000034a,0x00050041,0x0000000d,0x0000036b,0x00000048, + 0x0000036a,0x0004003d,0x00000006,0x0000036c,0x0000036b,0x000500ba,0x0000009b,0x0000036d, + 0x0000036c,0x0000009a,0x000300f7,0x0000036f,0x00000000,0x000400fa,0x0000036d,0x0000036e, + 0x0000036f,0x000200f8,0x0000036e,0x0004003d,0x00000006,0x00000372,0x00000044,0x0004003d, + 0x00000006,0x00000373,0x00000045,0x00050083,0x00000006,0x00000374,0x00000372,0x00000373, + 0x00050085,0x00000006,0x00000375,0x00000371,0x00000374,0x00050081,0x00000006,0x00000376, + 0x00000371,0x00000375,0x0003003e,0x00000370,0x00000376,0x00060041,0x0000000d,0x0000037b, + 0x00000043,0x000002c9,0x000002a3,0x0004003d,0x00000006,0x0000037c,0x0000037b,0x00060041, + 0x0000000d,0x0000037d,0x00000043,0x000002a3,0x000002c9,0x0004003d,0x00000006,0x0000037e, + 0x0000037d,0x0004003d,0x00000006,0x0000037f,0x00000370,0x0008000c,0x00000006,0x00000380, + 0x00000001,0x0000002e,0x0000037c,0x0000037e,0x0000037f,0x00050041,0x0000000d,0x00000381, + 0x0000037a,0x000002a3,0x0003003e,0x00000381,0x00000380,0x00060041,0x0000000d,0x00000382, + 0x00000043,0x000002ca,0x000002c9,0x0004003d,0x00000006,0x00000383,0x00000382,0x00060041, + 0x0000000d,0x00000384,0x00000043,0x000002c9,0x000002ca,0x0004003d,0x00000006,0x00000385, + 0x00000384,0x0004003d,0x00000006,0x00000386,0x00000370,0x0008000c,0x00000006,0x00000387, + 0x00000001,0x0000002e,0x00000383,0x00000385,0x00000386,0x00050041,0x0000000d,0x00000388, + 0x0000037a,0x000002ca,0x0003003e,0x00000388,0x00000387,0x00060041,0x0000000d,0x00000389, + 0x00000043,0x000002cb,0x000002ca,0x0004003d,0x00000006,0x0000038a,0x00000389,0x00060041, + 0x0000000d,0x0000038b,0x00000043,0x000002ca,0x000002cb,0x0004003d,0x00000006,0x0000038c, + 0x0000038b,0x0004003d,0x00000006,0x0000038d,0x00000370,0x0008000c,0x00000006,0x0000038e, + 0x00000001,0x0000002e,0x0000038a,0x0000038c,0x0000038d,0x00050041,0x0000000d,0x0000038f, + 0x0000037a,0x000002cc,0x0003003e,0x0000038f,0x0000038e,0x0004003d,0x00000006,0x00000390, + 0x00000370,0x00050083,0x00000006,0x00000391,0x00000390,0x00000371,0x0003003e,0x00000370, + 0x00000391,0x0004003d,0x00000006,0x00000393,0x00000370,0x000500be,0x0000009b,0x00000394, + 0x00000393,0x0000009a,0x000300f7,0x00000397,0x00000000,0x000400fa,0x00000394,0x00000396, + 0x0000039a,0x000200f8,0x00000396,0x00060041,0x0000000d,0x00000398,0x00000043,0x00000150, + 0x000002c9,0x0004003d,0x00000006,0x00000399,0x00000398,0x0003003e,0x00000395,0x00000399, + 0x000200f9,0x00000397,0x000200f8,0x0000039a,0x00060041,0x0000000d,0x0000039b,0x00000043, + 0x000002c9,0x00000150,0x0004003d,0x00000006,0x0000039c,0x0000039b,0x0003003e,0x00000395, + 0x0000039c,0x000200f9,0x00000397,0x000200f8,0x00000397,0x0004003d,0x00000006,0x0000039d, + 0x00000395,0x0003003e,0x00000392,0x0000039d,0x0004003d,0x00000006,0x0000039f,0x00000370, + 0x000500be,0x0000009b,0x000003a0,0x0000039f,0x0000009a,0x000300f7,0x000003a3,0x00000000, + 0x000400fa,0x000003a0,0x000003a2,0x000003a6,0x000200f8,0x000003a2,0x00060041,0x0000000d, + 0x000003a4,0x00000043,0x000002a3,0x000002ca,0x0004003d,0x00000006,0x000003a5,0x000003a4, + 0x0003003e,0x000003a1,0x000003a5,0x000200f9,0x000003a3,0x000200f8,0x000003a6,0x00060041, + 0x0000000d,0x000003a7,0x00000043,0x000002ca,0x000002a3,0x0004003d,0x00000006,0x000003a8, + 0x000003a7,0x0003003e,0x000003a1,0x000003a8,0x000200f9,0x000003a3,0x000200f8,0x000003a3, + 0x0004003d,0x00000006,0x000003a9,0x000003a1,0x0003003e,0x0000039e,0x000003a9,0x0004003d, + 0x00000006,0x000003ab,0x00000370,0x000500be,0x0000009b,0x000003ac,0x000003ab,0x0000009a, + 0x000300f7,0x000003af,0x00000000,0x000400fa,0x000003ac,0x000003ae,0x000003b2,0x000200f8, + 0x000003ae,0x00060041,0x0000000d,0x000003b0,0x00000043,0x000002c9,0x000002cb,0x0004003d, + 0x00000006,0x000003b1,0x000003b0,0x0003003e,0x000003ad,0x000003b1,0x000200f9,0x000003af, + 0x000200f8,0x000003b2,0x00060041,0x0000000d,0x000003b3,0x00000043,0x000002cb,0x000002c9, + 0x0004003d,0x00000006,0x000003b4,0x000003b3,0x0003003e,0x000003ad,0x000003b4,0x000200f9, + 0x000003af,0x000200f8,0x000003af,0x0004003d,0x00000006,0x000003b5,0x000003ad,0x0003003e, + 0x000003aa,0x000003b5,0x0004003d,0x00000006,0x000003b7,0x00000370,0x000500be,0x0000009b, + 0x000003b8,0x000003b7,0x0000009a,0x000300f7,0x000003bb,0x00000000,0x000400fa,0x000003b8, + 0x000003ba,0x000003be,0x000200f8,0x000003ba,0x00060041,0x0000000d,0x000003bc,0x00000043, + 0x000002ca,0x000002cc,0x0004003d,0x00000006,0x000003bd,0x000003bc,0x0003003e,0x000003b9, + 0x000003bd,0x000200f9,0x000003bb,0x000200f8,0x000003be,0x00060041,0x0000000d,0x000003bf, + 0x00000043,0x000002cc,0x000002ca,0x0004003d,0x00000006,0x000003c0,0x000003bf,0x0003003e, + 0x000003b9,0x000003c0,0x000200f9,0x000003bb,0x000200f8,0x000003bb,0x0004003d,0x00000006, + 0x000003c1,0x000003b9,0x0003003e,0x000003b6,0x000003c1,0x00060041,0x0000000d,0x000003c2, + 0x00000043,0x000002a3,0x000002a3,0x0004003d,0x00000006,0x000003c3,0x000003c2,0x0004003d, + 0x00000006,0x000003c4,0x00000392,0x0004003d,0x00000006,0x000003c5,0x00000370,0x0006000c, + 0x00000006,0x000003c6,0x00000001,0x00000004,0x000003c5,0x0008000c,0x00000006,0x000003c7, + 0x00000001,0x0000002e,0x000003c3,0x000003c4,0x000003c6,0x00050041,0x0000000d,0x000003c8, + 0x0000037a,0x00000150,0x0003003e,0x000003c8,0x000003c7,0x00060041,0x0000000d,0x000003c9, + 0x00000043,0x000002c9,0x000002c9,0x0004003d,0x00000006,0x000003ca,0x000003c9,0x0004003d, + 0x00000006,0x000003cb,0x0000039e,0x0004003d,0x00000006,0x000003cc,0x00000370,0x0006000c, + 0x00000006,0x000003cd,0x00000001,0x00000004,0x000003cc,0x0008000c,0x00000006,0x000003ce, + 0x00000001,0x0000002e,0x000003ca,0x000003cb,0x000003cd,0x00050041,0x0000000d,0x000003cf, + 0x0000037a,0x000002c9,0x0003003e,0x000003cf,0x000003ce,0x00060041,0x0000000d,0x000003d0, + 0x00000043,0x000002ca,0x000002ca,0x0004003d,0x00000006,0x000003d1,0x000003d0,0x0004003d, + 0x00000006,0x000003d2,0x000003aa,0x0004003d,0x00000006,0x000003d3,0x00000370,0x0006000c, + 0x00000006,0x000003d4,0x00000001,0x00000004,0x000003d3,0x0008000c,0x00000006,0x000003d5, + 0x00000001,0x0000002e,0x000003d1,0x000003d2,0x000003d4,0x00050041,0x0000000d,0x000003d6, + 0x0000037a,0x000002cb,0x0003003e,0x000003d6,0x000003d5,0x00060041,0x0000000d,0x000003d7, + 0x00000043,0x000002cb,0x000002cb,0x0004003d,0x00000006,0x000003d8,0x000003d7,0x0004003d, + 0x00000006,0x000003d9,0x000003b6,0x0004003d,0x00000006,0x000003da,0x00000370,0x0006000c, + 0x00000006,0x000003db,0x00000001,0x00000004,0x000003da,0x0008000c,0x00000006,0x000003dc, + 0x00000001,0x0000002e,0x000003d8,0x000003d9,0x000003db,0x00050041,0x0000000d,0x000003dd, + 0x0000037a,0x0000015c,0x0003003e,0x000003dd,0x000003dc,0x0004003d,0x00000006,0x000003df, + 0x00000044,0x0004003d,0x00000006,0x000003e0,0x00000045,0x00050081,0x00000006,0x000003e1, + 0x000003df,0x000003e0,0x0003003e,0x000003de,0x000003e1,0x0004003d,0x00000006,0x000003e2, + 0x000003de,0x000500be,0x0000009b,0x000003e3,0x000003e2,0x000000a8,0x000300f7,0x000003e5, + 0x00000000,0x000400fa,0x000003e3,0x000003e4,0x000003f9,0x000200f8,0x000003e4,0x0003003e, + 0x000003e6,0x00000150,0x000200f9,0x000003e7,0x000200f8,0x000003e7,0x000400f6,0x000003e9, + 0x000003ea,0x00000000,0x000200f9,0x000003eb,0x000200f8,0x000003eb,0x0004003d,0x00000025, + 0x000003ec,0x000003e6,0x000500b1,0x0000009b,0x000003ed,0x000003ec,0x0000015c,0x000400fa, + 0x000003ed,0x000003e8,0x000003e9,0x000200f8,0x000003e8,0x0004003d,0x00000025,0x000003ef, + 0x000003e6,0x0004003d,0x00000025,0x000003f0,0x000003e6,0x00050080,0x00000025,0x000003f1, + 0x000003f0,0x000002a3,0x00050041,0x0000000d,0x000003f2,0x0000037a,0x000003f1,0x0004003d, + 0x00000006,0x000003f3,0x000003f2,0x00050041,0x0000000d,0x000003f4,0x000003ee,0x000003ef, + 0x0003003e,0x000003f4,0x000003f3,0x000200f9,0x000003ea,0x000200f8,0x000003ea,0x0004003d, + 0x00000025,0x000003f5,0x000003e6,0x00050080,0x00000025,0x000003f6,0x000003f5,0x000002a3, + 0x0003003e,0x000003e6,0x000003f6,0x000200f9,0x000003e7,0x000200f8,0x000003e9,0x0004003d, + 0x00000006,0x000003f7,0x000003de,0x00050083,0x00000006,0x000003f8,0x000003f7,0x000000a8, + 0x0003003e,0x000003de,0x000003f8,0x000200f9,0x000003e5,0x000200f8,0x000003f9,0x0003003e, + 0x000003fa,0x00000150,0x000200f9,0x000003fb,0x000200f8,0x000003fb,0x000400f6,0x000003fd, + 0x000003fe,0x00000000,0x000200f9,0x000003ff,0x000200f8,0x000003ff,0x0004003d,0x00000025, + 0x00000400,0x000003fa,0x000500b1,0x0000009b,0x00000401,0x00000400,0x0000015c,0x000400fa, + 0x00000401,0x000003fc,0x000003fd,0x000200f8,0x000003fc,0x0004003d,0x00000025,0x00000402, + 0x000003fa,0x0004003d,0x00000025,0x00000403,0x000003fa,0x00050041,0x0000000d,0x00000404, + 0x0000037a,0x00000403,0x0004003d,0x00000006,0x00000405,0x00000404,0x00050041,0x0000000d, + 0x00000406,0x000003ee,0x00000402,0x0003003e,0x00000406,0x00000405,0x000200f9,0x000003fe, + 0x000200f8,0x000003fe,0x0004003d,0x00000025,0x00000407,0x000003fa,0x00050080,0x00000025, + 0x00000408,0x00000407,0x000002a3,0x0003003e,0x000003fa,0x00000408,0x000200f9,0x000003fb, + 0x000200f8,0x000003fd,0x000200f9,0x000003e5,0x000200f8,0x000003e5,0x0004003d,0x00000006, + 0x00000409,0x000003de,0x00050085,0x00000006,0x0000040b,0x00000409,0x0000040a,0x0004006e, + 0x00000025,0x0000040c,0x0000040b,0x0004003d,0x00000033,0x0000040e,0x000003ee,0x0003003e, + 0x0000040d,0x0000040e,0x0003003e,0x0000040f,0x0000040c,0x00060039,0x00000006,0x00000410, + 0x00000038,0x0000040d,0x0000040f,0x00050041,0x0000000d,0x00000411,0x00000048,0x0000036a, + 0x0004003d,0x00000006,0x00000412,0x00000411,0x00050085,0x00000006,0x00000413,0x00000410, + 0x00000412,0x0004003d,0x00000006,0x00000414,0x0000031f,0x00050081,0x00000006,0x00000415, + 0x00000414,0x00000413,0x0003003e,0x0000031f,0x00000415,0x000200f9,0x0000036f,0x000200f8, + 0x0000036f,0x00050041,0x0000000d,0x00000417,0x00000048,0x00000416,0x0004003d,0x00000006, + 0x00000418,0x00000417,0x000500ba,0x0000009b,0x00000419,0x00000418,0x0000009a,0x000300f7, + 0x0000041b,0x00000000,0x000400fa,0x00000419,0x0000041a,0x0000041b,0x000200f8,0x0000041a, + 0x0004003d,0x00000006,0x0000041d,0x00000044,0x0004003d,0x00000006,0x0000041e,0x00000045, + 0x00050081,0x00000006,0x0000041f,0x0000041d,0x0000041e,0x00050085,0x00000006,0x00000420, + 0x00000371,0x0000041f,0x0003003e,0x0000041c,0x00000420,0x00060041,0x0000000d,0x00000422, + 0x00000043,0x000002ca,0x000002a3,0x0004003d,0x00000006,0x00000423,0x00000422,0x00060041, + 0x0000000d,0x00000424,0x00000043,0x000002cb,0x000002c9,0x0004003d,0x00000006,0x00000425, + 0x00000424,0x0004003d,0x00000006,0x00000426,0x0000041c,0x0008000c,0x00000006,0x00000427, + 0x00000001,0x0000002e,0x00000423,0x00000425,0x00000426,0x00050041,0x0000000d,0x00000428, + 0x00000421,0x000002a3,0x0003003e,0x00000428,0x00000427,0x00060041,0x0000000d,0x00000429, + 0x00000043,0x000002c9,0x000002c9,0x0004003d,0x00000006,0x0000042a,0x00000429,0x00060041, + 0x0000000d,0x0000042b,0x00000043,0x000002ca,0x000002ca,0x0004003d,0x00000006,0x0000042c, + 0x0000042b,0x0004003d,0x00000006,0x0000042d,0x0000041c,0x0008000c,0x00000006,0x0000042e, + 0x00000001,0x0000002e,0x0000042a,0x0000042c,0x0000042d,0x00050041,0x0000000d,0x0000042f, + 0x00000421,0x000002ca,0x0003003e,0x0000042f,0x0000042e,0x00060041,0x0000000d,0x00000430, + 0x00000043,0x000002a3,0x000002ca,0x0004003d,0x00000006,0x00000431,0x00000430,0x00060041, + 0x0000000d,0x00000432,0x00000043,0x000002c9,0x000002cb,0x0004003d,0x00000006,0x00000433, + 0x00000432,0x0004003d,0x00000006,0x00000434,0x0000041c,0x0008000c,0x00000006,0x00000435, + 0x00000001,0x0000002e,0x00000431,0x00000433,0x00000434,0x00050041,0x0000000d,0x00000436, + 0x00000421,0x000002cc,0x0003003e,0x00000436,0x00000435,0x0004003d,0x00000006,0x00000437, + 0x0000041c,0x00050083,0x00000006,0x00000438,0x00000437,0x00000371,0x0003003e,0x0000041c, + 0x00000438,0x0004003d,0x00000006,0x0000043a,0x0000041c,0x000500be,0x0000009b,0x0000043b, + 0x0000043a,0x0000009a,0x000300f7,0x0000043e,0x00000000,0x000400fa,0x0000043b,0x0000043d, + 0x00000441,0x000200f8,0x0000043d,0x00060041,0x0000000d,0x0000043f,0x00000043,0x000002cc, + 0x000002c9,0x0004003d,0x00000006,0x00000440,0x0000043f,0x0003003e,0x0000043c,0x00000440, + 0x000200f9,0x0000043e,0x000200f8,0x00000441,0x00060041,0x0000000d,0x00000442,0x00000043, + 0x000002ca,0x00000150,0x0004003d,0x00000006,0x00000443,0x00000442,0x0003003e,0x0000043c, + 0x00000443,0x000200f9,0x0000043e,0x000200f8,0x0000043e,0x0004003d,0x00000006,0x00000444, + 0x0000043c,0x0003003e,0x00000439,0x00000444,0x0004003d,0x00000006,0x00000446,0x0000041c, + 0x000500be,0x0000009b,0x00000447,0x00000446,0x0000009a,0x000300f7,0x0000044a,0x00000000, + 0x000400fa,0x00000447,0x00000449,0x0000044d,0x000200f8,0x00000449,0x00060041,0x0000000d, + 0x0000044b,0x00000043,0x000002cb,0x000002ca,0x0004003d,0x00000006,0x0000044c,0x0000044b, + 0x0003003e,0x00000448,0x0000044c,0x000200f9,0x0000044a,0x000200f8,0x0000044d,0x00060041, + 0x0000000d,0x0000044e,0x00000043,0x000002c9,0x000002a3,0x0004003d,0x00000006,0x0000044f, + 0x0000044e,0x0003003e,0x00000448,0x0000044f,0x000200f9,0x0000044a,0x000200f8,0x0000044a, + 0x0004003d,0x00000006,0x00000450,0x00000448,0x0003003e,0x00000445,0x00000450,0x0004003d, + 0x00000006,0x00000452,0x0000041c,0x000500be,0x0000009b,0x00000453,0x00000452,0x0000009a, + 0x000300f7,0x00000456,0x00000000,0x000400fa,0x00000453,0x00000455,0x00000459,0x000200f8, + 0x00000455,0x00060041,0x0000000d,0x00000457,0x00000043,0x000002ca,0x000002cb,0x0004003d, + 0x00000006,0x00000458,0x00000457,0x0003003e,0x00000454,0x00000458,0x000200f9,0x00000456, + 0x000200f8,0x00000459,0x00060041,0x0000000d,0x0000045a,0x00000043,0x000002a3,0x000002c9, + 0x0004003d,0x00000006,0x0000045b,0x0000045a,0x0003003e,0x00000454,0x0000045b,0x000200f9, + 0x00000456,0x000200f8,0x00000456,0x0004003d,0x00000006,0x0000045c,0x00000454,0x0003003e, + 0x00000451,0x0000045c,0x0004003d,0x00000006,0x0000045e,0x0000041c,0x000500be,0x0000009b, + 0x0000045f,0x0000045e,0x0000009a,0x000300f7,0x00000462,0x00000000,0x000400fa,0x0000045f, + 0x00000461,0x00000465,0x000200f8,0x00000461,0x00060041,0x0000000d,0x00000463,0x00000043, + 0x000002c9,0x000002cc,0x0004003d,0x00000006,0x00000464,0x00000463,0x0003003e,0x00000460, + 0x00000464,0x000200f9,0x00000462,0x000200f8,0x00000465,0x00060041,0x0000000d,0x00000466, + 0x00000043,0x00000150,0x000002ca,0x0004003d,0x00000006,0x00000467,0x00000466,0x0003003e, + 0x00000460,0x00000467,0x000200f9,0x00000462,0x000200f8,0x00000462,0x0004003d,0x00000006, + 0x00000468,0x00000460,0x0003003e,0x0000045d,0x00000468,0x00060041,0x0000000d,0x00000469, + 0x00000043,0x000002cb,0x000002a3,0x0004003d,0x00000006,0x0000046a,0x00000469,0x0004003d, + 0x00000006,0x0000046b,0x00000439,0x0004003d,0x00000006,0x0000046c,0x0000041c,0x0006000c, + 0x00000006,0x0000046d,0x00000001,0x00000004,0x0000046c,0x0008000c,0x00000006,0x0000046e, + 0x00000001,0x0000002e,0x0000046a,0x0000046b,0x0000046d,0x00050041,0x0000000d,0x0000046f, + 0x00000421,0x00000150,0x0003003e,0x0000046f,0x0000046e,0x00060041,0x0000000d,0x00000470, + 0x00000043,0x000002ca,0x000002c9,0x0004003d,0x00000006,0x00000471,0x00000470,0x0004003d, + 0x00000006,0x00000472,0x00000445,0x0004003d,0x00000006,0x00000473,0x0000041c,0x0006000c, + 0x00000006,0x00000474,0x00000001,0x00000004,0x00000473,0x0008000c,0x00000006,0x00000475, + 0x00000001,0x0000002e,0x00000471,0x00000472,0x00000474,0x00050041,0x0000000d,0x00000476, + 0x00000421,0x000002c9,0x0003003e,0x00000476,0x00000475,0x00060041,0x0000000d,0x00000477, + 0x00000043,0x000002c9,0x000002ca,0x0004003d,0x00000006,0x00000478,0x00000477,0x0004003d, + 0x00000006,0x00000479,0x00000451,0x0004003d,0x00000006,0x0000047a,0x0000041c,0x0006000c, + 0x00000006,0x0000047b,0x00000001,0x00000004,0x0000047a,0x0008000c,0x00000006,0x0000047c, + 0x00000001,0x0000002e,0x00000478,0x00000479,0x0000047b,0x00050041,0x0000000d,0x0000047d, + 0x00000421,0x000002cb,0x0003003e,0x0000047d,0x0000047c,0x00060041,0x0000000d,0x0000047e, + 0x00000043,0x000002a3,0x000002cb,0x0004003d,0x00000006,0x0000047f,0x0000047e,0x0004003d, + 0x00000006,0x00000480,0x0000045d,0x0004003d,0x00000006,0x00000481,0x0000041c,0x0006000c, + 0x00000006,0x00000482,0x00000001,0x00000004,0x00000481,0x0008000c,0x00000006,0x00000483, + 0x00000001,0x0000002e,0x0000047f,0x00000480,0x00000482,0x00050041,0x0000000d,0x00000484, + 0x00000421,0x0000015c,0x0003003e,0x00000484,0x00000483,0x0004003d,0x00000006,0x00000486, + 0x00000044,0x0004003d,0x00000006,0x00000487,0x00000045,0x00050083,0x00000006,0x00000488, + 0x00000486,0x00000487,0x00050081,0x00000006,0x00000489,0x000000a8,0x00000488,0x0003003e, + 0x00000485,0x00000489,0x0004003d,0x00000006,0x0000048a,0x00000485,0x000500be,0x0000009b, + 0x0000048b,0x0000048a,0x000000a8,0x000300f7,0x0000048d,0x00000000,0x000400fa,0x0000048b, + 0x0000048c,0x000004a1,0x000200f8,0x0000048c,0x0003003e,0x0000048e,0x00000150,0x000200f9, + 0x0000048f,0x000200f8,0x0000048f,0x000400f6,0x00000491,0x00000492,0x00000000,0x000200f9, + 0x00000493,0x000200f8,0x00000493,0x0004003d,0x00000025,0x00000494,0x0000048e,0x000500b1, + 0x0000009b,0x00000495,0x00000494,0x0000015c,0x000400fa,0x00000495,0x00000490,0x00000491, + 0x000200f8,0x00000490,0x0004003d,0x00000025,0x00000497,0x0000048e,0x0004003d,0x00000025, + 0x00000498,0x0000048e,0x00050080,0x00000025,0x00000499,0x00000498,0x000002a3,0x00050041, + 0x0000000d,0x0000049a,0x00000421,0x00000499,0x0004003d,0x00000006,0x0000049b,0x0000049a, + 0x00050041,0x0000000d,0x0000049c,0x00000496,0x00000497,0x0003003e,0x0000049c,0x0000049b, + 0x000200f9,0x00000492,0x000200f8,0x00000492,0x0004003d,0x00000025,0x0000049d,0x0000048e, + 0x00050080,0x00000025,0x0000049e,0x0000049d,0x000002a3,0x0003003e,0x0000048e,0x0000049e, + 0x000200f9,0x0000048f,0x000200f8,0x00000491,0x0004003d,0x00000006,0x0000049f,0x00000485, + 0x00050083,0x00000006,0x000004a0,0x0000049f,0x000000a8,0x0003003e,0x00000485,0x000004a0, + 0x000200f9,0x0000048d,0x000200f8,0x000004a1,0x0003003e,0x000004a2,0x00000150,0x000200f9, + 0x000004a3,0x000200f8,0x000004a3,0x000400f6,0x000004a5,0x000004a6,0x00000000,0x000200f9, + 0x000004a7,0x000200f8,0x000004a7,0x0004003d,0x00000025,0x000004a8,0x000004a2,0x000500b1, + 0x0000009b,0x000004a9,0x000004a8,0x0000015c,0x000400fa,0x000004a9,0x000004a4,0x000004a5, + 0x000200f8,0x000004a4,0x0004003d,0x00000025,0x000004aa,0x000004a2,0x0004003d,0x00000025, + 0x000004ab,0x000004a2,0x00050041,0x0000000d,0x000004ac,0x00000421,0x000004ab,0x0004003d, + 0x00000006,0x000004ad,0x000004ac,0x00050041,0x0000000d,0x000004ae,0x00000496,0x000004aa, + 0x0003003e,0x000004ae,0x000004ad,0x000200f9,0x000004a6,0x000200f8,0x000004a6,0x0004003d, + 0x00000025,0x000004af,0x000004a2,0x00050080,0x00000025,0x000004b0,0x000004af,0x000002a3, + 0x0003003e,0x000004a2,0x000004b0,0x000200f9,0x000004a3,0x000200f8,0x000004a5,0x000200f9, + 0x0000048d,0x000200f8,0x0000048d,0x0004003d,0x00000006,0x000004b1,0x00000485,0x00050085, + 0x00000006,0x000004b2,0x000004b1,0x0000040a,0x0004006e,0x00000025,0x000004b3,0x000004b2, + 0x0004003d,0x00000033,0x000004b5,0x00000496,0x0003003e,0x000004b4,0x000004b5,0x0003003e, + 0x000004b6,0x000004b3,0x00060039,0x00000006,0x000004b7,0x00000038,0x000004b4,0x000004b6, + 0x00050041,0x0000000d,0x000004b8,0x00000048,0x00000416,0x0004003d,0x00000006,0x000004b9, + 0x000004b8,0x00050085,0x00000006,0x000004ba,0x000004b7,0x000004b9,0x0004003d,0x00000006, + 0x000004bb,0x0000031f,0x00050081,0x00000006,0x000004bc,0x000004bb,0x000004ba,0x0003003e, + 0x0000031f,0x000004bc,0x000200f9,0x0000041b,0x000200f8,0x0000041b,0x0004003d,0x00000006, + 0x000004bd,0x0000031f,0x000200fe,0x000004bd,0x00010038 }; diff --git a/app/src/main/cpp/shaders/nis_luma.frag b/app/src/main/cpp/shaders/nis_luma.frag new file mode 100644 index 0000000000..b1bdbebcb7 --- /dev/null +++ b/app/src/main/cpp/shaders/nis_luma.frag @@ -0,0 +1,36 @@ +#version 450 + +// ============================================================================= +// NIS prepass for nis3.frag: the game image copied 1:1 with its NIS luma in +// alpha (the compositor never uses the alpha of these targets). nis3.frag then +// reads four luma texels per textureGather instead of computing luma for each +// of 36 fetches per output pixel. +// +// Runs at the game (input) resolution into a target of the same size, so the +// output pixel reads its input pixel 1:1 (texelFetch at gl_FragCoord). +// Luma weights = nis.frag getY() (NVIDIA NIS, SDR: BT.709). +// ============================================================================= + +// DD_HALF: colour and luma in mediump; the texel address from gl_FragCoord stays highp +// (no default mediump: a 16-bit gl_FragCoord rounds pixel centres past x = 1024, e.g. +// 1279.5 -> 1280, and texelFetch then reads the wrong or an outside texel). +#ifdef DD_HALF +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0); full target +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out BL_MP vec4 outColor; + +void main() { + highp ivec2 p = ivec2(gl_FragCoord.xy); + BL_MP vec3 c = texelFetch(InputTexture, p, 0).rgb; + outColor = vec4(c, 0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b); +} diff --git a/app/src/main/cpp/shaders/nis_luma_half_frag.h b/app/src/main/cpp/shaders/nis_luma_half_frag.h new file mode 100644 index 0000000000..f03f042715 --- /dev/null +++ b/app/src/main/cpp/shaders/nis_luma_half_frag.h @@ -0,0 +1,58 @@ + // 1116.2.0 + #pragma once +const uint32_t nis_luma_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x0000003e,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0008000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000d,0x00000020,0x0000003d, + 0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004, + 0x6e69616d,0x00000000,0x00030005,0x00000009,0x00000070,0x00060005,0x0000000d,0x465f6c67, + 0x43676172,0x64726f6f,0x00000000,0x00030005,0x00000014,0x00000063,0x00060005,0x00000018, + 0x75706e49,0x78655474,0x65727574,0x00000000,0x00050005,0x00000020,0x4374756f,0x726f6c6f, + 0x00000000,0x00030005,0x00000039,0x00004350,0x00040006,0x00000039,0x00000000,0x0063646e, + 0x00030005,0x0000003b,0x00006370,0x00060005,0x0000003d,0x67617266,0x43786554,0x64726f6f, + 0x00000000,0x00040047,0x0000000d,0x0000000b,0x0000000f,0x00030047,0x00000014,0x00000000, + 0x00030047,0x00000018,0x00000000,0x00040047,0x00000018,0x00000021,0x00000000,0x00040047, + 0x00000018,0x00000022,0x00000000,0x00030047,0x00000019,0x00000000,0x00030047,0x0000001d, + 0x00000000,0x00030047,0x0000001e,0x00000000,0x00030047,0x00000020,0x00000000,0x00040047, + 0x00000020,0x0000001e,0x00000000,0x00030047,0x00000021,0x00000000,0x00030047,0x00000027, + 0x00000000,0x00030047,0x00000028,0x00000000,0x00030047,0x0000002c,0x00000000,0x00030047, + 0x0000002d,0x00000000,0x00030047,0x0000002e,0x00000000,0x00030047,0x00000032,0x00000000, + 0x00030047,0x00000033,0x00000000,0x00030047,0x00000034,0x00000000,0x00030047,0x00000035, + 0x00000000,0x00030047,0x00000036,0x00000000,0x00030047,0x00000037,0x00000000,0x00030047, + 0x00000038,0x00000000,0x00030047,0x00000039,0x00000002,0x00050048,0x00000039,0x00000000, + 0x00000023,0x00000000,0x00040047,0x0000003d,0x0000001e,0x00000000,0x00020013,0x00000002, + 0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040017, + 0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00030016, + 0x0000000a,0x00000020,0x00040017,0x0000000b,0x0000000a,0x00000004,0x00040020,0x0000000c, + 0x00000001,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040017,0x0000000e, + 0x0000000a,0x00000002,0x00040017,0x00000012,0x0000000a,0x00000003,0x00040020,0x00000013, + 0x00000007,0x00000012,0x00090019,0x00000015,0x0000000a,0x00000001,0x00000000,0x00000000, + 0x00000000,0x00000001,0x00000000,0x0003001b,0x00000016,0x00000015,0x00040020,0x00000017, + 0x00000000,0x00000016,0x0004003b,0x00000017,0x00000018,0x00000000,0x0004002b,0x00000006, + 0x0000001b,0x00000000,0x00040020,0x0000001f,0x00000003,0x0000000b,0x0004003b,0x0000001f, + 0x00000020,0x00000003,0x0004002b,0x0000000a,0x00000022,0x3e59b3d0,0x00040015,0x00000023, + 0x00000020,0x00000000,0x0004002b,0x00000023,0x00000024,0x00000000,0x00040020,0x00000025, + 0x00000007,0x0000000a,0x0004002b,0x0000000a,0x00000029,0x3f371759,0x0004002b,0x00000023, + 0x0000002a,0x00000001,0x0004002b,0x0000000a,0x0000002f,0x3d93dd98,0x0004002b,0x00000023, + 0x00000030,0x00000002,0x0003001e,0x00000039,0x0000000b,0x00040020,0x0000003a,0x00000009, + 0x00000039,0x0004003b,0x0000003a,0x0000003b,0x00000009,0x00040020,0x0000003c,0x00000001, + 0x0000000e,0x0004003b,0x0000003c,0x0000003d,0x00000001,0x00050036,0x00000002,0x00000004, + 0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007, + 0x0004003b,0x00000013,0x00000014,0x00000007,0x0004003d,0x0000000b,0x0000000f,0x0000000d, + 0x0007004f,0x0000000e,0x00000010,0x0000000f,0x0000000f,0x00000000,0x00000001,0x0004006e, + 0x00000007,0x00000011,0x00000010,0x0003003e,0x00000009,0x00000011,0x0004003d,0x00000016, + 0x00000019,0x00000018,0x0004003d,0x00000007,0x0000001a,0x00000009,0x00040064,0x00000015, + 0x0000001c,0x00000019,0x0007005f,0x0000000b,0x0000001d,0x0000001c,0x0000001a,0x00000002, + 0x0000001b,0x0008004f,0x00000012,0x0000001e,0x0000001d,0x0000001d,0x00000000,0x00000001, + 0x00000002,0x0003003e,0x00000014,0x0000001e,0x0004003d,0x00000012,0x00000021,0x00000014, + 0x00050041,0x00000025,0x00000026,0x00000014,0x00000024,0x0004003d,0x0000000a,0x00000027, + 0x00000026,0x00050085,0x0000000a,0x00000028,0x00000022,0x00000027,0x00050041,0x00000025, + 0x0000002b,0x00000014,0x0000002a,0x0004003d,0x0000000a,0x0000002c,0x0000002b,0x00050085, + 0x0000000a,0x0000002d,0x00000029,0x0000002c,0x00050081,0x0000000a,0x0000002e,0x00000028, + 0x0000002d,0x00050041,0x00000025,0x00000031,0x00000014,0x00000030,0x0004003d,0x0000000a, + 0x00000032,0x00000031,0x00050085,0x0000000a,0x00000033,0x0000002f,0x00000032,0x00050081, + 0x0000000a,0x00000034,0x0000002e,0x00000033,0x00050051,0x0000000a,0x00000035,0x00000021, + 0x00000000,0x00050051,0x0000000a,0x00000036,0x00000021,0x00000001,0x00050051,0x0000000a, + 0x00000037,0x00000021,0x00000002,0x00070050,0x0000000b,0x00000038,0x00000035,0x00000036, + 0x00000037,0x00000034,0x0003003e,0x00000020,0x00000038,0x000100fd,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/ntsc.frag b/app/src/main/cpp/shaders/ntsc.frag new file mode 100644 index 0000000000..9a57fa230f --- /dev/null +++ b/app/src/main/cpp/shaders/ntsc.frag @@ -0,0 +1,73 @@ +#version 450 + +// ============================================================================= +// NTSC composite-signal artifacts (YIQ chroma modulation + chromatic +// aberration + scanlines + subtle barrel warp) post effect. +// +// Ported verbatim from the OpenGL NTSCCombinedEffect.java shader. GL sampled +// with the varying vUV; here fragTexCoord IS that uv. GL's TextureSize and +// resolution uniforms were both the screen size -> we feed both from pc.resolution. +// Chroma offsets are fixed; this effect does not animate its color phase. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// Runs after HDR, before CRT in the canonical chain (analog signal, then tube). +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // screen size in px (= TextureSize = resolution in GL) +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +#define PI 3.14159265 +#define SCANLINE_INTENSITY 0.35 +#define CHROMA_OFFSET 0.005 +#define BLUR_RADIUS 0.002 +#define WARP_AMOUNT 0.01 +#define SCANLINE_DARKEN 0.5 + +const mat3 yiq_mat = mat3( + 0.299, 0.587, 0.114, + 0.596, -0.275, -0.321, + 0.212, -0.523, 0.311 +); +const mat3 yiq2rgb_mat = mat3( + 1.0, 0.956, 0.621, + 1.0, -0.272, -0.647, + 1.0, -1.106, 1.705 +); + +vec3 applyNTSC(vec2 uv) { + return vec3( + texture(InputTexture, uv + vec2(CHROMA_OFFSET, 0.0)).r, + texture(InputTexture, uv + vec2(0.0, BLUR_RADIUS)).g, + texture(InputTexture, uv - vec2(CHROMA_OFFSET, 0.0)).b + ); +} + +vec3 applyScanlines(vec2 uv, vec3 col) { + float scanline = abs(sin(uv.y * pc.resolution.y * 2.0)) * SCANLINE_INTENSITY; + col *= 1.0 - (scanline * SCANLINE_DARKEN); + return col; +} + +vec2 applyWarp(vec2 uv) { + uv = uv * 2.0 - 1.0; + float r = sqrt(uv.x * uv.x + uv.y * uv.y); + uv += uv * (r * r) * WARP_AMOUNT; + return uv * 0.5 + 0.5; +} + +void main() { + vec2 warpedUV = applyWarp(fragTexCoord); + vec3 centerColor = texture(InputTexture, warpedUV).rgb; + vec3 ntscColor = applyNTSC(warpedUV); + vec3 scanlineColor = applyScanlines(warpedUV, centerColor); + vec3 finalColor = mix(ntscColor, scanlineColor, 0.7); + outColor = vec4(finalColor, 1.0); +} diff --git a/app/src/main/cpp/shaders/ntsc_frag.h b/app/src/main/cpp/shaders/ntsc_frag.h index 409c9d90f0..2b22036f66 100644 --- a/app/src/main/cpp/shaders/ntsc_frag.h +++ b/app/src/main/cpp/shaders/ntsc_frag.h @@ -1,153 +1,126 @@ + // 1116.3.0 #pragma once const uint32_t ntsc_code[] = { - 0x07230203,0x00010000,0x0008000b,0x000000d5,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x07230203,0x00010000,0x0008000b,0x000000af,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x000000bc,0x000000cf,0x00030010, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000077,0x00000091,0x00030010, 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00060005,0x0000000c,0x6c707061,0x53544e79,0x66762843,0x00003b32,0x00030005, - 0x0000000b,0x00007675,0x00070005,0x0000000f,0x6c707061,0x61635379,0x6e696c6e,0x76287365, - 0x003b3266,0x00030005,0x0000000e,0x00007675,0x00060005,0x00000013,0x6c707061,0x72615779, - 0x66762870,0x00003b32,0x00030005,0x00000012,0x00007675,0x00030005,0x00000016,0x006c6f63, - 0x00060005,0x0000001a,0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x00000020, - 0x00716979,0x00050005,0x00000032,0x6f726863,0x6850616d,0x00657361,0x00030005,0x00000038, - 0x00004350,0x00040006,0x00000038,0x00000000,0x0063646e,0x00060006,0x00000038,0x00000001, - 0x6f736572,0x6974756c,0x00006e6f,0x00060006,0x00000038,0x00000002,0x6d617266,0x756f4365, - 0x0000746e,0x00030005,0x0000003a,0x00006370,0x00030005,0x00000058,0x00626772,0x00050005, - 0x00000066,0x616e6966,0x6c6f436c,0x0000726f,0x00030005,0x00000082,0x006c6f63,0x00050005, - 0x00000087,0x6e616373,0x656e696c,0x00000000,0x00030005,0x0000009e,0x00000072,0x00050005, - 0x000000ba,0x70726177,0x56556465,0x00000000,0x00060005,0x000000bc,0x67617266,0x43786554, - 0x64726f6f,0x00000000,0x00040005,0x000000bd,0x61726170,0x0000006d,0x00050005,0x000000c0, - 0x6373746e,0x6f6c6f43,0x00000072,0x00040005,0x000000c1,0x61726170,0x0000006d,0x00060005, - 0x000000c4,0x6e616373,0x656e696c,0x6f6c6f43,0x00000072,0x00040005,0x000000c5,0x61726170, - 0x0000006d,0x00050005,0x000000c8,0x616e6966,0x6c6f436c,0x0000726f,0x00050005,0x000000cf, - 0x4374756f,0x726f6c6f,0x00000000,0x00040047,0x0000001a,0x00000021,0x00000000,0x00040047, - 0x0000001a,0x00000022,0x00000000,0x00030047,0x00000038,0x00000002,0x00050048,0x00000038, - 0x00000000,0x00000023,0x00000000,0x00050048,0x00000038,0x00000001,0x00000023,0x00000010, - 0x00050048,0x00000038,0x00000002,0x00000023,0x00000018,0x00040047,0x000000bc,0x0000001e, - 0x00000000,0x00040047,0x000000cf,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021, - 0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006, - 0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00040017,0x00000009,0x00000006, - 0x00000003,0x00040021,0x0000000a,0x00000009,0x00000008,0x00040021,0x00000011,0x00000007, - 0x00000008,0x00040020,0x00000015,0x00000007,0x00000009,0x00090019,0x00000017,0x00000006, - 0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000018, - 0x00000017,0x00040020,0x00000019,0x00000000,0x00000018,0x0004003b,0x00000019,0x0000001a, - 0x00000000,0x00040017,0x0000001d,0x00000006,0x00000004,0x00040018,0x00000022,0x00000009, - 0x00000003,0x0004002b,0x00000006,0x00000023,0x3e991687,0x0004002b,0x00000006,0x00000024, - 0x3f1645a2,0x0004002b,0x00000006,0x00000025,0x3de978d5,0x0006002c,0x00000009,0x00000026, - 0x00000023,0x00000024,0x00000025,0x0004002b,0x00000006,0x00000027,0x3f189375,0x0004002b, - 0x00000006,0x00000028,0xbe8ccccd,0x0004002b,0x00000006,0x00000029,0xbea45a1d,0x0006002c, - 0x00000009,0x0000002a,0x00000027,0x00000028,0x00000029,0x0004002b,0x00000006,0x0000002b, - 0x3e591687,0x0004002b,0x00000006,0x0000002c,0xbf05e354,0x0004002b,0x00000006,0x0000002d, - 0x3e9f3b64,0x0006002c,0x00000009,0x0000002e,0x0000002b,0x0000002c,0x0000002d,0x0006002c, - 0x00000022,0x0000002f,0x00000026,0x0000002a,0x0000002e,0x00040020,0x00000031,0x00000007, - 0x00000006,0x0004002b,0x00000006,0x00000033,0x40490fdb,0x00040015,0x00000034,0x00000020, - 0x00000000,0x0004002b,0x00000034,0x00000035,0x00000001,0x0005001e,0x00000038,0x0000001d, - 0x00000007,0x00000006,0x00040020,0x00000039,0x00000009,0x00000038,0x0004003b,0x00000039, - 0x0000003a,0x00000009,0x00040015,0x0000003b,0x00000020,0x00000001,0x0004002b,0x0000003b, - 0x0000003c,0x00000001,0x00040020,0x0000003d,0x00000009,0x00000006,0x0004002b,0x00000006, - 0x00000041,0x40000000,0x0004002b,0x0000003b,0x00000043,0x00000002,0x0004002b,0x00000006, - 0x00000049,0x3f000000,0x0004002b,0x00000034,0x00000053,0x00000002,0x0004002b,0x00000006, - 0x0000005a,0x3f800000,0x0004002b,0x00000006,0x0000005b,0x3f74bc6a,0x0004002b,0x00000006, - 0x0000005c,0x3f1ef9db,0x0006002c,0x00000009,0x0000005d,0x0000005a,0x0000005b,0x0000005c, - 0x0004002b,0x00000006,0x0000005e,0xbe8b4396,0x0004002b,0x00000006,0x0000005f,0xbf25a1cb, - 0x0006002c,0x00000009,0x00000060,0x0000005a,0x0000005e,0x0000005f,0x0004002b,0x00000006, - 0x00000061,0xbf8d9168,0x0004002b,0x00000006,0x00000062,0x3fda3d71,0x0006002c,0x00000009, - 0x00000063,0x0000005a,0x00000061,0x00000062,0x0006002c,0x00000022,0x00000064,0x0000005d, - 0x00000060,0x00000063,0x0004002b,0x00000006,0x00000069,0x3ba3d70a,0x0004002b,0x00000006, - 0x0000006a,0x00000000,0x0005002c,0x00000007,0x0000006b,0x00000069,0x0000006a,0x0004002b, - 0x00000034,0x0000006e,0x00000000,0x0004002b,0x00000006,0x00000073,0x3b03126f,0x0005002c, - 0x00000007,0x00000074,0x0000006a,0x00000073,0x0004002b,0x00000006,0x00000090,0x3eb33333, - 0x0004002b,0x00000006,0x000000b0,0x3c23d70a,0x00040020,0x000000bb,0x00000001,0x00000007, - 0x0004003b,0x000000bb,0x000000bc,0x00000001,0x0004002b,0x00000006,0x000000cb,0x3f333333, - 0x00040020,0x000000ce,0x00000003,0x0000001d,0x0004003b,0x000000ce,0x000000cf,0x00000003, + 0x0000000b,0x00007675,0x00080005,0x00000012,0x6c707061,0x61635379,0x6e696c6e,0x76287365, + 0x763b3266,0x003b3366,0x00030005,0x00000010,0x00007675,0x00030005,0x00000011,0x006c6f63, + 0x00060005,0x00000016,0x6c707061,0x72615779,0x66762870,0x00003b32,0x00030005,0x00000015, + 0x00007675,0x00060005,0x0000001b,0x75706e49,0x78655474,0x65727574,0x00000000,0x00050005, + 0x00000039,0x6e616373,0x656e696c,0x00000000,0x00030005,0x0000003c,0x00004350,0x00040006, + 0x0000003c,0x00000000,0x0063646e,0x00060006,0x0000003c,0x00000001,0x6f736572,0x6974756c, + 0x00006e6f,0x00030005,0x0000003e,0x00006370,0x00030005,0x00000059,0x00000072,0x00050005, + 0x00000075,0x70726177,0x56556465,0x00000000,0x00060005,0x00000077,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00040005,0x00000078,0x61726170,0x0000006d,0x00050005,0x0000007b, + 0x746e6563,0x6f437265,0x00726f6c,0x00050005,0x00000080,0x6373746e,0x6f6c6f43,0x00000072, + 0x00040005,0x00000081,0x61726170,0x0000006d,0x00060005,0x00000084,0x6e616373,0x656e696c, + 0x6f6c6f43,0x00000072,0x00040005,0x00000085,0x61726170,0x0000006d,0x00040005,0x00000087, + 0x61726170,0x0000006d,0x00050005,0x0000008a,0x616e6966,0x6c6f436c,0x0000726f,0x00050005, + 0x00000091,0x4374756f,0x726f6c6f,0x00000000,0x00040047,0x0000001b,0x00000021,0x00000000, + 0x00040047,0x0000001b,0x00000022,0x00000000,0x00030047,0x0000003c,0x00000002,0x00050048, + 0x0000003c,0x00000000,0x00000023,0x00000000,0x00050048,0x0000003c,0x00000001,0x00000023, + 0x00000010,0x00040047,0x00000077,0x0000001e,0x00000000,0x00040047,0x00000091,0x0000001e, + 0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006, + 0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007, + 0x00000007,0x00040017,0x00000009,0x00000006,0x00000003,0x00040021,0x0000000a,0x00000009, + 0x00000008,0x00040020,0x0000000e,0x00000007,0x00000009,0x00050021,0x0000000f,0x00000009, + 0x00000008,0x0000000e,0x00040021,0x00000014,0x00000007,0x00000008,0x00090019,0x00000018, + 0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b, + 0x00000019,0x00000018,0x00040020,0x0000001a,0x00000000,0x00000019,0x0004003b,0x0000001a, + 0x0000001b,0x00000000,0x0004002b,0x00000006,0x0000001e,0x3ba3d70a,0x0004002b,0x00000006, + 0x0000001f,0x00000000,0x0005002c,0x00000007,0x00000020,0x0000001e,0x0000001f,0x00040017, + 0x00000022,0x00000006,0x00000004,0x00040015,0x00000024,0x00000020,0x00000000,0x0004002b, + 0x00000024,0x00000025,0x00000000,0x0004002b,0x00000006,0x00000029,0x3b03126f,0x0005002c, + 0x00000007,0x0000002a,0x0000001f,0x00000029,0x0004002b,0x00000024,0x0000002d,0x00000001, + 0x0004002b,0x00000024,0x00000033,0x00000002,0x00040020,0x00000038,0x00000007,0x00000006, + 0x0004001e,0x0000003c,0x00000022,0x00000007,0x00040020,0x0000003d,0x00000009,0x0000003c, + 0x0004003b,0x0000003d,0x0000003e,0x00000009,0x00040015,0x0000003f,0x00000020,0x00000001, + 0x0004002b,0x0000003f,0x00000040,0x00000001,0x00040020,0x00000041,0x00000009,0x00000006, + 0x0004002b,0x00000006,0x00000045,0x40000000,0x0004002b,0x00000006,0x00000049,0x3eb33333, + 0x0004002b,0x00000006,0x0000004b,0x3f800000,0x0004002b,0x00000006,0x0000004d,0x3f000000, + 0x0004002b,0x00000006,0x0000006b,0x3c23d70a,0x00040020,0x00000076,0x00000001,0x00000007, + 0x0004003b,0x00000076,0x00000077,0x00000001,0x0004002b,0x00000006,0x0000008d,0x3f333333, + 0x00040020,0x00000090,0x00000003,0x00000022,0x0004003b,0x00000090,0x00000091,0x00000003, + 0x00040018,0x00000097,0x00000009,0x00000003,0x0004002b,0x00000006,0x00000098,0x3e991687, + 0x0004002b,0x00000006,0x00000099,0x3f1645a2,0x0004002b,0x00000006,0x0000009a,0x3de978d5, + 0x0006002c,0x00000009,0x0000009b,0x00000098,0x00000099,0x0000009a,0x0004002b,0x00000006, + 0x0000009c,0x3f189375,0x0004002b,0x00000006,0x0000009d,0xbe8ccccd,0x0004002b,0x00000006, + 0x0000009e,0xbea45a1d,0x0006002c,0x00000009,0x0000009f,0x0000009c,0x0000009d,0x0000009e, + 0x0004002b,0x00000006,0x000000a0,0x3e591687,0x0004002b,0x00000006,0x000000a1,0xbf05e354, + 0x0004002b,0x00000006,0x000000a2,0x3e9f3b64,0x0006002c,0x00000009,0x000000a3,0x000000a0, + 0x000000a1,0x000000a2,0x0006002c,0x00000097,0x000000a4,0x0000009b,0x0000009f,0x000000a3, + 0x0004002b,0x00000006,0x000000a5,0x3f74bc6a,0x0004002b,0x00000006,0x000000a6,0x3f1ef9db, + 0x0006002c,0x00000009,0x000000a7,0x0000004b,0x000000a5,0x000000a6,0x0004002b,0x00000006, + 0x000000a8,0xbe8b4396,0x0004002b,0x00000006,0x000000a9,0xbf25a1cb,0x0006002c,0x00000009, + 0x000000aa,0x0000004b,0x000000a8,0x000000a9,0x0004002b,0x00000006,0x000000ab,0xbf8d9168, + 0x0004002b,0x00000006,0x000000ac,0x3fda3d71,0x0006002c,0x00000009,0x000000ad,0x0000004b, + 0x000000ab,0x000000ac,0x0006002c,0x00000097,0x000000ae,0x000000a7,0x000000aa,0x000000ad, 0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b, - 0x00000008,0x000000ba,0x00000007,0x0004003b,0x00000008,0x000000bd,0x00000007,0x0004003b, - 0x00000015,0x000000c0,0x00000007,0x0004003b,0x00000008,0x000000c1,0x00000007,0x0004003b, - 0x00000015,0x000000c4,0x00000007,0x0004003b,0x00000008,0x000000c5,0x00000007,0x0004003b, - 0x00000015,0x000000c8,0x00000007,0x0004003d,0x00000007,0x000000be,0x000000bc,0x0003003e, - 0x000000bd,0x000000be,0x00050039,0x00000007,0x000000bf,0x00000013,0x000000bd,0x0003003e, - 0x000000ba,0x000000bf,0x0004003d,0x00000007,0x000000c2,0x000000ba,0x0003003e,0x000000c1, - 0x000000c2,0x00050039,0x00000009,0x000000c3,0x0000000c,0x000000c1,0x0003003e,0x000000c0, - 0x000000c3,0x0004003d,0x00000007,0x000000c6,0x000000ba,0x0003003e,0x000000c5,0x000000c6, - 0x00050039,0x00000009,0x000000c7,0x0000000f,0x000000c5,0x0003003e,0x000000c4,0x000000c7, - 0x0004003d,0x00000009,0x000000c9,0x000000c0,0x0004003d,0x00000009,0x000000ca,0x000000c4, - 0x00060050,0x00000009,0x000000cc,0x000000cb,0x000000cb,0x000000cb,0x0008000c,0x00000009, - 0x000000cd,0x00000001,0x0000002e,0x000000c9,0x000000ca,0x000000cc,0x0003003e,0x000000c8, - 0x000000cd,0x0004003d,0x00000009,0x000000d0,0x000000c8,0x00050051,0x00000006,0x000000d1, - 0x000000d0,0x00000000,0x00050051,0x00000006,0x000000d2,0x000000d0,0x00000001,0x00050051, - 0x00000006,0x000000d3,0x000000d0,0x00000002,0x00070050,0x0000001d,0x000000d4,0x000000d1, - 0x000000d2,0x000000d3,0x0000005a,0x0003003e,0x000000cf,0x000000d4,0x000100fd,0x00010038, + 0x00000008,0x00000075,0x00000007,0x0004003b,0x00000008,0x00000078,0x00000007,0x0004003b, + 0x0000000e,0x0000007b,0x00000007,0x0004003b,0x0000000e,0x00000080,0x00000007,0x0004003b, + 0x00000008,0x00000081,0x00000007,0x0004003b,0x0000000e,0x00000084,0x00000007,0x0004003b, + 0x00000008,0x00000085,0x00000007,0x0004003b,0x0000000e,0x00000087,0x00000007,0x0004003b, + 0x0000000e,0x0000008a,0x00000007,0x0004003d,0x00000007,0x00000079,0x00000077,0x0003003e, + 0x00000078,0x00000079,0x00050039,0x00000007,0x0000007a,0x00000016,0x00000078,0x0003003e, + 0x00000075,0x0000007a,0x0004003d,0x00000019,0x0000007c,0x0000001b,0x0004003d,0x00000007, + 0x0000007d,0x00000075,0x00050057,0x00000022,0x0000007e,0x0000007c,0x0000007d,0x0008004f, + 0x00000009,0x0000007f,0x0000007e,0x0000007e,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x0000007b,0x0000007f,0x0004003d,0x00000007,0x00000082,0x00000075,0x0003003e,0x00000081, + 0x00000082,0x00050039,0x00000009,0x00000083,0x0000000c,0x00000081,0x0003003e,0x00000080, + 0x00000083,0x0004003d,0x00000007,0x00000086,0x00000075,0x0003003e,0x00000085,0x00000086, + 0x0004003d,0x00000009,0x00000088,0x0000007b,0x0003003e,0x00000087,0x00000088,0x00060039, + 0x00000009,0x00000089,0x00000012,0x00000085,0x00000087,0x0003003e,0x00000084,0x00000089, + 0x0004003d,0x00000009,0x0000008b,0x00000080,0x0004003d,0x00000009,0x0000008c,0x00000084, + 0x00060050,0x00000009,0x0000008e,0x0000008d,0x0000008d,0x0000008d,0x0008000c,0x00000009, + 0x0000008f,0x00000001,0x0000002e,0x0000008b,0x0000008c,0x0000008e,0x0003003e,0x0000008a, + 0x0000008f,0x0004003d,0x00000009,0x00000092,0x0000008a,0x00050051,0x00000006,0x00000093, + 0x00000092,0x00000000,0x00050051,0x00000006,0x00000094,0x00000092,0x00000001,0x00050051, + 0x00000006,0x00000095,0x00000092,0x00000002,0x00070050,0x00000022,0x00000096,0x00000093, + 0x00000094,0x00000095,0x0000004b,0x0003003e,0x00000091,0x00000096,0x000100fd,0x00010038, 0x00050036,0x00000009,0x0000000c,0x00000000,0x0000000a,0x00030037,0x00000008,0x0000000b, - 0x000200f8,0x0000000d,0x0004003b,0x00000015,0x00000016,0x00000007,0x0004003b,0x00000015, - 0x00000020,0x00000007,0x0004003b,0x00000031,0x00000032,0x00000007,0x0004003b,0x00000015, - 0x00000058,0x00000007,0x0004003b,0x00000015,0x00000066,0x00000007,0x0004003d,0x00000018, - 0x0000001b,0x0000001a,0x0004003d,0x00000007,0x0000001c,0x0000000b,0x00050057,0x0000001d, - 0x0000001e,0x0000001b,0x0000001c,0x0008004f,0x00000009,0x0000001f,0x0000001e,0x0000001e, - 0x00000000,0x00000001,0x00000002,0x0003003e,0x00000016,0x0000001f,0x0004003d,0x00000009, - 0x00000021,0x00000016,0x00050090,0x00000009,0x00000030,0x00000021,0x0000002f,0x0003003e, - 0x00000020,0x00000030,0x00050041,0x00000031,0x00000036,0x0000000b,0x00000035,0x0004003d, - 0x00000006,0x00000037,0x00000036,0x00060041,0x0000003d,0x0000003e,0x0000003a,0x0000003c, - 0x00000035,0x0004003d,0x00000006,0x0000003f,0x0000003e,0x00050085,0x00000006,0x00000040, - 0x00000037,0x0000003f,0x0005008d,0x00000006,0x00000042,0x00000040,0x00000041,0x00050041, - 0x0000003d,0x00000044,0x0000003a,0x00000043,0x0004003d,0x00000006,0x00000045,0x00000044, - 0x00050081,0x00000006,0x00000046,0x00000042,0x00000045,0x00050085,0x00000006,0x00000047, - 0x00000033,0x00000046,0x0003003e,0x00000032,0x00000047,0x0004003d,0x00000006,0x00000048, - 0x00000032,0x00050085,0x00000006,0x0000004a,0x00000048,0x00000049,0x0006000c,0x00000006, - 0x0000004b,0x00000001,0x0000000e,0x0000004a,0x00050041,0x00000031,0x0000004c,0x00000020, - 0x00000035,0x0004003d,0x00000006,0x0000004d,0x0000004c,0x00050085,0x00000006,0x0000004e, - 0x0000004d,0x0000004b,0x00050041,0x00000031,0x0000004f,0x00000020,0x00000035,0x0003003e, - 0x0000004f,0x0000004e,0x0004003d,0x00000006,0x00000050,0x00000032,0x00050085,0x00000006, - 0x00000051,0x00000050,0x00000049,0x0006000c,0x00000006,0x00000052,0x00000001,0x0000000d, - 0x00000051,0x00050041,0x00000031,0x00000054,0x00000020,0x00000053,0x0004003d,0x00000006, - 0x00000055,0x00000054,0x00050085,0x00000006,0x00000056,0x00000055,0x00000052,0x00050041, - 0x00000031,0x00000057,0x00000020,0x00000053,0x0003003e,0x00000057,0x00000056,0x0004003d, - 0x00000009,0x00000059,0x00000020,0x00050090,0x00000009,0x00000065,0x00000059,0x00000064, - 0x0003003e,0x00000058,0x00000065,0x0004003d,0x00000018,0x00000067,0x0000001a,0x0004003d, - 0x00000007,0x00000068,0x0000000b,0x00050081,0x00000007,0x0000006c,0x00000068,0x0000006b, - 0x00050057,0x0000001d,0x0000006d,0x00000067,0x0000006c,0x00050051,0x00000006,0x0000006f, - 0x0000006d,0x00000000,0x00050041,0x00000031,0x00000070,0x00000066,0x0000006e,0x0003003e, - 0x00000070,0x0000006f,0x0004003d,0x00000018,0x00000071,0x0000001a,0x0004003d,0x00000007, - 0x00000072,0x0000000b,0x00050081,0x00000007,0x00000075,0x00000072,0x00000074,0x00050057, - 0x0000001d,0x00000076,0x00000071,0x00000075,0x00050051,0x00000006,0x00000077,0x00000076, - 0x00000001,0x00050041,0x00000031,0x00000078,0x00000066,0x00000035,0x0003003e,0x00000078, - 0x00000077,0x0004003d,0x00000018,0x00000079,0x0000001a,0x0004003d,0x00000007,0x0000007a, - 0x0000000b,0x00050083,0x00000007,0x0000007b,0x0000007a,0x0000006b,0x00050057,0x0000001d, - 0x0000007c,0x00000079,0x0000007b,0x00050051,0x00000006,0x0000007d,0x0000007c,0x00000002, - 0x00050041,0x00000031,0x0000007e,0x00000066,0x00000053,0x0003003e,0x0000007e,0x0000007d, - 0x0004003d,0x00000009,0x0000007f,0x00000066,0x000200fe,0x0000007f,0x00010038,0x00050036, - 0x00000009,0x0000000f,0x00000000,0x0000000a,0x00030037,0x00000008,0x0000000e,0x000200f8, - 0x00000010,0x0004003b,0x00000015,0x00000082,0x00000007,0x0004003b,0x00000031,0x00000087, - 0x00000007,0x0004003d,0x00000018,0x00000083,0x0000001a,0x0004003d,0x00000007,0x00000084, - 0x0000000e,0x00050057,0x0000001d,0x00000085,0x00000083,0x00000084,0x0008004f,0x00000009, - 0x00000086,0x00000085,0x00000085,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000082, - 0x00000086,0x00050041,0x00000031,0x00000088,0x0000000e,0x00000035,0x0004003d,0x00000006, - 0x00000089,0x00000088,0x00060041,0x0000003d,0x0000008a,0x0000003a,0x0000003c,0x00000035, - 0x0004003d,0x00000006,0x0000008b,0x0000008a,0x00050085,0x00000006,0x0000008c,0x00000089, - 0x0000008b,0x00050085,0x00000006,0x0000008d,0x0000008c,0x00000041,0x0006000c,0x00000006, - 0x0000008e,0x00000001,0x0000000d,0x0000008d,0x0006000c,0x00000006,0x0000008f,0x00000001, - 0x00000004,0x0000008e,0x00050085,0x00000006,0x00000091,0x0000008f,0x00000090,0x0003003e, - 0x00000087,0x00000091,0x0004003d,0x00000006,0x00000092,0x00000087,0x00050085,0x00000006, - 0x00000093,0x00000092,0x00000049,0x00050083,0x00000006,0x00000094,0x0000005a,0x00000093, - 0x0004003d,0x00000009,0x00000095,0x00000082,0x0005008e,0x00000009,0x00000096,0x00000095, - 0x00000094,0x0003003e,0x00000082,0x00000096,0x0004003d,0x00000009,0x00000097,0x00000082, - 0x000200fe,0x00000097,0x00010038,0x00050036,0x00000007,0x00000013,0x00000000,0x00000011, - 0x00030037,0x00000008,0x00000012,0x000200f8,0x00000014,0x0004003b,0x00000031,0x0000009e, - 0x00000007,0x0004003d,0x00000007,0x0000009a,0x00000012,0x0005008e,0x00000007,0x0000009b, - 0x0000009a,0x00000041,0x00050050,0x00000007,0x0000009c,0x0000005a,0x0000005a,0x00050083, - 0x00000007,0x0000009d,0x0000009b,0x0000009c,0x0003003e,0x00000012,0x0000009d,0x00050041, - 0x00000031,0x0000009f,0x00000012,0x0000006e,0x0004003d,0x00000006,0x000000a0,0x0000009f, - 0x00050041,0x00000031,0x000000a1,0x00000012,0x0000006e,0x0004003d,0x00000006,0x000000a2, - 0x000000a1,0x00050085,0x00000006,0x000000a3,0x000000a0,0x000000a2,0x00050041,0x00000031, - 0x000000a4,0x00000012,0x00000035,0x0004003d,0x00000006,0x000000a5,0x000000a4,0x00050041, - 0x00000031,0x000000a6,0x00000012,0x00000035,0x0004003d,0x00000006,0x000000a7,0x000000a6, - 0x00050085,0x00000006,0x000000a8,0x000000a5,0x000000a7,0x00050081,0x00000006,0x000000a9, - 0x000000a3,0x000000a8,0x0006000c,0x00000006,0x000000aa,0x00000001,0x0000001f,0x000000a9, - 0x0003003e,0x0000009e,0x000000aa,0x0004003d,0x00000007,0x000000ab,0x00000012,0x0004003d, - 0x00000006,0x000000ac,0x0000009e,0x0004003d,0x00000006,0x000000ad,0x0000009e,0x00050085, - 0x00000006,0x000000ae,0x000000ac,0x000000ad,0x0005008e,0x00000007,0x000000af,0x000000ab, - 0x000000ae,0x0005008e,0x00000007,0x000000b1,0x000000af,0x000000b0,0x0004003d,0x00000007, - 0x000000b2,0x00000012,0x00050081,0x00000007,0x000000b3,0x000000b2,0x000000b1,0x0003003e, - 0x00000012,0x000000b3,0x0004003d,0x00000007,0x000000b4,0x00000012,0x0005008e,0x00000007, - 0x000000b5,0x000000b4,0x00000049,0x00050050,0x00000007,0x000000b6,0x00000049,0x00000049, - 0x00050081,0x00000007,0x000000b7,0x000000b5,0x000000b6,0x000200fe,0x000000b7,0x00010038 + 0x000200f8,0x0000000d,0x0004003d,0x00000019,0x0000001c,0x0000001b,0x0004003d,0x00000007, + 0x0000001d,0x0000000b,0x00050081,0x00000007,0x00000021,0x0000001d,0x00000020,0x00050057, + 0x00000022,0x00000023,0x0000001c,0x00000021,0x00050051,0x00000006,0x00000026,0x00000023, + 0x00000000,0x0004003d,0x00000019,0x00000027,0x0000001b,0x0004003d,0x00000007,0x00000028, + 0x0000000b,0x00050081,0x00000007,0x0000002b,0x00000028,0x0000002a,0x00050057,0x00000022, + 0x0000002c,0x00000027,0x0000002b,0x00050051,0x00000006,0x0000002e,0x0000002c,0x00000001, + 0x0004003d,0x00000019,0x0000002f,0x0000001b,0x0004003d,0x00000007,0x00000030,0x0000000b, + 0x00050083,0x00000007,0x00000031,0x00000030,0x00000020,0x00050057,0x00000022,0x00000032, + 0x0000002f,0x00000031,0x00050051,0x00000006,0x00000034,0x00000032,0x00000002,0x00060050, + 0x00000009,0x00000035,0x00000026,0x0000002e,0x00000034,0x000200fe,0x00000035,0x00010038, + 0x00050036,0x00000009,0x00000012,0x00000000,0x0000000f,0x00030037,0x00000008,0x00000010, + 0x00030037,0x0000000e,0x00000011,0x000200f8,0x00000013,0x0004003b,0x00000038,0x00000039, + 0x00000007,0x00050041,0x00000038,0x0000003a,0x00000010,0x0000002d,0x0004003d,0x00000006, + 0x0000003b,0x0000003a,0x00060041,0x00000041,0x00000042,0x0000003e,0x00000040,0x0000002d, + 0x0004003d,0x00000006,0x00000043,0x00000042,0x00050085,0x00000006,0x00000044,0x0000003b, + 0x00000043,0x00050085,0x00000006,0x00000046,0x00000044,0x00000045,0x0006000c,0x00000006, + 0x00000047,0x00000001,0x0000000d,0x00000046,0x0006000c,0x00000006,0x00000048,0x00000001, + 0x00000004,0x00000047,0x00050085,0x00000006,0x0000004a,0x00000048,0x00000049,0x0003003e, + 0x00000039,0x0000004a,0x0004003d,0x00000006,0x0000004c,0x00000039,0x00050085,0x00000006, + 0x0000004e,0x0000004c,0x0000004d,0x00050083,0x00000006,0x0000004f,0x0000004b,0x0000004e, + 0x0004003d,0x00000009,0x00000050,0x00000011,0x0005008e,0x00000009,0x00000051,0x00000050, + 0x0000004f,0x0003003e,0x00000011,0x00000051,0x0004003d,0x00000009,0x00000052,0x00000011, + 0x000200fe,0x00000052,0x00010038,0x00050036,0x00000007,0x00000016,0x00000000,0x00000014, + 0x00030037,0x00000008,0x00000015,0x000200f8,0x00000017,0x0004003b,0x00000038,0x00000059, + 0x00000007,0x0004003d,0x00000007,0x00000055,0x00000015,0x0005008e,0x00000007,0x00000056, + 0x00000055,0x00000045,0x00050050,0x00000007,0x00000057,0x0000004b,0x0000004b,0x00050083, + 0x00000007,0x00000058,0x00000056,0x00000057,0x0003003e,0x00000015,0x00000058,0x00050041, + 0x00000038,0x0000005a,0x00000015,0x00000025,0x0004003d,0x00000006,0x0000005b,0x0000005a, + 0x00050041,0x00000038,0x0000005c,0x00000015,0x00000025,0x0004003d,0x00000006,0x0000005d, + 0x0000005c,0x00050085,0x00000006,0x0000005e,0x0000005b,0x0000005d,0x00050041,0x00000038, + 0x0000005f,0x00000015,0x0000002d,0x0004003d,0x00000006,0x00000060,0x0000005f,0x00050041, + 0x00000038,0x00000061,0x00000015,0x0000002d,0x0004003d,0x00000006,0x00000062,0x00000061, + 0x00050085,0x00000006,0x00000063,0x00000060,0x00000062,0x00050081,0x00000006,0x00000064, + 0x0000005e,0x00000063,0x0006000c,0x00000006,0x00000065,0x00000001,0x0000001f,0x00000064, + 0x0003003e,0x00000059,0x00000065,0x0004003d,0x00000007,0x00000066,0x00000015,0x0004003d, + 0x00000006,0x00000067,0x00000059,0x0004003d,0x00000006,0x00000068,0x00000059,0x00050085, + 0x00000006,0x00000069,0x00000067,0x00000068,0x0005008e,0x00000007,0x0000006a,0x00000066, + 0x00000069,0x0005008e,0x00000007,0x0000006c,0x0000006a,0x0000006b,0x0004003d,0x00000007, + 0x0000006d,0x00000015,0x00050081,0x00000007,0x0000006e,0x0000006d,0x0000006c,0x0003003e, + 0x00000015,0x0000006e,0x0004003d,0x00000007,0x0000006f,0x00000015,0x0005008e,0x00000007, + 0x00000070,0x0000006f,0x0000004d,0x00050050,0x00000007,0x00000071,0x0000004d,0x0000004d, + 0x00050081,0x00000007,0x00000072,0x00000070,0x00000071,0x000200fe,0x00000072,0x00010038 }; diff --git a/app/src/main/cpp/shaders/sgsr.frag b/app/src/main/cpp/shaders/sgsr.frag new file mode 100644 index 0000000000..bd273e9ed7 --- /dev/null +++ b/app/src/main/cpp/shaders/sgsr.frag @@ -0,0 +1,118 @@ +#version 450 + +// ============================================================================= +// Snapdragon Game Super Resolution (SGSR) 1.0 - spatial upscaler, mobile path. +// +// Ported from Qualcomm's reference shader: +// SnapdragonStudios/snapdragon-gsr sgsr/v1/include/glsl/sgsr1_shader_mobile.frag +// +// Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +// +// Adapted for the Winlator native Vulkan compositor: +// - #version 450 (Vulkan GLSL) +// - ViewportInfo passed via push constant instead of a uniform block +// - specialised to OperationMode == 1 (RGBA); green channel is the edge luma +// - reuses window.vert (full-screen quad; fragTexCoord in [0,1] over the +// destination rect = normalised output position = normalised source position) +// ============================================================================= + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as in Qualcomm's +// reference; positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D ps0; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by window.vert (offset 0) + highp vec4 ViewportInfo; // xy = 1/inputSize (texel size), zw = inputSize in pixels + float EdgeSharpness; // driven by the "Sharpness" slider (default 2.0) +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 out_Target0; + +const float EdgeThreshold = 8.0 / 255.0; + +float fastLanczos2(float x) { + float wA = x - 4.0; + float wB = x * wA - wA; + wA *= wA; + return wB * wA; +} + +vec2 weightY(float dx, float dy, float c, float std) { + float x = ((dx * dx) + (dy * dy)) * 0.55 + clamp(abs(c) * std, 0.0, 1.0); + float w = fastLanczos2(x); + return vec2(w, w * c); +} + +void main() { + highp vec4 ViewportInfo = pc.ViewportInfo; + highp vec2 uv = fragTexCoord; + + vec4 color; + color.xyz = textureLod(ps0, uv, 0.0).xyz; + + highp vec2 imgCoord = ((uv * ViewportInfo.zw) + vec2(-0.5, 0.5)); + highp vec2 imgCoordPixel = floor(imgCoord); + highp vec2 coord = (imgCoordPixel * ViewportInfo.xy); + vec2 pl = (imgCoord + (-imgCoordPixel)); + vec4 left = textureGather(ps0, coord, 1); + + float edgeVote = abs(left.z - left.y) + abs(color.y - left.y) + abs(color.y - left.z); + if (edgeVote > EdgeThreshold) { + coord.x += ViewportInfo.x; + + vec4 right = textureGather(ps0, coord + vec2(ViewportInfo.x, 0.0), 1); + vec4 upDown; + upDown.xy = textureGather(ps0, coord + vec2(0.0, -ViewportInfo.y), 1).wz; + upDown.zw = textureGather(ps0, coord + vec2(0.0, ViewportInfo.y), 1).yx; + + float mean = (left.y + left.z + right.x + right.w) * 0.25; + left = left - vec4(mean); + right = right - vec4(mean); + upDown = upDown - vec4(mean); + color.w = color.y - mean; + + float sum = (((((abs(left.x) + abs(left.y)) + abs(left.z)) + abs(left.w)) + + (((abs(right.x) + abs(right.y)) + abs(right.z)) + abs(right.w))) + + (((abs(upDown.x) + abs(upDown.y)) + abs(upDown.z)) + abs(upDown.w))); + float std = 2.181818 / sum; + + vec2 aWY = weightY(pl.x, pl.y + 1.0, upDown.x, std); + aWY += weightY(pl.x - 1.0, pl.y + 1.0, upDown.y, std); + aWY += weightY(pl.x - 1.0, pl.y - 2.0, upDown.z, std); + aWY += weightY(pl.x, pl.y - 2.0, upDown.w, std); + aWY += weightY(pl.x + 1.0, pl.y - 1.0, left.x, std); + aWY += weightY(pl.x, pl.y - 1.0, left.y, std); + aWY += weightY(pl.x, pl.y, left.z, std); + aWY += weightY(pl.x + 1.0, pl.y, left.w, std); + aWY += weightY(pl.x - 1.0, pl.y - 1.0, right.x, std); + aWY += weightY(pl.x - 2.0, pl.y - 1.0, right.y, std); + aWY += weightY(pl.x - 2.0, pl.y, right.z, std); + aWY += weightY(pl.x - 1.0, pl.y, right.w, std); + + float finalY = aWY.y / aWY.x; + + float maxY = max(max(left.y, left.z), max(right.x, right.w)); + float minY = min(min(left.y, left.z), min(right.x, right.w)); + finalY = clamp(pc.EdgeSharpness * finalY, minY, maxY); + + float deltaY = finalY - color.w; + deltaY = clamp(deltaY, -23.0 / 255.0, 23.0 / 255.0); + + color.x = clamp((color.x + deltaY), 0.0, 1.0); + color.y = clamp((color.y + deltaY), 0.0, 1.0); + color.z = clamp((color.z + deltaY), 0.0, 1.0); + } + + color.w = 1.0; // alpha channel unused by the compositor blit + out_Target0 = color; +} diff --git a/app/src/main/cpp/shaders/sgsr_half_frag.h b/app/src/main/cpp/shaders/sgsr_half_frag.h new file mode 100644 index 0000000000..12438b654b --- /dev/null +++ b/app/src/main/cpp/shaders/sgsr_half_frag.h @@ -0,0 +1,530 @@ + // 1116.2.0 + #pragma once +const uint32_t sgsr_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x00000216,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000051,0x00000214,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00070005,0x0000000a,0x74736166,0x636e614c,0x32736f7a,0x3b316628,0x00000000, + 0x00030005,0x00000009,0x00000078,0x00080005,0x00000012,0x67696577,0x28597468,0x663b3166, + 0x31663b31,0x3b31663b,0x00000000,0x00030005,0x0000000e,0x00007864,0x00030005,0x0000000f, + 0x00007964,0x00030005,0x00000010,0x00000063,0x00030005,0x00000011,0x00647473,0x00030005, + 0x00000014,0x00004177,0x00030005,0x00000018,0x00004277,0x00030005,0x00000026,0x00000078, + 0x00030005,0x00000038,0x00000077,0x00040005,0x00000039,0x61726170,0x0000006d,0x00060005, + 0x00000045,0x77656956,0x74726f70,0x6f666e49,0x00000000,0x00030005,0x00000046,0x00004350, + 0x00040006,0x00000046,0x00000000,0x0063646e,0x00070006,0x00000046,0x00000001,0x77656956, + 0x74726f70,0x6f666e49,0x00000000,0x00070006,0x00000046,0x00000002,0x65676445,0x72616853, + 0x73656e70,0x00000073,0x00030005,0x00000048,0x00006370,0x00030005,0x0000004f,0x00007675, + 0x00060005,0x00000051,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00040005,0x00000053, + 0x6f6c6f63,0x00000072,0x00030005,0x00000057,0x00307370,0x00050005,0x00000067,0x43676d69, + 0x64726f6f,0x00000000,0x00060005,0x00000070,0x43676d69,0x64726f6f,0x65786950,0x0000006c, + 0x00040005,0x00000073,0x726f6f63,0x00000064,0x00030005,0x00000078,0x00006c70,0x00040005, + 0x0000007d,0x7466656c,0x00000000,0x00050005,0x00000081,0x65676465,0x65746f56,0x00000000, + 0x00040005,0x000000a2,0x68676972,0x00000074,0x00040005,0x000000aa,0x6f447075,0x00006e77, + 0x00040005,0x000000c5,0x6e61656d,0x00000000,0x00030005,0x000000e4,0x006d7573,0x00030005, + 0x00000114,0x00647473,0x00030005,0x00000118,0x00595761,0x00040005,0x0000011c,0x61726170, + 0x0000006d,0x00040005,0x0000011f,0x61726170,0x0000006d,0x00040005,0x00000120,0x61726170, + 0x0000006d,0x00040005,0x00000123,0x61726170,0x0000006d,0x00040005,0x0000012c,0x61726170, + 0x0000006d,0x00040005,0x0000012d,0x61726170,0x0000006d,0x00040005,0x0000012e,0x61726170, + 0x0000006d,0x00040005,0x00000131,0x61726170,0x0000006d,0x00040005,0x0000013d,0x61726170, + 0x0000006d,0x00040005,0x0000013e,0x61726170,0x0000006d,0x00040005,0x0000013f,0x61726170, + 0x0000006d,0x00040005,0x00000142,0x61726170,0x0000006d,0x00040005,0x0000014a,0x61726170, + 0x0000006d,0x00040005,0x0000014d,0x61726170,0x0000006d,0x00040005,0x0000014e,0x61726170, + 0x0000006d,0x00040005,0x00000151,0x61726170,0x0000006d,0x00040005,0x0000015c,0x61726170, + 0x0000006d,0x00040005,0x0000015d,0x61726170,0x0000006d,0x00040005,0x0000015e,0x61726170, + 0x0000006d,0x00040005,0x00000161,0x61726170,0x0000006d,0x00040005,0x00000169,0x61726170, + 0x0000006d,0x00040005,0x0000016c,0x61726170,0x0000006d,0x00040005,0x0000016d,0x61726170, + 0x0000006d,0x00040005,0x00000170,0x61726170,0x0000006d,0x00040005,0x00000175,0x61726170, + 0x0000006d,0x00040005,0x00000178,0x61726170,0x0000006d,0x00040005,0x0000017b,0x61726170, + 0x0000006d,0x00040005,0x0000017e,0x61726170,0x0000006d,0x00040005,0x00000186,0x61726170, + 0x0000006d,0x00040005,0x00000187,0x61726170,0x0000006d,0x00040005,0x0000018a,0x61726170, + 0x0000006d,0x00040005,0x0000018d,0x61726170,0x0000006d,0x00040005,0x00000198,0x61726170, + 0x0000006d,0x00040005,0x00000199,0x61726170,0x0000006d,0x00040005,0x0000019a,0x61726170, + 0x0000006d,0x00040005,0x0000019d,0x61726170,0x0000006d,0x00040005,0x000001a8,0x61726170, + 0x0000006d,0x00040005,0x000001a9,0x61726170,0x0000006d,0x00040005,0x000001aa,0x61726170, + 0x0000006d,0x00040005,0x000001ad,0x61726170,0x0000006d,0x00040005,0x000001b5,0x61726170, + 0x0000006d,0x00040005,0x000001b6,0x61726170,0x0000006d,0x00040005,0x000001b9,0x61726170, + 0x0000006d,0x00040005,0x000001bc,0x61726170,0x0000006d,0x00040005,0x000001c4,0x61726170, + 0x0000006d,0x00040005,0x000001c5,0x61726170,0x0000006d,0x00040005,0x000001c8,0x61726170, + 0x0000006d,0x00040005,0x000001cb,0x61726170,0x0000006d,0x00040005,0x000001d0,0x616e6966, + 0x0000596c,0x00040005,0x000001d6,0x5978616d,0x00000000,0x00040005,0x000001e2,0x596e696d, + 0x00000000,0x00040005,0x000001f7,0x746c6564,0x00005961,0x00050005,0x00000214,0x5f74756f, + 0x67726154,0x00307465,0x00030047,0x00000009,0x00000000,0x00030047,0x0000000a,0x00000000, + 0x00030047,0x0000000e,0x00000000,0x00030047,0x0000000f,0x00000000,0x00030047,0x00000010, + 0x00000000,0x00030047,0x00000011,0x00000000,0x00030047,0x00000012,0x00000000,0x00030047, + 0x00000014,0x00000000,0x00030047,0x00000015,0x00000000,0x00030047,0x00000017,0x00000000, + 0x00030047,0x00000018,0x00000000,0x00030047,0x00000019,0x00000000,0x00030047,0x0000001a, + 0x00000000,0x00030047,0x0000001b,0x00000000,0x00030047,0x0000001c,0x00000000,0x00030047, + 0x0000001d,0x00000000,0x00030047,0x0000001e,0x00000000,0x00030047,0x0000001f,0x00000000, + 0x00030047,0x00000020,0x00000000,0x00030047,0x00000021,0x00000000,0x00030047,0x00000022, + 0x00000000,0x00030047,0x00000023,0x00000000,0x00030047,0x00000026,0x00000000,0x00030047, + 0x00000027,0x00000000,0x00030047,0x00000028,0x00000000,0x00030047,0x00000029,0x00000000, + 0x00030047,0x0000002a,0x00000000,0x00030047,0x0000002b,0x00000000,0x00030047,0x0000002c, + 0x00000000,0x00030047,0x0000002d,0x00000000,0x00030047,0x0000002f,0x00000000,0x00030047, + 0x00000030,0x00000000,0x00030047,0x00000031,0x00000000,0x00030047,0x00000032,0x00000000, + 0x00030047,0x00000033,0x00000000,0x00030047,0x00000036,0x00000000,0x00030047,0x00000037, + 0x00000000,0x00030047,0x00000038,0x00000000,0x00030047,0x00000039,0x00000000,0x00030047, + 0x0000003a,0x00000000,0x00030047,0x0000003b,0x00000000,0x00030047,0x0000003c,0x00000000, + 0x00030047,0x0000003d,0x00000000,0x00030047,0x0000003e,0x00000000,0x00030047,0x0000003f, + 0x00000000,0x00030047,0x00000040,0x00000000,0x00030047,0x00000046,0x00000002,0x00050048, + 0x00000046,0x00000000,0x00000023,0x00000000,0x00050048,0x00000046,0x00000001,0x00000023, + 0x00000010,0x00040048,0x00000046,0x00000002,0x00000000,0x00050048,0x00000046,0x00000002, + 0x00000023,0x00000020,0x00040047,0x00000051,0x0000001e,0x00000000,0x00030047,0x00000053, + 0x00000000,0x00030047,0x00000057,0x00000000,0x00040047,0x00000057,0x00000021,0x00000000, + 0x00040047,0x00000057,0x00000022,0x00000000,0x00030047,0x00000058,0x00000000,0x00030047, + 0x0000005a,0x00000000,0x00030047,0x0000005c,0x00000000,0x00030047,0x00000078,0x00000000, + 0x00030047,0x0000007d,0x00000000,0x00030047,0x0000007e,0x00000000,0x00030047,0x00000080, + 0x00000000,0x00030047,0x00000081,0x00000000,0x00030047,0x00000083,0x00000000,0x00030047, + 0x00000085,0x00000000,0x00030047,0x00000086,0x00000000,0x00030047,0x00000087,0x00000000, + 0x00030047,0x00000089,0x00000000,0x00030047,0x0000008b,0x00000000,0x00030047,0x0000008c, + 0x00000000,0x00030047,0x0000008d,0x00000000,0x00030047,0x0000008e,0x00000000,0x00030047, + 0x00000090,0x00000000,0x00030047,0x00000092,0x00000000,0x00030047,0x00000093,0x00000000, + 0x00030047,0x00000094,0x00000000,0x00030047,0x00000095,0x00000000,0x00030047,0x00000096, + 0x00000000,0x00030047,0x00000097,0x00000000,0x00030047,0x000000a2,0x00000000,0x00030047, + 0x000000a3,0x00000000,0x00030047,0x000000a9,0x00000000,0x00030047,0x000000aa,0x00000000, + 0x00030047,0x000000ab,0x00000000,0x00030047,0x000000b2,0x00000000,0x00030047,0x000000b3, + 0x00000000,0x00030047,0x000000b8,0x00000000,0x00030047,0x000000be,0x00000000,0x00030047, + 0x000000bf,0x00000000,0x00030047,0x000000c5,0x00000000,0x00030047,0x000000c7,0x00000000, + 0x00030047,0x000000c9,0x00000000,0x00030047,0x000000ca,0x00000000,0x00030047,0x000000cc, + 0x00000000,0x00030047,0x000000cd,0x00000000,0x00030047,0x000000cf,0x00000000,0x00030047, + 0x000000d0,0x00000000,0x00030047,0x000000d2,0x00000000,0x00030047,0x000000d3,0x00000000, + 0x00030047,0x000000d4,0x00000000,0x00030047,0x000000d5,0x00000000,0x00030047,0x000000d6, + 0x00000000,0x00030047,0x000000d7,0x00000000,0x00030047,0x000000d8,0x00000000,0x00030047, + 0x000000d9,0x00000000,0x00030047,0x000000da,0x00000000,0x00030047,0x000000db,0x00000000, + 0x00030047,0x000000dc,0x00000000,0x00030047,0x000000dd,0x00000000,0x00030047,0x000000de, + 0x00000000,0x00030047,0x000000e0,0x00000000,0x00030047,0x000000e1,0x00000000,0x00030047, + 0x000000e2,0x00000000,0x00030047,0x000000e4,0x00000000,0x00030047,0x000000e6,0x00000000, + 0x00030047,0x000000e7,0x00000000,0x00030047,0x000000e9,0x00000000,0x00030047,0x000000ea, + 0x00000000,0x00030047,0x000000eb,0x00000000,0x00030047,0x000000ed,0x00000000,0x00030047, + 0x000000ee,0x00000000,0x00030047,0x000000ef,0x00000000,0x00030047,0x000000f1,0x00000000, + 0x00030047,0x000000f2,0x00000000,0x00030047,0x000000f3,0x00000000,0x00030047,0x000000f5, + 0x00000000,0x00030047,0x000000f6,0x00000000,0x00030047,0x000000f8,0x00000000,0x00030047, + 0x000000f9,0x00000000,0x00030047,0x000000fa,0x00000000,0x00030047,0x000000fc,0x00000000, + 0x00030047,0x000000fd,0x00000000,0x00030047,0x000000fe,0x00000000,0x00030047,0x00000100, + 0x00000000,0x00030047,0x00000101,0x00000000,0x00030047,0x00000102,0x00000000,0x00030047, + 0x00000103,0x00000000,0x00030047,0x00000105,0x00000000,0x00030047,0x00000106,0x00000000, + 0x00030047,0x00000108,0x00000000,0x00030047,0x00000109,0x00000000,0x00030047,0x0000010a, + 0x00000000,0x00030047,0x0000010c,0x00000000,0x00030047,0x0000010d,0x00000000,0x00030047, + 0x0000010e,0x00000000,0x00030047,0x00000110,0x00000000,0x00030047,0x00000111,0x00000000, + 0x00030047,0x00000112,0x00000000,0x00030047,0x00000113,0x00000000,0x00030047,0x00000114, + 0x00000000,0x00030047,0x00000116,0x00000000,0x00030047,0x00000117,0x00000000,0x00030047, + 0x00000118,0x00000000,0x00030047,0x0000011a,0x00000000,0x00030047,0x0000011b,0x00000000, + 0x00030047,0x0000011c,0x00000000,0x00030047,0x0000011e,0x00000000,0x00030047,0x0000011f, + 0x00000000,0x00030047,0x00000120,0x00000000,0x00030047,0x00000122,0x00000000,0x00030047, + 0x00000123,0x00000000,0x00030047,0x00000124,0x00000000,0x00030047,0x00000125,0x00000000, + 0x00030047,0x00000127,0x00000000,0x00030047,0x00000128,0x00000000,0x00030047,0x0000012a, + 0x00000000,0x00030047,0x0000012b,0x00000000,0x00030047,0x0000012c,0x00000000,0x00030047, + 0x0000012d,0x00000000,0x00030047,0x0000012e,0x00000000,0x00030047,0x00000130,0x00000000, + 0x00030047,0x00000131,0x00000000,0x00030047,0x00000132,0x00000000,0x00030047,0x00000133, + 0x00000000,0x00030047,0x00000134,0x00000000,0x00030047,0x00000135,0x00000000,0x00030047, + 0x00000137,0x00000000,0x00030047,0x00000138,0x00000000,0x00030047,0x0000013a,0x00000000, + 0x00030047,0x0000013c,0x00000000,0x00030047,0x0000013d,0x00000000,0x00030047,0x0000013e, + 0x00000000,0x00030047,0x0000013f,0x00000000,0x00030047,0x00000141,0x00000000,0x00030047, + 0x00000142,0x00000000,0x00030047,0x00000143,0x00000000,0x00030047,0x00000144,0x00000000, + 0x00030047,0x00000145,0x00000000,0x00030047,0x00000146,0x00000000,0x00030047,0x00000148, + 0x00000000,0x00030047,0x00000149,0x00000000,0x00030047,0x0000014a,0x00000000,0x00030047, + 0x0000014c,0x00000000,0x00030047,0x0000014d,0x00000000,0x00030047,0x0000014e,0x00000000, + 0x00030047,0x00000150,0x00000000,0x00030047,0x00000151,0x00000000,0x00030047,0x00000152, + 0x00000000,0x00030047,0x00000153,0x00000000,0x00030047,0x00000154,0x00000000,0x00030047, + 0x00000155,0x00000000,0x00030047,0x00000157,0x00000000,0x00030047,0x00000158,0x00000000, + 0x00030047,0x0000015a,0x00000000,0x00030047,0x0000015b,0x00000000,0x00030047,0x0000015c, + 0x00000000,0x00030047,0x0000015d,0x00000000,0x00030047,0x0000015e,0x00000000,0x00030047, + 0x00000160,0x00000000,0x00030047,0x00000161,0x00000000,0x00030047,0x00000162,0x00000000, + 0x00030047,0x00000163,0x00000000,0x00030047,0x00000164,0x00000000,0x00030047,0x00000165, + 0x00000000,0x00030047,0x00000167,0x00000000,0x00030047,0x00000168,0x00000000,0x00030047, + 0x00000169,0x00000000,0x00030047,0x0000016b,0x00000000,0x00030047,0x0000016c,0x00000000, + 0x00030047,0x0000016d,0x00000000,0x00030047,0x0000016f,0x00000000,0x00030047,0x00000170, + 0x00000000,0x00030047,0x00000171,0x00000000,0x00030047,0x00000172,0x00000000,0x00030047, + 0x00000173,0x00000000,0x00030047,0x00000174,0x00000000,0x00030047,0x00000175,0x00000000, + 0x00030047,0x00000177,0x00000000,0x00030047,0x00000178,0x00000000,0x00030047,0x0000017a, + 0x00000000,0x00030047,0x0000017b,0x00000000,0x00030047,0x0000017d,0x00000000,0x00030047, + 0x0000017e,0x00000000,0x00030047,0x0000017f,0x00000000,0x00030047,0x00000180,0x00000000, + 0x00030047,0x00000181,0x00000000,0x00030047,0x00000182,0x00000000,0x00030047,0x00000184, + 0x00000000,0x00030047,0x00000185,0x00000000,0x00030047,0x00000186,0x00000000,0x00030047, + 0x00000187,0x00000000,0x00030047,0x00000189,0x00000000,0x00030047,0x0000018a,0x00000000, + 0x00030047,0x0000018c,0x00000000,0x00030047,0x0000018d,0x00000000,0x00030047,0x0000018e, + 0x00000000,0x00030047,0x0000018f,0x00000000,0x00030047,0x00000190,0x00000000,0x00030047, + 0x00000191,0x00000000,0x00030047,0x00000193,0x00000000,0x00030047,0x00000194,0x00000000, + 0x00030047,0x00000196,0x00000000,0x00030047,0x00000197,0x00000000,0x00030047,0x00000198, + 0x00000000,0x00030047,0x00000199,0x00000000,0x00030047,0x0000019a,0x00000000,0x00030047, + 0x0000019c,0x00000000,0x00030047,0x0000019d,0x00000000,0x00030047,0x0000019e,0x00000000, + 0x00030047,0x0000019f,0x00000000,0x00030047,0x000001a0,0x00000000,0x00030047,0x000001a1, + 0x00000000,0x00030047,0x000001a3,0x00000000,0x00030047,0x000001a4,0x00000000,0x00030047, + 0x000001a6,0x00000000,0x00030047,0x000001a7,0x00000000,0x00030047,0x000001a8,0x00000000, + 0x00030047,0x000001a9,0x00000000,0x00030047,0x000001aa,0x00000000,0x00030047,0x000001ac, + 0x00000000,0x00030047,0x000001ad,0x00000000,0x00030047,0x000001ae,0x00000000,0x00030047, + 0x000001af,0x00000000,0x00030047,0x000001b0,0x00000000,0x00030047,0x000001b1,0x00000000, + 0x00030047,0x000001b3,0x00000000,0x00030047,0x000001b4,0x00000000,0x00030047,0x000001b5, + 0x00000000,0x00030047,0x000001b6,0x00000000,0x00030047,0x000001b8,0x00000000,0x00030047, + 0x000001b9,0x00000000,0x00030047,0x000001bb,0x00000000,0x00030047,0x000001bc,0x00000000, + 0x00030047,0x000001bd,0x00000000,0x00030047,0x000001be,0x00000000,0x00030047,0x000001bf, + 0x00000000,0x00030047,0x000001c0,0x00000000,0x00030047,0x000001c2,0x00000000,0x00030047, + 0x000001c3,0x00000000,0x00030047,0x000001c4,0x00000000,0x00030047,0x000001c5,0x00000000, + 0x00030047,0x000001c7,0x00000000,0x00030047,0x000001c8,0x00000000,0x00030047,0x000001ca, + 0x00000000,0x00030047,0x000001cb,0x00000000,0x00030047,0x000001cc,0x00000000,0x00030047, + 0x000001cd,0x00000000,0x00030047,0x000001ce,0x00000000,0x00030047,0x000001cf,0x00000000, + 0x00030047,0x000001d0,0x00000000,0x00030047,0x000001d2,0x00000000,0x00030047,0x000001d4, + 0x00000000,0x00030047,0x000001d5,0x00000000,0x00030047,0x000001d6,0x00000000,0x00030047, + 0x000001d8,0x00000000,0x00030047,0x000001da,0x00000000,0x00030047,0x000001db,0x00000000, + 0x00030047,0x000001dd,0x00000000,0x00030047,0x000001df,0x00000000,0x00030047,0x000001e0, + 0x00000000,0x00030047,0x000001e1,0x00000000,0x00030047,0x000001e2,0x00000000,0x00030047, + 0x000001e4,0x00000000,0x00030047,0x000001e6,0x00000000,0x00030047,0x000001e7,0x00000000, + 0x00030047,0x000001e9,0x00000000,0x00030047,0x000001eb,0x00000000,0x00030047,0x000001ec, + 0x00000000,0x00030047,0x000001ed,0x00000000,0x00030047,0x000001f1,0x00000000,0x00030047, + 0x000001f2,0x00000000,0x00030047,0x000001f3,0x00000000,0x00030047,0x000001f4,0x00000000, + 0x00030047,0x000001f5,0x00000000,0x00030047,0x000001f6,0x00000000,0x00030047,0x000001f7, + 0x00000000,0x00030047,0x000001f8,0x00000000,0x00030047,0x000001fa,0x00000000,0x00030047, + 0x000001fb,0x00000000,0x00030047,0x000001fc,0x00000000,0x00030047,0x000001ff,0x00000000, + 0x00030047,0x00000201,0x00000000,0x00030047,0x00000202,0x00000000,0x00030047,0x00000203, + 0x00000000,0x00030047,0x00000204,0x00000000,0x00030047,0x00000207,0x00000000,0x00030047, + 0x00000208,0x00000000,0x00030047,0x00000209,0x00000000,0x00030047,0x0000020a,0x00000000, + 0x00030047,0x0000020d,0x00000000,0x00030047,0x0000020e,0x00000000,0x00030047,0x0000020f, + 0x00000000,0x00030047,0x00000210,0x00000000,0x00030047,0x00000214,0x00000000,0x00040047, + 0x00000214,0x0000001e,0x00000000,0x00030047,0x00000215,0x00000000,0x00020013,0x00000002, + 0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040020,0x00000007, + 0x00000007,0x00000006,0x00040021,0x00000008,0x00000006,0x00000007,0x00040017,0x0000000c, + 0x00000006,0x00000002,0x00070021,0x0000000d,0x0000000c,0x00000007,0x00000007,0x00000007, + 0x00000007,0x0004002b,0x00000006,0x00000016,0x40800000,0x0004002b,0x00000006,0x0000002e, + 0x3f0ccccd,0x0004002b,0x00000006,0x00000034,0x00000000,0x0004002b,0x00000006,0x00000035, + 0x3f800000,0x00040017,0x00000043,0x00000006,0x00000004,0x00040020,0x00000044,0x00000007, + 0x00000043,0x0005001e,0x00000046,0x00000043,0x00000043,0x00000006,0x00040020,0x00000047, + 0x00000009,0x00000046,0x0004003b,0x00000047,0x00000048,0x00000009,0x00040015,0x00000049, + 0x00000020,0x00000001,0x0004002b,0x00000049,0x0000004a,0x00000001,0x00040020,0x0000004b, + 0x00000009,0x00000043,0x00040020,0x0000004e,0x00000007,0x0000000c,0x00040020,0x00000050, + 0x00000001,0x0000000c,0x0004003b,0x00000050,0x00000051,0x00000001,0x00090019,0x00000054, + 0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b, + 0x00000055,0x00000054,0x00040020,0x00000056,0x00000000,0x00000055,0x0004003b,0x00000056, + 0x00000057,0x00000000,0x00040017,0x0000005b,0x00000006,0x00000003,0x00040015,0x0000005d, + 0x00000020,0x00000000,0x0004002b,0x0000005d,0x0000005e,0x00000000,0x0004002b,0x0000005d, + 0x00000061,0x00000001,0x0004002b,0x0000005d,0x00000064,0x00000002,0x0004002b,0x00000006, + 0x0000006c,0xbf000000,0x0004002b,0x00000006,0x0000006d,0x3f000000,0x0005002c,0x0000000c, + 0x0000006e,0x0000006c,0x0000006d,0x0004002b,0x00000006,0x00000097,0x3d008081,0x00020014, + 0x00000098,0x0004002b,0x0000005d,0x000000c2,0x00000003,0x0004002b,0x00000006,0x000000d1, + 0x3e800000,0x0004002b,0x00000006,0x00000115,0x400ba2e8,0x0004002b,0x00000006,0x0000013b, + 0x40000000,0x0004002b,0x00000049,0x000001ee,0x00000002,0x00040020,0x000001ef,0x00000009, + 0x00000006,0x0004002b,0x00000006,0x000001fd,0xbdb8b8b9,0x0004002b,0x00000006,0x000001fe, + 0x3db8b8b9,0x00040020,0x00000213,0x00000003,0x00000043,0x0004003b,0x00000213,0x00000214, + 0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, + 0x0004003b,0x00000044,0x00000045,0x00000007,0x0004003b,0x0000004e,0x0000004f,0x00000007, + 0x0004003b,0x00000044,0x00000053,0x00000007,0x0004003b,0x0000004e,0x00000067,0x00000007, + 0x0004003b,0x0000004e,0x00000070,0x00000007,0x0004003b,0x0000004e,0x00000073,0x00000007, + 0x0004003b,0x0000004e,0x00000078,0x00000007,0x0004003b,0x00000044,0x0000007d,0x00000007, + 0x0004003b,0x00000007,0x00000081,0x00000007,0x0004003b,0x00000044,0x000000a2,0x00000007, + 0x0004003b,0x00000044,0x000000aa,0x00000007,0x0004003b,0x00000007,0x000000c5,0x00000007, + 0x0004003b,0x00000007,0x000000e4,0x00000007,0x0004003b,0x00000007,0x00000114,0x00000007, + 0x0004003b,0x0000004e,0x00000118,0x00000007,0x0004003b,0x00000007,0x0000011c,0x00000007, + 0x0004003b,0x00000007,0x0000011f,0x00000007,0x0004003b,0x00000007,0x00000120,0x00000007, + 0x0004003b,0x00000007,0x00000123,0x00000007,0x0004003b,0x00000007,0x0000012c,0x00000007, + 0x0004003b,0x00000007,0x0000012d,0x00000007,0x0004003b,0x00000007,0x0000012e,0x00000007, + 0x0004003b,0x00000007,0x00000131,0x00000007,0x0004003b,0x00000007,0x0000013d,0x00000007, + 0x0004003b,0x00000007,0x0000013e,0x00000007,0x0004003b,0x00000007,0x0000013f,0x00000007, + 0x0004003b,0x00000007,0x00000142,0x00000007,0x0004003b,0x00000007,0x0000014a,0x00000007, + 0x0004003b,0x00000007,0x0000014d,0x00000007,0x0004003b,0x00000007,0x0000014e,0x00000007, + 0x0004003b,0x00000007,0x00000151,0x00000007,0x0004003b,0x00000007,0x0000015c,0x00000007, + 0x0004003b,0x00000007,0x0000015d,0x00000007,0x0004003b,0x00000007,0x0000015e,0x00000007, + 0x0004003b,0x00000007,0x00000161,0x00000007,0x0004003b,0x00000007,0x00000169,0x00000007, + 0x0004003b,0x00000007,0x0000016c,0x00000007,0x0004003b,0x00000007,0x0000016d,0x00000007, + 0x0004003b,0x00000007,0x00000170,0x00000007,0x0004003b,0x00000007,0x00000175,0x00000007, + 0x0004003b,0x00000007,0x00000178,0x00000007,0x0004003b,0x00000007,0x0000017b,0x00000007, + 0x0004003b,0x00000007,0x0000017e,0x00000007,0x0004003b,0x00000007,0x00000186,0x00000007, + 0x0004003b,0x00000007,0x00000187,0x00000007,0x0004003b,0x00000007,0x0000018a,0x00000007, + 0x0004003b,0x00000007,0x0000018d,0x00000007,0x0004003b,0x00000007,0x00000198,0x00000007, + 0x0004003b,0x00000007,0x00000199,0x00000007,0x0004003b,0x00000007,0x0000019a,0x00000007, + 0x0004003b,0x00000007,0x0000019d,0x00000007,0x0004003b,0x00000007,0x000001a8,0x00000007, + 0x0004003b,0x00000007,0x000001a9,0x00000007,0x0004003b,0x00000007,0x000001aa,0x00000007, + 0x0004003b,0x00000007,0x000001ad,0x00000007,0x0004003b,0x00000007,0x000001b5,0x00000007, + 0x0004003b,0x00000007,0x000001b6,0x00000007,0x0004003b,0x00000007,0x000001b9,0x00000007, + 0x0004003b,0x00000007,0x000001bc,0x00000007,0x0004003b,0x00000007,0x000001c4,0x00000007, + 0x0004003b,0x00000007,0x000001c5,0x00000007,0x0004003b,0x00000007,0x000001c8,0x00000007, + 0x0004003b,0x00000007,0x000001cb,0x00000007,0x0004003b,0x00000007,0x000001d0,0x00000007, + 0x0004003b,0x00000007,0x000001d6,0x00000007,0x0004003b,0x00000007,0x000001e2,0x00000007, + 0x0004003b,0x00000007,0x000001f7,0x00000007,0x00050041,0x0000004b,0x0000004c,0x00000048, + 0x0000004a,0x0004003d,0x00000043,0x0000004d,0x0000004c,0x0003003e,0x00000045,0x0000004d, + 0x0004003d,0x0000000c,0x00000052,0x00000051,0x0003003e,0x0000004f,0x00000052,0x0004003d, + 0x00000055,0x00000058,0x00000057,0x0004003d,0x0000000c,0x00000059,0x0000004f,0x00070058, + 0x00000043,0x0000005a,0x00000058,0x00000059,0x00000002,0x00000034,0x0008004f,0x0000005b, + 0x0000005c,0x0000005a,0x0000005a,0x00000000,0x00000001,0x00000002,0x00050041,0x00000007, + 0x0000005f,0x00000053,0x0000005e,0x00050051,0x00000006,0x00000060,0x0000005c,0x00000000, + 0x0003003e,0x0000005f,0x00000060,0x00050041,0x00000007,0x00000062,0x00000053,0x00000061, + 0x00050051,0x00000006,0x00000063,0x0000005c,0x00000001,0x0003003e,0x00000062,0x00000063, + 0x00050041,0x00000007,0x00000065,0x00000053,0x00000064,0x00050051,0x00000006,0x00000066, + 0x0000005c,0x00000002,0x0003003e,0x00000065,0x00000066,0x0004003d,0x0000000c,0x00000068, + 0x0000004f,0x0004003d,0x00000043,0x00000069,0x00000045,0x0007004f,0x0000000c,0x0000006a, + 0x00000069,0x00000069,0x00000002,0x00000003,0x00050085,0x0000000c,0x0000006b,0x00000068, + 0x0000006a,0x00050081,0x0000000c,0x0000006f,0x0000006b,0x0000006e,0x0003003e,0x00000067, + 0x0000006f,0x0004003d,0x0000000c,0x00000071,0x00000067,0x0006000c,0x0000000c,0x00000072, + 0x00000001,0x00000008,0x00000071,0x0003003e,0x00000070,0x00000072,0x0004003d,0x0000000c, + 0x00000074,0x00000070,0x0004003d,0x00000043,0x00000075,0x00000045,0x0007004f,0x0000000c, + 0x00000076,0x00000075,0x00000075,0x00000000,0x00000001,0x00050085,0x0000000c,0x00000077, + 0x00000074,0x00000076,0x0003003e,0x00000073,0x00000077,0x0004003d,0x0000000c,0x00000079, + 0x00000067,0x0004003d,0x0000000c,0x0000007a,0x00000070,0x0004007f,0x0000000c,0x0000007b, + 0x0000007a,0x00050081,0x0000000c,0x0000007c,0x00000079,0x0000007b,0x0003003e,0x00000078, + 0x0000007c,0x0004003d,0x00000055,0x0000007e,0x00000057,0x0004003d,0x0000000c,0x0000007f, + 0x00000073,0x00060060,0x00000043,0x00000080,0x0000007e,0x0000007f,0x0000004a,0x0003003e, + 0x0000007d,0x00000080,0x00050041,0x00000007,0x00000082,0x0000007d,0x00000064,0x0004003d, + 0x00000006,0x00000083,0x00000082,0x00050041,0x00000007,0x00000084,0x0000007d,0x00000061, + 0x0004003d,0x00000006,0x00000085,0x00000084,0x00050083,0x00000006,0x00000086,0x00000083, + 0x00000085,0x0006000c,0x00000006,0x00000087,0x00000001,0x00000004,0x00000086,0x00050041, + 0x00000007,0x00000088,0x00000053,0x00000061,0x0004003d,0x00000006,0x00000089,0x00000088, + 0x00050041,0x00000007,0x0000008a,0x0000007d,0x00000061,0x0004003d,0x00000006,0x0000008b, + 0x0000008a,0x00050083,0x00000006,0x0000008c,0x00000089,0x0000008b,0x0006000c,0x00000006, + 0x0000008d,0x00000001,0x00000004,0x0000008c,0x00050081,0x00000006,0x0000008e,0x00000087, + 0x0000008d,0x00050041,0x00000007,0x0000008f,0x00000053,0x00000061,0x0004003d,0x00000006, + 0x00000090,0x0000008f,0x00050041,0x00000007,0x00000091,0x0000007d,0x00000064,0x0004003d, + 0x00000006,0x00000092,0x00000091,0x00050083,0x00000006,0x00000093,0x00000090,0x00000092, + 0x0006000c,0x00000006,0x00000094,0x00000001,0x00000004,0x00000093,0x00050081,0x00000006, + 0x00000095,0x0000008e,0x00000094,0x0003003e,0x00000081,0x00000095,0x0004003d,0x00000006, + 0x00000096,0x00000081,0x000500ba,0x00000098,0x00000099,0x00000096,0x00000097,0x000300f7, + 0x0000009b,0x00000000,0x000400fa,0x00000099,0x0000009a,0x0000009b,0x000200f8,0x0000009a, + 0x00050041,0x00000007,0x0000009c,0x00000045,0x0000005e,0x0004003d,0x00000006,0x0000009d, + 0x0000009c,0x00050041,0x00000007,0x0000009e,0x00000073,0x0000005e,0x0004003d,0x00000006, + 0x0000009f,0x0000009e,0x00050081,0x00000006,0x000000a0,0x0000009f,0x0000009d,0x00050041, + 0x00000007,0x000000a1,0x00000073,0x0000005e,0x0003003e,0x000000a1,0x000000a0,0x0004003d, + 0x00000055,0x000000a3,0x00000057,0x0004003d,0x0000000c,0x000000a4,0x00000073,0x00050041, + 0x00000007,0x000000a5,0x00000045,0x0000005e,0x0004003d,0x00000006,0x000000a6,0x000000a5, + 0x00050050,0x0000000c,0x000000a7,0x000000a6,0x00000034,0x00050081,0x0000000c,0x000000a8, + 0x000000a4,0x000000a7,0x00060060,0x00000043,0x000000a9,0x000000a3,0x000000a8,0x0000004a, + 0x0003003e,0x000000a2,0x000000a9,0x0004003d,0x00000055,0x000000ab,0x00000057,0x0004003d, + 0x0000000c,0x000000ac,0x00000073,0x00050041,0x00000007,0x000000ad,0x00000045,0x00000061, + 0x0004003d,0x00000006,0x000000ae,0x000000ad,0x0004007f,0x00000006,0x000000af,0x000000ae, + 0x00050050,0x0000000c,0x000000b0,0x00000034,0x000000af,0x00050081,0x0000000c,0x000000b1, + 0x000000ac,0x000000b0,0x00060060,0x00000043,0x000000b2,0x000000ab,0x000000b1,0x0000004a, + 0x0007004f,0x0000000c,0x000000b3,0x000000b2,0x000000b2,0x00000003,0x00000002,0x00050041, + 0x00000007,0x000000b4,0x000000aa,0x0000005e,0x00050051,0x00000006,0x000000b5,0x000000b3, + 0x00000000,0x0003003e,0x000000b4,0x000000b5,0x00050041,0x00000007,0x000000b6,0x000000aa, + 0x00000061,0x00050051,0x00000006,0x000000b7,0x000000b3,0x00000001,0x0003003e,0x000000b6, + 0x000000b7,0x0004003d,0x00000055,0x000000b8,0x00000057,0x0004003d,0x0000000c,0x000000b9, + 0x00000073,0x00050041,0x00000007,0x000000ba,0x00000045,0x00000061,0x0004003d,0x00000006, + 0x000000bb,0x000000ba,0x00050050,0x0000000c,0x000000bc,0x00000034,0x000000bb,0x00050081, + 0x0000000c,0x000000bd,0x000000b9,0x000000bc,0x00060060,0x00000043,0x000000be,0x000000b8, + 0x000000bd,0x0000004a,0x0007004f,0x0000000c,0x000000bf,0x000000be,0x000000be,0x00000001, + 0x00000000,0x00050041,0x00000007,0x000000c0,0x000000aa,0x00000064,0x00050051,0x00000006, + 0x000000c1,0x000000bf,0x00000000,0x0003003e,0x000000c0,0x000000c1,0x00050041,0x00000007, + 0x000000c3,0x000000aa,0x000000c2,0x00050051,0x00000006,0x000000c4,0x000000bf,0x00000001, + 0x0003003e,0x000000c3,0x000000c4,0x00050041,0x00000007,0x000000c6,0x0000007d,0x00000061, + 0x0004003d,0x00000006,0x000000c7,0x000000c6,0x00050041,0x00000007,0x000000c8,0x0000007d, + 0x00000064,0x0004003d,0x00000006,0x000000c9,0x000000c8,0x00050081,0x00000006,0x000000ca, + 0x000000c7,0x000000c9,0x00050041,0x00000007,0x000000cb,0x000000a2,0x0000005e,0x0004003d, + 0x00000006,0x000000cc,0x000000cb,0x00050081,0x00000006,0x000000cd,0x000000ca,0x000000cc, + 0x00050041,0x00000007,0x000000ce,0x000000a2,0x000000c2,0x0004003d,0x00000006,0x000000cf, + 0x000000ce,0x00050081,0x00000006,0x000000d0,0x000000cd,0x000000cf,0x00050085,0x00000006, + 0x000000d2,0x000000d0,0x000000d1,0x0003003e,0x000000c5,0x000000d2,0x0004003d,0x00000043, + 0x000000d3,0x0000007d,0x0004003d,0x00000006,0x000000d4,0x000000c5,0x00070050,0x00000043, + 0x000000d5,0x000000d4,0x000000d4,0x000000d4,0x000000d4,0x00050083,0x00000043,0x000000d6, + 0x000000d3,0x000000d5,0x0003003e,0x0000007d,0x000000d6,0x0004003d,0x00000043,0x000000d7, + 0x000000a2,0x0004003d,0x00000006,0x000000d8,0x000000c5,0x00070050,0x00000043,0x000000d9, + 0x000000d8,0x000000d8,0x000000d8,0x000000d8,0x00050083,0x00000043,0x000000da,0x000000d7, + 0x000000d9,0x0003003e,0x000000a2,0x000000da,0x0004003d,0x00000043,0x000000db,0x000000aa, + 0x0004003d,0x00000006,0x000000dc,0x000000c5,0x00070050,0x00000043,0x000000dd,0x000000dc, + 0x000000dc,0x000000dc,0x000000dc,0x00050083,0x00000043,0x000000de,0x000000db,0x000000dd, + 0x0003003e,0x000000aa,0x000000de,0x00050041,0x00000007,0x000000df,0x00000053,0x00000061, + 0x0004003d,0x00000006,0x000000e0,0x000000df,0x0004003d,0x00000006,0x000000e1,0x000000c5, + 0x00050083,0x00000006,0x000000e2,0x000000e0,0x000000e1,0x00050041,0x00000007,0x000000e3, + 0x00000053,0x000000c2,0x0003003e,0x000000e3,0x000000e2,0x00050041,0x00000007,0x000000e5, + 0x0000007d,0x0000005e,0x0004003d,0x00000006,0x000000e6,0x000000e5,0x0006000c,0x00000006, + 0x000000e7,0x00000001,0x00000004,0x000000e6,0x00050041,0x00000007,0x000000e8,0x0000007d, + 0x00000061,0x0004003d,0x00000006,0x000000e9,0x000000e8,0x0006000c,0x00000006,0x000000ea, + 0x00000001,0x00000004,0x000000e9,0x00050081,0x00000006,0x000000eb,0x000000e7,0x000000ea, + 0x00050041,0x00000007,0x000000ec,0x0000007d,0x00000064,0x0004003d,0x00000006,0x000000ed, + 0x000000ec,0x0006000c,0x00000006,0x000000ee,0x00000001,0x00000004,0x000000ed,0x00050081, + 0x00000006,0x000000ef,0x000000eb,0x000000ee,0x00050041,0x00000007,0x000000f0,0x0000007d, + 0x000000c2,0x0004003d,0x00000006,0x000000f1,0x000000f0,0x0006000c,0x00000006,0x000000f2, + 0x00000001,0x00000004,0x000000f1,0x00050081,0x00000006,0x000000f3,0x000000ef,0x000000f2, + 0x00050041,0x00000007,0x000000f4,0x000000a2,0x0000005e,0x0004003d,0x00000006,0x000000f5, + 0x000000f4,0x0006000c,0x00000006,0x000000f6,0x00000001,0x00000004,0x000000f5,0x00050041, + 0x00000007,0x000000f7,0x000000a2,0x00000061,0x0004003d,0x00000006,0x000000f8,0x000000f7, + 0x0006000c,0x00000006,0x000000f9,0x00000001,0x00000004,0x000000f8,0x00050081,0x00000006, + 0x000000fa,0x000000f6,0x000000f9,0x00050041,0x00000007,0x000000fb,0x000000a2,0x00000064, + 0x0004003d,0x00000006,0x000000fc,0x000000fb,0x0006000c,0x00000006,0x000000fd,0x00000001, + 0x00000004,0x000000fc,0x00050081,0x00000006,0x000000fe,0x000000fa,0x000000fd,0x00050041, + 0x00000007,0x000000ff,0x000000a2,0x000000c2,0x0004003d,0x00000006,0x00000100,0x000000ff, + 0x0006000c,0x00000006,0x00000101,0x00000001,0x00000004,0x00000100,0x00050081,0x00000006, + 0x00000102,0x000000fe,0x00000101,0x00050081,0x00000006,0x00000103,0x000000f3,0x00000102, + 0x00050041,0x00000007,0x00000104,0x000000aa,0x0000005e,0x0004003d,0x00000006,0x00000105, + 0x00000104,0x0006000c,0x00000006,0x00000106,0x00000001,0x00000004,0x00000105,0x00050041, + 0x00000007,0x00000107,0x000000aa,0x00000061,0x0004003d,0x00000006,0x00000108,0x00000107, + 0x0006000c,0x00000006,0x00000109,0x00000001,0x00000004,0x00000108,0x00050081,0x00000006, + 0x0000010a,0x00000106,0x00000109,0x00050041,0x00000007,0x0000010b,0x000000aa,0x00000064, + 0x0004003d,0x00000006,0x0000010c,0x0000010b,0x0006000c,0x00000006,0x0000010d,0x00000001, + 0x00000004,0x0000010c,0x00050081,0x00000006,0x0000010e,0x0000010a,0x0000010d,0x00050041, + 0x00000007,0x0000010f,0x000000aa,0x000000c2,0x0004003d,0x00000006,0x00000110,0x0000010f, + 0x0006000c,0x00000006,0x00000111,0x00000001,0x00000004,0x00000110,0x00050081,0x00000006, + 0x00000112,0x0000010e,0x00000111,0x00050081,0x00000006,0x00000113,0x00000103,0x00000112, + 0x0003003e,0x000000e4,0x00000113,0x0004003d,0x00000006,0x00000116,0x000000e4,0x00050088, + 0x00000006,0x00000117,0x00000115,0x00000116,0x0003003e,0x00000114,0x00000117,0x00050041, + 0x00000007,0x00000119,0x00000078,0x00000061,0x0004003d,0x00000006,0x0000011a,0x00000119, + 0x00050081,0x00000006,0x0000011b,0x0000011a,0x00000035,0x00050041,0x00000007,0x0000011d, + 0x00000078,0x0000005e,0x0004003d,0x00000006,0x0000011e,0x0000011d,0x0003003e,0x0000011c, + 0x0000011e,0x0003003e,0x0000011f,0x0000011b,0x00050041,0x00000007,0x00000121,0x000000aa, + 0x0000005e,0x0004003d,0x00000006,0x00000122,0x00000121,0x0003003e,0x00000120,0x00000122, + 0x0004003d,0x00000006,0x00000124,0x00000114,0x0003003e,0x00000123,0x00000124,0x00080039, + 0x0000000c,0x00000125,0x00000012,0x0000011c,0x0000011f,0x00000120,0x00000123,0x0003003e, + 0x00000118,0x00000125,0x00050041,0x00000007,0x00000126,0x00000078,0x0000005e,0x0004003d, + 0x00000006,0x00000127,0x00000126,0x00050083,0x00000006,0x00000128,0x00000127,0x00000035, + 0x00050041,0x00000007,0x00000129,0x00000078,0x00000061,0x0004003d,0x00000006,0x0000012a, + 0x00000129,0x00050081,0x00000006,0x0000012b,0x0000012a,0x00000035,0x0003003e,0x0000012c, + 0x00000128,0x0003003e,0x0000012d,0x0000012b,0x00050041,0x00000007,0x0000012f,0x000000aa, + 0x00000061,0x0004003d,0x00000006,0x00000130,0x0000012f,0x0003003e,0x0000012e,0x00000130, + 0x0004003d,0x00000006,0x00000132,0x00000114,0x0003003e,0x00000131,0x00000132,0x00080039, + 0x0000000c,0x00000133,0x00000012,0x0000012c,0x0000012d,0x0000012e,0x00000131,0x0004003d, + 0x0000000c,0x00000134,0x00000118,0x00050081,0x0000000c,0x00000135,0x00000134,0x00000133, + 0x0003003e,0x00000118,0x00000135,0x00050041,0x00000007,0x00000136,0x00000078,0x0000005e, + 0x0004003d,0x00000006,0x00000137,0x00000136,0x00050083,0x00000006,0x00000138,0x00000137, + 0x00000035,0x00050041,0x00000007,0x00000139,0x00000078,0x00000061,0x0004003d,0x00000006, + 0x0000013a,0x00000139,0x00050083,0x00000006,0x0000013c,0x0000013a,0x0000013b,0x0003003e, + 0x0000013d,0x00000138,0x0003003e,0x0000013e,0x0000013c,0x00050041,0x00000007,0x00000140, + 0x000000aa,0x00000064,0x0004003d,0x00000006,0x00000141,0x00000140,0x0003003e,0x0000013f, + 0x00000141,0x0004003d,0x00000006,0x00000143,0x00000114,0x0003003e,0x00000142,0x00000143, + 0x00080039,0x0000000c,0x00000144,0x00000012,0x0000013d,0x0000013e,0x0000013f,0x00000142, + 0x0004003d,0x0000000c,0x00000145,0x00000118,0x00050081,0x0000000c,0x00000146,0x00000145, + 0x00000144,0x0003003e,0x00000118,0x00000146,0x00050041,0x00000007,0x00000147,0x00000078, + 0x00000061,0x0004003d,0x00000006,0x00000148,0x00000147,0x00050083,0x00000006,0x00000149, + 0x00000148,0x0000013b,0x00050041,0x00000007,0x0000014b,0x00000078,0x0000005e,0x0004003d, + 0x00000006,0x0000014c,0x0000014b,0x0003003e,0x0000014a,0x0000014c,0x0003003e,0x0000014d, + 0x00000149,0x00050041,0x00000007,0x0000014f,0x000000aa,0x000000c2,0x0004003d,0x00000006, + 0x00000150,0x0000014f,0x0003003e,0x0000014e,0x00000150,0x0004003d,0x00000006,0x00000152, + 0x00000114,0x0003003e,0x00000151,0x00000152,0x00080039,0x0000000c,0x00000153,0x00000012, + 0x0000014a,0x0000014d,0x0000014e,0x00000151,0x0004003d,0x0000000c,0x00000154,0x00000118, + 0x00050081,0x0000000c,0x00000155,0x00000154,0x00000153,0x0003003e,0x00000118,0x00000155, + 0x00050041,0x00000007,0x00000156,0x00000078,0x0000005e,0x0004003d,0x00000006,0x00000157, + 0x00000156,0x00050081,0x00000006,0x00000158,0x00000157,0x00000035,0x00050041,0x00000007, + 0x00000159,0x00000078,0x00000061,0x0004003d,0x00000006,0x0000015a,0x00000159,0x00050083, + 0x00000006,0x0000015b,0x0000015a,0x00000035,0x0003003e,0x0000015c,0x00000158,0x0003003e, + 0x0000015d,0x0000015b,0x00050041,0x00000007,0x0000015f,0x0000007d,0x0000005e,0x0004003d, + 0x00000006,0x00000160,0x0000015f,0x0003003e,0x0000015e,0x00000160,0x0004003d,0x00000006, + 0x00000162,0x00000114,0x0003003e,0x00000161,0x00000162,0x00080039,0x0000000c,0x00000163, + 0x00000012,0x0000015c,0x0000015d,0x0000015e,0x00000161,0x0004003d,0x0000000c,0x00000164, + 0x00000118,0x00050081,0x0000000c,0x00000165,0x00000164,0x00000163,0x0003003e,0x00000118, + 0x00000165,0x00050041,0x00000007,0x00000166,0x00000078,0x00000061,0x0004003d,0x00000006, + 0x00000167,0x00000166,0x00050083,0x00000006,0x00000168,0x00000167,0x00000035,0x00050041, + 0x00000007,0x0000016a,0x00000078,0x0000005e,0x0004003d,0x00000006,0x0000016b,0x0000016a, + 0x0003003e,0x00000169,0x0000016b,0x0003003e,0x0000016c,0x00000168,0x00050041,0x00000007, + 0x0000016e,0x0000007d,0x00000061,0x0004003d,0x00000006,0x0000016f,0x0000016e,0x0003003e, + 0x0000016d,0x0000016f,0x0004003d,0x00000006,0x00000171,0x00000114,0x0003003e,0x00000170, + 0x00000171,0x00080039,0x0000000c,0x00000172,0x00000012,0x00000169,0x0000016c,0x0000016d, + 0x00000170,0x0004003d,0x0000000c,0x00000173,0x00000118,0x00050081,0x0000000c,0x00000174, + 0x00000173,0x00000172,0x0003003e,0x00000118,0x00000174,0x00050041,0x00000007,0x00000176, + 0x00000078,0x0000005e,0x0004003d,0x00000006,0x00000177,0x00000176,0x0003003e,0x00000175, + 0x00000177,0x00050041,0x00000007,0x00000179,0x00000078,0x00000061,0x0004003d,0x00000006, + 0x0000017a,0x00000179,0x0003003e,0x00000178,0x0000017a,0x00050041,0x00000007,0x0000017c, + 0x0000007d,0x00000064,0x0004003d,0x00000006,0x0000017d,0x0000017c,0x0003003e,0x0000017b, + 0x0000017d,0x0004003d,0x00000006,0x0000017f,0x00000114,0x0003003e,0x0000017e,0x0000017f, + 0x00080039,0x0000000c,0x00000180,0x00000012,0x00000175,0x00000178,0x0000017b,0x0000017e, + 0x0004003d,0x0000000c,0x00000181,0x00000118,0x00050081,0x0000000c,0x00000182,0x00000181, + 0x00000180,0x0003003e,0x00000118,0x00000182,0x00050041,0x00000007,0x00000183,0x00000078, + 0x0000005e,0x0004003d,0x00000006,0x00000184,0x00000183,0x00050081,0x00000006,0x00000185, + 0x00000184,0x00000035,0x0003003e,0x00000186,0x00000185,0x00050041,0x00000007,0x00000188, + 0x00000078,0x00000061,0x0004003d,0x00000006,0x00000189,0x00000188,0x0003003e,0x00000187, + 0x00000189,0x00050041,0x00000007,0x0000018b,0x0000007d,0x000000c2,0x0004003d,0x00000006, + 0x0000018c,0x0000018b,0x0003003e,0x0000018a,0x0000018c,0x0004003d,0x00000006,0x0000018e, + 0x00000114,0x0003003e,0x0000018d,0x0000018e,0x00080039,0x0000000c,0x0000018f,0x00000012, + 0x00000186,0x00000187,0x0000018a,0x0000018d,0x0004003d,0x0000000c,0x00000190,0x00000118, + 0x00050081,0x0000000c,0x00000191,0x00000190,0x0000018f,0x0003003e,0x00000118,0x00000191, + 0x00050041,0x00000007,0x00000192,0x00000078,0x0000005e,0x0004003d,0x00000006,0x00000193, + 0x00000192,0x00050083,0x00000006,0x00000194,0x00000193,0x00000035,0x00050041,0x00000007, + 0x00000195,0x00000078,0x00000061,0x0004003d,0x00000006,0x00000196,0x00000195,0x00050083, + 0x00000006,0x00000197,0x00000196,0x00000035,0x0003003e,0x00000198,0x00000194,0x0003003e, + 0x00000199,0x00000197,0x00050041,0x00000007,0x0000019b,0x000000a2,0x0000005e,0x0004003d, + 0x00000006,0x0000019c,0x0000019b,0x0003003e,0x0000019a,0x0000019c,0x0004003d,0x00000006, + 0x0000019e,0x00000114,0x0003003e,0x0000019d,0x0000019e,0x00080039,0x0000000c,0x0000019f, + 0x00000012,0x00000198,0x00000199,0x0000019a,0x0000019d,0x0004003d,0x0000000c,0x000001a0, + 0x00000118,0x00050081,0x0000000c,0x000001a1,0x000001a0,0x0000019f,0x0003003e,0x00000118, + 0x000001a1,0x00050041,0x00000007,0x000001a2,0x00000078,0x0000005e,0x0004003d,0x00000006, + 0x000001a3,0x000001a2,0x00050083,0x00000006,0x000001a4,0x000001a3,0x0000013b,0x00050041, + 0x00000007,0x000001a5,0x00000078,0x00000061,0x0004003d,0x00000006,0x000001a6,0x000001a5, + 0x00050083,0x00000006,0x000001a7,0x000001a6,0x00000035,0x0003003e,0x000001a8,0x000001a4, + 0x0003003e,0x000001a9,0x000001a7,0x00050041,0x00000007,0x000001ab,0x000000a2,0x00000061, + 0x0004003d,0x00000006,0x000001ac,0x000001ab,0x0003003e,0x000001aa,0x000001ac,0x0004003d, + 0x00000006,0x000001ae,0x00000114,0x0003003e,0x000001ad,0x000001ae,0x00080039,0x0000000c, + 0x000001af,0x00000012,0x000001a8,0x000001a9,0x000001aa,0x000001ad,0x0004003d,0x0000000c, + 0x000001b0,0x00000118,0x00050081,0x0000000c,0x000001b1,0x000001b0,0x000001af,0x0003003e, + 0x00000118,0x000001b1,0x00050041,0x00000007,0x000001b2,0x00000078,0x0000005e,0x0004003d, + 0x00000006,0x000001b3,0x000001b2,0x00050083,0x00000006,0x000001b4,0x000001b3,0x0000013b, + 0x0003003e,0x000001b5,0x000001b4,0x00050041,0x00000007,0x000001b7,0x00000078,0x00000061, + 0x0004003d,0x00000006,0x000001b8,0x000001b7,0x0003003e,0x000001b6,0x000001b8,0x00050041, + 0x00000007,0x000001ba,0x000000a2,0x00000064,0x0004003d,0x00000006,0x000001bb,0x000001ba, + 0x0003003e,0x000001b9,0x000001bb,0x0004003d,0x00000006,0x000001bd,0x00000114,0x0003003e, + 0x000001bc,0x000001bd,0x00080039,0x0000000c,0x000001be,0x00000012,0x000001b5,0x000001b6, + 0x000001b9,0x000001bc,0x0004003d,0x0000000c,0x000001bf,0x00000118,0x00050081,0x0000000c, + 0x000001c0,0x000001bf,0x000001be,0x0003003e,0x00000118,0x000001c0,0x00050041,0x00000007, + 0x000001c1,0x00000078,0x0000005e,0x0004003d,0x00000006,0x000001c2,0x000001c1,0x00050083, + 0x00000006,0x000001c3,0x000001c2,0x00000035,0x0003003e,0x000001c4,0x000001c3,0x00050041, + 0x00000007,0x000001c6,0x00000078,0x00000061,0x0004003d,0x00000006,0x000001c7,0x000001c6, + 0x0003003e,0x000001c5,0x000001c7,0x00050041,0x00000007,0x000001c9,0x000000a2,0x000000c2, + 0x0004003d,0x00000006,0x000001ca,0x000001c9,0x0003003e,0x000001c8,0x000001ca,0x0004003d, + 0x00000006,0x000001cc,0x00000114,0x0003003e,0x000001cb,0x000001cc,0x00080039,0x0000000c, + 0x000001cd,0x00000012,0x000001c4,0x000001c5,0x000001c8,0x000001cb,0x0004003d,0x0000000c, + 0x000001ce,0x00000118,0x00050081,0x0000000c,0x000001cf,0x000001ce,0x000001cd,0x0003003e, + 0x00000118,0x000001cf,0x00050041,0x00000007,0x000001d1,0x00000118,0x00000061,0x0004003d, + 0x00000006,0x000001d2,0x000001d1,0x00050041,0x00000007,0x000001d3,0x00000118,0x0000005e, + 0x0004003d,0x00000006,0x000001d4,0x000001d3,0x00050088,0x00000006,0x000001d5,0x000001d2, + 0x000001d4,0x0003003e,0x000001d0,0x000001d5,0x00050041,0x00000007,0x000001d7,0x0000007d, + 0x00000061,0x0004003d,0x00000006,0x000001d8,0x000001d7,0x00050041,0x00000007,0x000001d9, + 0x0000007d,0x00000064,0x0004003d,0x00000006,0x000001da,0x000001d9,0x0007000c,0x00000006, + 0x000001db,0x00000001,0x00000028,0x000001d8,0x000001da,0x00050041,0x00000007,0x000001dc, + 0x000000a2,0x0000005e,0x0004003d,0x00000006,0x000001dd,0x000001dc,0x00050041,0x00000007, + 0x000001de,0x000000a2,0x000000c2,0x0004003d,0x00000006,0x000001df,0x000001de,0x0007000c, + 0x00000006,0x000001e0,0x00000001,0x00000028,0x000001dd,0x000001df,0x0007000c,0x00000006, + 0x000001e1,0x00000001,0x00000028,0x000001db,0x000001e0,0x0003003e,0x000001d6,0x000001e1, + 0x00050041,0x00000007,0x000001e3,0x0000007d,0x00000061,0x0004003d,0x00000006,0x000001e4, + 0x000001e3,0x00050041,0x00000007,0x000001e5,0x0000007d,0x00000064,0x0004003d,0x00000006, + 0x000001e6,0x000001e5,0x0007000c,0x00000006,0x000001e7,0x00000001,0x00000025,0x000001e4, + 0x000001e6,0x00050041,0x00000007,0x000001e8,0x000000a2,0x0000005e,0x0004003d,0x00000006, + 0x000001e9,0x000001e8,0x00050041,0x00000007,0x000001ea,0x000000a2,0x000000c2,0x0004003d, + 0x00000006,0x000001eb,0x000001ea,0x0007000c,0x00000006,0x000001ec,0x00000001,0x00000025, + 0x000001e9,0x000001eb,0x0007000c,0x00000006,0x000001ed,0x00000001,0x00000025,0x000001e7, + 0x000001ec,0x0003003e,0x000001e2,0x000001ed,0x00050041,0x000001ef,0x000001f0,0x00000048, + 0x000001ee,0x0004003d,0x00000006,0x000001f1,0x000001f0,0x0004003d,0x00000006,0x000001f2, + 0x000001d0,0x00050085,0x00000006,0x000001f3,0x000001f1,0x000001f2,0x0004003d,0x00000006, + 0x000001f4,0x000001e2,0x0004003d,0x00000006,0x000001f5,0x000001d6,0x0008000c,0x00000006, + 0x000001f6,0x00000001,0x0000002b,0x000001f3,0x000001f4,0x000001f5,0x0003003e,0x000001d0, + 0x000001f6,0x0004003d,0x00000006,0x000001f8,0x000001d0,0x00050041,0x00000007,0x000001f9, + 0x00000053,0x000000c2,0x0004003d,0x00000006,0x000001fa,0x000001f9,0x00050083,0x00000006, + 0x000001fb,0x000001f8,0x000001fa,0x0003003e,0x000001f7,0x000001fb,0x0004003d,0x00000006, + 0x000001fc,0x000001f7,0x0008000c,0x00000006,0x000001ff,0x00000001,0x0000002b,0x000001fc, + 0x000001fd,0x000001fe,0x0003003e,0x000001f7,0x000001ff,0x00050041,0x00000007,0x00000200, + 0x00000053,0x0000005e,0x0004003d,0x00000006,0x00000201,0x00000200,0x0004003d,0x00000006, + 0x00000202,0x000001f7,0x00050081,0x00000006,0x00000203,0x00000201,0x00000202,0x0008000c, + 0x00000006,0x00000204,0x00000001,0x0000002b,0x00000203,0x00000034,0x00000035,0x00050041, + 0x00000007,0x00000205,0x00000053,0x0000005e,0x0003003e,0x00000205,0x00000204,0x00050041, + 0x00000007,0x00000206,0x00000053,0x00000061,0x0004003d,0x00000006,0x00000207,0x00000206, + 0x0004003d,0x00000006,0x00000208,0x000001f7,0x00050081,0x00000006,0x00000209,0x00000207, + 0x00000208,0x0008000c,0x00000006,0x0000020a,0x00000001,0x0000002b,0x00000209,0x00000034, + 0x00000035,0x00050041,0x00000007,0x0000020b,0x00000053,0x00000061,0x0003003e,0x0000020b, + 0x0000020a,0x00050041,0x00000007,0x0000020c,0x00000053,0x00000064,0x0004003d,0x00000006, + 0x0000020d,0x0000020c,0x0004003d,0x00000006,0x0000020e,0x000001f7,0x00050081,0x00000006, + 0x0000020f,0x0000020d,0x0000020e,0x0008000c,0x00000006,0x00000210,0x00000001,0x0000002b, + 0x0000020f,0x00000034,0x00000035,0x00050041,0x00000007,0x00000211,0x00000053,0x00000064, + 0x0003003e,0x00000211,0x00000210,0x000200f9,0x0000009b,0x000200f8,0x0000009b,0x00050041, + 0x00000007,0x00000212,0x00000053,0x000000c2,0x0003003e,0x00000212,0x00000035,0x0004003d, + 0x00000043,0x00000215,0x00000053,0x0003003e,0x00000214,0x00000215,0x000100fd,0x00010038, + 0x00050036,0x00000006,0x0000000a,0x00000000,0x00000008,0x00030037,0x00000007,0x00000009, + 0x000200f8,0x0000000b,0x0004003b,0x00000007,0x00000014,0x00000007,0x0004003b,0x00000007, + 0x00000018,0x00000007,0x0004003d,0x00000006,0x00000015,0x00000009,0x00050083,0x00000006, + 0x00000017,0x00000015,0x00000016,0x0003003e,0x00000014,0x00000017,0x0004003d,0x00000006, + 0x00000019,0x00000009,0x0004003d,0x00000006,0x0000001a,0x00000014,0x00050085,0x00000006, + 0x0000001b,0x00000019,0x0000001a,0x0004003d,0x00000006,0x0000001c,0x00000014,0x00050083, + 0x00000006,0x0000001d,0x0000001b,0x0000001c,0x0003003e,0x00000018,0x0000001d,0x0004003d, + 0x00000006,0x0000001e,0x00000014,0x0004003d,0x00000006,0x0000001f,0x00000014,0x00050085, + 0x00000006,0x00000020,0x0000001f,0x0000001e,0x0003003e,0x00000014,0x00000020,0x0004003d, + 0x00000006,0x00000021,0x00000018,0x0004003d,0x00000006,0x00000022,0x00000014,0x00050085, + 0x00000006,0x00000023,0x00000021,0x00000022,0x000200fe,0x00000023,0x00010038,0x00050036, + 0x0000000c,0x00000012,0x00000000,0x0000000d,0x00030037,0x00000007,0x0000000e,0x00030037, + 0x00000007,0x0000000f,0x00030037,0x00000007,0x00000010,0x00030037,0x00000007,0x00000011, + 0x000200f8,0x00000013,0x0004003b,0x00000007,0x00000026,0x00000007,0x0004003b,0x00000007, + 0x00000038,0x00000007,0x0004003b,0x00000007,0x00000039,0x00000007,0x0004003d,0x00000006, + 0x00000027,0x0000000e,0x0004003d,0x00000006,0x00000028,0x0000000e,0x00050085,0x00000006, + 0x00000029,0x00000027,0x00000028,0x0004003d,0x00000006,0x0000002a,0x0000000f,0x0004003d, + 0x00000006,0x0000002b,0x0000000f,0x00050085,0x00000006,0x0000002c,0x0000002a,0x0000002b, + 0x00050081,0x00000006,0x0000002d,0x00000029,0x0000002c,0x00050085,0x00000006,0x0000002f, + 0x0000002d,0x0000002e,0x0004003d,0x00000006,0x00000030,0x00000010,0x0006000c,0x00000006, + 0x00000031,0x00000001,0x00000004,0x00000030,0x0004003d,0x00000006,0x00000032,0x00000011, + 0x00050085,0x00000006,0x00000033,0x00000031,0x00000032,0x0008000c,0x00000006,0x00000036, + 0x00000001,0x0000002b,0x00000033,0x00000034,0x00000035,0x00050081,0x00000006,0x00000037, + 0x0000002f,0x00000036,0x0003003e,0x00000026,0x00000037,0x0004003d,0x00000006,0x0000003a, + 0x00000026,0x0003003e,0x00000039,0x0000003a,0x00050039,0x00000006,0x0000003b,0x0000000a, + 0x00000039,0x0003003e,0x00000038,0x0000003b,0x0004003d,0x00000006,0x0000003c,0x00000038, + 0x0004003d,0x00000006,0x0000003d,0x00000038,0x0004003d,0x00000006,0x0000003e,0x00000010, + 0x00050085,0x00000006,0x0000003f,0x0000003d,0x0000003e,0x00050050,0x0000000c,0x00000040, + 0x0000003c,0x0000003f,0x000200fe,0x00000040,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/sgsr_quality.frag b/app/src/main/cpp/shaders/sgsr_quality.frag new file mode 100644 index 0000000000..2cab792e5f --- /dev/null +++ b/app/src/main/cpp/shaders/sgsr_quality.frag @@ -0,0 +1,156 @@ +#version 450 + +// ============================================================================= +// Snapdragon Game Super Resolution (SGSR) 1 - "Quality" variant (edge direction). +// +// Ported from Qualcomm's reference shader: +// SnapdragonGameStudios/snapdragon-gsr +// sgsr/v1/include/glsl/sgsr1_shader_mobile_edge_direction.frag +// +// Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +// +// Same single pass, inputs and push constants as sgsr.frag (the mode-3 "SGSR" +// shader, left untouched). Differences, both taken from the reference file: +// - UseEdgeDirection: the Lanczos weights are stretched along the local edge +// direction, so diagonal edges reconstruct cleaner ("minimal cost increase" +// per Qualcomm). +// - the reference's retuned contrast term: std = (10.14185 / sum)^2 +// (sgsr.frag keeps the older 2.181818 / sum). +// Adapted for the Winlator native Vulkan compositor exactly like sgsr.frag: +// - #version 450 (Vulkan GLSL), ViewportInfo via push constant +// - specialised to OperationMode == 1 (RGBA); green channel is the edge luma +// - reuses window.vert (full-screen quad over the destination rect) +// ============================================================================= + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as in Qualcomm's +// reference; positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D ps0; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by window.vert (offset 0) + highp vec4 ViewportInfo; // xy = 1/inputSize (texel size), zw = inputSize in pixels + float EdgeSharpness; // driven by the "Sharpness" slider +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 out_Target0; + +const float EdgeThreshold = 8.0 / 255.0; + +float fastLanczos2(float x) { + float wA = x - 4.0; + float wB = x * wA - wA; + wA *= wA; + return wB * wA; +} + +// data.x = std, data.yz = normalised edge direction +vec2 weightY(float dx, float dy, float c, vec3 data) { + float std = data.x; + vec2 dir = data.yz; + float edgeDis = (dx * dir.y) + (dy * dir.x); + float x = ((dx * dx) + (dy * dy)) + + ((edgeDis * edgeDis) * ((clamp((c * c) * std, 0.0, 1.0) * 0.7) - 1.0)); + float w = fastLanczos2(x); + return vec2(w, w * c); +} + +vec2 edgeDirection(vec4 left, vec4 right) { + float RxLz = right.x - left.z; + float RwLy = right.w - left.y; + vec2 delta; + delta.x = RxLz + RwLy; + delta.y = RxLz - RwLy; +#ifdef DD_HALF + // 3.07574e-05 is below the smallest normal 16-bit float (6.1e-05) and is + // flushed to 0 where denormals are not kept: 0 * inf on a flat row. Highp here. + highp vec2 dh = delta; + float lengthInv = inversesqrt((dh.x * dh.x + 3.075740e-05) + (dh.y * dh.y)); +#else + float lengthInv = inversesqrt((delta.x * delta.x + 3.075740e-05) + (delta.y * delta.y)); +#endif + return delta * lengthInv; +} + +void main() { + highp vec4 ViewportInfo = pc.ViewportInfo; + highp vec2 uv = fragTexCoord; + + vec4 color; + color.xyz = textureLod(ps0, uv, 0.0).xyz; + + highp vec2 imgCoord = ((uv * ViewportInfo.zw) + vec2(-0.5, 0.5)); + highp vec2 imgCoordPixel = floor(imgCoord); + highp vec2 coord = (imgCoordPixel * ViewportInfo.xy); + vec2 pl = (imgCoord + (-imgCoordPixel)); + vec4 left = textureGather(ps0, coord, 1); + + float edgeVote = abs(left.z - left.y) + abs(color.y - left.y) + abs(color.y - left.z); + if (edgeVote > EdgeThreshold) { + coord.x += ViewportInfo.x; + + vec4 right = textureGather(ps0, coord + vec2(ViewportInfo.x, 0.0), 1); + vec4 upDown; + upDown.xy = textureGather(ps0, coord + vec2(0.0, -ViewportInfo.y), 1).wz; + upDown.zw = textureGather(ps0, coord + vec2(0.0, ViewportInfo.y), 1).yx; + + float mean = (left.y + left.z + right.x + right.w) * 0.25; + left = left - vec4(mean); + right = right - vec4(mean); + upDown = upDown - vec4(mean); + color.w = color.y - mean; + + float sum = (((((abs(left.x) + abs(left.y)) + abs(left.z)) + abs(left.w)) + + (((abs(right.x) + abs(right.y)) + abs(right.z)) + abs(right.w))) + + (((abs(upDown.x) + abs(upDown.y)) + abs(upDown.z)) + abs(upDown.w))); + float sumMean = 1.014185e+01 / sum; +#ifdef DD_HALF + // (10.14 / sum)^2 passes 65504 (16-bit max) once sum < ~0.04, and c * c * inf + // is NaN for c == 0. Capped: c * c * cap still saturates the clamp below for + // any c >= 1/255. + float std = min(sumMean * sumMean, 65504.0); +#else + float std = sumMean * sumMean; +#endif + + vec3 data = vec3(std, edgeDirection(left, right)); + + vec2 aWY = weightY(pl.x, pl.y + 1.0, upDown.x, data); + aWY += weightY(pl.x - 1.0, pl.y + 1.0, upDown.y, data); + aWY += weightY(pl.x - 1.0, pl.y - 2.0, upDown.z, data); + aWY += weightY(pl.x, pl.y - 2.0, upDown.w, data); + aWY += weightY(pl.x + 1.0, pl.y - 1.0, left.x, data); + aWY += weightY(pl.x, pl.y - 1.0, left.y, data); + aWY += weightY(pl.x, pl.y, left.z, data); + aWY += weightY(pl.x + 1.0, pl.y, left.w, data); + aWY += weightY(pl.x - 1.0, pl.y - 1.0, right.x, data); + aWY += weightY(pl.x - 2.0, pl.y - 1.0, right.y, data); + aWY += weightY(pl.x - 2.0, pl.y, right.z, data); + aWY += weightY(pl.x - 1.0, pl.y, right.w, data); + + float finalY = aWY.y / aWY.x; + + float maxY = max(max(left.y, left.z), max(right.x, right.w)); + float minY = min(min(left.y, left.z), min(right.x, right.w)); + finalY = clamp(pc.EdgeSharpness * finalY, minY, maxY); + + float deltaY = finalY - color.w; + deltaY = clamp(deltaY, -23.0 / 255.0, 23.0 / 255.0); + + color.x = clamp((color.x + deltaY), 0.0, 1.0); + color.y = clamp((color.y + deltaY), 0.0, 1.0); + color.z = clamp((color.z + deltaY), 0.0, 1.0); + } + + color.w = 1.0; // alpha channel unused by the compositor blit + out_Target0 = color; +} diff --git a/app/src/main/cpp/shaders/sgsr_quality_half_frag.h b/app/src/main/cpp/shaders/sgsr_quality_half_frag.h new file mode 100644 index 0000000000..d715a73972 --- /dev/null +++ b/app/src/main/cpp/shaders/sgsr_quality_half_frag.h @@ -0,0 +1,612 @@ + // 1116.2.0 + #pragma once +const uint32_t sgsr_quality_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x0000026d,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000009e,0x0000026b,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00070005,0x0000000a,0x74736166,0x636e614c,0x32736f7a,0x3b316628,0x00000000, + 0x00030005,0x00000009,0x00000078,0x00080005,0x00000014,0x67696577,0x28597468,0x663b3166, + 0x31663b31,0x3366763b,0x0000003b,0x00030005,0x00000010,0x00007864,0x00030005,0x00000011, + 0x00007964,0x00030005,0x00000012,0x00000063,0x00040005,0x00000013,0x61746164,0x00000000, + 0x00080005,0x0000001b,0x65676465,0x65726944,0x6f697463,0x6676286e,0x66763b34,0x00003b34, + 0x00040005,0x00000019,0x7466656c,0x00000000,0x00040005,0x0000001a,0x68676972,0x00000074, + 0x00030005,0x0000001d,0x00004177,0x00030005,0x00000021,0x00004277,0x00030005,0x0000002f, + 0x00647473,0x00030005,0x00000035,0x00726964,0x00040005,0x00000038,0x65676465,0x00736944, + 0x00030005,0x00000043,0x00000078,0x00030005,0x0000005b,0x00000077,0x00040005,0x0000005c, + 0x61726170,0x0000006d,0x00040005,0x00000066,0x7a4c7852,0x00000000,0x00040005,0x0000006d, + 0x794c7752,0x00000000,0x00040005,0x00000074,0x746c6564,0x00000061,0x00030005,0x0000007d, + 0x00006864,0x00050005,0x0000007f,0x676e656c,0x6e496874,0x00000076,0x00060005,0x00000093, + 0x77656956,0x74726f70,0x6f666e49,0x00000000,0x00030005,0x00000094,0x00004350,0x00040006, + 0x00000094,0x00000000,0x0063646e,0x00070006,0x00000094,0x00000001,0x77656956,0x74726f70, + 0x6f666e49,0x00000000,0x00070006,0x00000094,0x00000002,0x65676445,0x72616853,0x73656e70, + 0x00000073,0x00030005,0x00000096,0x00006370,0x00030005,0x0000009c,0x00007675,0x00060005, + 0x0000009e,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00040005,0x000000a0,0x6f6c6f63, + 0x00000072,0x00030005,0x000000a4,0x00307370,0x00050005,0x000000af,0x43676d69,0x64726f6f, + 0x00000000,0x00060005,0x000000b8,0x43676d69,0x64726f6f,0x65786950,0x0000006c,0x00040005, + 0x000000bb,0x726f6f63,0x00000064,0x00030005,0x000000c0,0x00006c70,0x00040005,0x000000c5, + 0x7466656c,0x00000000,0x00050005,0x000000c9,0x65676465,0x65746f56,0x00000000,0x00040005, + 0x000000ea,0x68676972,0x00000074,0x00040005,0x000000f2,0x6f447075,0x00006e77,0x00040005, + 0x0000010c,0x6e61656d,0x00000000,0x00030005,0x0000012b,0x006d7573,0x00040005,0x0000015b, + 0x4d6d7573,0x006e6165,0x00030005,0x0000015f,0x00647473,0x00040005,0x00000165,0x61746164, + 0x00000000,0x00040005,0x00000167,0x61726170,0x0000006d,0x00040005,0x00000169,0x61726170, + 0x0000006d,0x00030005,0x0000016f,0x00595761,0x00040005,0x00000173,0x61726170,0x0000006d, + 0x00040005,0x00000176,0x61726170,0x0000006d,0x00040005,0x00000177,0x61726170,0x0000006d, + 0x00040005,0x0000017a,0x61726170,0x0000006d,0x00040005,0x00000183,0x61726170,0x0000006d, + 0x00040005,0x00000184,0x61726170,0x0000006d,0x00040005,0x00000185,0x61726170,0x0000006d, + 0x00040005,0x00000188,0x61726170,0x0000006d,0x00040005,0x00000194,0x61726170,0x0000006d, + 0x00040005,0x00000195,0x61726170,0x0000006d,0x00040005,0x00000196,0x61726170,0x0000006d, + 0x00040005,0x00000199,0x61726170,0x0000006d,0x00040005,0x000001a1,0x61726170,0x0000006d, + 0x00040005,0x000001a4,0x61726170,0x0000006d,0x00040005,0x000001a5,0x61726170,0x0000006d, + 0x00040005,0x000001a8,0x61726170,0x0000006d,0x00040005,0x000001b3,0x61726170,0x0000006d, + 0x00040005,0x000001b4,0x61726170,0x0000006d,0x00040005,0x000001b5,0x61726170,0x0000006d, + 0x00040005,0x000001b8,0x61726170,0x0000006d,0x00040005,0x000001c0,0x61726170,0x0000006d, + 0x00040005,0x000001c3,0x61726170,0x0000006d,0x00040005,0x000001c4,0x61726170,0x0000006d, + 0x00040005,0x000001c7,0x61726170,0x0000006d,0x00040005,0x000001cc,0x61726170,0x0000006d, + 0x00040005,0x000001cf,0x61726170,0x0000006d,0x00040005,0x000001d2,0x61726170,0x0000006d, + 0x00040005,0x000001d5,0x61726170,0x0000006d,0x00040005,0x000001dd,0x61726170,0x0000006d, + 0x00040005,0x000001de,0x61726170,0x0000006d,0x00040005,0x000001e1,0x61726170,0x0000006d, + 0x00040005,0x000001e4,0x61726170,0x0000006d,0x00040005,0x000001ef,0x61726170,0x0000006d, + 0x00040005,0x000001f0,0x61726170,0x0000006d,0x00040005,0x000001f1,0x61726170,0x0000006d, + 0x00040005,0x000001f4,0x61726170,0x0000006d,0x00040005,0x000001ff,0x61726170,0x0000006d, + 0x00040005,0x00000200,0x61726170,0x0000006d,0x00040005,0x00000201,0x61726170,0x0000006d, + 0x00040005,0x00000204,0x61726170,0x0000006d,0x00040005,0x0000020c,0x61726170,0x0000006d, + 0x00040005,0x0000020d,0x61726170,0x0000006d,0x00040005,0x00000210,0x61726170,0x0000006d, + 0x00040005,0x00000213,0x61726170,0x0000006d,0x00040005,0x0000021b,0x61726170,0x0000006d, + 0x00040005,0x0000021c,0x61726170,0x0000006d,0x00040005,0x0000021f,0x61726170,0x0000006d, + 0x00040005,0x00000222,0x61726170,0x0000006d,0x00040005,0x00000227,0x616e6966,0x0000596c, + 0x00040005,0x0000022d,0x5978616d,0x00000000,0x00040005,0x00000239,0x596e696d,0x00000000, + 0x00040005,0x0000024e,0x746c6564,0x00005961,0x00050005,0x0000026b,0x5f74756f,0x67726154, + 0x00307465,0x00030047,0x00000009,0x00000000,0x00030047,0x0000000a,0x00000000,0x00030047, + 0x00000010,0x00000000,0x00030047,0x00000011,0x00000000,0x00030047,0x00000012,0x00000000, + 0x00030047,0x00000013,0x00000000,0x00030047,0x00000014,0x00000000,0x00030047,0x00000019, + 0x00000000,0x00030047,0x0000001a,0x00000000,0x00030047,0x0000001b,0x00000000,0x00030047, + 0x0000001d,0x00000000,0x00030047,0x0000001e,0x00000000,0x00030047,0x00000020,0x00000000, + 0x00030047,0x00000021,0x00000000,0x00030047,0x00000022,0x00000000,0x00030047,0x00000023, + 0x00000000,0x00030047,0x00000024,0x00000000,0x00030047,0x00000025,0x00000000,0x00030047, + 0x00000026,0x00000000,0x00030047,0x00000027,0x00000000,0x00030047,0x00000028,0x00000000, + 0x00030047,0x00000029,0x00000000,0x00030047,0x0000002a,0x00000000,0x00030047,0x0000002b, + 0x00000000,0x00030047,0x0000002c,0x00000000,0x00030047,0x0000002f,0x00000000,0x00030047, + 0x00000033,0x00000000,0x00030047,0x00000035,0x00000000,0x00030047,0x00000036,0x00000000, + 0x00030047,0x00000037,0x00000000,0x00030047,0x00000038,0x00000000,0x00030047,0x00000039, + 0x00000000,0x00030047,0x0000003c,0x00000000,0x00030047,0x0000003d,0x00000000,0x00030047, + 0x0000003e,0x00000000,0x00030047,0x00000040,0x00000000,0x00030047,0x00000041,0x00000000, + 0x00030047,0x00000042,0x00000000,0x00030047,0x00000043,0x00000000,0x00030047,0x00000044, + 0x00000000,0x00030047,0x00000045,0x00000000,0x00030047,0x00000046,0x00000000,0x00030047, + 0x00000047,0x00000000,0x00030047,0x00000048,0x00000000,0x00030047,0x00000049,0x00000000, + 0x00030047,0x0000004a,0x00000000,0x00030047,0x0000004b,0x00000000,0x00030047,0x0000004c, + 0x00000000,0x00030047,0x0000004d,0x00000000,0x00030047,0x0000004e,0x00000000,0x00030047, + 0x0000004f,0x00000000,0x00030047,0x00000050,0x00000000,0x00030047,0x00000051,0x00000000, + 0x00030047,0x00000052,0x00000000,0x00030047,0x00000055,0x00000000,0x00030047,0x00000057, + 0x00000000,0x00030047,0x00000058,0x00000000,0x00030047,0x00000059,0x00000000,0x00030047, + 0x0000005a,0x00000000,0x00030047,0x0000005b,0x00000000,0x00030047,0x0000005c,0x00000000, + 0x00030047,0x0000005d,0x00000000,0x00030047,0x0000005e,0x00000000,0x00030047,0x0000005f, + 0x00000000,0x00030047,0x00000060,0x00000000,0x00030047,0x00000061,0x00000000,0x00030047, + 0x00000062,0x00000000,0x00030047,0x00000063,0x00000000,0x00030047,0x00000066,0x00000000, + 0x00030047,0x00000068,0x00000000,0x00030047,0x0000006b,0x00000000,0x00030047,0x0000006c, + 0x00000000,0x00030047,0x0000006d,0x00000000,0x00030047,0x00000070,0x00000000,0x00030047, + 0x00000072,0x00000000,0x00030047,0x00000073,0x00000000,0x00030047,0x00000074,0x00000000, + 0x00030047,0x00000075,0x00000000,0x00030047,0x00000076,0x00000000,0x00030047,0x00000077, + 0x00000000,0x00030047,0x00000079,0x00000000,0x00030047,0x0000007a,0x00000000,0x00030047, + 0x0000007b,0x00000000,0x00030047,0x0000007e,0x00000000,0x00030047,0x0000007f,0x00000000, + 0x00030047,0x0000008e,0x00000000,0x00030047,0x0000008f,0x00000000,0x00030047,0x00000090, + 0x00000000,0x00030047,0x00000094,0x00000002,0x00050048,0x00000094,0x00000000,0x00000023, + 0x00000000,0x00050048,0x00000094,0x00000001,0x00000023,0x00000010,0x00040048,0x00000094, + 0x00000002,0x00000000,0x00050048,0x00000094,0x00000002,0x00000023,0x00000020,0x00040047, + 0x0000009e,0x0000001e,0x00000000,0x00030047,0x000000a0,0x00000000,0x00030047,0x000000a4, + 0x00000000,0x00040047,0x000000a4,0x00000021,0x00000000,0x00040047,0x000000a4,0x00000022, + 0x00000000,0x00030047,0x000000a5,0x00000000,0x00030047,0x000000a7,0x00000000,0x00030047, + 0x000000a8,0x00000000,0x00030047,0x000000c0,0x00000000,0x00030047,0x000000c5,0x00000000, + 0x00030047,0x000000c6,0x00000000,0x00030047,0x000000c8,0x00000000,0x00030047,0x000000c9, + 0x00000000,0x00030047,0x000000cb,0x00000000,0x00030047,0x000000cd,0x00000000,0x00030047, + 0x000000ce,0x00000000,0x00030047,0x000000cf,0x00000000,0x00030047,0x000000d1,0x00000000, + 0x00030047,0x000000d3,0x00000000,0x00030047,0x000000d4,0x00000000,0x00030047,0x000000d5, + 0x00000000,0x00030047,0x000000d6,0x00000000,0x00030047,0x000000d8,0x00000000,0x00030047, + 0x000000da,0x00000000,0x00030047,0x000000db,0x00000000,0x00030047,0x000000dc,0x00000000, + 0x00030047,0x000000dd,0x00000000,0x00030047,0x000000de,0x00000000,0x00030047,0x000000df, + 0x00000000,0x00030047,0x000000ea,0x00000000,0x00030047,0x000000eb,0x00000000,0x00030047, + 0x000000f1,0x00000000,0x00030047,0x000000f2,0x00000000,0x00030047,0x000000f3,0x00000000, + 0x00030047,0x000000fa,0x00000000,0x00030047,0x000000fb,0x00000000,0x00030047,0x00000100, + 0x00000000,0x00030047,0x00000106,0x00000000,0x00030047,0x00000107,0x00000000,0x00030047, + 0x0000010c,0x00000000,0x00030047,0x0000010e,0x00000000,0x00030047,0x00000110,0x00000000, + 0x00030047,0x00000111,0x00000000,0x00030047,0x00000113,0x00000000,0x00030047,0x00000114, + 0x00000000,0x00030047,0x00000116,0x00000000,0x00030047,0x00000117,0x00000000,0x00030047, + 0x00000119,0x00000000,0x00030047,0x0000011a,0x00000000,0x00030047,0x0000011b,0x00000000, + 0x00030047,0x0000011c,0x00000000,0x00030047,0x0000011d,0x00000000,0x00030047,0x0000011e, + 0x00000000,0x00030047,0x0000011f,0x00000000,0x00030047,0x00000120,0x00000000,0x00030047, + 0x00000121,0x00000000,0x00030047,0x00000122,0x00000000,0x00030047,0x00000123,0x00000000, + 0x00030047,0x00000124,0x00000000,0x00030047,0x00000125,0x00000000,0x00030047,0x00000127, + 0x00000000,0x00030047,0x00000128,0x00000000,0x00030047,0x00000129,0x00000000,0x00030047, + 0x0000012b,0x00000000,0x00030047,0x0000012d,0x00000000,0x00030047,0x0000012e,0x00000000, + 0x00030047,0x00000130,0x00000000,0x00030047,0x00000131,0x00000000,0x00030047,0x00000132, + 0x00000000,0x00030047,0x00000134,0x00000000,0x00030047,0x00000135,0x00000000,0x00030047, + 0x00000136,0x00000000,0x00030047,0x00000138,0x00000000,0x00030047,0x00000139,0x00000000, + 0x00030047,0x0000013a,0x00000000,0x00030047,0x0000013c,0x00000000,0x00030047,0x0000013d, + 0x00000000,0x00030047,0x0000013f,0x00000000,0x00030047,0x00000140,0x00000000,0x00030047, + 0x00000141,0x00000000,0x00030047,0x00000143,0x00000000,0x00030047,0x00000144,0x00000000, + 0x00030047,0x00000145,0x00000000,0x00030047,0x00000147,0x00000000,0x00030047,0x00000148, + 0x00000000,0x00030047,0x00000149,0x00000000,0x00030047,0x0000014a,0x00000000,0x00030047, + 0x0000014c,0x00000000,0x00030047,0x0000014d,0x00000000,0x00030047,0x0000014f,0x00000000, + 0x00030047,0x00000150,0x00000000,0x00030047,0x00000151,0x00000000,0x00030047,0x00000153, + 0x00000000,0x00030047,0x00000154,0x00000000,0x00030047,0x00000155,0x00000000,0x00030047, + 0x00000157,0x00000000,0x00030047,0x00000158,0x00000000,0x00030047,0x00000159,0x00000000, + 0x00030047,0x0000015a,0x00000000,0x00030047,0x0000015b,0x00000000,0x00030047,0x0000015d, + 0x00000000,0x00030047,0x0000015e,0x00000000,0x00030047,0x0000015f,0x00000000,0x00030047, + 0x00000160,0x00000000,0x00030047,0x00000161,0x00000000,0x00030047,0x00000162,0x00000000, + 0x00030047,0x00000164,0x00000000,0x00030047,0x00000165,0x00000000,0x00030047,0x00000166, + 0x00000000,0x00030047,0x00000167,0x00000000,0x00030047,0x00000168,0x00000000,0x00030047, + 0x00000169,0x00000000,0x00030047,0x0000016a,0x00000000,0x00030047,0x0000016b,0x00000000, + 0x00030047,0x0000016c,0x00000000,0x00030047,0x0000016d,0x00000000,0x00030047,0x0000016e, + 0x00000000,0x00030047,0x0000016f,0x00000000,0x00030047,0x00000171,0x00000000,0x00030047, + 0x00000172,0x00000000,0x00030047,0x00000173,0x00000000,0x00030047,0x00000175,0x00000000, + 0x00030047,0x00000176,0x00000000,0x00030047,0x00000177,0x00000000,0x00030047,0x00000179, + 0x00000000,0x00030047,0x0000017a,0x00000000,0x00030047,0x0000017b,0x00000000,0x00030047, + 0x0000017c,0x00000000,0x00030047,0x0000017e,0x00000000,0x00030047,0x0000017f,0x00000000, + 0x00030047,0x00000181,0x00000000,0x00030047,0x00000182,0x00000000,0x00030047,0x00000183, + 0x00000000,0x00030047,0x00000184,0x00000000,0x00030047,0x00000185,0x00000000,0x00030047, + 0x00000187,0x00000000,0x00030047,0x00000188,0x00000000,0x00030047,0x00000189,0x00000000, + 0x00030047,0x0000018a,0x00000000,0x00030047,0x0000018b,0x00000000,0x00030047,0x0000018c, + 0x00000000,0x00030047,0x0000018e,0x00000000,0x00030047,0x0000018f,0x00000000,0x00030047, + 0x00000191,0x00000000,0x00030047,0x00000193,0x00000000,0x00030047,0x00000194,0x00000000, + 0x00030047,0x00000195,0x00000000,0x00030047,0x00000196,0x00000000,0x00030047,0x00000198, + 0x00000000,0x00030047,0x00000199,0x00000000,0x00030047,0x0000019a,0x00000000,0x00030047, + 0x0000019b,0x00000000,0x00030047,0x0000019c,0x00000000,0x00030047,0x0000019d,0x00000000, + 0x00030047,0x0000019f,0x00000000,0x00030047,0x000001a0,0x00000000,0x00030047,0x000001a1, + 0x00000000,0x00030047,0x000001a3,0x00000000,0x00030047,0x000001a4,0x00000000,0x00030047, + 0x000001a5,0x00000000,0x00030047,0x000001a7,0x00000000,0x00030047,0x000001a8,0x00000000, + 0x00030047,0x000001a9,0x00000000,0x00030047,0x000001aa,0x00000000,0x00030047,0x000001ab, + 0x00000000,0x00030047,0x000001ac,0x00000000,0x00030047,0x000001ae,0x00000000,0x00030047, + 0x000001af,0x00000000,0x00030047,0x000001b1,0x00000000,0x00030047,0x000001b2,0x00000000, + 0x00030047,0x000001b3,0x00000000,0x00030047,0x000001b4,0x00000000,0x00030047,0x000001b5, + 0x00000000,0x00030047,0x000001b7,0x00000000,0x00030047,0x000001b8,0x00000000,0x00030047, + 0x000001b9,0x00000000,0x00030047,0x000001ba,0x00000000,0x00030047,0x000001bb,0x00000000, + 0x00030047,0x000001bc,0x00000000,0x00030047,0x000001be,0x00000000,0x00030047,0x000001bf, + 0x00000000,0x00030047,0x000001c0,0x00000000,0x00030047,0x000001c2,0x00000000,0x00030047, + 0x000001c3,0x00000000,0x00030047,0x000001c4,0x00000000,0x00030047,0x000001c6,0x00000000, + 0x00030047,0x000001c7,0x00000000,0x00030047,0x000001c8,0x00000000,0x00030047,0x000001c9, + 0x00000000,0x00030047,0x000001ca,0x00000000,0x00030047,0x000001cb,0x00000000,0x00030047, + 0x000001cc,0x00000000,0x00030047,0x000001ce,0x00000000,0x00030047,0x000001cf,0x00000000, + 0x00030047,0x000001d1,0x00000000,0x00030047,0x000001d2,0x00000000,0x00030047,0x000001d4, + 0x00000000,0x00030047,0x000001d5,0x00000000,0x00030047,0x000001d6,0x00000000,0x00030047, + 0x000001d7,0x00000000,0x00030047,0x000001d8,0x00000000,0x00030047,0x000001d9,0x00000000, + 0x00030047,0x000001db,0x00000000,0x00030047,0x000001dc,0x00000000,0x00030047,0x000001dd, + 0x00000000,0x00030047,0x000001de,0x00000000,0x00030047,0x000001e0,0x00000000,0x00030047, + 0x000001e1,0x00000000,0x00030047,0x000001e3,0x00000000,0x00030047,0x000001e4,0x00000000, + 0x00030047,0x000001e5,0x00000000,0x00030047,0x000001e6,0x00000000,0x00030047,0x000001e7, + 0x00000000,0x00030047,0x000001e8,0x00000000,0x00030047,0x000001ea,0x00000000,0x00030047, + 0x000001eb,0x00000000,0x00030047,0x000001ed,0x00000000,0x00030047,0x000001ee,0x00000000, + 0x00030047,0x000001ef,0x00000000,0x00030047,0x000001f0,0x00000000,0x00030047,0x000001f1, + 0x00000000,0x00030047,0x000001f3,0x00000000,0x00030047,0x000001f4,0x00000000,0x00030047, + 0x000001f5,0x00000000,0x00030047,0x000001f6,0x00000000,0x00030047,0x000001f7,0x00000000, + 0x00030047,0x000001f8,0x00000000,0x00030047,0x000001fa,0x00000000,0x00030047,0x000001fb, + 0x00000000,0x00030047,0x000001fd,0x00000000,0x00030047,0x000001fe,0x00000000,0x00030047, + 0x000001ff,0x00000000,0x00030047,0x00000200,0x00000000,0x00030047,0x00000201,0x00000000, + 0x00030047,0x00000203,0x00000000,0x00030047,0x00000204,0x00000000,0x00030047,0x00000205, + 0x00000000,0x00030047,0x00000206,0x00000000,0x00030047,0x00000207,0x00000000,0x00030047, + 0x00000208,0x00000000,0x00030047,0x0000020a,0x00000000,0x00030047,0x0000020b,0x00000000, + 0x00030047,0x0000020c,0x00000000,0x00030047,0x0000020d,0x00000000,0x00030047,0x0000020f, + 0x00000000,0x00030047,0x00000210,0x00000000,0x00030047,0x00000212,0x00000000,0x00030047, + 0x00000213,0x00000000,0x00030047,0x00000214,0x00000000,0x00030047,0x00000215,0x00000000, + 0x00030047,0x00000216,0x00000000,0x00030047,0x00000217,0x00000000,0x00030047,0x00000219, + 0x00000000,0x00030047,0x0000021a,0x00000000,0x00030047,0x0000021b,0x00000000,0x00030047, + 0x0000021c,0x00000000,0x00030047,0x0000021e,0x00000000,0x00030047,0x0000021f,0x00000000, + 0x00030047,0x00000221,0x00000000,0x00030047,0x00000222,0x00000000,0x00030047,0x00000223, + 0x00000000,0x00030047,0x00000224,0x00000000,0x00030047,0x00000225,0x00000000,0x00030047, + 0x00000226,0x00000000,0x00030047,0x00000227,0x00000000,0x00030047,0x00000229,0x00000000, + 0x00030047,0x0000022b,0x00000000,0x00030047,0x0000022c,0x00000000,0x00030047,0x0000022d, + 0x00000000,0x00030047,0x0000022f,0x00000000,0x00030047,0x00000231,0x00000000,0x00030047, + 0x00000232,0x00000000,0x00030047,0x00000234,0x00000000,0x00030047,0x00000236,0x00000000, + 0x00030047,0x00000237,0x00000000,0x00030047,0x00000238,0x00000000,0x00030047,0x00000239, + 0x00000000,0x00030047,0x0000023b,0x00000000,0x00030047,0x0000023d,0x00000000,0x00030047, + 0x0000023e,0x00000000,0x00030047,0x00000240,0x00000000,0x00030047,0x00000242,0x00000000, + 0x00030047,0x00000243,0x00000000,0x00030047,0x00000244,0x00000000,0x00030047,0x00000248, + 0x00000000,0x00030047,0x00000249,0x00000000,0x00030047,0x0000024a,0x00000000,0x00030047, + 0x0000024b,0x00000000,0x00030047,0x0000024c,0x00000000,0x00030047,0x0000024d,0x00000000, + 0x00030047,0x0000024e,0x00000000,0x00030047,0x0000024f,0x00000000,0x00030047,0x00000251, + 0x00000000,0x00030047,0x00000252,0x00000000,0x00030047,0x00000253,0x00000000,0x00030047, + 0x00000256,0x00000000,0x00030047,0x00000258,0x00000000,0x00030047,0x00000259,0x00000000, + 0x00030047,0x0000025a,0x00000000,0x00030047,0x0000025b,0x00000000,0x00030047,0x0000025e, + 0x00000000,0x00030047,0x0000025f,0x00000000,0x00030047,0x00000260,0x00000000,0x00030047, + 0x00000261,0x00000000,0x00030047,0x00000264,0x00000000,0x00030047,0x00000265,0x00000000, + 0x00030047,0x00000266,0x00000000,0x00030047,0x00000267,0x00000000,0x00030047,0x0000026b, + 0x00000000,0x00040047,0x0000026b,0x0000001e,0x00000000,0x00030047,0x0000026c,0x00000000, + 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, + 0x00040020,0x00000007,0x00000007,0x00000006,0x00040021,0x00000008,0x00000006,0x00000007, + 0x00040017,0x0000000c,0x00000006,0x00000003,0x00040020,0x0000000d,0x00000007,0x0000000c, + 0x00040017,0x0000000e,0x00000006,0x00000002,0x00070021,0x0000000f,0x0000000e,0x00000007, + 0x00000007,0x00000007,0x0000000d,0x00040017,0x00000016,0x00000006,0x00000004,0x00040020, + 0x00000017,0x00000007,0x00000016,0x00050021,0x00000018,0x0000000e,0x00000017,0x00000017, + 0x0004002b,0x00000006,0x0000001f,0x40800000,0x00040015,0x00000030,0x00000020,0x00000000, + 0x0004002b,0x00000030,0x00000031,0x00000000,0x00040020,0x00000034,0x00000007,0x0000000e, + 0x0004002b,0x00000030,0x0000003a,0x00000001,0x0004002b,0x00000006,0x00000053,0x00000000, + 0x0004002b,0x00000006,0x00000054,0x3f800000,0x0004002b,0x00000006,0x00000056,0x3f333333, + 0x0004002b,0x00000030,0x00000069,0x00000002,0x0004002b,0x00000030,0x0000006e,0x00000003, + 0x0004002b,0x00000006,0x00000085,0x38010182,0x0005001e,0x00000094,0x00000016,0x00000016, + 0x00000006,0x00040020,0x00000095,0x00000009,0x00000094,0x0004003b,0x00000095,0x00000096, + 0x00000009,0x00040015,0x00000097,0x00000020,0x00000001,0x0004002b,0x00000097,0x00000098, + 0x00000001,0x00040020,0x00000099,0x00000009,0x00000016,0x00040020,0x0000009d,0x00000001, + 0x0000000e,0x0004003b,0x0000009d,0x0000009e,0x00000001,0x00090019,0x000000a1,0x00000006, + 0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x000000a2, + 0x000000a1,0x00040020,0x000000a3,0x00000000,0x000000a2,0x0004003b,0x000000a3,0x000000a4, + 0x00000000,0x0004002b,0x00000006,0x000000b4,0xbf000000,0x0004002b,0x00000006,0x000000b5, + 0x3f000000,0x0005002c,0x0000000e,0x000000b6,0x000000b4,0x000000b5,0x0004002b,0x00000006, + 0x000000df,0x3d008081,0x00020014,0x000000e0,0x0004002b,0x00000006,0x00000118,0x3e800000, + 0x0004002b,0x00000006,0x0000015c,0x41224505,0x0004002b,0x00000006,0x00000163,0x477fe000, + 0x0004002b,0x00000006,0x00000192,0x40000000,0x0004002b,0x00000097,0x00000245,0x00000002, + 0x00040020,0x00000246,0x00000009,0x00000006,0x0004002b,0x00000006,0x00000254,0xbdb8b8b9, + 0x0004002b,0x00000006,0x00000255,0x3db8b8b9,0x00040020,0x0000026a,0x00000003,0x00000016, + 0x0004003b,0x0000026a,0x0000026b,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000, + 0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000017,0x00000093,0x00000007,0x0004003b, + 0x00000034,0x0000009c,0x00000007,0x0004003b,0x00000017,0x000000a0,0x00000007,0x0004003b, + 0x00000034,0x000000af,0x00000007,0x0004003b,0x00000034,0x000000b8,0x00000007,0x0004003b, + 0x00000034,0x000000bb,0x00000007,0x0004003b,0x00000034,0x000000c0,0x00000007,0x0004003b, + 0x00000017,0x000000c5,0x00000007,0x0004003b,0x00000007,0x000000c9,0x00000007,0x0004003b, + 0x00000017,0x000000ea,0x00000007,0x0004003b,0x00000017,0x000000f2,0x00000007,0x0004003b, + 0x00000007,0x0000010c,0x00000007,0x0004003b,0x00000007,0x0000012b,0x00000007,0x0004003b, + 0x00000007,0x0000015b,0x00000007,0x0004003b,0x00000007,0x0000015f,0x00000007,0x0004003b, + 0x0000000d,0x00000165,0x00000007,0x0004003b,0x00000017,0x00000167,0x00000007,0x0004003b, + 0x00000017,0x00000169,0x00000007,0x0004003b,0x00000034,0x0000016f,0x00000007,0x0004003b, + 0x00000007,0x00000173,0x00000007,0x0004003b,0x00000007,0x00000176,0x00000007,0x0004003b, + 0x00000007,0x00000177,0x00000007,0x0004003b,0x0000000d,0x0000017a,0x00000007,0x0004003b, + 0x00000007,0x00000183,0x00000007,0x0004003b,0x00000007,0x00000184,0x00000007,0x0004003b, + 0x00000007,0x00000185,0x00000007,0x0004003b,0x0000000d,0x00000188,0x00000007,0x0004003b, + 0x00000007,0x00000194,0x00000007,0x0004003b,0x00000007,0x00000195,0x00000007,0x0004003b, + 0x00000007,0x00000196,0x00000007,0x0004003b,0x0000000d,0x00000199,0x00000007,0x0004003b, + 0x00000007,0x000001a1,0x00000007,0x0004003b,0x00000007,0x000001a4,0x00000007,0x0004003b, + 0x00000007,0x000001a5,0x00000007,0x0004003b,0x0000000d,0x000001a8,0x00000007,0x0004003b, + 0x00000007,0x000001b3,0x00000007,0x0004003b,0x00000007,0x000001b4,0x00000007,0x0004003b, + 0x00000007,0x000001b5,0x00000007,0x0004003b,0x0000000d,0x000001b8,0x00000007,0x0004003b, + 0x00000007,0x000001c0,0x00000007,0x0004003b,0x00000007,0x000001c3,0x00000007,0x0004003b, + 0x00000007,0x000001c4,0x00000007,0x0004003b,0x0000000d,0x000001c7,0x00000007,0x0004003b, + 0x00000007,0x000001cc,0x00000007,0x0004003b,0x00000007,0x000001cf,0x00000007,0x0004003b, + 0x00000007,0x000001d2,0x00000007,0x0004003b,0x0000000d,0x000001d5,0x00000007,0x0004003b, + 0x00000007,0x000001dd,0x00000007,0x0004003b,0x00000007,0x000001de,0x00000007,0x0004003b, + 0x00000007,0x000001e1,0x00000007,0x0004003b,0x0000000d,0x000001e4,0x00000007,0x0004003b, + 0x00000007,0x000001ef,0x00000007,0x0004003b,0x00000007,0x000001f0,0x00000007,0x0004003b, + 0x00000007,0x000001f1,0x00000007,0x0004003b,0x0000000d,0x000001f4,0x00000007,0x0004003b, + 0x00000007,0x000001ff,0x00000007,0x0004003b,0x00000007,0x00000200,0x00000007,0x0004003b, + 0x00000007,0x00000201,0x00000007,0x0004003b,0x0000000d,0x00000204,0x00000007,0x0004003b, + 0x00000007,0x0000020c,0x00000007,0x0004003b,0x00000007,0x0000020d,0x00000007,0x0004003b, + 0x00000007,0x00000210,0x00000007,0x0004003b,0x0000000d,0x00000213,0x00000007,0x0004003b, + 0x00000007,0x0000021b,0x00000007,0x0004003b,0x00000007,0x0000021c,0x00000007,0x0004003b, + 0x00000007,0x0000021f,0x00000007,0x0004003b,0x0000000d,0x00000222,0x00000007,0x0004003b, + 0x00000007,0x00000227,0x00000007,0x0004003b,0x00000007,0x0000022d,0x00000007,0x0004003b, + 0x00000007,0x00000239,0x00000007,0x0004003b,0x00000007,0x0000024e,0x00000007,0x00050041, + 0x00000099,0x0000009a,0x00000096,0x00000098,0x0004003d,0x00000016,0x0000009b,0x0000009a, + 0x0003003e,0x00000093,0x0000009b,0x0004003d,0x0000000e,0x0000009f,0x0000009e,0x0003003e, + 0x0000009c,0x0000009f,0x0004003d,0x000000a2,0x000000a5,0x000000a4,0x0004003d,0x0000000e, + 0x000000a6,0x0000009c,0x00070058,0x00000016,0x000000a7,0x000000a5,0x000000a6,0x00000002, + 0x00000053,0x0008004f,0x0000000c,0x000000a8,0x000000a7,0x000000a7,0x00000000,0x00000001, + 0x00000002,0x00050041,0x00000007,0x000000a9,0x000000a0,0x00000031,0x00050051,0x00000006, + 0x000000aa,0x000000a8,0x00000000,0x0003003e,0x000000a9,0x000000aa,0x00050041,0x00000007, + 0x000000ab,0x000000a0,0x0000003a,0x00050051,0x00000006,0x000000ac,0x000000a8,0x00000001, + 0x0003003e,0x000000ab,0x000000ac,0x00050041,0x00000007,0x000000ad,0x000000a0,0x00000069, + 0x00050051,0x00000006,0x000000ae,0x000000a8,0x00000002,0x0003003e,0x000000ad,0x000000ae, + 0x0004003d,0x0000000e,0x000000b0,0x0000009c,0x0004003d,0x00000016,0x000000b1,0x00000093, + 0x0007004f,0x0000000e,0x000000b2,0x000000b1,0x000000b1,0x00000002,0x00000003,0x00050085, + 0x0000000e,0x000000b3,0x000000b0,0x000000b2,0x00050081,0x0000000e,0x000000b7,0x000000b3, + 0x000000b6,0x0003003e,0x000000af,0x000000b7,0x0004003d,0x0000000e,0x000000b9,0x000000af, + 0x0006000c,0x0000000e,0x000000ba,0x00000001,0x00000008,0x000000b9,0x0003003e,0x000000b8, + 0x000000ba,0x0004003d,0x0000000e,0x000000bc,0x000000b8,0x0004003d,0x00000016,0x000000bd, + 0x00000093,0x0007004f,0x0000000e,0x000000be,0x000000bd,0x000000bd,0x00000000,0x00000001, + 0x00050085,0x0000000e,0x000000bf,0x000000bc,0x000000be,0x0003003e,0x000000bb,0x000000bf, + 0x0004003d,0x0000000e,0x000000c1,0x000000af,0x0004003d,0x0000000e,0x000000c2,0x000000b8, + 0x0004007f,0x0000000e,0x000000c3,0x000000c2,0x00050081,0x0000000e,0x000000c4,0x000000c1, + 0x000000c3,0x0003003e,0x000000c0,0x000000c4,0x0004003d,0x000000a2,0x000000c6,0x000000a4, + 0x0004003d,0x0000000e,0x000000c7,0x000000bb,0x00060060,0x00000016,0x000000c8,0x000000c6, + 0x000000c7,0x00000098,0x0003003e,0x000000c5,0x000000c8,0x00050041,0x00000007,0x000000ca, + 0x000000c5,0x00000069,0x0004003d,0x00000006,0x000000cb,0x000000ca,0x00050041,0x00000007, + 0x000000cc,0x000000c5,0x0000003a,0x0004003d,0x00000006,0x000000cd,0x000000cc,0x00050083, + 0x00000006,0x000000ce,0x000000cb,0x000000cd,0x0006000c,0x00000006,0x000000cf,0x00000001, + 0x00000004,0x000000ce,0x00050041,0x00000007,0x000000d0,0x000000a0,0x0000003a,0x0004003d, + 0x00000006,0x000000d1,0x000000d0,0x00050041,0x00000007,0x000000d2,0x000000c5,0x0000003a, + 0x0004003d,0x00000006,0x000000d3,0x000000d2,0x00050083,0x00000006,0x000000d4,0x000000d1, + 0x000000d3,0x0006000c,0x00000006,0x000000d5,0x00000001,0x00000004,0x000000d4,0x00050081, + 0x00000006,0x000000d6,0x000000cf,0x000000d5,0x00050041,0x00000007,0x000000d7,0x000000a0, + 0x0000003a,0x0004003d,0x00000006,0x000000d8,0x000000d7,0x00050041,0x00000007,0x000000d9, + 0x000000c5,0x00000069,0x0004003d,0x00000006,0x000000da,0x000000d9,0x00050083,0x00000006, + 0x000000db,0x000000d8,0x000000da,0x0006000c,0x00000006,0x000000dc,0x00000001,0x00000004, + 0x000000db,0x00050081,0x00000006,0x000000dd,0x000000d6,0x000000dc,0x0003003e,0x000000c9, + 0x000000dd,0x0004003d,0x00000006,0x000000de,0x000000c9,0x000500ba,0x000000e0,0x000000e1, + 0x000000de,0x000000df,0x000300f7,0x000000e3,0x00000000,0x000400fa,0x000000e1,0x000000e2, + 0x000000e3,0x000200f8,0x000000e2,0x00050041,0x00000007,0x000000e4,0x00000093,0x00000031, + 0x0004003d,0x00000006,0x000000e5,0x000000e4,0x00050041,0x00000007,0x000000e6,0x000000bb, + 0x00000031,0x0004003d,0x00000006,0x000000e7,0x000000e6,0x00050081,0x00000006,0x000000e8, + 0x000000e7,0x000000e5,0x00050041,0x00000007,0x000000e9,0x000000bb,0x00000031,0x0003003e, + 0x000000e9,0x000000e8,0x0004003d,0x000000a2,0x000000eb,0x000000a4,0x0004003d,0x0000000e, + 0x000000ec,0x000000bb,0x00050041,0x00000007,0x000000ed,0x00000093,0x00000031,0x0004003d, + 0x00000006,0x000000ee,0x000000ed,0x00050050,0x0000000e,0x000000ef,0x000000ee,0x00000053, + 0x00050081,0x0000000e,0x000000f0,0x000000ec,0x000000ef,0x00060060,0x00000016,0x000000f1, + 0x000000eb,0x000000f0,0x00000098,0x0003003e,0x000000ea,0x000000f1,0x0004003d,0x000000a2, + 0x000000f3,0x000000a4,0x0004003d,0x0000000e,0x000000f4,0x000000bb,0x00050041,0x00000007, + 0x000000f5,0x00000093,0x0000003a,0x0004003d,0x00000006,0x000000f6,0x000000f5,0x0004007f, + 0x00000006,0x000000f7,0x000000f6,0x00050050,0x0000000e,0x000000f8,0x00000053,0x000000f7, + 0x00050081,0x0000000e,0x000000f9,0x000000f4,0x000000f8,0x00060060,0x00000016,0x000000fa, + 0x000000f3,0x000000f9,0x00000098,0x0007004f,0x0000000e,0x000000fb,0x000000fa,0x000000fa, + 0x00000003,0x00000002,0x00050041,0x00000007,0x000000fc,0x000000f2,0x00000031,0x00050051, + 0x00000006,0x000000fd,0x000000fb,0x00000000,0x0003003e,0x000000fc,0x000000fd,0x00050041, + 0x00000007,0x000000fe,0x000000f2,0x0000003a,0x00050051,0x00000006,0x000000ff,0x000000fb, + 0x00000001,0x0003003e,0x000000fe,0x000000ff,0x0004003d,0x000000a2,0x00000100,0x000000a4, + 0x0004003d,0x0000000e,0x00000101,0x000000bb,0x00050041,0x00000007,0x00000102,0x00000093, + 0x0000003a,0x0004003d,0x00000006,0x00000103,0x00000102,0x00050050,0x0000000e,0x00000104, + 0x00000053,0x00000103,0x00050081,0x0000000e,0x00000105,0x00000101,0x00000104,0x00060060, + 0x00000016,0x00000106,0x00000100,0x00000105,0x00000098,0x0007004f,0x0000000e,0x00000107, + 0x00000106,0x00000106,0x00000001,0x00000000,0x00050041,0x00000007,0x00000108,0x000000f2, + 0x00000069,0x00050051,0x00000006,0x00000109,0x00000107,0x00000000,0x0003003e,0x00000108, + 0x00000109,0x00050041,0x00000007,0x0000010a,0x000000f2,0x0000006e,0x00050051,0x00000006, + 0x0000010b,0x00000107,0x00000001,0x0003003e,0x0000010a,0x0000010b,0x00050041,0x00000007, + 0x0000010d,0x000000c5,0x0000003a,0x0004003d,0x00000006,0x0000010e,0x0000010d,0x00050041, + 0x00000007,0x0000010f,0x000000c5,0x00000069,0x0004003d,0x00000006,0x00000110,0x0000010f, + 0x00050081,0x00000006,0x00000111,0x0000010e,0x00000110,0x00050041,0x00000007,0x00000112, + 0x000000ea,0x00000031,0x0004003d,0x00000006,0x00000113,0x00000112,0x00050081,0x00000006, + 0x00000114,0x00000111,0x00000113,0x00050041,0x00000007,0x00000115,0x000000ea,0x0000006e, + 0x0004003d,0x00000006,0x00000116,0x00000115,0x00050081,0x00000006,0x00000117,0x00000114, + 0x00000116,0x00050085,0x00000006,0x00000119,0x00000117,0x00000118,0x0003003e,0x0000010c, + 0x00000119,0x0004003d,0x00000016,0x0000011a,0x000000c5,0x0004003d,0x00000006,0x0000011b, + 0x0000010c,0x00070050,0x00000016,0x0000011c,0x0000011b,0x0000011b,0x0000011b,0x0000011b, + 0x00050083,0x00000016,0x0000011d,0x0000011a,0x0000011c,0x0003003e,0x000000c5,0x0000011d, + 0x0004003d,0x00000016,0x0000011e,0x000000ea,0x0004003d,0x00000006,0x0000011f,0x0000010c, + 0x00070050,0x00000016,0x00000120,0x0000011f,0x0000011f,0x0000011f,0x0000011f,0x00050083, + 0x00000016,0x00000121,0x0000011e,0x00000120,0x0003003e,0x000000ea,0x00000121,0x0004003d, + 0x00000016,0x00000122,0x000000f2,0x0004003d,0x00000006,0x00000123,0x0000010c,0x00070050, + 0x00000016,0x00000124,0x00000123,0x00000123,0x00000123,0x00000123,0x00050083,0x00000016, + 0x00000125,0x00000122,0x00000124,0x0003003e,0x000000f2,0x00000125,0x00050041,0x00000007, + 0x00000126,0x000000a0,0x0000003a,0x0004003d,0x00000006,0x00000127,0x00000126,0x0004003d, + 0x00000006,0x00000128,0x0000010c,0x00050083,0x00000006,0x00000129,0x00000127,0x00000128, + 0x00050041,0x00000007,0x0000012a,0x000000a0,0x0000006e,0x0003003e,0x0000012a,0x00000129, + 0x00050041,0x00000007,0x0000012c,0x000000c5,0x00000031,0x0004003d,0x00000006,0x0000012d, + 0x0000012c,0x0006000c,0x00000006,0x0000012e,0x00000001,0x00000004,0x0000012d,0x00050041, + 0x00000007,0x0000012f,0x000000c5,0x0000003a,0x0004003d,0x00000006,0x00000130,0x0000012f, + 0x0006000c,0x00000006,0x00000131,0x00000001,0x00000004,0x00000130,0x00050081,0x00000006, + 0x00000132,0x0000012e,0x00000131,0x00050041,0x00000007,0x00000133,0x000000c5,0x00000069, + 0x0004003d,0x00000006,0x00000134,0x00000133,0x0006000c,0x00000006,0x00000135,0x00000001, + 0x00000004,0x00000134,0x00050081,0x00000006,0x00000136,0x00000132,0x00000135,0x00050041, + 0x00000007,0x00000137,0x000000c5,0x0000006e,0x0004003d,0x00000006,0x00000138,0x00000137, + 0x0006000c,0x00000006,0x00000139,0x00000001,0x00000004,0x00000138,0x00050081,0x00000006, + 0x0000013a,0x00000136,0x00000139,0x00050041,0x00000007,0x0000013b,0x000000ea,0x00000031, + 0x0004003d,0x00000006,0x0000013c,0x0000013b,0x0006000c,0x00000006,0x0000013d,0x00000001, + 0x00000004,0x0000013c,0x00050041,0x00000007,0x0000013e,0x000000ea,0x0000003a,0x0004003d, + 0x00000006,0x0000013f,0x0000013e,0x0006000c,0x00000006,0x00000140,0x00000001,0x00000004, + 0x0000013f,0x00050081,0x00000006,0x00000141,0x0000013d,0x00000140,0x00050041,0x00000007, + 0x00000142,0x000000ea,0x00000069,0x0004003d,0x00000006,0x00000143,0x00000142,0x0006000c, + 0x00000006,0x00000144,0x00000001,0x00000004,0x00000143,0x00050081,0x00000006,0x00000145, + 0x00000141,0x00000144,0x00050041,0x00000007,0x00000146,0x000000ea,0x0000006e,0x0004003d, + 0x00000006,0x00000147,0x00000146,0x0006000c,0x00000006,0x00000148,0x00000001,0x00000004, + 0x00000147,0x00050081,0x00000006,0x00000149,0x00000145,0x00000148,0x00050081,0x00000006, + 0x0000014a,0x0000013a,0x00000149,0x00050041,0x00000007,0x0000014b,0x000000f2,0x00000031, + 0x0004003d,0x00000006,0x0000014c,0x0000014b,0x0006000c,0x00000006,0x0000014d,0x00000001, + 0x00000004,0x0000014c,0x00050041,0x00000007,0x0000014e,0x000000f2,0x0000003a,0x0004003d, + 0x00000006,0x0000014f,0x0000014e,0x0006000c,0x00000006,0x00000150,0x00000001,0x00000004, + 0x0000014f,0x00050081,0x00000006,0x00000151,0x0000014d,0x00000150,0x00050041,0x00000007, + 0x00000152,0x000000f2,0x00000069,0x0004003d,0x00000006,0x00000153,0x00000152,0x0006000c, + 0x00000006,0x00000154,0x00000001,0x00000004,0x00000153,0x00050081,0x00000006,0x00000155, + 0x00000151,0x00000154,0x00050041,0x00000007,0x00000156,0x000000f2,0x0000006e,0x0004003d, + 0x00000006,0x00000157,0x00000156,0x0006000c,0x00000006,0x00000158,0x00000001,0x00000004, + 0x00000157,0x00050081,0x00000006,0x00000159,0x00000155,0x00000158,0x00050081,0x00000006, + 0x0000015a,0x0000014a,0x00000159,0x0003003e,0x0000012b,0x0000015a,0x0004003d,0x00000006, + 0x0000015d,0x0000012b,0x00050088,0x00000006,0x0000015e,0x0000015c,0x0000015d,0x0003003e, + 0x0000015b,0x0000015e,0x0004003d,0x00000006,0x00000160,0x0000015b,0x0004003d,0x00000006, + 0x00000161,0x0000015b,0x00050085,0x00000006,0x00000162,0x00000160,0x00000161,0x0007000c, + 0x00000006,0x00000164,0x00000001,0x00000025,0x00000162,0x00000163,0x0003003e,0x0000015f, + 0x00000164,0x0004003d,0x00000006,0x00000166,0x0000015f,0x0004003d,0x00000016,0x00000168, + 0x000000c5,0x0003003e,0x00000167,0x00000168,0x0004003d,0x00000016,0x0000016a,0x000000ea, + 0x0003003e,0x00000169,0x0000016a,0x00060039,0x0000000e,0x0000016b,0x0000001b,0x00000167, + 0x00000169,0x00050051,0x00000006,0x0000016c,0x0000016b,0x00000000,0x00050051,0x00000006, + 0x0000016d,0x0000016b,0x00000001,0x00060050,0x0000000c,0x0000016e,0x00000166,0x0000016c, + 0x0000016d,0x0003003e,0x00000165,0x0000016e,0x00050041,0x00000007,0x00000170,0x000000c0, + 0x0000003a,0x0004003d,0x00000006,0x00000171,0x00000170,0x00050081,0x00000006,0x00000172, + 0x00000171,0x00000054,0x00050041,0x00000007,0x00000174,0x000000c0,0x00000031,0x0004003d, + 0x00000006,0x00000175,0x00000174,0x0003003e,0x00000173,0x00000175,0x0003003e,0x00000176, + 0x00000172,0x00050041,0x00000007,0x00000178,0x000000f2,0x00000031,0x0004003d,0x00000006, + 0x00000179,0x00000178,0x0003003e,0x00000177,0x00000179,0x0004003d,0x0000000c,0x0000017b, + 0x00000165,0x0003003e,0x0000017a,0x0000017b,0x00080039,0x0000000e,0x0000017c,0x00000014, + 0x00000173,0x00000176,0x00000177,0x0000017a,0x0003003e,0x0000016f,0x0000017c,0x00050041, + 0x00000007,0x0000017d,0x000000c0,0x00000031,0x0004003d,0x00000006,0x0000017e,0x0000017d, + 0x00050083,0x00000006,0x0000017f,0x0000017e,0x00000054,0x00050041,0x00000007,0x00000180, + 0x000000c0,0x0000003a,0x0004003d,0x00000006,0x00000181,0x00000180,0x00050081,0x00000006, + 0x00000182,0x00000181,0x00000054,0x0003003e,0x00000183,0x0000017f,0x0003003e,0x00000184, + 0x00000182,0x00050041,0x00000007,0x00000186,0x000000f2,0x0000003a,0x0004003d,0x00000006, + 0x00000187,0x00000186,0x0003003e,0x00000185,0x00000187,0x0004003d,0x0000000c,0x00000189, + 0x00000165,0x0003003e,0x00000188,0x00000189,0x00080039,0x0000000e,0x0000018a,0x00000014, + 0x00000183,0x00000184,0x00000185,0x00000188,0x0004003d,0x0000000e,0x0000018b,0x0000016f, + 0x00050081,0x0000000e,0x0000018c,0x0000018b,0x0000018a,0x0003003e,0x0000016f,0x0000018c, + 0x00050041,0x00000007,0x0000018d,0x000000c0,0x00000031,0x0004003d,0x00000006,0x0000018e, + 0x0000018d,0x00050083,0x00000006,0x0000018f,0x0000018e,0x00000054,0x00050041,0x00000007, + 0x00000190,0x000000c0,0x0000003a,0x0004003d,0x00000006,0x00000191,0x00000190,0x00050083, + 0x00000006,0x00000193,0x00000191,0x00000192,0x0003003e,0x00000194,0x0000018f,0x0003003e, + 0x00000195,0x00000193,0x00050041,0x00000007,0x00000197,0x000000f2,0x00000069,0x0004003d, + 0x00000006,0x00000198,0x00000197,0x0003003e,0x00000196,0x00000198,0x0004003d,0x0000000c, + 0x0000019a,0x00000165,0x0003003e,0x00000199,0x0000019a,0x00080039,0x0000000e,0x0000019b, + 0x00000014,0x00000194,0x00000195,0x00000196,0x00000199,0x0004003d,0x0000000e,0x0000019c, + 0x0000016f,0x00050081,0x0000000e,0x0000019d,0x0000019c,0x0000019b,0x0003003e,0x0000016f, + 0x0000019d,0x00050041,0x00000007,0x0000019e,0x000000c0,0x0000003a,0x0004003d,0x00000006, + 0x0000019f,0x0000019e,0x00050083,0x00000006,0x000001a0,0x0000019f,0x00000192,0x00050041, + 0x00000007,0x000001a2,0x000000c0,0x00000031,0x0004003d,0x00000006,0x000001a3,0x000001a2, + 0x0003003e,0x000001a1,0x000001a3,0x0003003e,0x000001a4,0x000001a0,0x00050041,0x00000007, + 0x000001a6,0x000000f2,0x0000006e,0x0004003d,0x00000006,0x000001a7,0x000001a6,0x0003003e, + 0x000001a5,0x000001a7,0x0004003d,0x0000000c,0x000001a9,0x00000165,0x0003003e,0x000001a8, + 0x000001a9,0x00080039,0x0000000e,0x000001aa,0x00000014,0x000001a1,0x000001a4,0x000001a5, + 0x000001a8,0x0004003d,0x0000000e,0x000001ab,0x0000016f,0x00050081,0x0000000e,0x000001ac, + 0x000001ab,0x000001aa,0x0003003e,0x0000016f,0x000001ac,0x00050041,0x00000007,0x000001ad, + 0x000000c0,0x00000031,0x0004003d,0x00000006,0x000001ae,0x000001ad,0x00050081,0x00000006, + 0x000001af,0x000001ae,0x00000054,0x00050041,0x00000007,0x000001b0,0x000000c0,0x0000003a, + 0x0004003d,0x00000006,0x000001b1,0x000001b0,0x00050083,0x00000006,0x000001b2,0x000001b1, + 0x00000054,0x0003003e,0x000001b3,0x000001af,0x0003003e,0x000001b4,0x000001b2,0x00050041, + 0x00000007,0x000001b6,0x000000c5,0x00000031,0x0004003d,0x00000006,0x000001b7,0x000001b6, + 0x0003003e,0x000001b5,0x000001b7,0x0004003d,0x0000000c,0x000001b9,0x00000165,0x0003003e, + 0x000001b8,0x000001b9,0x00080039,0x0000000e,0x000001ba,0x00000014,0x000001b3,0x000001b4, + 0x000001b5,0x000001b8,0x0004003d,0x0000000e,0x000001bb,0x0000016f,0x00050081,0x0000000e, + 0x000001bc,0x000001bb,0x000001ba,0x0003003e,0x0000016f,0x000001bc,0x00050041,0x00000007, + 0x000001bd,0x000000c0,0x0000003a,0x0004003d,0x00000006,0x000001be,0x000001bd,0x00050083, + 0x00000006,0x000001bf,0x000001be,0x00000054,0x00050041,0x00000007,0x000001c1,0x000000c0, + 0x00000031,0x0004003d,0x00000006,0x000001c2,0x000001c1,0x0003003e,0x000001c0,0x000001c2, + 0x0003003e,0x000001c3,0x000001bf,0x00050041,0x00000007,0x000001c5,0x000000c5,0x0000003a, + 0x0004003d,0x00000006,0x000001c6,0x000001c5,0x0003003e,0x000001c4,0x000001c6,0x0004003d, + 0x0000000c,0x000001c8,0x00000165,0x0003003e,0x000001c7,0x000001c8,0x00080039,0x0000000e, + 0x000001c9,0x00000014,0x000001c0,0x000001c3,0x000001c4,0x000001c7,0x0004003d,0x0000000e, + 0x000001ca,0x0000016f,0x00050081,0x0000000e,0x000001cb,0x000001ca,0x000001c9,0x0003003e, + 0x0000016f,0x000001cb,0x00050041,0x00000007,0x000001cd,0x000000c0,0x00000031,0x0004003d, + 0x00000006,0x000001ce,0x000001cd,0x0003003e,0x000001cc,0x000001ce,0x00050041,0x00000007, + 0x000001d0,0x000000c0,0x0000003a,0x0004003d,0x00000006,0x000001d1,0x000001d0,0x0003003e, + 0x000001cf,0x000001d1,0x00050041,0x00000007,0x000001d3,0x000000c5,0x00000069,0x0004003d, + 0x00000006,0x000001d4,0x000001d3,0x0003003e,0x000001d2,0x000001d4,0x0004003d,0x0000000c, + 0x000001d6,0x00000165,0x0003003e,0x000001d5,0x000001d6,0x00080039,0x0000000e,0x000001d7, + 0x00000014,0x000001cc,0x000001cf,0x000001d2,0x000001d5,0x0004003d,0x0000000e,0x000001d8, + 0x0000016f,0x00050081,0x0000000e,0x000001d9,0x000001d8,0x000001d7,0x0003003e,0x0000016f, + 0x000001d9,0x00050041,0x00000007,0x000001da,0x000000c0,0x00000031,0x0004003d,0x00000006, + 0x000001db,0x000001da,0x00050081,0x00000006,0x000001dc,0x000001db,0x00000054,0x0003003e, + 0x000001dd,0x000001dc,0x00050041,0x00000007,0x000001df,0x000000c0,0x0000003a,0x0004003d, + 0x00000006,0x000001e0,0x000001df,0x0003003e,0x000001de,0x000001e0,0x00050041,0x00000007, + 0x000001e2,0x000000c5,0x0000006e,0x0004003d,0x00000006,0x000001e3,0x000001e2,0x0003003e, + 0x000001e1,0x000001e3,0x0004003d,0x0000000c,0x000001e5,0x00000165,0x0003003e,0x000001e4, + 0x000001e5,0x00080039,0x0000000e,0x000001e6,0x00000014,0x000001dd,0x000001de,0x000001e1, + 0x000001e4,0x0004003d,0x0000000e,0x000001e7,0x0000016f,0x00050081,0x0000000e,0x000001e8, + 0x000001e7,0x000001e6,0x0003003e,0x0000016f,0x000001e8,0x00050041,0x00000007,0x000001e9, + 0x000000c0,0x00000031,0x0004003d,0x00000006,0x000001ea,0x000001e9,0x00050083,0x00000006, + 0x000001eb,0x000001ea,0x00000054,0x00050041,0x00000007,0x000001ec,0x000000c0,0x0000003a, + 0x0004003d,0x00000006,0x000001ed,0x000001ec,0x00050083,0x00000006,0x000001ee,0x000001ed, + 0x00000054,0x0003003e,0x000001ef,0x000001eb,0x0003003e,0x000001f0,0x000001ee,0x00050041, + 0x00000007,0x000001f2,0x000000ea,0x00000031,0x0004003d,0x00000006,0x000001f3,0x000001f2, + 0x0003003e,0x000001f1,0x000001f3,0x0004003d,0x0000000c,0x000001f5,0x00000165,0x0003003e, + 0x000001f4,0x000001f5,0x00080039,0x0000000e,0x000001f6,0x00000014,0x000001ef,0x000001f0, + 0x000001f1,0x000001f4,0x0004003d,0x0000000e,0x000001f7,0x0000016f,0x00050081,0x0000000e, + 0x000001f8,0x000001f7,0x000001f6,0x0003003e,0x0000016f,0x000001f8,0x00050041,0x00000007, + 0x000001f9,0x000000c0,0x00000031,0x0004003d,0x00000006,0x000001fa,0x000001f9,0x00050083, + 0x00000006,0x000001fb,0x000001fa,0x00000192,0x00050041,0x00000007,0x000001fc,0x000000c0, + 0x0000003a,0x0004003d,0x00000006,0x000001fd,0x000001fc,0x00050083,0x00000006,0x000001fe, + 0x000001fd,0x00000054,0x0003003e,0x000001ff,0x000001fb,0x0003003e,0x00000200,0x000001fe, + 0x00050041,0x00000007,0x00000202,0x000000ea,0x0000003a,0x0004003d,0x00000006,0x00000203, + 0x00000202,0x0003003e,0x00000201,0x00000203,0x0004003d,0x0000000c,0x00000205,0x00000165, + 0x0003003e,0x00000204,0x00000205,0x00080039,0x0000000e,0x00000206,0x00000014,0x000001ff, + 0x00000200,0x00000201,0x00000204,0x0004003d,0x0000000e,0x00000207,0x0000016f,0x00050081, + 0x0000000e,0x00000208,0x00000207,0x00000206,0x0003003e,0x0000016f,0x00000208,0x00050041, + 0x00000007,0x00000209,0x000000c0,0x00000031,0x0004003d,0x00000006,0x0000020a,0x00000209, + 0x00050083,0x00000006,0x0000020b,0x0000020a,0x00000192,0x0003003e,0x0000020c,0x0000020b, + 0x00050041,0x00000007,0x0000020e,0x000000c0,0x0000003a,0x0004003d,0x00000006,0x0000020f, + 0x0000020e,0x0003003e,0x0000020d,0x0000020f,0x00050041,0x00000007,0x00000211,0x000000ea, + 0x00000069,0x0004003d,0x00000006,0x00000212,0x00000211,0x0003003e,0x00000210,0x00000212, + 0x0004003d,0x0000000c,0x00000214,0x00000165,0x0003003e,0x00000213,0x00000214,0x00080039, + 0x0000000e,0x00000215,0x00000014,0x0000020c,0x0000020d,0x00000210,0x00000213,0x0004003d, + 0x0000000e,0x00000216,0x0000016f,0x00050081,0x0000000e,0x00000217,0x00000216,0x00000215, + 0x0003003e,0x0000016f,0x00000217,0x00050041,0x00000007,0x00000218,0x000000c0,0x00000031, + 0x0004003d,0x00000006,0x00000219,0x00000218,0x00050083,0x00000006,0x0000021a,0x00000219, + 0x00000054,0x0003003e,0x0000021b,0x0000021a,0x00050041,0x00000007,0x0000021d,0x000000c0, + 0x0000003a,0x0004003d,0x00000006,0x0000021e,0x0000021d,0x0003003e,0x0000021c,0x0000021e, + 0x00050041,0x00000007,0x00000220,0x000000ea,0x0000006e,0x0004003d,0x00000006,0x00000221, + 0x00000220,0x0003003e,0x0000021f,0x00000221,0x0004003d,0x0000000c,0x00000223,0x00000165, + 0x0003003e,0x00000222,0x00000223,0x00080039,0x0000000e,0x00000224,0x00000014,0x0000021b, + 0x0000021c,0x0000021f,0x00000222,0x0004003d,0x0000000e,0x00000225,0x0000016f,0x00050081, + 0x0000000e,0x00000226,0x00000225,0x00000224,0x0003003e,0x0000016f,0x00000226,0x00050041, + 0x00000007,0x00000228,0x0000016f,0x0000003a,0x0004003d,0x00000006,0x00000229,0x00000228, + 0x00050041,0x00000007,0x0000022a,0x0000016f,0x00000031,0x0004003d,0x00000006,0x0000022b, + 0x0000022a,0x00050088,0x00000006,0x0000022c,0x00000229,0x0000022b,0x0003003e,0x00000227, + 0x0000022c,0x00050041,0x00000007,0x0000022e,0x000000c5,0x0000003a,0x0004003d,0x00000006, + 0x0000022f,0x0000022e,0x00050041,0x00000007,0x00000230,0x000000c5,0x00000069,0x0004003d, + 0x00000006,0x00000231,0x00000230,0x0007000c,0x00000006,0x00000232,0x00000001,0x00000028, + 0x0000022f,0x00000231,0x00050041,0x00000007,0x00000233,0x000000ea,0x00000031,0x0004003d, + 0x00000006,0x00000234,0x00000233,0x00050041,0x00000007,0x00000235,0x000000ea,0x0000006e, + 0x0004003d,0x00000006,0x00000236,0x00000235,0x0007000c,0x00000006,0x00000237,0x00000001, + 0x00000028,0x00000234,0x00000236,0x0007000c,0x00000006,0x00000238,0x00000001,0x00000028, + 0x00000232,0x00000237,0x0003003e,0x0000022d,0x00000238,0x00050041,0x00000007,0x0000023a, + 0x000000c5,0x0000003a,0x0004003d,0x00000006,0x0000023b,0x0000023a,0x00050041,0x00000007, + 0x0000023c,0x000000c5,0x00000069,0x0004003d,0x00000006,0x0000023d,0x0000023c,0x0007000c, + 0x00000006,0x0000023e,0x00000001,0x00000025,0x0000023b,0x0000023d,0x00050041,0x00000007, + 0x0000023f,0x000000ea,0x00000031,0x0004003d,0x00000006,0x00000240,0x0000023f,0x00050041, + 0x00000007,0x00000241,0x000000ea,0x0000006e,0x0004003d,0x00000006,0x00000242,0x00000241, + 0x0007000c,0x00000006,0x00000243,0x00000001,0x00000025,0x00000240,0x00000242,0x0007000c, + 0x00000006,0x00000244,0x00000001,0x00000025,0x0000023e,0x00000243,0x0003003e,0x00000239, + 0x00000244,0x00050041,0x00000246,0x00000247,0x00000096,0x00000245,0x0004003d,0x00000006, + 0x00000248,0x00000247,0x0004003d,0x00000006,0x00000249,0x00000227,0x00050085,0x00000006, + 0x0000024a,0x00000248,0x00000249,0x0004003d,0x00000006,0x0000024b,0x00000239,0x0004003d, + 0x00000006,0x0000024c,0x0000022d,0x0008000c,0x00000006,0x0000024d,0x00000001,0x0000002b, + 0x0000024a,0x0000024b,0x0000024c,0x0003003e,0x00000227,0x0000024d,0x0004003d,0x00000006, + 0x0000024f,0x00000227,0x00050041,0x00000007,0x00000250,0x000000a0,0x0000006e,0x0004003d, + 0x00000006,0x00000251,0x00000250,0x00050083,0x00000006,0x00000252,0x0000024f,0x00000251, + 0x0003003e,0x0000024e,0x00000252,0x0004003d,0x00000006,0x00000253,0x0000024e,0x0008000c, + 0x00000006,0x00000256,0x00000001,0x0000002b,0x00000253,0x00000254,0x00000255,0x0003003e, + 0x0000024e,0x00000256,0x00050041,0x00000007,0x00000257,0x000000a0,0x00000031,0x0004003d, + 0x00000006,0x00000258,0x00000257,0x0004003d,0x00000006,0x00000259,0x0000024e,0x00050081, + 0x00000006,0x0000025a,0x00000258,0x00000259,0x0008000c,0x00000006,0x0000025b,0x00000001, + 0x0000002b,0x0000025a,0x00000053,0x00000054,0x00050041,0x00000007,0x0000025c,0x000000a0, + 0x00000031,0x0003003e,0x0000025c,0x0000025b,0x00050041,0x00000007,0x0000025d,0x000000a0, + 0x0000003a,0x0004003d,0x00000006,0x0000025e,0x0000025d,0x0004003d,0x00000006,0x0000025f, + 0x0000024e,0x00050081,0x00000006,0x00000260,0x0000025e,0x0000025f,0x0008000c,0x00000006, + 0x00000261,0x00000001,0x0000002b,0x00000260,0x00000053,0x00000054,0x00050041,0x00000007, + 0x00000262,0x000000a0,0x0000003a,0x0003003e,0x00000262,0x00000261,0x00050041,0x00000007, + 0x00000263,0x000000a0,0x00000069,0x0004003d,0x00000006,0x00000264,0x00000263,0x0004003d, + 0x00000006,0x00000265,0x0000024e,0x00050081,0x00000006,0x00000266,0x00000264,0x00000265, + 0x0008000c,0x00000006,0x00000267,0x00000001,0x0000002b,0x00000266,0x00000053,0x00000054, + 0x00050041,0x00000007,0x00000268,0x000000a0,0x00000069,0x0003003e,0x00000268,0x00000267, + 0x000200f9,0x000000e3,0x000200f8,0x000000e3,0x00050041,0x00000007,0x00000269,0x000000a0, + 0x0000006e,0x0003003e,0x00000269,0x00000054,0x0004003d,0x00000016,0x0000026c,0x000000a0, + 0x0003003e,0x0000026b,0x0000026c,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000a, + 0x00000000,0x00000008,0x00030037,0x00000007,0x00000009,0x000200f8,0x0000000b,0x0004003b, + 0x00000007,0x0000001d,0x00000007,0x0004003b,0x00000007,0x00000021,0x00000007,0x0004003d, + 0x00000006,0x0000001e,0x00000009,0x00050083,0x00000006,0x00000020,0x0000001e,0x0000001f, + 0x0003003e,0x0000001d,0x00000020,0x0004003d,0x00000006,0x00000022,0x00000009,0x0004003d, + 0x00000006,0x00000023,0x0000001d,0x00050085,0x00000006,0x00000024,0x00000022,0x00000023, + 0x0004003d,0x00000006,0x00000025,0x0000001d,0x00050083,0x00000006,0x00000026,0x00000024, + 0x00000025,0x0003003e,0x00000021,0x00000026,0x0004003d,0x00000006,0x00000027,0x0000001d, + 0x0004003d,0x00000006,0x00000028,0x0000001d,0x00050085,0x00000006,0x00000029,0x00000028, + 0x00000027,0x0003003e,0x0000001d,0x00000029,0x0004003d,0x00000006,0x0000002a,0x00000021, + 0x0004003d,0x00000006,0x0000002b,0x0000001d,0x00050085,0x00000006,0x0000002c,0x0000002a, + 0x0000002b,0x000200fe,0x0000002c,0x00010038,0x00050036,0x0000000e,0x00000014,0x00000000, + 0x0000000f,0x00030037,0x00000007,0x00000010,0x00030037,0x00000007,0x00000011,0x00030037, + 0x00000007,0x00000012,0x00030037,0x0000000d,0x00000013,0x000200f8,0x00000015,0x0004003b, + 0x00000007,0x0000002f,0x00000007,0x0004003b,0x00000034,0x00000035,0x00000007,0x0004003b, + 0x00000007,0x00000038,0x00000007,0x0004003b,0x00000007,0x00000043,0x00000007,0x0004003b, + 0x00000007,0x0000005b,0x00000007,0x0004003b,0x00000007,0x0000005c,0x00000007,0x00050041, + 0x00000007,0x00000032,0x00000013,0x00000031,0x0004003d,0x00000006,0x00000033,0x00000032, + 0x0003003e,0x0000002f,0x00000033,0x0004003d,0x0000000c,0x00000036,0x00000013,0x0007004f, + 0x0000000e,0x00000037,0x00000036,0x00000036,0x00000001,0x00000002,0x0003003e,0x00000035, + 0x00000037,0x0004003d,0x00000006,0x00000039,0x00000010,0x00050041,0x00000007,0x0000003b, + 0x00000035,0x0000003a,0x0004003d,0x00000006,0x0000003c,0x0000003b,0x00050085,0x00000006, + 0x0000003d,0x00000039,0x0000003c,0x0004003d,0x00000006,0x0000003e,0x00000011,0x00050041, + 0x00000007,0x0000003f,0x00000035,0x00000031,0x0004003d,0x00000006,0x00000040,0x0000003f, + 0x00050085,0x00000006,0x00000041,0x0000003e,0x00000040,0x00050081,0x00000006,0x00000042, + 0x0000003d,0x00000041,0x0003003e,0x00000038,0x00000042,0x0004003d,0x00000006,0x00000044, + 0x00000010,0x0004003d,0x00000006,0x00000045,0x00000010,0x00050085,0x00000006,0x00000046, + 0x00000044,0x00000045,0x0004003d,0x00000006,0x00000047,0x00000011,0x0004003d,0x00000006, + 0x00000048,0x00000011,0x00050085,0x00000006,0x00000049,0x00000047,0x00000048,0x00050081, + 0x00000006,0x0000004a,0x00000046,0x00000049,0x0004003d,0x00000006,0x0000004b,0x00000038, + 0x0004003d,0x00000006,0x0000004c,0x00000038,0x00050085,0x00000006,0x0000004d,0x0000004b, + 0x0000004c,0x0004003d,0x00000006,0x0000004e,0x00000012,0x0004003d,0x00000006,0x0000004f, + 0x00000012,0x00050085,0x00000006,0x00000050,0x0000004e,0x0000004f,0x0004003d,0x00000006, + 0x00000051,0x0000002f,0x00050085,0x00000006,0x00000052,0x00000050,0x00000051,0x0008000c, + 0x00000006,0x00000055,0x00000001,0x0000002b,0x00000052,0x00000053,0x00000054,0x00050085, + 0x00000006,0x00000057,0x00000055,0x00000056,0x00050083,0x00000006,0x00000058,0x00000057, + 0x00000054,0x00050085,0x00000006,0x00000059,0x0000004d,0x00000058,0x00050081,0x00000006, + 0x0000005a,0x0000004a,0x00000059,0x0003003e,0x00000043,0x0000005a,0x0004003d,0x00000006, + 0x0000005d,0x00000043,0x0003003e,0x0000005c,0x0000005d,0x00050039,0x00000006,0x0000005e, + 0x0000000a,0x0000005c,0x0003003e,0x0000005b,0x0000005e,0x0004003d,0x00000006,0x0000005f, + 0x0000005b,0x0004003d,0x00000006,0x00000060,0x0000005b,0x0004003d,0x00000006,0x00000061, + 0x00000012,0x00050085,0x00000006,0x00000062,0x00000060,0x00000061,0x00050050,0x0000000e, + 0x00000063,0x0000005f,0x00000062,0x000200fe,0x00000063,0x00010038,0x00050036,0x0000000e, + 0x0000001b,0x00000000,0x00000018,0x00030037,0x00000017,0x00000019,0x00030037,0x00000017, + 0x0000001a,0x000200f8,0x0000001c,0x0004003b,0x00000007,0x00000066,0x00000007,0x0004003b, + 0x00000007,0x0000006d,0x00000007,0x0004003b,0x00000034,0x00000074,0x00000007,0x0004003b, + 0x00000034,0x0000007d,0x00000007,0x0004003b,0x00000007,0x0000007f,0x00000007,0x00050041, + 0x00000007,0x00000067,0x0000001a,0x00000031,0x0004003d,0x00000006,0x00000068,0x00000067, + 0x00050041,0x00000007,0x0000006a,0x00000019,0x00000069,0x0004003d,0x00000006,0x0000006b, + 0x0000006a,0x00050083,0x00000006,0x0000006c,0x00000068,0x0000006b,0x0003003e,0x00000066, + 0x0000006c,0x00050041,0x00000007,0x0000006f,0x0000001a,0x0000006e,0x0004003d,0x00000006, + 0x00000070,0x0000006f,0x00050041,0x00000007,0x00000071,0x00000019,0x0000003a,0x0004003d, + 0x00000006,0x00000072,0x00000071,0x00050083,0x00000006,0x00000073,0x00000070,0x00000072, + 0x0003003e,0x0000006d,0x00000073,0x0004003d,0x00000006,0x00000075,0x00000066,0x0004003d, + 0x00000006,0x00000076,0x0000006d,0x00050081,0x00000006,0x00000077,0x00000075,0x00000076, + 0x00050041,0x00000007,0x00000078,0x00000074,0x00000031,0x0003003e,0x00000078,0x00000077, + 0x0004003d,0x00000006,0x00000079,0x00000066,0x0004003d,0x00000006,0x0000007a,0x0000006d, + 0x00050083,0x00000006,0x0000007b,0x00000079,0x0000007a,0x00050041,0x00000007,0x0000007c, + 0x00000074,0x0000003a,0x0003003e,0x0000007c,0x0000007b,0x0004003d,0x0000000e,0x0000007e, + 0x00000074,0x0003003e,0x0000007d,0x0000007e,0x00050041,0x00000007,0x00000080,0x0000007d, + 0x00000031,0x0004003d,0x00000006,0x00000081,0x00000080,0x00050041,0x00000007,0x00000082, + 0x0000007d,0x00000031,0x0004003d,0x00000006,0x00000083,0x00000082,0x00050085,0x00000006, + 0x00000084,0x00000081,0x00000083,0x00050081,0x00000006,0x00000086,0x00000084,0x00000085, + 0x00050041,0x00000007,0x00000087,0x0000007d,0x0000003a,0x0004003d,0x00000006,0x00000088, + 0x00000087,0x00050041,0x00000007,0x00000089,0x0000007d,0x0000003a,0x0004003d,0x00000006, + 0x0000008a,0x00000089,0x00050085,0x00000006,0x0000008b,0x00000088,0x0000008a,0x00050081, + 0x00000006,0x0000008c,0x00000086,0x0000008b,0x0006000c,0x00000006,0x0000008d,0x00000001, + 0x00000020,0x0000008c,0x0003003e,0x0000007f,0x0000008d,0x0004003d,0x0000000e,0x0000008e, + 0x00000074,0x0004003d,0x00000006,0x0000008f,0x0000007f,0x0005008e,0x0000000e,0x00000090, + 0x0000008e,0x0000008f,0x000200fe,0x00000090,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/smaa.frag b/app/src/main/cpp/shaders/smaa.frag deleted file mode 100644 index 55160fdcff..0000000000 --- a/app/src/main/cpp/shaders/smaa.frag +++ /dev/null @@ -1,100 +0,0 @@ -#version 450 - -layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 outColor; -layout(set = 0, binding = 0) uniform sampler2D InputTexture; -layout(push_constant) uniform Constants { - vec4 ndc; - vec2 resolution; - float extra; - float pad; -} pc; - -float luma(vec3 c) { - return dot(c, vec3(0.2126, 0.7152, 0.0722)); -} - -float edgeVertical(vec2 uv, vec2 px) { - float a = luma(texture(InputTexture, uv - vec2(px.x, 0.0)).rgb); - float b = luma(texture(InputTexture, uv + vec2(px.x, 0.0)).rgb); - return abs(a - b); -} - -float edgeHorizontal(vec2 uv, vec2 px) { - float a = luma(texture(InputTexture, uv - vec2(0.0, px.y)).rgb); - float b = luma(texture(InputTexture, uv + vec2(0.0, px.y)).rgb); - return abs(a - b); -} - -void main() { - vec2 px = 1.0 / max(pc.resolution, vec2(1.0)); - vec2 uv = clamp(fragTexCoord, px * 0.5, vec2(1.0) - px * 0.5); - vec4 center = texture(InputTexture, uv); - - float lc = luma(center.rgb); - float ll = luma(texture(InputTexture, uv - vec2(px.x, 0.0)).rgb); - float lr = luma(texture(InputTexture, uv + vec2(px.x, 0.0)).rgb); - float lu = luma(texture(InputTexture, uv - vec2(0.0, px.y)).rgb); - float ld = luma(texture(InputTexture, uv + vec2(0.0, px.y)).rgb); - - float dL = abs(lc - ll); - float dR = abs(lc - lr); - float dU = abs(lc - lu); - float dD = abs(lc - ld); - float localMin = min(lc, min(min(ll, lr), min(lu, ld))); - float localMax = max(lc, max(max(ll, lr), max(lu, ld))); - float localContrast = localMax - localMin; - float threshold = max(0.045, localContrast * 0.08); - - float vertical = max(dL, dR); - float horizontal = max(dU, dD); - float strongest = max(vertical, horizontal); - if (strongest <= threshold) { - outColor = center; - return; - } - - bool verticalEdge = vertical >= horizontal; - vec2 tangent = verticalEdge ? vec2(0.0, px.y) : vec2(px.x, 0.0); - vec2 normal = verticalEdge - ? vec2(dL >= dR ? -1.0 : 1.0, 0.0) - : vec2(0.0, dU >= dD ? -1.0 : 1.0); - - float negativeRun = 0.0; - float positiveRun = 0.0; - for (int i = 1; i <= 6; ++i) { - vec2 offset = tangent * float(i); - float edgeN = verticalEdge ? edgeVertical(uv - offset, px) : edgeHorizontal(uv - offset, px); - float edgeP = verticalEdge ? edgeVertical(uv + offset, px) : edgeHorizontal(uv + offset, px); - if (negativeRun == float(i - 1) && edgeN > threshold * 0.65) negativeRun = float(i); - if (positiveRun == float(i - 1) && edgeP > threshold * 0.65) positiveRun = float(i); - } - - float span = negativeRun + positiveRun; - float edgeConfidence = smoothstep(threshold, threshold * 2.5, strongest); - - float nw = luma(texture(InputTexture, uv + vec2(-px.x, -px.y)).rgb); - float ne = luma(texture(InputTexture, uv + vec2(px.x, -px.y)).rgb); - float sw = luma(texture(InputTexture, uv + vec2(-px.x, px.y)).rgb); - float se = luma(texture(InputTexture, uv + vec2(px.x, px.y)).rgb); - float endpointPattern = clamp(abs(negativeRun - positiveRun) / max(span, 1.0), 0.0, 1.0); - float endpointArea = endpointPattern / (1.0 + span * 0.055); - float crossingA = verticalEdge ? abs(nw - ne) : abs(nw - sw); - float crossingB = verticalEdge ? abs(sw - se) : abs(ne - se); - float crossingContrast = abs(crossingA - crossingB); - float crossingPattern = smoothstep(threshold, threshold * 2.5, crossingContrast); - float areaWeight = 0.38 * crossingPattern * clamp(span / 4.0, 0.0, 1.0); - float diagonalContrast = max(abs(nw - se), abs(ne - sw)); - 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 diagonalFallback = 0.16 * diagonalPattern * edgeConfidence - * cornerFactor * diagonalContinuity * crossingPattern; - - float weight = clamp(max(baseWeight, diagonalFallback), 0.0, 0.42); - vec3 across = texture(InputTexture, uv + normal * px).rgb; - outColor = vec4(mix(center.rgb, across, weight), center.a); -} diff --git a/app/src/main/cpp/shaders/smaa_blend.frag b/app/src/main/cpp/shaders/smaa_blend.frag new file mode 100644 index 0000000000..cf4a2302a6 --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_blend.frag @@ -0,0 +1,30 @@ +#version 450 + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; +layout(set = 0, binding = 0) uniform sampler2D InputTexture; +layout(set = 1, binding = 0) uniform sampler2D WeightTexture; +layout(push_constant) uniform Constants { + vec4 ndc; + vec2 resolution; + float extra; + float pad; +} pc; + +void main() { + vec2 px = 1.0 / max(pc.resolution, vec2(1.0)); + vec2 uv = clamp(fragTexCoord, px * 0.5, vec2(1.0) - px * 0.5); + 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); +} diff --git a/app/src/main/cpp/shaders/smaa_blend_frag.h b/app/src/main/cpp/shaders/smaa_blend_frag.h new file mode 100644 index 0000000000..bcb4749618 --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_blend_frag.h @@ -0,0 +1,88 @@ + // 1116.3.0 + #pragma once +const uint32_t smaa_blend_code[] = { + 0x07230203,0x00010000,0x0008000b,0x0000006b,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000001a,0x00000041,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00030005,0x00000009,0x00007870,0x00050005,0x0000000c,0x736e6f43,0x746e6174, + 0x00000073,0x00040006,0x0000000c,0x00000000,0x0063646e,0x00060006,0x0000000c,0x00000001, + 0x6f736572,0x6974756c,0x00006e6f,0x00050006,0x0000000c,0x00000002,0x72747865,0x00000061, + 0x00040006,0x0000000c,0x00000003,0x00646170,0x00030005,0x0000000e,0x00006370,0x00030005, + 0x00000018,0x00007675,0x00060005,0x0000001a,0x67617266,0x43786554,0x64726f6f,0x00000000, + 0x00040005,0x00000024,0x746e6563,0x00007265,0x00060005,0x00000028,0x75706e49,0x78655474, + 0x65727574,0x00000000,0x00040005,0x0000002c,0x67696577,0x00737468,0x00060005,0x0000002d, + 0x67696557,0x65547468,0x72757478,0x00000065,0x00040005,0x00000032,0x67696577,0x00007468, + 0x00050005,0x00000041,0x4374756f,0x726f6c6f,0x00000000,0x00040005,0x00000044,0x6d726f6e, + 0x00006c61,0x00050005,0x0000004b,0x6f726361,0x76557373,0x00000000,0x00040005,0x00000059, + 0x6f726361,0x00007373,0x00030047,0x0000000c,0x00000002,0x00050048,0x0000000c,0x00000000, + 0x00000023,0x00000000,0x00050048,0x0000000c,0x00000001,0x00000023,0x00000010,0x00050048, + 0x0000000c,0x00000002,0x00000023,0x00000018,0x00050048,0x0000000c,0x00000003,0x00000023, + 0x0000001c,0x00040047,0x0000001a,0x0000001e,0x00000000,0x00040047,0x00000028,0x00000021, + 0x00000000,0x00040047,0x00000028,0x00000022,0x00000000,0x00040047,0x0000002d,0x00000021, + 0x00000000,0x00040047,0x0000002d,0x00000022,0x00000001,0x00040047,0x00000041,0x0000001e, + 0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006, + 0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007, + 0x00000007,0x0004002b,0x00000006,0x0000000a,0x3f800000,0x00040017,0x0000000b,0x00000006, + 0x00000004,0x0006001e,0x0000000c,0x0000000b,0x00000007,0x00000006,0x00000006,0x00040020, + 0x0000000d,0x00000009,0x0000000c,0x0004003b,0x0000000d,0x0000000e,0x00000009,0x00040015, + 0x0000000f,0x00000020,0x00000001,0x0004002b,0x0000000f,0x00000010,0x00000001,0x00040020, + 0x00000011,0x00000009,0x00000007,0x0005002c,0x00000007,0x00000014,0x0000000a,0x0000000a, + 0x00040020,0x00000019,0x00000001,0x00000007,0x0004003b,0x00000019,0x0000001a,0x00000001, + 0x0004002b,0x00000006,0x0000001d,0x3f000000,0x00040020,0x00000023,0x00000007,0x0000000b, + 0x00090019,0x00000025,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001, + 0x00000000,0x0003001b,0x00000026,0x00000025,0x00040020,0x00000027,0x00000000,0x00000026, + 0x0004003b,0x00000027,0x00000028,0x00000000,0x0004003b,0x00000027,0x0000002d,0x00000000, + 0x00040020,0x00000031,0x00000007,0x00000006,0x00040015,0x00000033,0x00000020,0x00000000, + 0x0004002b,0x00000033,0x00000034,0x00000000,0x0004002b,0x00000006,0x00000037,0x00000000, + 0x0004002b,0x00000006,0x00000038,0x3ed70a3d,0x0004002b,0x00000006,0x0000003b,0x3a83126f, + 0x00020014,0x0000003c,0x00040020,0x00000040,0x00000003,0x0000000b,0x0004003b,0x00000040, + 0x00000041,0x00000003,0x0004002b,0x00000006,0x00000047,0x40000000,0x00040017,0x00000057, + 0x00000006,0x00000003,0x00040020,0x00000058,0x00000007,0x00000057,0x0004002b,0x00000033, + 0x00000064,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, + 0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000008,0x00000018, + 0x00000007,0x0004003b,0x00000023,0x00000024,0x00000007,0x0004003b,0x00000023,0x0000002c, + 0x00000007,0x0004003b,0x00000031,0x00000032,0x00000007,0x0004003b,0x00000008,0x00000044, + 0x00000007,0x0004003b,0x00000008,0x0000004b,0x00000007,0x0004003b,0x00000058,0x00000059, + 0x00000007,0x00050041,0x00000011,0x00000012,0x0000000e,0x00000010,0x0004003d,0x00000007, + 0x00000013,0x00000012,0x0007000c,0x00000007,0x00000015,0x00000001,0x00000028,0x00000013, + 0x00000014,0x00050050,0x00000007,0x00000016,0x0000000a,0x0000000a,0x00050088,0x00000007, + 0x00000017,0x00000016,0x00000015,0x0003003e,0x00000009,0x00000017,0x0004003d,0x00000007, + 0x0000001b,0x0000001a,0x0004003d,0x00000007,0x0000001c,0x00000009,0x0005008e,0x00000007, + 0x0000001e,0x0000001c,0x0000001d,0x0004003d,0x00000007,0x0000001f,0x00000009,0x0005008e, + 0x00000007,0x00000020,0x0000001f,0x0000001d,0x00050083,0x00000007,0x00000021,0x00000014, + 0x00000020,0x0008000c,0x00000007,0x00000022,0x00000001,0x0000002b,0x0000001b,0x0000001e, + 0x00000021,0x0003003e,0x00000018,0x00000022,0x0004003d,0x00000026,0x00000029,0x00000028, + 0x0004003d,0x00000007,0x0000002a,0x00000018,0x00050057,0x0000000b,0x0000002b,0x00000029, + 0x0000002a,0x0003003e,0x00000024,0x0000002b,0x0004003d,0x00000026,0x0000002e,0x0000002d, + 0x0004003d,0x00000007,0x0000002f,0x00000018,0x00050057,0x0000000b,0x00000030,0x0000002e, + 0x0000002f,0x0003003e,0x0000002c,0x00000030,0x00050041,0x00000031,0x00000035,0x0000002c, + 0x00000034,0x0004003d,0x00000006,0x00000036,0x00000035,0x0008000c,0x00000006,0x00000039, + 0x00000001,0x0000002b,0x00000036,0x00000037,0x00000038,0x0003003e,0x00000032,0x00000039, + 0x0004003d,0x00000006,0x0000003a,0x00000032,0x000500bc,0x0000003c,0x0000003d,0x0000003a, + 0x0000003b,0x000300f7,0x0000003f,0x00000000,0x000400fa,0x0000003d,0x0000003e,0x0000003f, + 0x000200f8,0x0000003e,0x0004003d,0x0000000b,0x00000042,0x00000024,0x0003003e,0x00000041, + 0x00000042,0x000100fd,0x000200f8,0x0000003f,0x0004003d,0x0000000b,0x00000045,0x0000002c, + 0x0007004f,0x00000007,0x00000046,0x00000045,0x00000045,0x00000001,0x00000002,0x0005008e, + 0x00000007,0x00000048,0x00000046,0x00000047,0x00050050,0x00000007,0x00000049,0x0000000a, + 0x0000000a,0x00050083,0x00000007,0x0000004a,0x00000048,0x00000049,0x0003003e,0x00000044, + 0x0000004a,0x0004003d,0x00000007,0x0000004c,0x00000018,0x0004003d,0x00000007,0x0000004d, + 0x00000044,0x0004003d,0x00000007,0x0000004e,0x00000009,0x00050085,0x00000007,0x0000004f, + 0x0000004d,0x0000004e,0x00050081,0x00000007,0x00000050,0x0000004c,0x0000004f,0x0004003d, + 0x00000007,0x00000051,0x00000009,0x0005008e,0x00000007,0x00000052,0x00000051,0x0000001d, + 0x0004003d,0x00000007,0x00000053,0x00000009,0x0005008e,0x00000007,0x00000054,0x00000053, + 0x0000001d,0x00050083,0x00000007,0x00000055,0x00000014,0x00000054,0x0008000c,0x00000007, + 0x00000056,0x00000001,0x0000002b,0x00000050,0x00000052,0x00000055,0x0003003e,0x0000004b, + 0x00000056,0x0004003d,0x00000026,0x0000005a,0x00000028,0x0004003d,0x00000007,0x0000005b, + 0x0000004b,0x00050057,0x0000000b,0x0000005c,0x0000005a,0x0000005b,0x0008004f,0x00000057, + 0x0000005d,0x0000005c,0x0000005c,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000059, + 0x0000005d,0x0004003d,0x0000000b,0x0000005e,0x00000024,0x0008004f,0x00000057,0x0000005f, + 0x0000005e,0x0000005e,0x00000000,0x00000001,0x00000002,0x0004003d,0x00000057,0x00000060, + 0x00000059,0x0004003d,0x00000006,0x00000061,0x00000032,0x00060050,0x00000057,0x00000062, + 0x00000061,0x00000061,0x00000061,0x0008000c,0x00000057,0x00000063,0x00000001,0x0000002e, + 0x0000005f,0x00000060,0x00000062,0x00050041,0x00000031,0x00000065,0x00000024,0x00000064, + 0x0004003d,0x00000006,0x00000066,0x00000065,0x00050051,0x00000006,0x00000067,0x00000063, + 0x00000000,0x00050051,0x00000006,0x00000068,0x00000063,0x00000001,0x00050051,0x00000006, + 0x00000069,0x00000063,0x00000002,0x00070050,0x0000000b,0x0000006a,0x00000067,0x00000068, + 0x00000069,0x00000066,0x0003003e,0x00000041,0x0000006a,0x000100fd,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/smaa_edge.frag b/app/src/main/cpp/shaders/smaa_edge.frag new file mode 100644 index 0000000000..44073b00c4 --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_edge.frag @@ -0,0 +1,29 @@ +#version 450 + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; +layout(set = 0, binding = 0) uniform sampler2D InputTexture; +layout(push_constant) uniform Constants { + vec4 ndc; + vec2 resolution; + float extra; + float pad; +} pc; + +float luma(vec3 c) { + return dot(c, vec3(0.2126, 0.7152, 0.0722)); +} + +void main() { + vec2 px = 1.0 / max(pc.resolution, vec2(1.0)); + vec2 uv = clamp(fragTexCoord, px * 0.5, vec2(1.0) - px * 0.5); + 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)); +} diff --git a/app/src/main/cpp/shaders/smaa_edge_frag.h b/app/src/main/cpp/shaders/smaa_edge_frag.h new file mode 100644 index 0000000000..7d133264c9 --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_edge_frag.h @@ -0,0 +1,102 @@ + // 1116.3.0 + #pragma once +const uint32_t smaa_edge_code[] = { + 0x07230203,0x00010000,0x0008000b,0x00000080,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000028,0x0000006e,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00050005,0x0000000b,0x616d756c,0x33667628,0x0000003b,0x00030005,0x0000000a, + 0x00000063,0x00030005,0x00000017,0x00007870,0x00050005,0x0000001a,0x736e6f43,0x746e6174, + 0x00000073,0x00040006,0x0000001a,0x00000000,0x0063646e,0x00060006,0x0000001a,0x00000001, + 0x6f736572,0x6974756c,0x00006e6f,0x00050006,0x0000001a,0x00000002,0x72747865,0x00000061, + 0x00040006,0x0000001a,0x00000003,0x00646170,0x00030005,0x0000001c,0x00006370,0x00030005, + 0x00000026,0x00007675,0x00060005,0x00000028,0x67617266,0x43786554,0x64726f6f,0x00000000, + 0x00040005,0x00000032,0x746e6563,0x00007265,0x00060005,0x00000036,0x75706e49,0x78655474, + 0x65727574,0x00000000,0x00040005,0x0000003a,0x61726170,0x0000006d,0x00040005,0x0000003d, + 0x7466656c,0x00000000,0x00040005,0x00000048,0x61726170,0x0000006d,0x00040005,0x0000004b, + 0x68676972,0x00000074,0x00040005,0x00000053,0x61726170,0x0000006d,0x00030005,0x00000056, + 0x00007075,0x00040005,0x0000005f,0x61726170,0x0000006d,0x00040005,0x00000062,0x6e776f64, + 0x00000000,0x00040005,0x0000006a,0x61726170,0x0000006d,0x00050005,0x0000006e,0x4374756f, + 0x726f6c6f,0x00000000,0x00030047,0x0000001a,0x00000002,0x00050048,0x0000001a,0x00000000, + 0x00000023,0x00000000,0x00050048,0x0000001a,0x00000001,0x00000023,0x00000010,0x00050048, + 0x0000001a,0x00000002,0x00000023,0x00000018,0x00050048,0x0000001a,0x00000003,0x00000023, + 0x0000001c,0x00040047,0x00000028,0x0000001e,0x00000000,0x00040047,0x00000036,0x00000021, + 0x00000000,0x00040047,0x00000036,0x00000022,0x00000000,0x00040047,0x0000006e,0x0000001e, + 0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006, + 0x00000020,0x00040017,0x00000007,0x00000006,0x00000003,0x00040020,0x00000008,0x00000007, + 0x00000007,0x00040021,0x00000009,0x00000006,0x00000008,0x0004002b,0x00000006,0x0000000e, + 0x3e59b3d0,0x0004002b,0x00000006,0x0000000f,0x3f371759,0x0004002b,0x00000006,0x00000010, + 0x3d93dd98,0x0006002c,0x00000007,0x00000011,0x0000000e,0x0000000f,0x00000010,0x00040017, + 0x00000015,0x00000006,0x00000002,0x00040020,0x00000016,0x00000007,0x00000015,0x0004002b, + 0x00000006,0x00000018,0x3f800000,0x00040017,0x00000019,0x00000006,0x00000004,0x0006001e, + 0x0000001a,0x00000019,0x00000015,0x00000006,0x00000006,0x00040020,0x0000001b,0x00000009, + 0x0000001a,0x0004003b,0x0000001b,0x0000001c,0x00000009,0x00040015,0x0000001d,0x00000020, + 0x00000001,0x0004002b,0x0000001d,0x0000001e,0x00000001,0x00040020,0x0000001f,0x00000009, + 0x00000015,0x0005002c,0x00000015,0x00000022,0x00000018,0x00000018,0x00040020,0x00000027, + 0x00000001,0x00000015,0x0004003b,0x00000027,0x00000028,0x00000001,0x0004002b,0x00000006, + 0x0000002b,0x3f000000,0x00040020,0x00000031,0x00000007,0x00000006,0x00090019,0x00000033, + 0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b, + 0x00000034,0x00000033,0x00040020,0x00000035,0x00000000,0x00000034,0x0004003b,0x00000035, + 0x00000036,0x00000000,0x00040015,0x00000040,0x00000020,0x00000000,0x0004002b,0x00000040, + 0x00000041,0x00000000,0x0004002b,0x00000006,0x00000044,0x00000000,0x0004002b,0x00000040, + 0x00000059,0x00000001,0x00040020,0x0000006d,0x00000003,0x00000019,0x0004003b,0x0000006d, + 0x0000006e,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, + 0x00000005,0x0004003b,0x00000016,0x00000017,0x00000007,0x0004003b,0x00000016,0x00000026, + 0x00000007,0x0004003b,0x00000031,0x00000032,0x00000007,0x0004003b,0x00000008,0x0000003a, + 0x00000007,0x0004003b,0x00000031,0x0000003d,0x00000007,0x0004003b,0x00000008,0x00000048, + 0x00000007,0x0004003b,0x00000031,0x0000004b,0x00000007,0x0004003b,0x00000008,0x00000053, + 0x00000007,0x0004003b,0x00000031,0x00000056,0x00000007,0x0004003b,0x00000008,0x0000005f, + 0x00000007,0x0004003b,0x00000031,0x00000062,0x00000007,0x0004003b,0x00000008,0x0000006a, + 0x00000007,0x00050041,0x0000001f,0x00000020,0x0000001c,0x0000001e,0x0004003d,0x00000015, + 0x00000021,0x00000020,0x0007000c,0x00000015,0x00000023,0x00000001,0x00000028,0x00000021, + 0x00000022,0x00050050,0x00000015,0x00000024,0x00000018,0x00000018,0x00050088,0x00000015, + 0x00000025,0x00000024,0x00000023,0x0003003e,0x00000017,0x00000025,0x0004003d,0x00000015, + 0x00000029,0x00000028,0x0004003d,0x00000015,0x0000002a,0x00000017,0x0005008e,0x00000015, + 0x0000002c,0x0000002a,0x0000002b,0x0004003d,0x00000015,0x0000002d,0x00000017,0x0005008e, + 0x00000015,0x0000002e,0x0000002d,0x0000002b,0x00050083,0x00000015,0x0000002f,0x00000022, + 0x0000002e,0x0008000c,0x00000015,0x00000030,0x00000001,0x0000002b,0x00000029,0x0000002c, + 0x0000002f,0x0003003e,0x00000026,0x00000030,0x0004003d,0x00000034,0x00000037,0x00000036, + 0x0004003d,0x00000015,0x00000038,0x00000026,0x00050057,0x00000019,0x00000039,0x00000037, + 0x00000038,0x0008004f,0x00000007,0x0000003b,0x00000039,0x00000039,0x00000000,0x00000001, + 0x00000002,0x0003003e,0x0000003a,0x0000003b,0x00050039,0x00000006,0x0000003c,0x0000000b, + 0x0000003a,0x0003003e,0x00000032,0x0000003c,0x0004003d,0x00000034,0x0000003e,0x00000036, + 0x0004003d,0x00000015,0x0000003f,0x00000026,0x00050041,0x00000031,0x00000042,0x00000017, + 0x00000041,0x0004003d,0x00000006,0x00000043,0x00000042,0x00050050,0x00000015,0x00000045, + 0x00000043,0x00000044,0x00050083,0x00000015,0x00000046,0x0000003f,0x00000045,0x00050057, + 0x00000019,0x00000047,0x0000003e,0x00000046,0x0008004f,0x00000007,0x00000049,0x00000047, + 0x00000047,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000048,0x00000049,0x00050039, + 0x00000006,0x0000004a,0x0000000b,0x00000048,0x0003003e,0x0000003d,0x0000004a,0x0004003d, + 0x00000034,0x0000004c,0x00000036,0x0004003d,0x00000015,0x0000004d,0x00000026,0x00050041, + 0x00000031,0x0000004e,0x00000017,0x00000041,0x0004003d,0x00000006,0x0000004f,0x0000004e, + 0x00050050,0x00000015,0x00000050,0x0000004f,0x00000044,0x00050081,0x00000015,0x00000051, + 0x0000004d,0x00000050,0x00050057,0x00000019,0x00000052,0x0000004c,0x00000051,0x0008004f, + 0x00000007,0x00000054,0x00000052,0x00000052,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x00000053,0x00000054,0x00050039,0x00000006,0x00000055,0x0000000b,0x00000053,0x0003003e, + 0x0000004b,0x00000055,0x0004003d,0x00000034,0x00000057,0x00000036,0x0004003d,0x00000015, + 0x00000058,0x00000026,0x00050041,0x00000031,0x0000005a,0x00000017,0x00000059,0x0004003d, + 0x00000006,0x0000005b,0x0000005a,0x00050050,0x00000015,0x0000005c,0x00000044,0x0000005b, + 0x00050083,0x00000015,0x0000005d,0x00000058,0x0000005c,0x00050057,0x00000019,0x0000005e, + 0x00000057,0x0000005d,0x0008004f,0x00000007,0x00000060,0x0000005e,0x0000005e,0x00000000, + 0x00000001,0x00000002,0x0003003e,0x0000005f,0x00000060,0x00050039,0x00000006,0x00000061, + 0x0000000b,0x0000005f,0x0003003e,0x00000056,0x00000061,0x0004003d,0x00000034,0x00000063, + 0x00000036,0x0004003d,0x00000015,0x00000064,0x00000026,0x00050041,0x00000031,0x00000065, + 0x00000017,0x00000059,0x0004003d,0x00000006,0x00000066,0x00000065,0x00050050,0x00000015, + 0x00000067,0x00000044,0x00000066,0x00050081,0x00000015,0x00000068,0x00000064,0x00000067, + 0x00050057,0x00000019,0x00000069,0x00000063,0x00000068,0x0008004f,0x00000007,0x0000006b, + 0x00000069,0x00000069,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000006a,0x0000006b, + 0x00050039,0x00000006,0x0000006c,0x0000000b,0x0000006a,0x0003003e,0x00000062,0x0000006c, + 0x0004003d,0x00000006,0x0000006f,0x00000032,0x0004003d,0x00000006,0x00000070,0x0000003d, + 0x00050083,0x00000006,0x00000071,0x0000006f,0x00000070,0x0006000c,0x00000006,0x00000072, + 0x00000001,0x00000004,0x00000071,0x0004003d,0x00000006,0x00000073,0x00000032,0x0004003d, + 0x00000006,0x00000074,0x0000004b,0x00050083,0x00000006,0x00000075,0x00000073,0x00000074, + 0x0006000c,0x00000006,0x00000076,0x00000001,0x00000004,0x00000075,0x0004003d,0x00000006, + 0x00000077,0x00000032,0x0004003d,0x00000006,0x00000078,0x00000056,0x00050083,0x00000006, + 0x00000079,0x00000077,0x00000078,0x0006000c,0x00000006,0x0000007a,0x00000001,0x00000004, + 0x00000079,0x0004003d,0x00000006,0x0000007b,0x00000032,0x0004003d,0x00000006,0x0000007c, + 0x00000062,0x00050083,0x00000006,0x0000007d,0x0000007b,0x0000007c,0x0006000c,0x00000006, + 0x0000007e,0x00000001,0x00000004,0x0000007d,0x00070050,0x00000019,0x0000007f,0x00000072, + 0x00000076,0x0000007a,0x0000007e,0x0003003e,0x0000006e,0x0000007f,0x000100fd,0x00010038, + 0x00050036,0x00000006,0x0000000b,0x00000000,0x00000009,0x00030037,0x00000008,0x0000000a, + 0x000200f8,0x0000000c,0x0004003d,0x00000007,0x0000000d,0x0000000a,0x00050094,0x00000006, + 0x00000012,0x0000000d,0x00000011,0x000200fe,0x00000012,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/smaa_frag.h b/app/src/main/cpp/shaders/smaa_frag.h deleted file mode 100644 index 1467b4efc0..0000000000 --- a/app/src/main/cpp/shaders/smaa_frag.h +++ /dev/null @@ -1,443 +0,0 @@ -#pragma once -#include - -static const uint32_t smaa_code[] = { - 0x07230203u, 0x00010000u, 0x0008000bu, 0x00000251u, 0x00000000u, 0x00020011u, 0x00000001u, 0x0006000bu, - 0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, 0x00000000u, 0x00000001u, - 0x0007000fu, 0x00000004u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x00000072u, 0x000000f6u, 0x00030010u, - 0x00000004u, 0x00000007u, 0x00030003u, 0x00000002u, 0x000001c2u, 0x00040005u, 0x00000004u, 0x6e69616du, - 0x00000000u, 0x00050005u, 0x0000000bu, 0x616d756cu, 0x33667628u, 0x0000003bu, 0x00030005u, 0x0000000au, - 0x00000063u, 0x00080005u, 0x00000012u, 0x65676465u, 0x74726556u, 0x6c616369u, 0x32667628u, 0x3266763bu, - 0x0000003bu, 0x00030005u, 0x00000010u, 0x00007675u, 0x00030005u, 0x00000011u, 0x00007870u, 0x00080005u, - 0x00000016u, 0x65676465u, 0x69726f48u, 0x746e6f7au, 0x76286c61u, 0x763b3266u, 0x003b3266u, 0x00030005u, - 0x00000014u, 0x00007675u, 0x00030005u, 0x00000015u, 0x00007870u, 0x00030005u, 0x00000021u, 0x00000061u, - 0x00060005u, 0x00000025u, 0x75706e49u, 0x78655474u, 0x65727574u, 0x00000000u, 0x00040005u, 0x00000031u, - 0x61726170u, 0x0000006du, 0x00030005u, 0x00000034u, 0x00000062u, 0x00040005u, 0x0000003cu, 0x61726170u, - 0x0000006du, 0x00030005u, 0x00000045u, 0x00000061u, 0x00040005u, 0x0000004eu, 0x61726170u, 0x0000006du, - 0x00030005u, 0x00000051u, 0x00000062u, 0x00040005u, 0x00000059u, 0x61726170u, 0x0000006du, 0x00030005u, - 0x00000062u, 0x00007870u, 0x00050005u, 0x00000064u, 0x736e6f43u, 0x746e6174u, 0x00000073u, 0x00040006u, - 0x00000064u, 0x00000000u, 0x0063646eu, 0x00060006u, 0x00000064u, 0x00000001u, 0x6f736572u, 0x6974756cu, - 0x00006e6fu, 0x00050006u, 0x00000064u, 0x00000002u, 0x72747865u, 0x00000061u, 0x00040006u, 0x00000064u, - 0x00000003u, 0x00646170u, 0x00030005u, 0x00000066u, 0x00006370u, 0x00030005u, 0x00000070u, 0x00007675u, - 0x00060005u, 0x00000072u, 0x67617266u, 0x43786554u, 0x64726f6fu, 0x00000000u, 0x00040005u, 0x0000007cu, - 0x746e6563u, 0x00007265u, 0x00030005u, 0x00000080u, 0x0000636cu, 0x00040005u, 0x00000081u, 0x61726170u, - 0x0000006du, 0x00030005u, 0x00000085u, 0x00006c6cu, 0x00040005u, 0x0000008du, 0x61726170u, 0x0000006du, - 0x00030005u, 0x00000090u, 0x0000726cu, 0x00040005u, 0x00000098u, 0x61726170u, 0x0000006du, 0x00030005u, - 0x0000009bu, 0x0000756cu, 0x00040005u, 0x000000a3u, 0x61726170u, 0x0000006du, 0x00030005u, 0x000000a6u, - 0x0000646cu, 0x00040005u, 0x000000aeu, 0x61726170u, 0x0000006du, 0x00030005u, 0x000000b1u, 0x00004c64u, - 0x00030005u, 0x000000b6u, 0x00005264u, 0x00030005u, 0x000000bbu, 0x00005564u, 0x00030005u, 0x000000c0u, - 0x00004464u, 0x00050005u, 0x000000c5u, 0x61636f6cu, 0x6e694d6cu, 0x00000000u, 0x00050005u, 0x000000cfu, - 0x61636f6cu, 0x78614d6cu, 0x00000000u, 0x00060005u, 0x000000d9u, 0x61636f6cu, 0x6e6f436cu, 0x73617274u, - 0x00000074u, 0x00050005u, 0x000000ddu, 0x65726874u, 0x6c6f6873u, 0x00000064u, 0x00050005u, 0x000000e3u, - 0x74726576u, 0x6c616369u, 0x00000000u, 0x00050005u, 0x000000e7u, 0x69726f68u, 0x746e6f7au, 0x00006c61u, - 0x00050005u, 0x000000ebu, 0x6f727473u, 0x7365676eu, 0x00000074u, 0x00050005u, 0x000000f6u, 0x4374756fu, - 0x726f6c6fu, 0x00000000u, 0x00060005u, 0x000000fau, 0x74726576u, 0x6c616369u, 0x65676445u, 0x00000000u, - 0x00040005u, 0x000000feu, 0x676e6174u, 0x00746e65u, 0x00040005u, 0x0000010bu, 0x6d726f6eu, 0x00006c61u, - 0x00050005u, 0x0000011du, 0x6167656eu, 0x65766974u, 0x006e7552u, 0x00050005u, 0x0000011eu, 0x69736f70u, - 0x65766974u, 0x006e7552u, 0x00030005u, 0x00000120u, 0x00000069u, 0x00040005u, 0x00000129u, 0x7366666fu, - 0x00007465u, 0x00040005u, 0x0000012eu, 0x65676465u, 0x0000004eu, 0x00040005u, 0x00000136u, 0x61726170u, - 0x0000006du, 0x00040005u, 0x00000137u, 0x61726170u, 0x0000006du, 0x00040005u, 0x0000013eu, 0x61726170u, - 0x0000006du, 0x00040005u, 0x0000013fu, 0x61726170u, 0x0000006du, 0x00040005u, 0x00000143u, 0x65676465u, - 0x00000050u, 0x00040005u, 0x0000014bu, 0x61726170u, 0x0000006du, 0x00040005u, 0x0000014cu, 0x61726170u, - 0x0000006du, 0x00040005u, 0x00000153u, 0x61726170u, 0x0000006du, 0x00040005u, 0x00000154u, 0x61726170u, - 0x0000006du, 0x00040005u, 0x0000017bu, 0x6e617073u, 0x00000000u, 0x00060005u, 0x0000017fu, 0x65676465u, - 0x666e6f43u, 0x6e656469u, 0x00006563u, 0x00030005u, 0x00000186u, 0x0000776eu, 0x00040005u, 0x00000192u, - 0x61726170u, 0x0000006du, 0x00030005u, 0x00000195u, 0x0000656eu, 0x00040005u, 0x000001a0u, 0x61726170u, - 0x0000006du, 0x00030005u, 0x000001a3u, 0x00007773u, 0x00040005u, 0x000001aeu, 0x61726170u, 0x0000006du, - 0x00030005u, 0x000001b1u, 0x00006573u, 0x00040005u, 0x000001bbu, 0x61726170u, 0x0000006du, 0x00060005u, - 0x000001beu, 0x70646e65u, 0x746e696fu, 0x74746150u, 0x006e7265u, 0x00060005u, 0x000001c7u, 0x70646e65u, - 0x746e696fu, 0x61657241u, 0x00000000u, 0x00050005u, 0x000001ceu, 0x736f7263u, 0x676e6973u, 0x00000041u, - 0x00050005u, 0x000001ddu, 0x736f7263u, 0x676e6973u, 0x00000042u, 0x00070005u, 0x000001ecu, 0x736f7263u, - 0x676e6973u, 0x746e6f43u, 0x74736172u, 0x00000000u, 0x00060005u, 0x000001f1u, 0x736f7263u, 0x676e6973u, - 0x74746150u, 0x006e7265u, 0x00050005u, 0x000001f7u, 0x61657261u, 0x67696557u, 0x00007468u, 0x00070005u, - 0x00000200u, 0x67616964u, 0x6c616e6fu, 0x746e6f43u, 0x74736172u, 0x00000000u, 0x00060005u, 0x0000020au, - 0x6e726f63u, 0x61467265u, 0x726f7463u, 0x00000000u, 0x00050005u, 0x00000214u, 0x65736162u, 0x67696557u, - 0x00007468u, 0x00070005u, 0x0000021cu, 0x67616964u, 0x6c616e6fu, 0x65727453u, 0x6874676eu, 0x00000000u, - 0x00060005u, 0x00000220u, 0x67616964u, 0x6c616e6fu, 0x74746150u, 0x006e7265u, 0x00070005u, 0x00000226u, - 0x67616964u, 0x6c616e6fu, 0x746e6f43u, 0x69756e69u, 0x00007974u, 0x00070005u, 0x00000229u, 0x67616964u, - 0x6c616e6fu, 0x6c6c6146u, 0x6b636162u, 0x00000000u, 0x00040005u, 0x00000235u, 0x67696577u, 0x00007468u, - 0x00040005u, 0x0000023bu, 0x6f726361u, 0x00007373u, 0x00040047u, 0x00000025u, 0x00000021u, 0x00000000u, - 0x00040047u, 0x00000025u, 0x00000022u, 0x00000000u, 0x00030047u, 0x00000064u, 0x00000002u, 0x00050048u, - 0x00000064u, 0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u, 0x00000064u, 0x00000001u, 0x00000023u, - 0x00000010u, 0x00050048u, 0x00000064u, 0x00000002u, 0x00000023u, 0x00000018u, 0x00050048u, 0x00000064u, - 0x00000003u, 0x00000023u, 0x0000001cu, 0x00040047u, 0x00000072u, 0x0000001eu, 0x00000000u, 0x00040047u, - 0x000000f6u, 0x0000001eu, 0x00000000u, 0x00020013u, 0x00000002u, 0x00030021u, 0x00000003u, 0x00000002u, - 0x00030016u, 0x00000006u, 0x00000020u, 0x00040017u, 0x00000007u, 0x00000006u, 0x00000003u, 0x00040020u, - 0x00000008u, 0x00000007u, 0x00000007u, 0x00040021u, 0x00000009u, 0x00000006u, 0x00000008u, 0x00040017u, - 0x0000000du, 0x00000006u, 0x00000002u, 0x00040020u, 0x0000000eu, 0x00000007u, 0x0000000du, 0x00050021u, - 0x0000000fu, 0x00000006u, 0x0000000eu, 0x0000000eu, 0x0004002bu, 0x00000006u, 0x00000019u, 0x3e59b3d0u, - 0x0004002bu, 0x00000006u, 0x0000001au, 0x3f371759u, 0x0004002bu, 0x00000006u, 0x0000001bu, 0x3d93dd98u, - 0x0006002cu, 0x00000007u, 0x0000001cu, 0x00000019u, 0x0000001au, 0x0000001bu, 0x00040020u, 0x00000020u, - 0x00000007u, 0x00000006u, 0x00090019u, 0x00000022u, 0x00000006u, 0x00000001u, 0x00000000u, 0x00000000u, - 0x00000000u, 0x00000001u, 0x00000000u, 0x0003001bu, 0x00000023u, 0x00000022u, 0x00040020u, 0x00000024u, - 0x00000000u, 0x00000023u, 0x0004003bu, 0x00000024u, 0x00000025u, 0x00000000u, 0x00040015u, 0x00000028u, - 0x00000020u, 0x00000000u, 0x0004002bu, 0x00000028u, 0x00000029u, 0x00000000u, 0x0004002bu, 0x00000006u, - 0x0000002cu, 0x00000000u, 0x00040017u, 0x0000002fu, 0x00000006u, 0x00000004u, 0x0004002bu, 0x00000028u, - 0x00000048u, 0x00000001u, 0x0004002bu, 0x00000006u, 0x00000063u, 0x3f800000u, 0x0006001eu, 0x00000064u, - 0x0000002fu, 0x0000000du, 0x00000006u, 0x00000006u, 0x00040020u, 0x00000065u, 0x00000009u, 0x00000064u, - 0x0004003bu, 0x00000065u, 0x00000066u, 0x00000009u, 0x00040015u, 0x00000067u, 0x00000020u, 0x00000001u, - 0x0004002bu, 0x00000067u, 0x00000068u, 0x00000001u, 0x00040020u, 0x00000069u, 0x00000009u, 0x0000000du, - 0x0005002cu, 0x0000000du, 0x0000006cu, 0x00000063u, 0x00000063u, 0x00040020u, 0x00000071u, 0x00000001u, - 0x0000000du, 0x0004003bu, 0x00000071u, 0x00000072u, 0x00000001u, 0x0004002bu, 0x00000006u, 0x00000075u, - 0x3f000000u, 0x00040020u, 0x0000007bu, 0x00000007u, 0x0000002fu, 0x0004002bu, 0x00000006u, 0x000000deu, - 0x3d3851ecu, 0x0004002bu, 0x00000006u, 0x000000e0u, 0x3da3d70au, 0x00020014u, 0x000000f1u, 0x00040020u, - 0x000000f5u, 0x00000003u, 0x0000002fu, 0x0004003bu, 0x000000f5u, 0x000000f6u, 0x00000003u, 0x00040020u, - 0x000000f9u, 0x00000007u, 0x000000f1u, 0x0004002bu, 0x00000006u, 0x00000113u, 0xbf800000u, 0x00040020u, - 0x0000011fu, 0x00000007u, 0x00000067u, 0x0004002bu, 0x00000067u, 0x00000127u, 0x00000006u, 0x0004002bu, - 0x00000006u, 0x00000161u, 0x3f266666u, 0x0004002bu, 0x00000006u, 0x00000182u, 0x40200000u, 0x0004002bu, - 0x00000006u, 0x000001cau, 0x3d6147aeu, 0x0004002bu, 0x00000006u, 0x000001f8u, 0x3ec28f5cu, 0x0004002bu, - 0x00000006u, 0x000001fcu, 0x40800000u, 0x0004002bu, 0x00000006u, 0x0000020bu, 0x3eb33333u, 0x0004002bu, - 0x00000006u, 0x0000020eu, 0x40400000u, 0x0004002bu, 0x00000006u, 0x0000022au, 0x3e23d70au, 0x0004002bu, - 0x00000006u, 0x00000239u, 0x3ed70a3du, 0x0004002bu, 0x00000028u, 0x0000024au, 0x00000003u, 0x00050036u, - 0x00000002u, 0x00000004u, 0x00000000u, 0x00000003u, 0x000200f8u, 0x00000005u, 0x0004003bu, 0x0000000eu, - 0x00000062u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000070u, 0x00000007u, 0x0004003bu, 0x0000007bu, - 0x0000007cu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000080u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x00000081u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000085u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x0000008du, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000090u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x00000098u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000009bu, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x000000a3u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000a6u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x000000aeu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000b1u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000000b6u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000bbu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000000c0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000c5u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000000cfu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000d9u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000000ddu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000e3u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000000e7u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000ebu, 0x00000007u, 0x0004003bu, 0x000000f9u, - 0x000000fau, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x000000feu, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x00000100u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000010bu, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x0000010du, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000011du, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x0000011eu, 0x00000007u, 0x0004003bu, 0x0000011fu, 0x00000120u, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x00000129u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000012eu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000130u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000136u, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x00000137u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000013eu, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x0000013fu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000143u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000145u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000014bu, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x0000014cu, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000153u, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x00000154u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000017bu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x0000017fu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000186u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x00000192u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000195u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x000001a0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001a3u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x000001aeu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001b1u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x000001bbu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001beu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000001c7u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ceu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000001d0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ddu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000001dfu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ecu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000001f1u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001f7u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000200u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000020au, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000214u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000021cu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000220u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000226u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000229u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000235u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x0000023bu, 0x00000007u, 0x00050041u, 0x00000069u, 0x0000006au, 0x00000066u, 0x00000068u, 0x0004003du, - 0x0000000du, 0x0000006bu, 0x0000006au, 0x0007000cu, 0x0000000du, 0x0000006du, 0x00000001u, 0x00000028u, - 0x0000006bu, 0x0000006cu, 0x00050050u, 0x0000000du, 0x0000006eu, 0x00000063u, 0x00000063u, 0x00050088u, - 0x0000000du, 0x0000006fu, 0x0000006eu, 0x0000006du, 0x0003003eu, 0x00000062u, 0x0000006fu, 0x0004003du, - 0x0000000du, 0x00000073u, 0x00000072u, 0x0004003du, 0x0000000du, 0x00000074u, 0x00000062u, 0x0005008eu, - 0x0000000du, 0x00000076u, 0x00000074u, 0x00000075u, 0x0004003du, 0x0000000du, 0x00000077u, 0x00000062u, - 0x0005008eu, 0x0000000du, 0x00000078u, 0x00000077u, 0x00000075u, 0x00050083u, 0x0000000du, 0x00000079u, - 0x0000006cu, 0x00000078u, 0x0008000cu, 0x0000000du, 0x0000007au, 0x00000001u, 0x0000002bu, 0x00000073u, - 0x00000076u, 0x00000079u, 0x0003003eu, 0x00000070u, 0x0000007au, 0x0004003du, 0x00000023u, 0x0000007du, - 0x00000025u, 0x0004003du, 0x0000000du, 0x0000007eu, 0x00000070u, 0x00050057u, 0x0000002fu, 0x0000007fu, - 0x0000007du, 0x0000007eu, 0x0003003eu, 0x0000007cu, 0x0000007fu, 0x0004003du, 0x0000002fu, 0x00000082u, - 0x0000007cu, 0x0008004fu, 0x00000007u, 0x00000083u, 0x00000082u, 0x00000082u, 0x00000000u, 0x00000001u, - 0x00000002u, 0x0003003eu, 0x00000081u, 0x00000083u, 0x00050039u, 0x00000006u, 0x00000084u, 0x0000000bu, - 0x00000081u, 0x0003003eu, 0x00000080u, 0x00000084u, 0x0004003du, 0x00000023u, 0x00000086u, 0x00000025u, - 0x0004003du, 0x0000000du, 0x00000087u, 0x00000070u, 0x00050041u, 0x00000020u, 0x00000088u, 0x00000062u, - 0x00000029u, 0x0004003du, 0x00000006u, 0x00000089u, 0x00000088u, 0x00050050u, 0x0000000du, 0x0000008au, - 0x00000089u, 0x0000002cu, 0x00050083u, 0x0000000du, 0x0000008bu, 0x00000087u, 0x0000008au, 0x00050057u, - 0x0000002fu, 0x0000008cu, 0x00000086u, 0x0000008bu, 0x0008004fu, 0x00000007u, 0x0000008eu, 0x0000008cu, - 0x0000008cu, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x0000008du, 0x0000008eu, 0x00050039u, - 0x00000006u, 0x0000008fu, 0x0000000bu, 0x0000008du, 0x0003003eu, 0x00000085u, 0x0000008fu, 0x0004003du, - 0x00000023u, 0x00000091u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000092u, 0x00000070u, 0x00050041u, - 0x00000020u, 0x00000093u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u, 0x00000094u, 0x00000093u, - 0x00050050u, 0x0000000du, 0x00000095u, 0x00000094u, 0x0000002cu, 0x00050081u, 0x0000000du, 0x00000096u, - 0x00000092u, 0x00000095u, 0x00050057u, 0x0000002fu, 0x00000097u, 0x00000091u, 0x00000096u, 0x0008004fu, - 0x00000007u, 0x00000099u, 0x00000097u, 0x00000097u, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, - 0x00000098u, 0x00000099u, 0x00050039u, 0x00000006u, 0x0000009au, 0x0000000bu, 0x00000098u, 0x0003003eu, - 0x00000090u, 0x0000009au, 0x0004003du, 0x00000023u, 0x0000009cu, 0x00000025u, 0x0004003du, 0x0000000du, - 0x0000009du, 0x00000070u, 0x00050041u, 0x00000020u, 0x0000009eu, 0x00000062u, 0x00000048u, 0x0004003du, - 0x00000006u, 0x0000009fu, 0x0000009eu, 0x00050050u, 0x0000000du, 0x000000a0u, 0x0000002cu, 0x0000009fu, - 0x00050083u, 0x0000000du, 0x000000a1u, 0x0000009du, 0x000000a0u, 0x00050057u, 0x0000002fu, 0x000000a2u, - 0x0000009cu, 0x000000a1u, 0x0008004fu, 0x00000007u, 0x000000a4u, 0x000000a2u, 0x000000a2u, 0x00000000u, - 0x00000001u, 0x00000002u, 0x0003003eu, 0x000000a3u, 0x000000a4u, 0x00050039u, 0x00000006u, 0x000000a5u, - 0x0000000bu, 0x000000a3u, 0x0003003eu, 0x0000009bu, 0x000000a5u, 0x0004003du, 0x00000023u, 0x000000a7u, - 0x00000025u, 0x0004003du, 0x0000000du, 0x000000a8u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000000a9u, - 0x00000062u, 0x00000048u, 0x0004003du, 0x00000006u, 0x000000aau, 0x000000a9u, 0x00050050u, 0x0000000du, - 0x000000abu, 0x0000002cu, 0x000000aau, 0x00050081u, 0x0000000du, 0x000000acu, 0x000000a8u, 0x000000abu, - 0x00050057u, 0x0000002fu, 0x000000adu, 0x000000a7u, 0x000000acu, 0x0008004fu, 0x00000007u, 0x000000afu, - 0x000000adu, 0x000000adu, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x000000aeu, 0x000000afu, - 0x00050039u, 0x00000006u, 0x000000b0u, 0x0000000bu, 0x000000aeu, 0x0003003eu, 0x000000a6u, 0x000000b0u, - 0x0004003du, 0x00000006u, 0x000000b2u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000b3u, 0x00000085u, - 0x00050083u, 0x00000006u, 0x000000b4u, 0x000000b2u, 0x000000b3u, 0x0006000cu, 0x00000006u, 0x000000b5u, - 0x00000001u, 0x00000004u, 0x000000b4u, 0x0003003eu, 0x000000b1u, 0x000000b5u, 0x0004003du, 0x00000006u, - 0x000000b7u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000b8u, 0x00000090u, 0x00050083u, 0x00000006u, - 0x000000b9u, 0x000000b7u, 0x000000b8u, 0x0006000cu, 0x00000006u, 0x000000bau, 0x00000001u, 0x00000004u, - 0x000000b9u, 0x0003003eu, 0x000000b6u, 0x000000bau, 0x0004003du, 0x00000006u, 0x000000bcu, 0x00000080u, - 0x0004003du, 0x00000006u, 0x000000bdu, 0x0000009bu, 0x00050083u, 0x00000006u, 0x000000beu, 0x000000bcu, - 0x000000bdu, 0x0006000cu, 0x00000006u, 0x000000bfu, 0x00000001u, 0x00000004u, 0x000000beu, 0x0003003eu, - 0x000000bbu, 0x000000bfu, 0x0004003du, 0x00000006u, 0x000000c1u, 0x00000080u, 0x0004003du, 0x00000006u, - 0x000000c2u, 0x000000a6u, 0x00050083u, 0x00000006u, 0x000000c3u, 0x000000c1u, 0x000000c2u, 0x0006000cu, - 0x00000006u, 0x000000c4u, 0x00000001u, 0x00000004u, 0x000000c3u, 0x0003003eu, 0x000000c0u, 0x000000c4u, - 0x0004003du, 0x00000006u, 0x000000c6u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000c7u, 0x00000085u, - 0x0004003du, 0x00000006u, 0x000000c8u, 0x00000090u, 0x0007000cu, 0x00000006u, 0x000000c9u, 0x00000001u, - 0x00000025u, 0x000000c7u, 0x000000c8u, 0x0004003du, 0x00000006u, 0x000000cau, 0x0000009bu, 0x0004003du, - 0x00000006u, 0x000000cbu, 0x000000a6u, 0x0007000cu, 0x00000006u, 0x000000ccu, 0x00000001u, 0x00000025u, - 0x000000cau, 0x000000cbu, 0x0007000cu, 0x00000006u, 0x000000cdu, 0x00000001u, 0x00000025u, 0x000000c9u, - 0x000000ccu, 0x0007000cu, 0x00000006u, 0x000000ceu, 0x00000001u, 0x00000025u, 0x000000c6u, 0x000000cdu, - 0x0003003eu, 0x000000c5u, 0x000000ceu, 0x0004003du, 0x00000006u, 0x000000d0u, 0x00000080u, 0x0004003du, - 0x00000006u, 0x000000d1u, 0x00000085u, 0x0004003du, 0x00000006u, 0x000000d2u, 0x00000090u, 0x0007000cu, - 0x00000006u, 0x000000d3u, 0x00000001u, 0x00000028u, 0x000000d1u, 0x000000d2u, 0x0004003du, 0x00000006u, - 0x000000d4u, 0x0000009bu, 0x0004003du, 0x00000006u, 0x000000d5u, 0x000000a6u, 0x0007000cu, 0x00000006u, - 0x000000d6u, 0x00000001u, 0x00000028u, 0x000000d4u, 0x000000d5u, 0x0007000cu, 0x00000006u, 0x000000d7u, - 0x00000001u, 0x00000028u, 0x000000d3u, 0x000000d6u, 0x0007000cu, 0x00000006u, 0x000000d8u, 0x00000001u, - 0x00000028u, 0x000000d0u, 0x000000d7u, 0x0003003eu, 0x000000cfu, 0x000000d8u, 0x0004003du, 0x00000006u, - 0x000000dau, 0x000000cfu, 0x0004003du, 0x00000006u, 0x000000dbu, 0x000000c5u, 0x00050083u, 0x00000006u, - 0x000000dcu, 0x000000dau, 0x000000dbu, 0x0003003eu, 0x000000d9u, 0x000000dcu, 0x0004003du, 0x00000006u, - 0x000000dfu, 0x000000d9u, 0x00050085u, 0x00000006u, 0x000000e1u, 0x000000dfu, 0x000000e0u, 0x0007000cu, - 0x00000006u, 0x000000e2u, 0x00000001u, 0x00000028u, 0x000000deu, 0x000000e1u, 0x0003003eu, 0x000000ddu, - 0x000000e2u, 0x0004003du, 0x00000006u, 0x000000e4u, 0x000000b1u, 0x0004003du, 0x00000006u, 0x000000e5u, - 0x000000b6u, 0x0007000cu, 0x00000006u, 0x000000e6u, 0x00000001u, 0x00000028u, 0x000000e4u, 0x000000e5u, - 0x0003003eu, 0x000000e3u, 0x000000e6u, 0x0004003du, 0x00000006u, 0x000000e8u, 0x000000bbu, 0x0004003du, - 0x00000006u, 0x000000e9u, 0x000000c0u, 0x0007000cu, 0x00000006u, 0x000000eau, 0x00000001u, 0x00000028u, - 0x000000e8u, 0x000000e9u, 0x0003003eu, 0x000000e7u, 0x000000eau, 0x0004003du, 0x00000006u, 0x000000ecu, - 0x000000e3u, 0x0004003du, 0x00000006u, 0x000000edu, 0x000000e7u, 0x0007000cu, 0x00000006u, 0x000000eeu, - 0x00000001u, 0x00000028u, 0x000000ecu, 0x000000edu, 0x0003003eu, 0x000000ebu, 0x000000eeu, 0x0004003du, - 0x00000006u, 0x000000efu, 0x000000ebu, 0x0004003du, 0x00000006u, 0x000000f0u, 0x000000ddu, 0x000500bcu, - 0x000000f1u, 0x000000f2u, 0x000000efu, 0x000000f0u, 0x000300f7u, 0x000000f4u, 0x00000000u, 0x000400fau, - 0x000000f2u, 0x000000f3u, 0x000000f4u, 0x000200f8u, 0x000000f3u, 0x0004003du, 0x0000002fu, 0x000000f7u, - 0x0000007cu, 0x0003003eu, 0x000000f6u, 0x000000f7u, 0x000100fdu, 0x000200f8u, 0x000000f4u, 0x0004003du, - 0x00000006u, 0x000000fbu, 0x000000e3u, 0x0004003du, 0x00000006u, 0x000000fcu, 0x000000e7u, 0x000500beu, - 0x000000f1u, 0x000000fdu, 0x000000fbu, 0x000000fcu, 0x0003003eu, 0x000000fau, 0x000000fdu, 0x0004003du, - 0x000000f1u, 0x000000ffu, 0x000000fau, 0x000300f7u, 0x00000102u, 0x00000000u, 0x000400fau, 0x000000ffu, - 0x00000101u, 0x00000106u, 0x000200f8u, 0x00000101u, 0x00050041u, 0x00000020u, 0x00000103u, 0x00000062u, - 0x00000048u, 0x0004003du, 0x00000006u, 0x00000104u, 0x00000103u, 0x00050050u, 0x0000000du, 0x00000105u, - 0x0000002cu, 0x00000104u, 0x0003003eu, 0x00000100u, 0x00000105u, 0x000200f9u, 0x00000102u, 0x000200f8u, - 0x00000106u, 0x00050041u, 0x00000020u, 0x00000107u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u, - 0x00000108u, 0x00000107u, 0x00050050u, 0x0000000du, 0x00000109u, 0x00000108u, 0x0000002cu, 0x0003003eu, - 0x00000100u, 0x00000109u, 0x000200f9u, 0x00000102u, 0x000200f8u, 0x00000102u, 0x0004003du, 0x0000000du, - 0x0000010au, 0x00000100u, 0x0003003eu, 0x000000feu, 0x0000010au, 0x0004003du, 0x000000f1u, 0x0000010cu, - 0x000000fau, 0x000300f7u, 0x0000010fu, 0x00000000u, 0x000400fau, 0x0000010cu, 0x0000010eu, 0x00000116u, - 0x000200f8u, 0x0000010eu, 0x0004003du, 0x00000006u, 0x00000110u, 0x000000b1u, 0x0004003du, 0x00000006u, - 0x00000111u, 0x000000b6u, 0x000500beu, 0x000000f1u, 0x00000112u, 0x00000110u, 0x00000111u, 0x000600a9u, - 0x00000006u, 0x00000114u, 0x00000112u, 0x00000113u, 0x00000063u, 0x00050050u, 0x0000000du, 0x00000115u, - 0x00000114u, 0x0000002cu, 0x0003003eu, 0x0000010du, 0x00000115u, 0x000200f9u, 0x0000010fu, 0x000200f8u, - 0x00000116u, 0x0004003du, 0x00000006u, 0x00000117u, 0x000000bbu, 0x0004003du, 0x00000006u, 0x00000118u, - 0x000000c0u, 0x000500beu, 0x000000f1u, 0x00000119u, 0x00000117u, 0x00000118u, 0x000600a9u, 0x00000006u, - 0x0000011au, 0x00000119u, 0x00000113u, 0x00000063u, 0x00050050u, 0x0000000du, 0x0000011bu, 0x0000002cu, - 0x0000011au, 0x0003003eu, 0x0000010du, 0x0000011bu, 0x000200f9u, 0x0000010fu, 0x000200f8u, 0x0000010fu, - 0x0004003du, 0x0000000du, 0x0000011cu, 0x0000010du, 0x0003003eu, 0x0000010bu, 0x0000011cu, 0x0003003eu, - 0x0000011du, 0x0000002cu, 0x0003003eu, 0x0000011eu, 0x0000002cu, 0x0003003eu, 0x00000120u, 0x00000068u, - 0x000200f9u, 0x00000121u, 0x000200f8u, 0x00000121u, 0x000400f6u, 0x00000123u, 0x00000124u, 0x00000000u, - 0x000200f9u, 0x00000125u, 0x000200f8u, 0x00000125u, 0x0004003du, 0x00000067u, 0x00000126u, 0x00000120u, - 0x000500b3u, 0x000000f1u, 0x00000128u, 0x00000126u, 0x00000127u, 0x000400fau, 0x00000128u, 0x00000122u, - 0x00000123u, 0x000200f8u, 0x00000122u, 0x0004003du, 0x0000000du, 0x0000012au, 0x000000feu, 0x0004003du, - 0x00000067u, 0x0000012bu, 0x00000120u, 0x0004006fu, 0x00000006u, 0x0000012cu, 0x0000012bu, 0x0005008eu, - 0x0000000du, 0x0000012du, 0x0000012au, 0x0000012cu, 0x0003003eu, 0x00000129u, 0x0000012du, 0x0004003du, - 0x000000f1u, 0x0000012fu, 0x000000fau, 0x000300f7u, 0x00000132u, 0x00000000u, 0x000400fau, 0x0000012fu, - 0x00000131u, 0x0000013au, 0x000200f8u, 0x00000131u, 0x0004003du, 0x0000000du, 0x00000133u, 0x00000070u, - 0x0004003du, 0x0000000du, 0x00000134u, 0x00000129u, 0x00050083u, 0x0000000du, 0x00000135u, 0x00000133u, - 0x00000134u, 0x0003003eu, 0x00000136u, 0x00000135u, 0x0004003du, 0x0000000du, 0x00000138u, 0x00000062u, - 0x0003003eu, 0x00000137u, 0x00000138u, 0x00060039u, 0x00000006u, 0x00000139u, 0x00000012u, 0x00000136u, - 0x00000137u, 0x0003003eu, 0x00000130u, 0x00000139u, 0x000200f9u, 0x00000132u, 0x000200f8u, 0x0000013au, - 0x0004003du, 0x0000000du, 0x0000013bu, 0x00000070u, 0x0004003du, 0x0000000du, 0x0000013cu, 0x00000129u, - 0x00050083u, 0x0000000du, 0x0000013du, 0x0000013bu, 0x0000013cu, 0x0003003eu, 0x0000013eu, 0x0000013du, - 0x0004003du, 0x0000000du, 0x00000140u, 0x00000062u, 0x0003003eu, 0x0000013fu, 0x00000140u, 0x00060039u, - 0x00000006u, 0x00000141u, 0x00000016u, 0x0000013eu, 0x0000013fu, 0x0003003eu, 0x00000130u, 0x00000141u, - 0x000200f9u, 0x00000132u, 0x000200f8u, 0x00000132u, 0x0004003du, 0x00000006u, 0x00000142u, 0x00000130u, - 0x0003003eu, 0x0000012eu, 0x00000142u, 0x0004003du, 0x000000f1u, 0x00000144u, 0x000000fau, 0x000300f7u, - 0x00000147u, 0x00000000u, 0x000400fau, 0x00000144u, 0x00000146u, 0x0000014fu, 0x000200f8u, 0x00000146u, - 0x0004003du, 0x0000000du, 0x00000148u, 0x00000070u, 0x0004003du, 0x0000000du, 0x00000149u, 0x00000129u, - 0x00050081u, 0x0000000du, 0x0000014au, 0x00000148u, 0x00000149u, 0x0003003eu, 0x0000014bu, 0x0000014au, - 0x0004003du, 0x0000000du, 0x0000014du, 0x00000062u, 0x0003003eu, 0x0000014cu, 0x0000014du, 0x00060039u, - 0x00000006u, 0x0000014eu, 0x00000012u, 0x0000014bu, 0x0000014cu, 0x0003003eu, 0x00000145u, 0x0000014eu, - 0x000200f9u, 0x00000147u, 0x000200f8u, 0x0000014fu, 0x0004003du, 0x0000000du, 0x00000150u, 0x00000070u, - 0x0004003du, 0x0000000du, 0x00000151u, 0x00000129u, 0x00050081u, 0x0000000du, 0x00000152u, 0x00000150u, - 0x00000151u, 0x0003003eu, 0x00000153u, 0x00000152u, 0x0004003du, 0x0000000du, 0x00000155u, 0x00000062u, - 0x0003003eu, 0x00000154u, 0x00000155u, 0x00060039u, 0x00000006u, 0x00000156u, 0x00000016u, 0x00000153u, - 0x00000154u, 0x0003003eu, 0x00000145u, 0x00000156u, 0x000200f9u, 0x00000147u, 0x000200f8u, 0x00000147u, - 0x0004003du, 0x00000006u, 0x00000157u, 0x00000145u, 0x0003003eu, 0x00000143u, 0x00000157u, 0x0004003du, - 0x00000006u, 0x00000158u, 0x0000011du, 0x0004003du, 0x00000067u, 0x00000159u, 0x00000120u, 0x00050082u, - 0x00000067u, 0x0000015au, 0x00000159u, 0x00000068u, 0x0004006fu, 0x00000006u, 0x0000015bu, 0x0000015au, - 0x000500b4u, 0x000000f1u, 0x0000015cu, 0x00000158u, 0x0000015bu, 0x000300f7u, 0x0000015eu, 0x00000000u, - 0x000400fau, 0x0000015cu, 0x0000015du, 0x0000015eu, 0x000200f8u, 0x0000015du, 0x0004003du, 0x00000006u, - 0x0000015fu, 0x0000012eu, 0x0004003du, 0x00000006u, 0x00000160u, 0x000000ddu, 0x00050085u, 0x00000006u, - 0x00000162u, 0x00000160u, 0x00000161u, 0x000500bau, 0x000000f1u, 0x00000163u, 0x0000015fu, 0x00000162u, - 0x000200f9u, 0x0000015eu, 0x000200f8u, 0x0000015eu, 0x000700f5u, 0x000000f1u, 0x00000164u, 0x0000015cu, - 0x00000147u, 0x00000163u, 0x0000015du, 0x000300f7u, 0x00000166u, 0x00000000u, 0x000400fau, 0x00000164u, - 0x00000165u, 0x00000166u, 0x000200f8u, 0x00000165u, 0x0004003du, 0x00000067u, 0x00000167u, 0x00000120u, - 0x0004006fu, 0x00000006u, 0x00000168u, 0x00000167u, 0x0003003eu, 0x0000011du, 0x00000168u, 0x000200f9u, - 0x00000166u, 0x000200f8u, 0x00000166u, 0x0004003du, 0x00000006u, 0x00000169u, 0x0000011eu, 0x0004003du, - 0x00000067u, 0x0000016au, 0x00000120u, 0x00050082u, 0x00000067u, 0x0000016bu, 0x0000016au, 0x00000068u, - 0x0004006fu, 0x00000006u, 0x0000016cu, 0x0000016bu, 0x000500b4u, 0x000000f1u, 0x0000016du, 0x00000169u, - 0x0000016cu, 0x000300f7u, 0x0000016fu, 0x00000000u, 0x000400fau, 0x0000016du, 0x0000016eu, 0x0000016fu, - 0x000200f8u, 0x0000016eu, 0x0004003du, 0x00000006u, 0x00000170u, 0x00000143u, 0x0004003du, 0x00000006u, - 0x00000171u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000172u, 0x00000171u, 0x00000161u, 0x000500bau, - 0x000000f1u, 0x00000173u, 0x00000170u, 0x00000172u, 0x000200f9u, 0x0000016fu, 0x000200f8u, 0x0000016fu, - 0x000700f5u, 0x000000f1u, 0x00000174u, 0x0000016du, 0x00000166u, 0x00000173u, 0x0000016eu, 0x000300f7u, - 0x00000176u, 0x00000000u, 0x000400fau, 0x00000174u, 0x00000175u, 0x00000176u, 0x000200f8u, 0x00000175u, - 0x0004003du, 0x00000067u, 0x00000177u, 0x00000120u, 0x0004006fu, 0x00000006u, 0x00000178u, 0x00000177u, - 0x0003003eu, 0x0000011eu, 0x00000178u, 0x000200f9u, 0x00000176u, 0x000200f8u, 0x00000176u, 0x000200f9u, - 0x00000124u, 0x000200f8u, 0x00000124u, 0x0004003du, 0x00000067u, 0x00000179u, 0x00000120u, 0x00050080u, - 0x00000067u, 0x0000017au, 0x00000179u, 0x00000068u, 0x0003003eu, 0x00000120u, 0x0000017au, 0x000200f9u, - 0x00000121u, 0x000200f8u, 0x00000123u, 0x0004003du, 0x00000006u, 0x0000017cu, 0x0000011du, 0x0004003du, - 0x00000006u, 0x0000017du, 0x0000011eu, 0x00050081u, 0x00000006u, 0x0000017eu, 0x0000017cu, 0x0000017du, - 0x0003003eu, 0x0000017bu, 0x0000017eu, 0x0004003du, 0x00000006u, 0x00000180u, 0x000000ddu, 0x0004003du, - 0x00000006u, 0x00000181u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000183u, 0x00000181u, 0x00000182u, - 0x0004003du, 0x00000006u, 0x00000184u, 0x000000ebu, 0x0008000cu, 0x00000006u, 0x00000185u, 0x00000001u, - 0x00000031u, 0x00000180u, 0x00000183u, 0x00000184u, 0x0003003eu, 0x0000017fu, 0x00000185u, 0x0004003du, - 0x00000023u, 0x00000187u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000188u, 0x00000070u, 0x00050041u, - 0x00000020u, 0x00000189u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u, 0x0000018au, 0x00000189u, - 0x0004007fu, 0x00000006u, 0x0000018bu, 0x0000018au, 0x00050041u, 0x00000020u, 0x0000018cu, 0x00000062u, - 0x00000048u, 0x0004003du, 0x00000006u, 0x0000018du, 0x0000018cu, 0x0004007fu, 0x00000006u, 0x0000018eu, - 0x0000018du, 0x00050050u, 0x0000000du, 0x0000018fu, 0x0000018bu, 0x0000018eu, 0x00050081u, 0x0000000du, - 0x00000190u, 0x00000188u, 0x0000018fu, 0x00050057u, 0x0000002fu, 0x00000191u, 0x00000187u, 0x00000190u, - 0x0008004fu, 0x00000007u, 0x00000193u, 0x00000191u, 0x00000191u, 0x00000000u, 0x00000001u, 0x00000002u, - 0x0003003eu, 0x00000192u, 0x00000193u, 0x00050039u, 0x00000006u, 0x00000194u, 0x0000000bu, 0x00000192u, - 0x0003003eu, 0x00000186u, 0x00000194u, 0x0004003du, 0x00000023u, 0x00000196u, 0x00000025u, 0x0004003du, - 0x0000000du, 0x00000197u, 0x00000070u, 0x00050041u, 0x00000020u, 0x00000198u, 0x00000062u, 0x00000029u, - 0x0004003du, 0x00000006u, 0x00000199u, 0x00000198u, 0x00050041u, 0x00000020u, 0x0000019au, 0x00000062u, - 0x00000048u, 0x0004003du, 0x00000006u, 0x0000019bu, 0x0000019au, 0x0004007fu, 0x00000006u, 0x0000019cu, - 0x0000019bu, 0x00050050u, 0x0000000du, 0x0000019du, 0x00000199u, 0x0000019cu, 0x00050081u, 0x0000000du, - 0x0000019eu, 0x00000197u, 0x0000019du, 0x00050057u, 0x0000002fu, 0x0000019fu, 0x00000196u, 0x0000019eu, - 0x0008004fu, 0x00000007u, 0x000001a1u, 0x0000019fu, 0x0000019fu, 0x00000000u, 0x00000001u, 0x00000002u, - 0x0003003eu, 0x000001a0u, 0x000001a1u, 0x00050039u, 0x00000006u, 0x000001a2u, 0x0000000bu, 0x000001a0u, - 0x0003003eu, 0x00000195u, 0x000001a2u, 0x0004003du, 0x00000023u, 0x000001a4u, 0x00000025u, 0x0004003du, - 0x0000000du, 0x000001a5u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000001a6u, 0x00000062u, 0x00000029u, - 0x0004003du, 0x00000006u, 0x000001a7u, 0x000001a6u, 0x0004007fu, 0x00000006u, 0x000001a8u, 0x000001a7u, - 0x00050041u, 0x00000020u, 0x000001a9u, 0x00000062u, 0x00000048u, 0x0004003du, 0x00000006u, 0x000001aau, - 0x000001a9u, 0x00050050u, 0x0000000du, 0x000001abu, 0x000001a8u, 0x000001aau, 0x00050081u, 0x0000000du, - 0x000001acu, 0x000001a5u, 0x000001abu, 0x00050057u, 0x0000002fu, 0x000001adu, 0x000001a4u, 0x000001acu, - 0x0008004fu, 0x00000007u, 0x000001afu, 0x000001adu, 0x000001adu, 0x00000000u, 0x00000001u, 0x00000002u, - 0x0003003eu, 0x000001aeu, 0x000001afu, 0x00050039u, 0x00000006u, 0x000001b0u, 0x0000000bu, 0x000001aeu, - 0x0003003eu, 0x000001a3u, 0x000001b0u, 0x0004003du, 0x00000023u, 0x000001b2u, 0x00000025u, 0x0004003du, - 0x0000000du, 0x000001b3u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000001b4u, 0x00000062u, 0x00000029u, - 0x0004003du, 0x00000006u, 0x000001b5u, 0x000001b4u, 0x00050041u, 0x00000020u, 0x000001b6u, 0x00000062u, - 0x00000048u, 0x0004003du, 0x00000006u, 0x000001b7u, 0x000001b6u, 0x00050050u, 0x0000000du, 0x000001b8u, - 0x000001b5u, 0x000001b7u, 0x00050081u, 0x0000000du, 0x000001b9u, 0x000001b3u, 0x000001b8u, 0x00050057u, - 0x0000002fu, 0x000001bau, 0x000001b2u, 0x000001b9u, 0x0008004fu, 0x00000007u, 0x000001bcu, 0x000001bau, - 0x000001bau, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x000001bbu, 0x000001bcu, 0x00050039u, - 0x00000006u, 0x000001bdu, 0x0000000bu, 0x000001bbu, 0x0003003eu, 0x000001b1u, 0x000001bdu, 0x0004003du, - 0x00000006u, 0x000001bfu, 0x0000011du, 0x0004003du, 0x00000006u, 0x000001c0u, 0x0000011eu, 0x00050083u, - 0x00000006u, 0x000001c1u, 0x000001bfu, 0x000001c0u, 0x0006000cu, 0x00000006u, 0x000001c2u, 0x00000001u, - 0x00000004u, 0x000001c1u, 0x0004003du, 0x00000006u, 0x000001c3u, 0x0000017bu, 0x0007000cu, 0x00000006u, - 0x000001c4u, 0x00000001u, 0x00000028u, 0x000001c3u, 0x00000063u, 0x00050088u, 0x00000006u, 0x000001c5u, - 0x000001c2u, 0x000001c4u, 0x0008000cu, 0x00000006u, 0x000001c6u, 0x00000001u, 0x0000002bu, 0x000001c5u, - 0x0000002cu, 0x00000063u, 0x0003003eu, 0x000001beu, 0x000001c6u, 0x0004003du, 0x00000006u, 0x000001c8u, - 0x000001beu, 0x0004003du, 0x00000006u, 0x000001c9u, 0x0000017bu, 0x00050085u, 0x00000006u, 0x000001cbu, - 0x000001c9u, 0x000001cau, 0x00050081u, 0x00000006u, 0x000001ccu, 0x00000063u, 0x000001cbu, 0x00050088u, - 0x00000006u, 0x000001cdu, 0x000001c8u, 0x000001ccu, 0x0003003eu, 0x000001c7u, 0x000001cdu, 0x0004003du, - 0x000000f1u, 0x000001cfu, 0x000000fau, 0x000300f7u, 0x000001d2u, 0x00000000u, 0x000400fau, 0x000001cfu, - 0x000001d1u, 0x000001d7u, 0x000200f8u, 0x000001d1u, 0x0004003du, 0x00000006u, 0x000001d3u, 0x00000186u, - 0x0004003du, 0x00000006u, 0x000001d4u, 0x00000195u, 0x00050083u, 0x00000006u, 0x000001d5u, 0x000001d3u, - 0x000001d4u, 0x0006000cu, 0x00000006u, 0x000001d6u, 0x00000001u, 0x00000004u, 0x000001d5u, 0x0003003eu, - 0x000001d0u, 0x000001d6u, 0x000200f9u, 0x000001d2u, 0x000200f8u, 0x000001d7u, 0x0004003du, 0x00000006u, - 0x000001d8u, 0x00000186u, 0x0004003du, 0x00000006u, 0x000001d9u, 0x000001a3u, 0x00050083u, 0x00000006u, - 0x000001dau, 0x000001d8u, 0x000001d9u, 0x0006000cu, 0x00000006u, 0x000001dbu, 0x00000001u, 0x00000004u, - 0x000001dau, 0x0003003eu, 0x000001d0u, 0x000001dbu, 0x000200f9u, 0x000001d2u, 0x000200f8u, 0x000001d2u, - 0x0004003du, 0x00000006u, 0x000001dcu, 0x000001d0u, 0x0003003eu, 0x000001ceu, 0x000001dcu, 0x0004003du, - 0x000000f1u, 0x000001deu, 0x000000fau, 0x000300f7u, 0x000001e1u, 0x00000000u, 0x000400fau, 0x000001deu, - 0x000001e0u, 0x000001e6u, 0x000200f8u, 0x000001e0u, 0x0004003du, 0x00000006u, 0x000001e2u, 0x000001a3u, - 0x0004003du, 0x00000006u, 0x000001e3u, 0x000001b1u, 0x00050083u, 0x00000006u, 0x000001e4u, 0x000001e2u, - 0x000001e3u, 0x0006000cu, 0x00000006u, 0x000001e5u, 0x00000001u, 0x00000004u, 0x000001e4u, 0x0003003eu, - 0x000001dfu, 0x000001e5u, 0x000200f9u, 0x000001e1u, 0x000200f8u, 0x000001e6u, 0x0004003du, 0x00000006u, - 0x000001e7u, 0x00000195u, 0x0004003du, 0x00000006u, 0x000001e8u, 0x000001b1u, 0x00050083u, 0x00000006u, - 0x000001e9u, 0x000001e7u, 0x000001e8u, 0x0006000cu, 0x00000006u, 0x000001eau, 0x00000001u, 0x00000004u, - 0x000001e9u, 0x0003003eu, 0x000001dfu, 0x000001eau, 0x000200f9u, 0x000001e1u, 0x000200f8u, 0x000001e1u, - 0x0004003du, 0x00000006u, 0x000001ebu, 0x000001dfu, 0x0003003eu, 0x000001ddu, 0x000001ebu, 0x0004003du, - 0x00000006u, 0x000001edu, 0x000001ceu, 0x0004003du, 0x00000006u, 0x000001eeu, 0x000001ddu, 0x00050083u, - 0x00000006u, 0x000001efu, 0x000001edu, 0x000001eeu, 0x0006000cu, 0x00000006u, 0x000001f0u, 0x00000001u, - 0x00000004u, 0x000001efu, 0x0003003eu, 0x000001ecu, 0x000001f0u, 0x0004003du, 0x00000006u, 0x000001f2u, - 0x000000ddu, 0x0004003du, 0x00000006u, 0x000001f3u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x000001f4u, - 0x000001f3u, 0x00000182u, 0x0004003du, 0x00000006u, 0x000001f5u, 0x000001ecu, 0x0008000cu, 0x00000006u, - 0x000001f6u, 0x00000001u, 0x00000031u, 0x000001f2u, 0x000001f4u, 0x000001f5u, 0x0003003eu, 0x000001f1u, - 0x000001f6u, 0x0004003du, 0x00000006u, 0x000001f9u, 0x000001f1u, 0x00050085u, 0x00000006u, 0x000001fau, - 0x000001f8u, 0x000001f9u, 0x0004003du, 0x00000006u, 0x000001fbu, 0x0000017bu, 0x00050088u, 0x00000006u, - 0x000001fdu, 0x000001fbu, 0x000001fcu, 0x0008000cu, 0x00000006u, 0x000001feu, 0x00000001u, 0x0000002bu, - 0x000001fdu, 0x0000002cu, 0x00000063u, 0x00050085u, 0x00000006u, 0x000001ffu, 0x000001fau, 0x000001feu, - 0x0003003eu, 0x000001f7u, 0x000001ffu, 0x0004003du, 0x00000006u, 0x00000201u, 0x00000186u, 0x0004003du, - 0x00000006u, 0x00000202u, 0x000001b1u, 0x00050083u, 0x00000006u, 0x00000203u, 0x00000201u, 0x00000202u, - 0x0006000cu, 0x00000006u, 0x00000204u, 0x00000001u, 0x00000004u, 0x00000203u, 0x0004003du, 0x00000006u, - 0x00000205u, 0x00000195u, 0x0004003du, 0x00000006u, 0x00000206u, 0x000001a3u, 0x00050083u, 0x00000006u, - 0x00000207u, 0x00000205u, 0x00000206u, 0x0006000cu, 0x00000006u, 0x00000208u, 0x00000001u, 0x00000004u, - 0x00000207u, 0x0007000cu, 0x00000006u, 0x00000209u, 0x00000001u, 0x00000028u, 0x00000204u, 0x00000208u, - 0x0003003eu, 0x00000200u, 0x00000209u, 0x0004003du, 0x00000006u, 0x0000020cu, 0x000000ddu, 0x0004003du, - 0x00000006u, 0x0000020du, 0x000000ddu, 0x00050085u, 0x00000006u, 0x0000020fu, 0x0000020du, 0x0000020eu, - 0x0004003du, 0x00000006u, 0x00000210u, 0x00000200u, 0x0008000cu, 0x00000006u, 0x00000211u, 0x00000001u, - 0x00000031u, 0x0000020cu, 0x0000020fu, 0x00000210u, 0x00050085u, 0x00000006u, 0x00000212u, 0x0000020bu, - 0x00000211u, 0x00050083u, 0x00000006u, 0x00000213u, 0x00000063u, 0x00000212u, 0x0003003eu, 0x0000020au, - 0x00000213u, 0x0004003du, 0x00000006u, 0x00000215u, 0x000001f7u, 0x0004003du, 0x00000006u, 0x00000216u, - 0x000001c7u, 0x00050085u, 0x00000006u, 0x00000217u, 0x00000215u, 0x00000216u, 0x0004003du, 0x00000006u, - 0x00000218u, 0x0000017fu, 0x00050085u, 0x00000006u, 0x00000219u, 0x00000217u, 0x00000218u, 0x0004003du, - 0x00000006u, 0x0000021au, 0x0000020au, 0x00050085u, 0x00000006u, 0x0000021bu, 0x00000219u, 0x0000021au, - 0x0003003eu, 0x00000214u, 0x0000021bu, 0x0004003du, 0x00000006u, 0x0000021du, 0x000000e3u, 0x0004003du, - 0x00000006u, 0x0000021eu, 0x000000e7u, 0x0007000cu, 0x00000006u, 0x0000021fu, 0x00000001u, 0x00000025u, - 0x0000021du, 0x0000021eu, 0x0003003eu, 0x0000021cu, 0x0000021fu, 0x0004003du, 0x00000006u, 0x00000221u, - 0x000000ddu, 0x0004003du, 0x00000006u, 0x00000222u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000223u, - 0x00000222u, 0x00000182u, 0x0004003du, 0x00000006u, 0x00000224u, 0x0000021cu, 0x0008000cu, 0x00000006u, - 0x00000225u, 0x00000001u, 0x00000031u, 0x00000221u, 0x00000223u, 0x00000224u, 0x0003003eu, 0x00000220u, - 0x00000225u, 0x0004003du, 0x00000006u, 0x00000227u, 0x0000017bu, 0x0008000cu, 0x00000006u, 0x00000228u, - 0x00000001u, 0x00000031u, 0x00000063u, 0x0000020eu, 0x00000227u, 0x0003003eu, 0x00000226u, 0x00000228u, - 0x0004003du, 0x00000006u, 0x0000022bu, 0x00000220u, 0x00050085u, 0x00000006u, 0x0000022cu, 0x0000022au, - 0x0000022bu, 0x0004003du, 0x00000006u, 0x0000022du, 0x0000017fu, 0x00050085u, 0x00000006u, 0x0000022eu, - 0x0000022cu, 0x0000022du, 0x0004003du, 0x00000006u, 0x0000022fu, 0x0000020au, 0x00050085u, 0x00000006u, - 0x00000230u, 0x0000022eu, 0x0000022fu, 0x0004003du, 0x00000006u, 0x00000231u, 0x00000226u, 0x00050085u, - 0x00000006u, 0x00000232u, 0x00000230u, 0x00000231u, 0x0004003du, 0x00000006u, 0x00000233u, 0x000001f1u, - 0x00050085u, 0x00000006u, 0x00000234u, 0x00000232u, 0x00000233u, 0x0003003eu, 0x00000229u, 0x00000234u, - 0x0004003du, 0x00000006u, 0x00000236u, 0x00000214u, 0x0004003du, 0x00000006u, 0x00000237u, 0x00000229u, - 0x0007000cu, 0x00000006u, 0x00000238u, 0x00000001u, 0x00000028u, 0x00000236u, 0x00000237u, 0x0008000cu, - 0x00000006u, 0x0000023au, 0x00000001u, 0x0000002bu, 0x00000238u, 0x0000002cu, 0x00000239u, 0x0003003eu, - 0x00000235u, 0x0000023au, 0x0004003du, 0x00000023u, 0x0000023cu, 0x00000025u, 0x0004003du, 0x0000000du, - 0x0000023du, 0x00000070u, 0x0004003du, 0x0000000du, 0x0000023eu, 0x0000010bu, 0x0004003du, 0x0000000du, - 0x0000023fu, 0x00000062u, 0x00050085u, 0x0000000du, 0x00000240u, 0x0000023eu, 0x0000023fu, 0x00050081u, - 0x0000000du, 0x00000241u, 0x0000023du, 0x00000240u, 0x00050057u, 0x0000002fu, 0x00000242u, 0x0000023cu, - 0x00000241u, 0x0008004fu, 0x00000007u, 0x00000243u, 0x00000242u, 0x00000242u, 0x00000000u, 0x00000001u, - 0x00000002u, 0x0003003eu, 0x0000023bu, 0x00000243u, 0x0004003du, 0x0000002fu, 0x00000244u, 0x0000007cu, - 0x0008004fu, 0x00000007u, 0x00000245u, 0x00000244u, 0x00000244u, 0x00000000u, 0x00000001u, 0x00000002u, - 0x0004003du, 0x00000007u, 0x00000246u, 0x0000023bu, 0x0004003du, 0x00000006u, 0x00000247u, 0x00000235u, - 0x00060050u, 0x00000007u, 0x00000248u, 0x00000247u, 0x00000247u, 0x00000247u, 0x0008000cu, 0x00000007u, - 0x00000249u, 0x00000001u, 0x0000002eu, 0x00000245u, 0x00000246u, 0x00000248u, 0x00050041u, 0x00000020u, - 0x0000024bu, 0x0000007cu, 0x0000024au, 0x0004003du, 0x00000006u, 0x0000024cu, 0x0000024bu, 0x00050051u, - 0x00000006u, 0x0000024du, 0x00000249u, 0x00000000u, 0x00050051u, 0x00000006u, 0x0000024eu, 0x00000249u, - 0x00000001u, 0x00050051u, 0x00000006u, 0x0000024fu, 0x00000249u, 0x00000002u, 0x00070050u, 0x0000002fu, - 0x00000250u, 0x0000024du, 0x0000024eu, 0x0000024fu, 0x0000024cu, 0x0003003eu, 0x000000f6u, 0x00000250u, - 0x000100fdu, 0x00010038u, 0x00050036u, 0x00000006u, 0x0000000bu, 0x00000000u, 0x00000009u, 0x00030037u, - 0x00000008u, 0x0000000au, 0x000200f8u, 0x0000000cu, 0x0004003du, 0x00000007u, 0x00000018u, 0x0000000au, - 0x00050094u, 0x00000006u, 0x0000001du, 0x00000018u, 0x0000001cu, 0x000200feu, 0x0000001du, 0x00010038u, - 0x00050036u, 0x00000006u, 0x00000012u, 0x00000000u, 0x0000000fu, 0x00030037u, 0x0000000eu, 0x00000010u, - 0x00030037u, 0x0000000eu, 0x00000011u, 0x000200f8u, 0x00000013u, 0x0004003bu, 0x00000020u, 0x00000021u, - 0x00000007u, 0x0004003bu, 0x00000008u, 0x00000031u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000034u, - 0x00000007u, 0x0004003bu, 0x00000008u, 0x0000003cu, 0x00000007u, 0x0004003du, 0x00000023u, 0x00000026u, - 0x00000025u, 0x0004003du, 0x0000000du, 0x00000027u, 0x00000010u, 0x00050041u, 0x00000020u, 0x0000002au, - 0x00000011u, 0x00000029u, 0x0004003du, 0x00000006u, 0x0000002bu, 0x0000002au, 0x00050050u, 0x0000000du, - 0x0000002du, 0x0000002bu, 0x0000002cu, 0x00050083u, 0x0000000du, 0x0000002eu, 0x00000027u, 0x0000002du, - 0x00050057u, 0x0000002fu, 0x00000030u, 0x00000026u, 0x0000002eu, 0x0008004fu, 0x00000007u, 0x00000032u, - 0x00000030u, 0x00000030u, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x00000031u, 0x00000032u, - 0x00050039u, 0x00000006u, 0x00000033u, 0x0000000bu, 0x00000031u, 0x0003003eu, 0x00000021u, 0x00000033u, - 0x0004003du, 0x00000023u, 0x00000035u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000036u, 0x00000010u, - 0x00050041u, 0x00000020u, 0x00000037u, 0x00000011u, 0x00000029u, 0x0004003du, 0x00000006u, 0x00000038u, - 0x00000037u, 0x00050050u, 0x0000000du, 0x00000039u, 0x00000038u, 0x0000002cu, 0x00050081u, 0x0000000du, - 0x0000003au, 0x00000036u, 0x00000039u, 0x00050057u, 0x0000002fu, 0x0000003bu, 0x00000035u, 0x0000003au, - 0x0008004fu, 0x00000007u, 0x0000003du, 0x0000003bu, 0x0000003bu, 0x00000000u, 0x00000001u, 0x00000002u, - 0x0003003eu, 0x0000003cu, 0x0000003du, 0x00050039u, 0x00000006u, 0x0000003eu, 0x0000000bu, 0x0000003cu, - 0x0003003eu, 0x00000034u, 0x0000003eu, 0x0004003du, 0x00000006u, 0x0000003fu, 0x00000021u, 0x0004003du, - 0x00000006u, 0x00000040u, 0x00000034u, 0x00050083u, 0x00000006u, 0x00000041u, 0x0000003fu, 0x00000040u, - 0x0006000cu, 0x00000006u, 0x00000042u, 0x00000001u, 0x00000004u, 0x00000041u, 0x000200feu, 0x00000042u, - 0x00010038u, 0x00050036u, 0x00000006u, 0x00000016u, 0x00000000u, 0x0000000fu, 0x00030037u, 0x0000000eu, - 0x00000014u, 0x00030037u, 0x0000000eu, 0x00000015u, 0x000200f8u, 0x00000017u, 0x0004003bu, 0x00000020u, - 0x00000045u, 0x00000007u, 0x0004003bu, 0x00000008u, 0x0000004eu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000051u, 0x00000007u, 0x0004003bu, 0x00000008u, 0x00000059u, 0x00000007u, 0x0004003du, 0x00000023u, - 0x00000046u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000047u, 0x00000014u, 0x00050041u, 0x00000020u, - 0x00000049u, 0x00000015u, 0x00000048u, 0x0004003du, 0x00000006u, 0x0000004au, 0x00000049u, 0x00050050u, - 0x0000000du, 0x0000004bu, 0x0000002cu, 0x0000004au, 0x00050083u, 0x0000000du, 0x0000004cu, 0x00000047u, - 0x0000004bu, 0x00050057u, 0x0000002fu, 0x0000004du, 0x00000046u, 0x0000004cu, 0x0008004fu, 0x00000007u, - 0x0000004fu, 0x0000004du, 0x0000004du, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x0000004eu, - 0x0000004fu, 0x00050039u, 0x00000006u, 0x00000050u, 0x0000000bu, 0x0000004eu, 0x0003003eu, 0x00000045u, - 0x00000050u, 0x0004003du, 0x00000023u, 0x00000052u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000053u, - 0x00000014u, 0x00050041u, 0x00000020u, 0x00000054u, 0x00000015u, 0x00000048u, 0x0004003du, 0x00000006u, - 0x00000055u, 0x00000054u, 0x00050050u, 0x0000000du, 0x00000056u, 0x0000002cu, 0x00000055u, 0x00050081u, - 0x0000000du, 0x00000057u, 0x00000053u, 0x00000056u, 0x00050057u, 0x0000002fu, 0x00000058u, 0x00000052u, - 0x00000057u, 0x0008004fu, 0x00000007u, 0x0000005au, 0x00000058u, 0x00000058u, 0x00000000u, 0x00000001u, - 0x00000002u, 0x0003003eu, 0x00000059u, 0x0000005au, 0x00050039u, 0x00000006u, 0x0000005bu, 0x0000000bu, - 0x00000059u, 0x0003003eu, 0x00000051u, 0x0000005bu, 0x0004003du, 0x00000006u, 0x0000005cu, 0x00000045u, - 0x0004003du, 0x00000006u, 0x0000005du, 0x00000051u, 0x00050083u, 0x00000006u, 0x0000005eu, 0x0000005cu, - 0x0000005du, 0x0006000cu, 0x00000006u, 0x0000005fu, 0x00000001u, 0x00000004u, 0x0000005eu, 0x000200feu, - 0x0000005fu, 0x00010038u, -}; diff --git a/app/src/main/cpp/shaders/smaa_weights.frag b/app/src/main/cpp/shaders/smaa_weights.frag new file mode 100644 index 0000000000..32e8b404cd --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_weights.frag @@ -0,0 +1,153 @@ +#version 450 + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; +layout(set = 0, binding = 0) uniform sampler2D EdgeTexture; +layout(push_constant) uniform Constants { + vec4 ndc; + vec2 resolution; + float extra; + float pad; +} pc; + +vec4 edgeAt(vec2 uv, vec2 px) { + vec2 edgeUV = clamp(uv, px * 0.5, vec2(1.0) - px * 0.5); + vec4 e = textureLod(EdgeTexture, edgeUV, 0.0); + 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() { + vec2 px = 1.0 / max(pc.resolution, vec2(1.0)); + vec2 uv = clamp(fragTexCoord, px * 0.5, vec2(1.0) - px * 0.5); + vec4 e = edgeAt(uv, px); + + 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); +} diff --git a/app/src/main/cpp/shaders/smaa_weights_frag.h b/app/src/main/cpp/shaders/smaa_weights_frag.h new file mode 100644 index 0000000000..be2681e8a2 --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_weights_frag.h @@ -0,0 +1,567 @@ +// SPIR-V gerado +#pragma once +const uint32_t smaa_weights_code[] = { + 0x07230203,0x00010000,0x0008000b,0x000002e6,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x000000cb,0x000000fd,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00060005,0x0000000d,0x65676465,0x76287441,0x763b3266,0x003b3266,0x00030005, + 0x0000000b,0x00007675,0x00030005,0x0000000c,0x00007870,0x00080005,0x00000012,0x74726576, + 0x6c616369,0x65676445,0x32667628,0x3266763b,0x0000003b,0x00030005,0x00000010,0x00007675, + 0x00030005,0x00000011,0x00007870,0x00080005,0x00000016,0x69726f68,0x746e6f7a,0x64456c61, + 0x76286567,0x763b3266,0x003b3266,0x00030005,0x00000014,0x00007675,0x00030005,0x00000015, + 0x00007870,0x000b0005,0x00000022,0x7361656d,0x52657275,0x76286e75,0x763b3266,0x763b3266, + 0x623b3266,0x31663b31,0x3b31623b,0x00000000,0x00040005,0x0000001c,0x6769726f,0x00006e69, + 0x00040005,0x0000001d,0x65786574,0x0000006c,0x00040005,0x0000001e,0x676e6174,0x00746e65, + 0x00060005,0x0000001f,0x74726576,0x6c616369,0x656e694c,0x00000000,0x00040005,0x00000020, + 0x696d696c,0x00000074,0x00050005,0x00000021,0x69736f70,0x65766974,0x00000000,0x00040005, + 0x00000024,0x65676465,0x00005655,0x00030005,0x00000030,0x00000065,0x00050005,0x00000034, + 0x65676445,0x74786554,0x00657275,0x00030005,0x0000004d,0x00000065,0x00040005,0x0000004e, + 0x61726170,0x0000006d,0x00040005,0x00000050,0x61726170,0x0000006d,0x00030005,0x0000005b, + 0x00000065,0x00040005,0x0000005c,0x61726170,0x0000006d,0x00040005,0x0000005e,0x61726170, + 0x0000006d,0x00030005,0x00000069,0x006e7572,0x00030005,0x0000006c,0x00000069,0x00040005, + 0x00000076,0x626f7270,0x00000065,0x00040005,0x00000083,0x65646e69,0x00000078,0x00050005, + 0x00000085,0x736e6f43,0x746e6174,0x00000073,0x00040006,0x00000085,0x00000000,0x0063646e, + 0x00060006,0x00000085,0x00000001,0x6f736572,0x6974756c,0x00006e6f,0x00050006,0x00000085, + 0x00000002,0x72747865,0x00000061,0x00040006,0x00000085,0x00000003,0x00646170,0x00030005, + 0x00000087,0x00006370,0x00040005,0x0000008e,0x657a6973,0x00000000,0x00040005,0x000000a3, + 0x65676465,0x00000000,0x00040005,0x000000a8,0x61726170,0x0000006d,0x00040005,0x000000aa, + 0x61726170,0x0000006d,0x00040005,0x000000ae,0x61726170,0x0000006d,0x00040005,0x000000b0, + 0x61726170,0x0000006d,0x00030005,0x000000c3,0x00007870,0x00030005,0x000000c9,0x00007675, + 0x00060005,0x000000cb,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00030005,0x000000d3, + 0x00000065,0x00040005,0x000000d4,0x61726170,0x0000006d,0x00040005,0x000000d6,0x61726170, + 0x0000006d,0x00030005,0x000000d9,0x00004c64,0x00030005,0x000000dc,0x00005264,0x00030005, + 0x000000df,0x00005564,0x00030005,0x000000e2,0x00004464,0x00050005,0x000000e5,0x74726576, + 0x6c616369,0x00000000,0x00050005,0x000000e9,0x69726f68,0x746e6f7a,0x00006c61,0x00050005, + 0x000000ed,0x6f727473,0x7365676e,0x00000074,0x00050005,0x000000f1,0x65726874,0x6c6f6873, + 0x00000064,0x00050005,0x000000fd,0x4374756f,0x726f6c6f,0x00000000,0x00050005,0x00000100, + 0x6167656e,0x65766974,0x006e7552,0x00050005,0x00000101,0x69736f70,0x65766974,0x006e7552, + 0x00060005,0x00000102,0x736e7572,0x7361654d,0x64657275,0x00000000,0x00060005,0x00000109, + 0x74726576,0x6c616369,0x656e694c,0x00000000,0x00040005,0x00000112,0x67654e76,0x00000000, + 0x00040005,0x00000116,0x61726170,0x0000006d,0x00040005,0x00000118,0x61726170,0x0000006d, + 0x00040005,0x0000011a,0x61726170,0x0000006d,0x00040005,0x0000011b,0x61726170,0x0000006d, + 0x00040005,0x0000011c,0x61726170,0x0000006d,0x00040005,0x0000011e,0x61726170,0x0000006d, + 0x00040005,0x00000120,0x736f5076,0x00000000,0x00040005,0x00000124,0x61726170,0x0000006d, + 0x00040005,0x00000126,0x61726170,0x0000006d,0x00040005,0x00000128,0x61726170,0x0000006d, + 0x00040005,0x00000129,0x61726170,0x0000006d,0x00040005,0x0000012a,0x61726170,0x0000006d, + 0x00040005,0x0000012c,0x61726170,0x0000006d,0x00040005,0x0000012e,0x67654e68,0x00000000, + 0x00040005,0x00000132,0x61726170,0x0000006d,0x00040005,0x00000134,0x61726170,0x0000006d, + 0x00040005,0x00000136,0x61726170,0x0000006d,0x00040005,0x00000137,0x61726170,0x0000006d, + 0x00040005,0x00000138,0x61726170,0x0000006d,0x00040005,0x0000013a,0x61726170,0x0000006d, + 0x00040005,0x0000013c,0x736f5068,0x00000000,0x00040005,0x00000140,0x61726170,0x0000006d, + 0x00040005,0x00000142,0x61726170,0x0000006d,0x00040005,0x00000144,0x61726170,0x0000006d, + 0x00040005,0x00000145,0x61726170,0x0000006d,0x00040005,0x00000146,0x61726170,0x0000006d, + 0x00040005,0x00000148,0x61726170,0x0000006d,0x00040005,0x00000159,0x676e6174,0x00746e65, + 0x00040005,0x00000166,0x6d726f6e,0x00006c61,0x00040005,0x0000017b,0x61726170,0x0000006d, + 0x00040005,0x0000017d,0x61726170,0x0000006d,0x00040005,0x0000017f,0x61726170,0x0000006d, + 0x00040005,0x00000181,0x61726170,0x0000006d,0x00040005,0x00000183,0x61726170,0x0000006d, + 0x00040005,0x00000185,0x61726170,0x0000006d,0x00040005,0x00000187,0x61726170,0x0000006d, + 0x00040005,0x00000189,0x61726170,0x0000006d,0x00040005,0x0000018b,0x61726170,0x0000006d, + 0x00040005,0x0000018d,0x61726170,0x0000006d,0x00040005,0x0000018f,0x61726170,0x0000006d, + 0x00040005,0x00000191,0x61726170,0x0000006d,0x00040005,0x00000193,0x6e617073,0x00000000, + 0x00060005,0x00000197,0x65676465,0x666e6f43,0x6e656469,0x00006563,0x00030005,0x0000019e, + 0x0000776e,0x00040005,0x000001a8,0x61726170,0x0000006d,0x00040005,0x000001a9,0x61726170, + 0x0000006d,0x00030005,0x000001ac,0x0000656e,0x00040005,0x000001b5,0x61726170,0x0000006d, + 0x00040005,0x000001b6,0x61726170,0x0000006d,0x00030005,0x000001b9,0x00007773,0x00040005, + 0x000001c2,0x61726170,0x0000006d,0x00040005,0x000001c3,0x61726170,0x0000006d,0x00030005, + 0x000001c6,0x00006573,0x00040005,0x000001ce,0x61726170,0x0000006d,0x00040005,0x000001cf, + 0x61726170,0x0000006d,0x00070005,0x000001d2,0x456e7572,0x6f70646e,0x50746e69,0x65747461, + 0x00006e72,0x00050005,0x000001db,0x736f7263,0x676e6973,0x00000041,0x00050005,0x000001ee, + 0x736f7263,0x676e6973,0x00000042,0x00070005,0x00000201,0x736f7263,0x676e6973,0x746e6f43, + 0x74736172,0x00000000,0x00060005,0x00000206,0x736f7263,0x676e6973,0x74746150,0x006e7265, + 0x00040005,0x0000020c,0x65676465,0x006e694d,0x00040005,0x00000214,0x65676465,0x0078614d, + 0x00060005,0x0000021c,0x65676465,0x69726156,0x6f697461,0x0000006e,0x00070005,0x00000234, + 0x616c6162,0x6465636e,0x736f7243,0x676e6973,0x00000000,0x00060005,0x00000244,0x70646e65, + 0x746e696f,0x74746150,0x006e7265,0x00060005,0x00000250,0x70646e65,0x746e696f,0x61657241, + 0x00000000,0x00050005,0x00000257,0x61657261,0x67696557,0x00007468,0x00070005,0x00000260, + 0x67616964,0x6c616e6f,0x746e6f43,0x74736172,0x00000000,0x00060005,0x00000298,0x6e726f63, + 0x61467265,0x726f7463,0x00000000,0x00050005,0x000002a2,0x65736162,0x67696557,0x00007468, + 0x00070005,0x000002aa,0x67616964,0x6c616e6f,0x65727453,0x6874676e,0x00000000,0x00060005, + 0x000002ae,0x67616964,0x6c616e6f,0x74746150,0x006e7265,0x00070005,0x000002b4,0x67616964, + 0x6c616e6f,0x746e6f43,0x69756e69,0x00007974,0x00080005,0x000002b7,0x726f6873,0x61694474, + 0x616e6f67,0x6c61466c,0x6361626c,0x0000006b,0x00070005,0x000002c6,0x67616964,0x6c616e6f, + 0x6c6c6146,0x6b636162,0x00000000,0x00040005,0x000002d6,0x67696577,0x00007468,0x00040047, + 0x00000034,0x00000021,0x00000000,0x00040047,0x00000034,0x00000022,0x00000000,0x00030047, + 0x00000085,0x00000002,0x00050048,0x00000085,0x00000000,0x00000023,0x00000000,0x00050048, + 0x00000085,0x00000001,0x00000023,0x00000010,0x00050048,0x00000085,0x00000002,0x00000023, + 0x00000018,0x00050048,0x00000085,0x00000003,0x00000023,0x0000001c,0x00040047,0x000000cb, + 0x0000001e,0x00000000,0x00040047,0x000000fd,0x0000001e,0x00000000,0x00020013,0x00000002, + 0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007, + 0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00040017,0x00000009, + 0x00000006,0x00000004,0x00050021,0x0000000a,0x00000009,0x00000008,0x00000008,0x00050021, + 0x0000000f,0x00000006,0x00000008,0x00000008,0x00020014,0x00000018,0x00040020,0x00000019, + 0x00000007,0x00000018,0x00040020,0x0000001a,0x00000007,0x00000006,0x00090021,0x0000001b, + 0x00000006,0x00000008,0x00000008,0x00000008,0x00000019,0x0000001a,0x00000019,0x0004002b, + 0x00000006,0x00000027,0x3f000000,0x0004002b,0x00000006,0x00000029,0x3f800000,0x0005002c, + 0x00000007,0x0000002a,0x00000029,0x00000029,0x00040020,0x0000002f,0x00000007,0x00000009, + 0x00090019,0x00000031,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001, + 0x00000000,0x0003001b,0x00000032,0x00000031,0x00040020,0x00000033,0x00000000,0x00000032, + 0x0004003b,0x00000033,0x00000034,0x00000000,0x0004002b,0x00000006,0x00000037,0x00000000, + 0x00040015,0x00000039,0x00000020,0x00000000,0x0004002b,0x00000039,0x0000003a,0x00000001, + 0x0004002b,0x00000039,0x00000045,0x00000003,0x0004002b,0x00000039,0x00000053,0x00000000, + 0x0004002b,0x00000039,0x00000061,0x00000002,0x00040015,0x0000006a,0x00000020,0x00000001, + 0x00040020,0x0000006b,0x00000007,0x0000006a,0x0004002b,0x0000006a,0x0000006d,0x00000001, + 0x0004002b,0x0000006a,0x00000074,0x00000006,0x0004002b,0x00000006,0x0000007d,0xbf800000, + 0x00040017,0x00000081,0x0000006a,0x00000002,0x00040020,0x00000082,0x00000007,0x00000081, + 0x0006001e,0x00000085,0x00000009,0x00000007,0x00000006,0x00000006,0x00040020,0x00000086, + 0x00000009,0x00000085,0x0004003b,0x00000086,0x00000087,0x00000009,0x00040020,0x00000088, + 0x00000009,0x00000007,0x0004002b,0x0000006a,0x00000093,0x00000000,0x0005002c,0x00000081, + 0x00000094,0x00000093,0x00000093,0x00040017,0x00000095,0x00000018,0x00000002,0x0004002b, + 0x00000006,0x000000b6,0x3f266666,0x00040020,0x000000ca,0x00000001,0x00000007,0x0004003b, + 0x000000ca,0x000000cb,0x00000001,0x0004002b,0x00000006,0x000000f2,0x3d3851ec,0x0004002b, + 0x00000006,0x000000f4,0x3df5c28f,0x00040020,0x000000fc,0x00000003,0x00000009,0x0004003b, + 0x000000fc,0x000000fd,0x00000003,0x0007002c,0x00000009,0x000000fe,0x00000037,0x00000027, + 0x00000027,0x00000037,0x0003002a,0x00000018,0x00000103,0x00030029,0x00000018,0x0000010a, + 0x0004002b,0x00000006,0x0000019a,0x40200000,0x0004002b,0x00000006,0x00000236,0x3c23d70a, + 0x0004002b,0x00000006,0x00000253,0x3d6147ae,0x0004002b,0x00000006,0x00000258,0x3ec28f5c, + 0x0004002b,0x00000006,0x0000025c,0x40800000,0x0004002b,0x00000006,0x00000299,0x3eb33333, + 0x0004002b,0x00000006,0x0000029c,0x40400000,0x0004002b,0x00000006,0x000002c7,0x3e23d70a, + 0x0004002b,0x00000006,0x000002da,0x3ed70a3d,0x00050036,0x00000002,0x00000004,0x00000000, + 0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x000000c3,0x00000007,0x0004003b, + 0x00000008,0x000000c9,0x00000007,0x0004003b,0x0000002f,0x000000d3,0x00000007,0x0004003b, + 0x00000008,0x000000d4,0x00000007,0x0004003b,0x00000008,0x000000d6,0x00000007,0x0004003b, + 0x0000001a,0x000000d9,0x00000007,0x0004003b,0x0000001a,0x000000dc,0x00000007,0x0004003b, + 0x0000001a,0x000000df,0x00000007,0x0004003b,0x0000001a,0x000000e2,0x00000007,0x0004003b, + 0x0000001a,0x000000e5,0x00000007,0x0004003b,0x0000001a,0x000000e9,0x00000007,0x0004003b, + 0x0000001a,0x000000ed,0x00000007,0x0004003b,0x0000001a,0x000000f1,0x00000007,0x0004003b, + 0x0000001a,0x00000100,0x00000007,0x0004003b,0x0000001a,0x00000101,0x00000007,0x0004003b, + 0x00000019,0x00000102,0x00000007,0x0004003b,0x00000019,0x00000109,0x00000007,0x0004003b, + 0x0000001a,0x00000112,0x00000007,0x0004003b,0x00000008,0x00000116,0x00000007,0x0004003b, + 0x00000008,0x00000118,0x00000007,0x0004003b,0x00000008,0x0000011a,0x00000007,0x0004003b, + 0x00000019,0x0000011b,0x00000007,0x0004003b,0x0000001a,0x0000011c,0x00000007,0x0004003b, + 0x00000019,0x0000011e,0x00000007,0x0004003b,0x0000001a,0x00000120,0x00000007,0x0004003b, + 0x00000008,0x00000124,0x00000007,0x0004003b,0x00000008,0x00000126,0x00000007,0x0004003b, + 0x00000008,0x00000128,0x00000007,0x0004003b,0x00000019,0x00000129,0x00000007,0x0004003b, + 0x0000001a,0x0000012a,0x00000007,0x0004003b,0x00000019,0x0000012c,0x00000007,0x0004003b, + 0x0000001a,0x0000012e,0x00000007,0x0004003b,0x00000008,0x00000132,0x00000007,0x0004003b, + 0x00000008,0x00000134,0x00000007,0x0004003b,0x00000008,0x00000136,0x00000007,0x0004003b, + 0x00000019,0x00000137,0x00000007,0x0004003b,0x0000001a,0x00000138,0x00000007,0x0004003b, + 0x00000019,0x0000013a,0x00000007,0x0004003b,0x0000001a,0x0000013c,0x00000007,0x0004003b, + 0x00000008,0x00000140,0x00000007,0x0004003b,0x00000008,0x00000142,0x00000007,0x0004003b, + 0x00000008,0x00000144,0x00000007,0x0004003b,0x00000019,0x00000145,0x00000007,0x0004003b, + 0x0000001a,0x00000146,0x00000007,0x0004003b,0x00000019,0x00000148,0x00000007,0x0004003b, + 0x00000008,0x00000159,0x00000007,0x0004003b,0x00000008,0x0000015b,0x00000007,0x0004003b, + 0x00000008,0x00000166,0x00000007,0x0004003b,0x00000008,0x00000168,0x00000007,0x0004003b, + 0x00000008,0x0000017b,0x00000007,0x0004003b,0x00000008,0x0000017d,0x00000007,0x0004003b, + 0x00000008,0x0000017f,0x00000007,0x0004003b,0x00000019,0x00000181,0x00000007,0x0004003b, + 0x0000001a,0x00000183,0x00000007,0x0004003b,0x00000019,0x00000185,0x00000007,0x0004003b, + 0x00000008,0x00000187,0x00000007,0x0004003b,0x00000008,0x00000189,0x00000007,0x0004003b, + 0x00000008,0x0000018b,0x00000007,0x0004003b,0x00000019,0x0000018d,0x00000007,0x0004003b, + 0x0000001a,0x0000018f,0x00000007,0x0004003b,0x00000019,0x00000191,0x00000007,0x0004003b, + 0x0000001a,0x00000193,0x00000007,0x0004003b,0x0000001a,0x00000197,0x00000007,0x0004003b, + 0x0000002f,0x0000019e,0x00000007,0x0004003b,0x00000008,0x000001a8,0x00000007,0x0004003b, + 0x00000008,0x000001a9,0x00000007,0x0004003b,0x0000002f,0x000001ac,0x00000007,0x0004003b, + 0x00000008,0x000001b5,0x00000007,0x0004003b,0x00000008,0x000001b6,0x00000007,0x0004003b, + 0x0000002f,0x000001b9,0x00000007,0x0004003b,0x00000008,0x000001c2,0x00000007,0x0004003b, + 0x00000008,0x000001c3,0x00000007,0x0004003b,0x0000002f,0x000001c6,0x00000007,0x0004003b, + 0x00000008,0x000001ce,0x00000007,0x0004003b,0x00000008,0x000001cf,0x00000007,0x0004003b, + 0x0000001a,0x000001d2,0x00000007,0x0004003b,0x0000001a,0x000001db,0x00000007,0x0004003b, + 0x0000001a,0x000001dd,0x00000007,0x0004003b,0x0000001a,0x000001ee,0x00000007,0x0004003b, + 0x0000001a,0x000001f0,0x00000007,0x0004003b,0x0000001a,0x00000201,0x00000007,0x0004003b, + 0x0000001a,0x00000206,0x00000007,0x0004003b,0x0000002f,0x0000020c,0x00000007,0x0004003b, + 0x0000002f,0x00000214,0x00000007,0x0004003b,0x0000001a,0x0000021c,0x00000007,0x0004003b, + 0x0000001a,0x00000234,0x00000007,0x0004003b,0x0000001a,0x00000238,0x00000007,0x0004003b, + 0x0000001a,0x00000244,0x00000007,0x0004003b,0x0000001a,0x00000247,0x00000007,0x0004003b, + 0x0000001a,0x00000250,0x00000007,0x0004003b,0x0000001a,0x00000257,0x00000007,0x0004003b, + 0x0000001a,0x00000260,0x00000007,0x0004003b,0x0000001a,0x00000298,0x00000007,0x0004003b, + 0x0000001a,0x000002a2,0x00000007,0x0004003b,0x0000001a,0x000002aa,0x00000007,0x0004003b, + 0x0000001a,0x000002ae,0x00000007,0x0004003b,0x0000001a,0x000002b4,0x00000007,0x0004003b, + 0x0000001a,0x000002b7,0x00000007,0x0004003b,0x0000001a,0x000002c6,0x00000007,0x0004003b, + 0x0000001a,0x000002d6,0x00000007,0x00050041,0x00000088,0x000000c4,0x00000087,0x0000006d, + 0x0004003d,0x00000007,0x000000c5,0x000000c4,0x0007000c,0x00000007,0x000000c6,0x00000001, + 0x00000028,0x000000c5,0x0000002a,0x00050050,0x00000007,0x000000c7,0x00000029,0x00000029, + 0x00050088,0x00000007,0x000000c8,0x000000c7,0x000000c6,0x0003003e,0x000000c3,0x000000c8, + 0x0004003d,0x00000007,0x000000cc,0x000000cb,0x0004003d,0x00000007,0x000000cd,0x000000c3, + 0x0005008e,0x00000007,0x000000ce,0x000000cd,0x00000027,0x0004003d,0x00000007,0x000000cf, + 0x000000c3,0x0005008e,0x00000007,0x000000d0,0x000000cf,0x00000027,0x00050083,0x00000007, + 0x000000d1,0x0000002a,0x000000d0,0x0008000c,0x00000007,0x000000d2,0x00000001,0x0000002b, + 0x000000cc,0x000000ce,0x000000d1,0x0003003e,0x000000c9,0x000000d2,0x0004003d,0x00000007, + 0x000000d5,0x000000c9,0x0003003e,0x000000d4,0x000000d5,0x0004003d,0x00000007,0x000000d7, + 0x000000c3,0x0003003e,0x000000d6,0x000000d7,0x00060039,0x00000009,0x000000d8,0x0000000d, + 0x000000d4,0x000000d6,0x0003003e,0x000000d3,0x000000d8,0x00050041,0x0000001a,0x000000da, + 0x000000d3,0x00000053,0x0004003d,0x00000006,0x000000db,0x000000da,0x0003003e,0x000000d9, + 0x000000db,0x00050041,0x0000001a,0x000000dd,0x000000d3,0x0000003a,0x0004003d,0x00000006, + 0x000000de,0x000000dd,0x0003003e,0x000000dc,0x000000de,0x00050041,0x0000001a,0x000000e0, + 0x000000d3,0x00000061,0x0004003d,0x00000006,0x000000e1,0x000000e0,0x0003003e,0x000000df, + 0x000000e1,0x00050041,0x0000001a,0x000000e3,0x000000d3,0x00000045,0x0004003d,0x00000006, + 0x000000e4,0x000000e3,0x0003003e,0x000000e2,0x000000e4,0x0004003d,0x00000006,0x000000e6, + 0x000000d9,0x0004003d,0x00000006,0x000000e7,0x000000dc,0x0007000c,0x00000006,0x000000e8, + 0x00000001,0x00000028,0x000000e6,0x000000e7,0x0003003e,0x000000e5,0x000000e8,0x0004003d, + 0x00000006,0x000000ea,0x000000df,0x0004003d,0x00000006,0x000000eb,0x000000e2,0x0007000c, + 0x00000006,0x000000ec,0x00000001,0x00000028,0x000000ea,0x000000eb,0x0003003e,0x000000e9, + 0x000000ec,0x0004003d,0x00000006,0x000000ee,0x000000e5,0x0004003d,0x00000006,0x000000ef, + 0x000000e9,0x0007000c,0x00000006,0x000000f0,0x00000001,0x00000028,0x000000ee,0x000000ef, + 0x0003003e,0x000000ed,0x000000f0,0x0004003d,0x00000006,0x000000f3,0x000000ed,0x00050085, + 0x00000006,0x000000f5,0x000000f3,0x000000f4,0x0007000c,0x00000006,0x000000f6,0x00000001, + 0x00000028,0x000000f2,0x000000f5,0x0003003e,0x000000f1,0x000000f6,0x0004003d,0x00000006, + 0x000000f7,0x000000ed,0x0004003d,0x00000006,0x000000f8,0x000000f1,0x000500bc,0x00000018, + 0x000000f9,0x000000f7,0x000000f8,0x000300f7,0x000000fb,0x00000000,0x000400fa,0x000000f9, + 0x000000fa,0x000000fb,0x000200f8,0x000000fa,0x0003003e,0x000000fd,0x000000fe,0x000100fd, + 0x000200f8,0x000000fb,0x0003003e,0x00000100,0x00000037,0x0003003e,0x00000101,0x00000037, + 0x0003003e,0x00000102,0x00000103,0x0004003d,0x00000006,0x00000104,0x000000e5,0x0004003d, + 0x00000006,0x00000105,0x000000e9,0x000500ba,0x00000018,0x00000106,0x00000104,0x00000105, + 0x000300f7,0x00000108,0x00000000,0x000400fa,0x00000106,0x00000107,0x0000010b,0x000200f8, + 0x00000107,0x0003003e,0x00000109,0x0000010a,0x000200f9,0x00000108,0x000200f8,0x0000010b, + 0x0004003d,0x00000006,0x0000010c,0x000000e9,0x0004003d,0x00000006,0x0000010d,0x000000e5, + 0x000500ba,0x00000018,0x0000010e,0x0000010c,0x0000010d,0x000300f7,0x00000110,0x00000000, + 0x000400fa,0x0000010e,0x0000010f,0x00000111,0x000200f8,0x0000010f,0x0003003e,0x00000109, + 0x00000103,0x000200f9,0x00000110,0x000200f8,0x00000111,0x00050041,0x0000001a,0x00000113, + 0x000000c3,0x0000003a,0x0004003d,0x00000006,0x00000114,0x00000113,0x00050050,0x00000007, + 0x00000115,0x00000037,0x00000114,0x0004003d,0x00000007,0x00000117,0x000000c9,0x0003003e, + 0x00000116,0x00000117,0x0004003d,0x00000007,0x00000119,0x000000c3,0x0003003e,0x00000118, + 0x00000119,0x0003003e,0x0000011a,0x00000115,0x0003003e,0x0000011b,0x0000010a,0x0004003d, + 0x00000006,0x0000011d,0x000000f1,0x0003003e,0x0000011c,0x0000011d,0x0003003e,0x0000011e, + 0x00000103,0x000a0039,0x00000006,0x0000011f,0x00000022,0x00000116,0x00000118,0x0000011a, + 0x0000011b,0x0000011c,0x0000011e,0x0003003e,0x00000112,0x0000011f,0x00050041,0x0000001a, + 0x00000121,0x000000c3,0x0000003a,0x0004003d,0x00000006,0x00000122,0x00000121,0x00050050, + 0x00000007,0x00000123,0x00000037,0x00000122,0x0004003d,0x00000007,0x00000125,0x000000c9, + 0x0003003e,0x00000124,0x00000125,0x0004003d,0x00000007,0x00000127,0x000000c3,0x0003003e, + 0x00000126,0x00000127,0x0003003e,0x00000128,0x00000123,0x0003003e,0x00000129,0x0000010a, + 0x0004003d,0x00000006,0x0000012b,0x000000f1,0x0003003e,0x0000012a,0x0000012b,0x0003003e, + 0x0000012c,0x0000010a,0x000a0039,0x00000006,0x0000012d,0x00000022,0x00000124,0x00000126, + 0x00000128,0x00000129,0x0000012a,0x0000012c,0x0003003e,0x00000120,0x0000012d,0x00050041, + 0x0000001a,0x0000012f,0x000000c3,0x00000053,0x0004003d,0x00000006,0x00000130,0x0000012f, + 0x00050050,0x00000007,0x00000131,0x00000130,0x00000037,0x0004003d,0x00000007,0x00000133, + 0x000000c9,0x0003003e,0x00000132,0x00000133,0x0004003d,0x00000007,0x00000135,0x000000c3, + 0x0003003e,0x00000134,0x00000135,0x0003003e,0x00000136,0x00000131,0x0003003e,0x00000137, + 0x00000103,0x0004003d,0x00000006,0x00000139,0x000000f1,0x0003003e,0x00000138,0x00000139, + 0x0003003e,0x0000013a,0x00000103,0x000a0039,0x00000006,0x0000013b,0x00000022,0x00000132, + 0x00000134,0x00000136,0x00000137,0x00000138,0x0000013a,0x0003003e,0x0000012e,0x0000013b, + 0x00050041,0x0000001a,0x0000013d,0x000000c3,0x00000053,0x0004003d,0x00000006,0x0000013e, + 0x0000013d,0x00050050,0x00000007,0x0000013f,0x0000013e,0x00000037,0x0004003d,0x00000007, + 0x00000141,0x000000c9,0x0003003e,0x00000140,0x00000141,0x0004003d,0x00000007,0x00000143, + 0x000000c3,0x0003003e,0x00000142,0x00000143,0x0003003e,0x00000144,0x0000013f,0x0003003e, + 0x00000145,0x00000103,0x0004003d,0x00000006,0x00000147,0x000000f1,0x0003003e,0x00000146, + 0x00000147,0x0003003e,0x00000148,0x0000010a,0x000a0039,0x00000006,0x00000149,0x00000022, + 0x00000140,0x00000142,0x00000144,0x00000145,0x00000146,0x00000148,0x0003003e,0x0000013c, + 0x00000149,0x0004003d,0x00000006,0x0000014a,0x00000112,0x0004003d,0x00000006,0x0000014b, + 0x00000120,0x00050081,0x00000006,0x0000014c,0x0000014a,0x0000014b,0x0004003d,0x00000006, + 0x0000014d,0x0000012e,0x0004003d,0x00000006,0x0000014e,0x0000013c,0x00050081,0x00000006, + 0x0000014f,0x0000014d,0x0000014e,0x000500be,0x00000018,0x00000150,0x0000014c,0x0000014f, + 0x0003003e,0x00000109,0x00000150,0x0004003d,0x00000018,0x00000151,0x00000109,0x0004003d, + 0x00000006,0x00000152,0x00000112,0x0004003d,0x00000006,0x00000153,0x0000012e,0x000600a9, + 0x00000006,0x00000154,0x00000151,0x00000152,0x00000153,0x0003003e,0x00000100,0x00000154, + 0x0004003d,0x00000018,0x00000155,0x00000109,0x0004003d,0x00000006,0x00000156,0x00000120, + 0x0004003d,0x00000006,0x00000157,0x0000013c,0x000600a9,0x00000006,0x00000158,0x00000155, + 0x00000156,0x00000157,0x0003003e,0x00000101,0x00000158,0x0003003e,0x00000102,0x0000010a, + 0x000200f9,0x00000110,0x000200f8,0x00000110,0x000200f9,0x00000108,0x000200f8,0x00000108, + 0x0004003d,0x00000018,0x0000015a,0x00000109,0x000300f7,0x0000015d,0x00000000,0x000400fa, + 0x0000015a,0x0000015c,0x00000161,0x000200f8,0x0000015c,0x00050041,0x0000001a,0x0000015e, + 0x000000c3,0x0000003a,0x0004003d,0x00000006,0x0000015f,0x0000015e,0x00050050,0x00000007, + 0x00000160,0x00000037,0x0000015f,0x0003003e,0x0000015b,0x00000160,0x000200f9,0x0000015d, + 0x000200f8,0x00000161,0x00050041,0x0000001a,0x00000162,0x000000c3,0x00000053,0x0004003d, + 0x00000006,0x00000163,0x00000162,0x00050050,0x00000007,0x00000164,0x00000163,0x00000037, + 0x0003003e,0x0000015b,0x00000164,0x000200f9,0x0000015d,0x000200f8,0x0000015d,0x0004003d, + 0x00000007,0x00000165,0x0000015b,0x0003003e,0x00000159,0x00000165,0x0004003d,0x00000018, + 0x00000167,0x00000109,0x000300f7,0x0000016a,0x00000000,0x000400fa,0x00000167,0x00000169, + 0x00000170,0x000200f8,0x00000169,0x0004003d,0x00000006,0x0000016b,0x000000d9,0x0004003d, + 0x00000006,0x0000016c,0x000000dc,0x000500be,0x00000018,0x0000016d,0x0000016b,0x0000016c, + 0x000600a9,0x00000006,0x0000016e,0x0000016d,0x0000007d,0x00000029,0x00050050,0x00000007, + 0x0000016f,0x0000016e,0x00000037,0x0003003e,0x00000168,0x0000016f,0x000200f9,0x0000016a, + 0x000200f8,0x00000170,0x0004003d,0x00000006,0x00000171,0x000000df,0x0004003d,0x00000006, + 0x00000172,0x000000e2,0x000500be,0x00000018,0x00000173,0x00000171,0x00000172,0x000600a9, + 0x00000006,0x00000174,0x00000173,0x0000007d,0x00000029,0x00050050,0x00000007,0x00000175, + 0x00000037,0x00000174,0x0003003e,0x00000168,0x00000175,0x000200f9,0x0000016a,0x000200f8, + 0x0000016a,0x0004003d,0x00000007,0x00000176,0x00000168,0x0003003e,0x00000166,0x00000176, + 0x0004003d,0x00000018,0x00000177,0x00000102,0x000400a8,0x00000018,0x00000178,0x00000177, + 0x000300f7,0x0000017a,0x00000000,0x000400fa,0x00000178,0x00000179,0x0000017a,0x000200f8, + 0x00000179,0x0004003d,0x00000007,0x0000017c,0x000000c9,0x0003003e,0x0000017b,0x0000017c, + 0x0004003d,0x00000007,0x0000017e,0x000000c3,0x0003003e,0x0000017d,0x0000017e,0x0004003d, + 0x00000007,0x00000180,0x00000159,0x0003003e,0x0000017f,0x00000180,0x0004003d,0x00000018, + 0x00000182,0x00000109,0x0003003e,0x00000181,0x00000182,0x0004003d,0x00000006,0x00000184, + 0x000000f1,0x0003003e,0x00000183,0x00000184,0x0003003e,0x00000185,0x00000103,0x000a0039, + 0x00000006,0x00000186,0x00000022,0x0000017b,0x0000017d,0x0000017f,0x00000181,0x00000183, + 0x00000185,0x0003003e,0x00000100,0x00000186,0x0004003d,0x00000007,0x00000188,0x000000c9, + 0x0003003e,0x00000187,0x00000188,0x0004003d,0x00000007,0x0000018a,0x000000c3,0x0003003e, + 0x00000189,0x0000018a,0x0004003d,0x00000007,0x0000018c,0x00000159,0x0003003e,0x0000018b, + 0x0000018c,0x0004003d,0x00000018,0x0000018e,0x00000109,0x0003003e,0x0000018d,0x0000018e, + 0x0004003d,0x00000006,0x00000190,0x000000f1,0x0003003e,0x0000018f,0x00000190,0x0003003e, + 0x00000191,0x0000010a,0x000a0039,0x00000006,0x00000192,0x00000022,0x00000187,0x00000189, + 0x0000018b,0x0000018d,0x0000018f,0x00000191,0x0003003e,0x00000101,0x00000192,0x000200f9, + 0x0000017a,0x000200f8,0x0000017a,0x0004003d,0x00000006,0x00000194,0x00000100,0x0004003d, + 0x00000006,0x00000195,0x00000101,0x00050081,0x00000006,0x00000196,0x00000194,0x00000195, + 0x0003003e,0x00000193,0x00000196,0x0004003d,0x00000006,0x00000198,0x000000f1,0x0004003d, + 0x00000006,0x00000199,0x000000f1,0x00050085,0x00000006,0x0000019b,0x00000199,0x0000019a, + 0x0004003d,0x00000006,0x0000019c,0x000000ed,0x0008000c,0x00000006,0x0000019d,0x00000001, + 0x00000031,0x00000198,0x0000019b,0x0000019c,0x0003003e,0x00000197,0x0000019d,0x0004003d, + 0x00000007,0x0000019f,0x000000c9,0x00050041,0x0000001a,0x000001a0,0x000000c3,0x00000053, + 0x0004003d,0x00000006,0x000001a1,0x000001a0,0x0004007f,0x00000006,0x000001a2,0x000001a1, + 0x00050041,0x0000001a,0x000001a3,0x000000c3,0x0000003a,0x0004003d,0x00000006,0x000001a4, + 0x000001a3,0x0004007f,0x00000006,0x000001a5,0x000001a4,0x00050050,0x00000007,0x000001a6, + 0x000001a2,0x000001a5,0x00050081,0x00000007,0x000001a7,0x0000019f,0x000001a6,0x0003003e, + 0x000001a8,0x000001a7,0x0004003d,0x00000007,0x000001aa,0x000000c3,0x0003003e,0x000001a9, + 0x000001aa,0x00060039,0x00000009,0x000001ab,0x0000000d,0x000001a8,0x000001a9,0x0003003e, + 0x0000019e,0x000001ab,0x0004003d,0x00000007,0x000001ad,0x000000c9,0x00050041,0x0000001a, + 0x000001ae,0x000000c3,0x00000053,0x0004003d,0x00000006,0x000001af,0x000001ae,0x00050041, + 0x0000001a,0x000001b0,0x000000c3,0x0000003a,0x0004003d,0x00000006,0x000001b1,0x000001b0, + 0x0004007f,0x00000006,0x000001b2,0x000001b1,0x00050050,0x00000007,0x000001b3,0x000001af, + 0x000001b2,0x00050081,0x00000007,0x000001b4,0x000001ad,0x000001b3,0x0003003e,0x000001b5, + 0x000001b4,0x0004003d,0x00000007,0x000001b7,0x000000c3,0x0003003e,0x000001b6,0x000001b7, + 0x00060039,0x00000009,0x000001b8,0x0000000d,0x000001b5,0x000001b6,0x0003003e,0x000001ac, + 0x000001b8,0x0004003d,0x00000007,0x000001ba,0x000000c9,0x00050041,0x0000001a,0x000001bb, + 0x000000c3,0x00000053,0x0004003d,0x00000006,0x000001bc,0x000001bb,0x0004007f,0x00000006, + 0x000001bd,0x000001bc,0x00050041,0x0000001a,0x000001be,0x000000c3,0x0000003a,0x0004003d, + 0x00000006,0x000001bf,0x000001be,0x00050050,0x00000007,0x000001c0,0x000001bd,0x000001bf, + 0x00050081,0x00000007,0x000001c1,0x000001ba,0x000001c0,0x0003003e,0x000001c2,0x000001c1, + 0x0004003d,0x00000007,0x000001c4,0x000000c3,0x0003003e,0x000001c3,0x000001c4,0x00060039, + 0x00000009,0x000001c5,0x0000000d,0x000001c2,0x000001c3,0x0003003e,0x000001b9,0x000001c5, + 0x0004003d,0x00000007,0x000001c7,0x000000c9,0x00050041,0x0000001a,0x000001c8,0x000000c3, + 0x00000053,0x0004003d,0x00000006,0x000001c9,0x000001c8,0x00050041,0x0000001a,0x000001ca, + 0x000000c3,0x0000003a,0x0004003d,0x00000006,0x000001cb,0x000001ca,0x00050050,0x00000007, + 0x000001cc,0x000001c9,0x000001cb,0x00050081,0x00000007,0x000001cd,0x000001c7,0x000001cc, + 0x0003003e,0x000001ce,0x000001cd,0x0004003d,0x00000007,0x000001d0,0x000000c3,0x0003003e, + 0x000001cf,0x000001d0,0x00060039,0x00000009,0x000001d1,0x0000000d,0x000001ce,0x000001cf, + 0x0003003e,0x000001c6,0x000001d1,0x0004003d,0x00000006,0x000001d3,0x00000100,0x0004003d, + 0x00000006,0x000001d4,0x00000101,0x00050083,0x00000006,0x000001d5,0x000001d3,0x000001d4, + 0x0006000c,0x00000006,0x000001d6,0x00000001,0x00000004,0x000001d5,0x0004003d,0x00000006, + 0x000001d7,0x00000193,0x0007000c,0x00000006,0x000001d8,0x00000001,0x00000028,0x000001d7, + 0x00000029,0x00050088,0x00000006,0x000001d9,0x000001d6,0x000001d8,0x0008000c,0x00000006, + 0x000001da,0x00000001,0x0000002b,0x000001d9,0x00000037,0x00000029,0x0003003e,0x000001d2, + 0x000001da,0x0004003d,0x00000018,0x000001dc,0x00000109,0x000300f7,0x000001df,0x00000000, + 0x000400fa,0x000001dc,0x000001de,0x000001e6,0x000200f8,0x000001de,0x00050041,0x0000001a, + 0x000001e0,0x0000019e,0x00000045,0x0004003d,0x00000006,0x000001e1,0x000001e0,0x00050041, + 0x0000001a,0x000001e2,0x000001ac,0x00000045,0x0004003d,0x00000006,0x000001e3,0x000001e2, + 0x00050083,0x00000006,0x000001e4,0x000001e1,0x000001e3,0x0006000c,0x00000006,0x000001e5, + 0x00000001,0x00000004,0x000001e4,0x0003003e,0x000001dd,0x000001e5,0x000200f9,0x000001df, + 0x000200f8,0x000001e6,0x00050041,0x0000001a,0x000001e7,0x0000019e,0x0000003a,0x0004003d, + 0x00000006,0x000001e8,0x000001e7,0x00050041,0x0000001a,0x000001e9,0x000001b9,0x0000003a, + 0x0004003d,0x00000006,0x000001ea,0x000001e9,0x00050083,0x00000006,0x000001eb,0x000001e8, + 0x000001ea,0x0006000c,0x00000006,0x000001ec,0x00000001,0x00000004,0x000001eb,0x0003003e, + 0x000001dd,0x000001ec,0x000200f9,0x000001df,0x000200f8,0x000001df,0x0004003d,0x00000006, + 0x000001ed,0x000001dd,0x0003003e,0x000001db,0x000001ed,0x0004003d,0x00000018,0x000001ef, + 0x00000109,0x000300f7,0x000001f2,0x00000000,0x000400fa,0x000001ef,0x000001f1,0x000001f9, + 0x000200f8,0x000001f1,0x00050041,0x0000001a,0x000001f3,0x000001b9,0x00000061,0x0004003d, + 0x00000006,0x000001f4,0x000001f3,0x00050041,0x0000001a,0x000001f5,0x000001c6,0x00000061, + 0x0004003d,0x00000006,0x000001f6,0x000001f5,0x00050083,0x00000006,0x000001f7,0x000001f4, + 0x000001f6,0x0006000c,0x00000006,0x000001f8,0x00000001,0x00000004,0x000001f7,0x0003003e, + 0x000001f0,0x000001f8,0x000200f9,0x000001f2,0x000200f8,0x000001f9,0x00050041,0x0000001a, + 0x000001fa,0x000001ac,0x00000053,0x0004003d,0x00000006,0x000001fb,0x000001fa,0x00050041, + 0x0000001a,0x000001fc,0x000001c6,0x00000053,0x0004003d,0x00000006,0x000001fd,0x000001fc, + 0x00050083,0x00000006,0x000001fe,0x000001fb,0x000001fd,0x0006000c,0x00000006,0x000001ff, + 0x00000001,0x00000004,0x000001fe,0x0003003e,0x000001f0,0x000001ff,0x000200f9,0x000001f2, + 0x000200f8,0x000001f2,0x0004003d,0x00000006,0x00000200,0x000001f0,0x0003003e,0x000001ee, + 0x00000200,0x0004003d,0x00000006,0x00000202,0x000001db,0x0004003d,0x00000006,0x00000203, + 0x000001ee,0x00050083,0x00000006,0x00000204,0x00000202,0x00000203,0x0006000c,0x00000006, + 0x00000205,0x00000001,0x00000004,0x00000204,0x0003003e,0x00000201,0x00000205,0x0004003d, + 0x00000006,0x00000207,0x000000f1,0x0004003d,0x00000006,0x00000208,0x000000f1,0x00050085, + 0x00000006,0x00000209,0x00000208,0x0000019a,0x0004003d,0x00000006,0x0000020a,0x00000201, + 0x0008000c,0x00000006,0x0000020b,0x00000001,0x00000031,0x00000207,0x00000209,0x0000020a, + 0x0003003e,0x00000206,0x0000020b,0x0004003d,0x00000009,0x0000020d,0x0000019e,0x0004003d, + 0x00000009,0x0000020e,0x000001ac,0x0007000c,0x00000009,0x0000020f,0x00000001,0x00000025, + 0x0000020d,0x0000020e,0x0004003d,0x00000009,0x00000210,0x000001b9,0x0004003d,0x00000009, + 0x00000211,0x000001c6,0x0007000c,0x00000009,0x00000212,0x00000001,0x00000025,0x00000210, + 0x00000211,0x0007000c,0x00000009,0x00000213,0x00000001,0x00000025,0x0000020f,0x00000212, + 0x0003003e,0x0000020c,0x00000213,0x0004003d,0x00000009,0x00000215,0x0000019e,0x0004003d, + 0x00000009,0x00000216,0x000001ac,0x0007000c,0x00000009,0x00000217,0x00000001,0x00000028, + 0x00000215,0x00000216,0x0004003d,0x00000009,0x00000218,0x000001b9,0x0004003d,0x00000009, + 0x00000219,0x000001c6,0x0007000c,0x00000009,0x0000021a,0x00000001,0x00000028,0x00000218, + 0x00000219,0x0007000c,0x00000009,0x0000021b,0x00000001,0x00000028,0x00000217,0x0000021a, + 0x0003003e,0x00000214,0x0000021b,0x00050041,0x0000001a,0x0000021d,0x00000214,0x00000053, + 0x0004003d,0x00000006,0x0000021e,0x0000021d,0x00050041,0x0000001a,0x0000021f,0x0000020c, + 0x00000053,0x0004003d,0x00000006,0x00000220,0x0000021f,0x00050083,0x00000006,0x00000221, + 0x0000021e,0x00000220,0x00050041,0x0000001a,0x00000222,0x00000214,0x0000003a,0x0004003d, + 0x00000006,0x00000223,0x00000222,0x00050041,0x0000001a,0x00000224,0x0000020c,0x0000003a, + 0x0004003d,0x00000006,0x00000225,0x00000224,0x00050083,0x00000006,0x00000226,0x00000223, + 0x00000225,0x0007000c,0x00000006,0x00000227,0x00000001,0x00000028,0x00000221,0x00000226, + 0x00050041,0x0000001a,0x00000228,0x00000214,0x00000061,0x0004003d,0x00000006,0x00000229, + 0x00000228,0x00050041,0x0000001a,0x0000022a,0x0000020c,0x00000061,0x0004003d,0x00000006, + 0x0000022b,0x0000022a,0x00050083,0x00000006,0x0000022c,0x00000229,0x0000022b,0x00050041, + 0x0000001a,0x0000022d,0x00000214,0x00000045,0x0004003d,0x00000006,0x0000022e,0x0000022d, + 0x00050041,0x0000001a,0x0000022f,0x0000020c,0x00000045,0x0004003d,0x00000006,0x00000230, + 0x0000022f,0x00050083,0x00000006,0x00000231,0x0000022e,0x00000230,0x0007000c,0x00000006, + 0x00000232,0x00000001,0x00000028,0x0000022c,0x00000231,0x0007000c,0x00000006,0x00000233, + 0x00000001,0x00000028,0x00000227,0x00000232,0x0003003e,0x0000021c,0x00000233,0x0004003d, + 0x00000006,0x00000235,0x0000021c,0x000500ba,0x00000018,0x00000237,0x00000235,0x00000236, + 0x000300f7,0x0000023a,0x00000000,0x000400fa,0x00000237,0x00000239,0x00000242,0x000200f8, + 0x00000239,0x0004003d,0x00000006,0x0000023b,0x000000f1,0x0004003d,0x00000006,0x0000023c, + 0x000000f1,0x00050085,0x00000006,0x0000023d,0x0000023c,0x0000019a,0x0004003d,0x00000006, + 0x0000023e,0x000001db,0x0004003d,0x00000006,0x0000023f,0x000001ee,0x0007000c,0x00000006, + 0x00000240,0x00000001,0x00000025,0x0000023e,0x0000023f,0x0008000c,0x00000006,0x00000241, + 0x00000001,0x00000031,0x0000023b,0x0000023d,0x00000240,0x0003003e,0x00000238,0x00000241, + 0x000200f9,0x0000023a,0x000200f8,0x00000242,0x0003003e,0x00000238,0x00000037,0x000200f9, + 0x0000023a,0x000200f8,0x0000023a,0x0004003d,0x00000006,0x00000243,0x00000238,0x0003003e, + 0x00000234,0x00000243,0x0004003d,0x00000006,0x00000245,0x000001d2,0x000500ba,0x00000018, + 0x00000246,0x00000245,0x00000236,0x000300f7,0x00000249,0x00000000,0x000400fa,0x00000246, + 0x00000248,0x0000024d,0x000200f8,0x00000248,0x0004003d,0x00000006,0x0000024a,0x000001d2, + 0x0004003d,0x00000006,0x0000024b,0x00000234,0x0007000c,0x00000006,0x0000024c,0x00000001, + 0x00000028,0x0000024a,0x0000024b,0x0003003e,0x00000247,0x0000024c,0x000200f9,0x00000249, + 0x000200f8,0x0000024d,0x0004003d,0x00000006,0x0000024e,0x000001d2,0x0003003e,0x00000247, + 0x0000024e,0x000200f9,0x00000249,0x000200f8,0x00000249,0x0004003d,0x00000006,0x0000024f, + 0x00000247,0x0003003e,0x00000244,0x0000024f,0x0004003d,0x00000006,0x00000251,0x00000244, + 0x0004003d,0x00000006,0x00000252,0x00000193,0x00050085,0x00000006,0x00000254,0x00000252, + 0x00000253,0x00050081,0x00000006,0x00000255,0x00000029,0x00000254,0x00050088,0x00000006, + 0x00000256,0x00000251,0x00000255,0x0003003e,0x00000250,0x00000256,0x0004003d,0x00000006, + 0x00000259,0x00000206,0x00050085,0x00000006,0x0000025a,0x00000258,0x00000259,0x0004003d, + 0x00000006,0x0000025b,0x00000193,0x00050088,0x00000006,0x0000025d,0x0000025b,0x0000025c, + 0x0008000c,0x00000006,0x0000025e,0x00000001,0x0000002b,0x0000025d,0x00000037,0x00000029, + 0x00050085,0x00000006,0x0000025f,0x0000025a,0x0000025e,0x0003003e,0x00000257,0x0000025f, + 0x00050041,0x0000001a,0x00000261,0x0000019e,0x00000053,0x0004003d,0x00000006,0x00000262, + 0x00000261,0x00050041,0x0000001a,0x00000263,0x000001c6,0x00000053,0x0004003d,0x00000006, + 0x00000264,0x00000263,0x00050083,0x00000006,0x00000265,0x00000262,0x00000264,0x0006000c, + 0x00000006,0x00000266,0x00000001,0x00000004,0x00000265,0x00050041,0x0000001a,0x00000267, + 0x0000019e,0x0000003a,0x0004003d,0x00000006,0x00000268,0x00000267,0x00050041,0x0000001a, + 0x00000269,0x000001c6,0x0000003a,0x0004003d,0x00000006,0x0000026a,0x00000269,0x00050083, + 0x00000006,0x0000026b,0x00000268,0x0000026a,0x0006000c,0x00000006,0x0000026c,0x00000001, + 0x00000004,0x0000026b,0x0007000c,0x00000006,0x0000026d,0x00000001,0x00000028,0x00000266, + 0x0000026c,0x00050041,0x0000001a,0x0000026e,0x0000019e,0x00000061,0x0004003d,0x00000006, + 0x0000026f,0x0000026e,0x00050041,0x0000001a,0x00000270,0x000001c6,0x00000061,0x0004003d, + 0x00000006,0x00000271,0x00000270,0x00050083,0x00000006,0x00000272,0x0000026f,0x00000271, + 0x0006000c,0x00000006,0x00000273,0x00000001,0x00000004,0x00000272,0x00050041,0x0000001a, + 0x00000274,0x0000019e,0x00000045,0x0004003d,0x00000006,0x00000275,0x00000274,0x00050041, + 0x0000001a,0x00000276,0x000001c6,0x00000045,0x0004003d,0x00000006,0x00000277,0x00000276, + 0x00050083,0x00000006,0x00000278,0x00000275,0x00000277,0x0006000c,0x00000006,0x00000279, + 0x00000001,0x00000004,0x00000278,0x0007000c,0x00000006,0x0000027a,0x00000001,0x00000028, + 0x00000273,0x00000279,0x0007000c,0x00000006,0x0000027b,0x00000001,0x00000028,0x0000026d, + 0x0000027a,0x00050041,0x0000001a,0x0000027c,0x000001ac,0x00000053,0x0004003d,0x00000006, + 0x0000027d,0x0000027c,0x00050041,0x0000001a,0x0000027e,0x000001b9,0x00000053,0x0004003d, + 0x00000006,0x0000027f,0x0000027e,0x00050083,0x00000006,0x00000280,0x0000027d,0x0000027f, + 0x0006000c,0x00000006,0x00000281,0x00000001,0x00000004,0x00000280,0x00050041,0x0000001a, + 0x00000282,0x000001ac,0x0000003a,0x0004003d,0x00000006,0x00000283,0x00000282,0x00050041, + 0x0000001a,0x00000284,0x000001b9,0x0000003a,0x0004003d,0x00000006,0x00000285,0x00000284, + 0x00050083,0x00000006,0x00000286,0x00000283,0x00000285,0x0006000c,0x00000006,0x00000287, + 0x00000001,0x00000004,0x00000286,0x0007000c,0x00000006,0x00000288,0x00000001,0x00000028, + 0x00000281,0x00000287,0x00050041,0x0000001a,0x00000289,0x000001ac,0x00000061,0x0004003d, + 0x00000006,0x0000028a,0x00000289,0x00050041,0x0000001a,0x0000028b,0x000001b9,0x00000061, + 0x0004003d,0x00000006,0x0000028c,0x0000028b,0x00050083,0x00000006,0x0000028d,0x0000028a, + 0x0000028c,0x0006000c,0x00000006,0x0000028e,0x00000001,0x00000004,0x0000028d,0x00050041, + 0x0000001a,0x0000028f,0x000001ac,0x00000045,0x0004003d,0x00000006,0x00000290,0x0000028f, + 0x00050041,0x0000001a,0x00000291,0x000001b9,0x00000045,0x0004003d,0x00000006,0x00000292, + 0x00000291,0x00050083,0x00000006,0x00000293,0x00000290,0x00000292,0x0006000c,0x00000006, + 0x00000294,0x00000001,0x00000004,0x00000293,0x0007000c,0x00000006,0x00000295,0x00000001, + 0x00000028,0x0000028e,0x00000294,0x0007000c,0x00000006,0x00000296,0x00000001,0x00000028, + 0x00000288,0x00000295,0x0007000c,0x00000006,0x00000297,0x00000001,0x00000028,0x0000027b, + 0x00000296,0x0003003e,0x00000260,0x00000297,0x0004003d,0x00000006,0x0000029a,0x000000f1, + 0x0004003d,0x00000006,0x0000029b,0x000000f1,0x00050085,0x00000006,0x0000029d,0x0000029b, + 0x0000029c,0x0004003d,0x00000006,0x0000029e,0x00000260,0x0008000c,0x00000006,0x0000029f, + 0x00000001,0x00000031,0x0000029a,0x0000029d,0x0000029e,0x00050085,0x00000006,0x000002a0, + 0x00000299,0x0000029f,0x00050083,0x00000006,0x000002a1,0x00000029,0x000002a0,0x0003003e, + 0x00000298,0x000002a1,0x0004003d,0x00000006,0x000002a3,0x00000257,0x0004003d,0x00000006, + 0x000002a4,0x00000250,0x00050085,0x00000006,0x000002a5,0x000002a3,0x000002a4,0x0004003d, + 0x00000006,0x000002a6,0x00000197,0x00050085,0x00000006,0x000002a7,0x000002a5,0x000002a6, + 0x0004003d,0x00000006,0x000002a8,0x00000298,0x00050085,0x00000006,0x000002a9,0x000002a7, + 0x000002a8,0x0003003e,0x000002a2,0x000002a9,0x0004003d,0x00000006,0x000002ab,0x000000e5, + 0x0004003d,0x00000006,0x000002ac,0x000000e9,0x0007000c,0x00000006,0x000002ad,0x00000001, + 0x00000025,0x000002ab,0x000002ac,0x0003003e,0x000002aa,0x000002ad,0x0004003d,0x00000006, + 0x000002af,0x000000f1,0x0004003d,0x00000006,0x000002b0,0x000000f1,0x00050085,0x00000006, + 0x000002b1,0x000002b0,0x0000019a,0x0004003d,0x00000006,0x000002b2,0x000002aa,0x0008000c, + 0x00000006,0x000002b3,0x00000001,0x00000031,0x000002af,0x000002b1,0x000002b2,0x0003003e, + 0x000002ae,0x000002b3,0x0004003d,0x00000006,0x000002b5,0x00000193,0x0008000c,0x00000006, + 0x000002b6,0x00000001,0x00000031,0x00000029,0x0000029c,0x000002b5,0x0003003e,0x000002b4, + 0x000002b6,0x0004003d,0x00000006,0x000002b8,0x00000193,0x000500ba,0x00000018,0x000002b9, + 0x000002b8,0x00000037,0x0004003d,0x00000006,0x000002ba,0x00000193,0x000500bc,0x00000018, + 0x000002bb,0x000002ba,0x00000029,0x000500a7,0x00000018,0x000002bc,0x000002b9,0x000002bb, + 0x0004003d,0x00000006,0x000002bd,0x00000201,0x0004003d,0x00000006,0x000002be,0x000000f1, + 0x000500bc,0x00000018,0x000002bf,0x000002bd,0x000002be,0x000500a7,0x00000018,0x000002c0, + 0x000002bc,0x000002bf,0x0004003d,0x00000006,0x000002c1,0x000002aa,0x0004003d,0x00000006, + 0x000002c2,0x000000f1,0x000500ba,0x00000018,0x000002c3,0x000002c1,0x000002c2,0x000500a7, + 0x00000018,0x000002c4,0x000002c0,0x000002c3,0x000600a9,0x00000006,0x000002c5,0x000002c4, + 0x00000029,0x00000037,0x0003003e,0x000002b7,0x000002c5,0x0004003d,0x00000006,0x000002c8, + 0x000002ae,0x00050085,0x00000006,0x000002c9,0x000002c7,0x000002c8,0x0004003d,0x00000006, + 0x000002ca,0x00000197,0x00050085,0x00000006,0x000002cb,0x000002c9,0x000002ca,0x0004003d, + 0x00000006,0x000002cc,0x00000298,0x00050085,0x00000006,0x000002cd,0x000002cb,0x000002cc, + 0x0004003d,0x00000006,0x000002ce,0x000002b4,0x0004003d,0x00000006,0x000002cf,0x00000206, + 0x0004003d,0x00000006,0x000002d0,0x00000234,0x0007000c,0x00000006,0x000002d1,0x00000001, + 0x00000028,0x000002cf,0x000002d0,0x00050085,0x00000006,0x000002d2,0x000002ce,0x000002d1, + 0x0004003d,0x00000006,0x000002d3,0x000002b7,0x0007000c,0x00000006,0x000002d4,0x00000001, + 0x00000028,0x000002d2,0x000002d3,0x00050085,0x00000006,0x000002d5,0x000002cd,0x000002d4, + 0x0003003e,0x000002c6,0x000002d5,0x0004003d,0x00000006,0x000002d7,0x000002a2,0x0004003d, + 0x00000006,0x000002d8,0x000002c6,0x0007000c,0x00000006,0x000002d9,0x00000001,0x00000028, + 0x000002d7,0x000002d8,0x0008000c,0x00000006,0x000002db,0x00000001,0x0000002b,0x000002d9, + 0x00000037,0x000002da,0x0003003e,0x000002d6,0x000002db,0x0004003d,0x00000006,0x000002dc, + 0x000002d6,0x00050041,0x0000001a,0x000002dd,0x00000166,0x00000053,0x0004003d,0x00000006, + 0x000002de,0x000002dd,0x00050085,0x00000006,0x000002df,0x000002de,0x00000027,0x00050081, + 0x00000006,0x000002e0,0x000002df,0x00000027,0x00050041,0x0000001a,0x000002e1,0x00000166, + 0x0000003a,0x0004003d,0x00000006,0x000002e2,0x000002e1,0x00050085,0x00000006,0x000002e3, + 0x000002e2,0x00000027,0x00050081,0x00000006,0x000002e4,0x000002e3,0x00000027,0x00070050, + 0x00000009,0x000002e5,0x000002dc,0x000002e0,0x000002e4,0x00000029,0x0003003e,0x000000fd, + 0x000002e5,0x000100fd,0x00010038,0x00050036,0x00000009,0x0000000d,0x00000000,0x0000000a, + 0x00030037,0x00000008,0x0000000b,0x00030037,0x00000008,0x0000000c,0x000200f8,0x0000000e, + 0x0004003b,0x00000008,0x00000024,0x00000007,0x0004003b,0x0000002f,0x00000030,0x00000007, + 0x0004003b,0x0000001a,0x00000041,0x00000007,0x0004003d,0x00000007,0x00000025,0x0000000b, + 0x0004003d,0x00000007,0x00000026,0x0000000c,0x0005008e,0x00000007,0x00000028,0x00000026, + 0x00000027,0x0004003d,0x00000007,0x0000002b,0x0000000c,0x0005008e,0x00000007,0x0000002c, + 0x0000002b,0x00000027,0x00050083,0x00000007,0x0000002d,0x0000002a,0x0000002c,0x0008000c, + 0x00000007,0x0000002e,0x00000001,0x0000002b,0x00000025,0x00000028,0x0000002d,0x0003003e, + 0x00000024,0x0000002e,0x0004003d,0x00000032,0x00000035,0x00000034,0x0004003d,0x00000007, + 0x00000036,0x00000024,0x00070058,0x00000009,0x00000038,0x00000035,0x00000036,0x00000002, + 0x00000037,0x0003003e,0x00000030,0x00000038,0x00050041,0x0000001a,0x0000003b,0x00000024, + 0x0000003a,0x0004003d,0x00000006,0x0000003c,0x0000003b,0x00050041,0x0000001a,0x0000003d, + 0x0000000c,0x0000003a,0x0004003d,0x00000006,0x0000003e,0x0000003d,0x00050083,0x00000006, + 0x0000003f,0x00000029,0x0000003e,0x000500be,0x00000018,0x00000040,0x0000003c,0x0000003f, + 0x000300f7,0x00000043,0x00000000,0x000400fa,0x00000040,0x00000042,0x00000044,0x000200f8, + 0x00000042,0x0003003e,0x00000041,0x00000037,0x000200f9,0x00000043,0x000200f8,0x00000044, + 0x00050041,0x0000001a,0x00000046,0x00000030,0x00000045,0x0004003d,0x00000006,0x00000047, + 0x00000046,0x0003003e,0x00000041,0x00000047,0x000200f9,0x00000043,0x000200f8,0x00000043, + 0x0004003d,0x00000006,0x00000048,0x00000041,0x00050041,0x0000001a,0x00000049,0x00000030, + 0x00000045,0x0003003e,0x00000049,0x00000048,0x0004003d,0x00000009,0x0000004a,0x00000030, + 0x000200fe,0x0000004a,0x00010038,0x00050036,0x00000006,0x00000012,0x00000000,0x0000000f, + 0x00030037,0x00000008,0x00000010,0x00030037,0x00000008,0x00000011,0x000200f8,0x00000013, + 0x0004003b,0x0000002f,0x0000004d,0x00000007,0x0004003b,0x00000008,0x0000004e,0x00000007, + 0x0004003b,0x00000008,0x00000050,0x00000007,0x0004003d,0x00000007,0x0000004f,0x00000010, + 0x0003003e,0x0000004e,0x0000004f,0x0004003d,0x00000007,0x00000051,0x00000011,0x0003003e, + 0x00000050,0x00000051,0x00060039,0x00000009,0x00000052,0x0000000d,0x0000004e,0x00000050, + 0x0003003e,0x0000004d,0x00000052,0x00050041,0x0000001a,0x00000054,0x0000004d,0x00000053, + 0x0004003d,0x00000006,0x00000055,0x00000054,0x00050041,0x0000001a,0x00000056,0x0000004d, + 0x0000003a,0x0004003d,0x00000006,0x00000057,0x00000056,0x0007000c,0x00000006,0x00000058, + 0x00000001,0x00000028,0x00000055,0x00000057,0x000200fe,0x00000058,0x00010038,0x00050036, + 0x00000006,0x00000016,0x00000000,0x0000000f,0x00030037,0x00000008,0x00000014,0x00030037, + 0x00000008,0x00000015,0x000200f8,0x00000017,0x0004003b,0x0000002f,0x0000005b,0x00000007, + 0x0004003b,0x00000008,0x0000005c,0x00000007,0x0004003b,0x00000008,0x0000005e,0x00000007, + 0x0004003d,0x00000007,0x0000005d,0x00000014,0x0003003e,0x0000005c,0x0000005d,0x0004003d, + 0x00000007,0x0000005f,0x00000015,0x0003003e,0x0000005e,0x0000005f,0x00060039,0x00000009, + 0x00000060,0x0000000d,0x0000005c,0x0000005e,0x0003003e,0x0000005b,0x00000060,0x00050041, + 0x0000001a,0x00000062,0x0000005b,0x00000061,0x0004003d,0x00000006,0x00000063,0x00000062, + 0x00050041,0x0000001a,0x00000064,0x0000005b,0x00000045,0x0004003d,0x00000006,0x00000065, + 0x00000064,0x0007000c,0x00000006,0x00000066,0x00000001,0x00000028,0x00000063,0x00000065, + 0x000200fe,0x00000066,0x00010038,0x00050036,0x00000006,0x00000022,0x00000000,0x0000001b, + 0x00030037,0x00000008,0x0000001c,0x00030037,0x00000008,0x0000001d,0x00030037,0x00000008, + 0x0000001e,0x00030037,0x00000019,0x0000001f,0x00030037,0x0000001a,0x00000020,0x00030037, + 0x00000019,0x00000021,0x000200f8,0x00000023,0x0004003b,0x0000001a,0x00000069,0x00000007, + 0x0004003b,0x0000006b,0x0000006c,0x00000007,0x0004003b,0x00000008,0x00000076,0x00000007, + 0x0004003b,0x00000082,0x00000083,0x00000007,0x0004003b,0x00000082,0x0000008e,0x00000007, + 0x0004003b,0x0000001a,0x000000a3,0x00000007,0x0004003b,0x0000001a,0x000000a5,0x00000007, + 0x0004003b,0x00000008,0x000000a8,0x00000007,0x0004003b,0x00000008,0x000000aa,0x00000007, + 0x0004003b,0x00000008,0x000000ae,0x00000007,0x0004003b,0x00000008,0x000000b0,0x00000007, + 0x0003003e,0x00000069,0x00000037,0x0003003e,0x0000006c,0x0000006d,0x000200f9,0x0000006e, + 0x000200f8,0x0000006e,0x000400f6,0x00000070,0x00000071,0x00000000,0x000200f9,0x00000072, + 0x000200f8,0x00000072,0x0004003d,0x0000006a,0x00000073,0x0000006c,0x000500b3,0x00000018, + 0x00000075,0x00000073,0x00000074,0x000400fa,0x00000075,0x0000006f,0x00000070,0x000200f8, + 0x0000006f,0x0004003d,0x00000007,0x00000077,0x0000001c,0x0004003d,0x00000007,0x00000078, + 0x0000001e,0x0004003d,0x0000006a,0x00000079,0x0000006c,0x0004006f,0x00000006,0x0000007a, + 0x00000079,0x0005008e,0x00000007,0x0000007b,0x00000078,0x0000007a,0x0004003d,0x00000018, + 0x0000007c,0x00000021,0x000600a9,0x00000006,0x0000007e,0x0000007c,0x00000029,0x0000007d, + 0x0005008e,0x00000007,0x0000007f,0x0000007b,0x0000007e,0x00050081,0x00000007,0x00000080, + 0x00000077,0x0000007f,0x0003003e,0x00000076,0x00000080,0x0004003d,0x00000007,0x00000084, + 0x00000076,0x00050041,0x00000088,0x00000089,0x00000087,0x0000006d,0x0004003d,0x00000007, + 0x0000008a,0x00000089,0x00050085,0x00000007,0x0000008b,0x00000084,0x0000008a,0x0006000c, + 0x00000007,0x0000008c,0x00000001,0x00000008,0x0000008b,0x0004006e,0x00000081,0x0000008d, + 0x0000008c,0x0003003e,0x00000083,0x0000008d,0x00050041,0x00000088,0x0000008f,0x00000087, + 0x0000006d,0x0004003d,0x00000007,0x00000090,0x0000008f,0x0004006e,0x00000081,0x00000091, + 0x00000090,0x0003003e,0x0000008e,0x00000091,0x0004003d,0x00000081,0x00000092,0x00000083, + 0x000500b1,0x00000095,0x00000096,0x00000092,0x00000094,0x0004009a,0x00000018,0x00000097, + 0x00000096,0x000400a8,0x00000018,0x00000098,0x00000097,0x000300f7,0x0000009a,0x00000000, + 0x000400fa,0x00000098,0x00000099,0x0000009a,0x000200f8,0x00000099,0x0004003d,0x00000081, + 0x0000009b,0x00000083,0x0004003d,0x00000081,0x0000009c,0x0000008e,0x000500af,0x00000095, + 0x0000009d,0x0000009b,0x0000009c,0x0004009a,0x00000018,0x0000009e,0x0000009d,0x000200f9, + 0x0000009a,0x000200f8,0x0000009a,0x000700f5,0x00000018,0x0000009f,0x00000097,0x0000006f, + 0x0000009e,0x00000099,0x000300f7,0x000000a1,0x00000000,0x000400fa,0x0000009f,0x000000a0, + 0x000000a1,0x000200f8,0x000000a0,0x000200f9,0x00000070,0x000200f8,0x000000a1,0x0004003d, + 0x00000018,0x000000a4,0x0000001f,0x000300f7,0x000000a7,0x00000000,0x000400fa,0x000000a4, + 0x000000a6,0x000000ad,0x000200f8,0x000000a6,0x0004003d,0x00000007,0x000000a9,0x00000076, + 0x0003003e,0x000000a8,0x000000a9,0x0004003d,0x00000007,0x000000ab,0x0000001d,0x0003003e, + 0x000000aa,0x000000ab,0x00060039,0x00000006,0x000000ac,0x00000012,0x000000a8,0x000000aa, + 0x0003003e,0x000000a5,0x000000ac,0x000200f9,0x000000a7,0x000200f8,0x000000ad,0x0004003d, + 0x00000007,0x000000af,0x00000076,0x0003003e,0x000000ae,0x000000af,0x0004003d,0x00000007, + 0x000000b1,0x0000001d,0x0003003e,0x000000b0,0x000000b1,0x00060039,0x00000006,0x000000b2, + 0x00000016,0x000000ae,0x000000b0,0x0003003e,0x000000a5,0x000000b2,0x000200f9,0x000000a7, + 0x000200f8,0x000000a7,0x0004003d,0x00000006,0x000000b3,0x000000a5,0x0003003e,0x000000a3, + 0x000000b3,0x0004003d,0x00000006,0x000000b4,0x000000a3,0x0004003d,0x00000006,0x000000b5, + 0x00000020,0x00050085,0x00000006,0x000000b7,0x000000b5,0x000000b6,0x000500bc,0x00000018, + 0x000000b8,0x000000b4,0x000000b7,0x000300f7,0x000000ba,0x00000000,0x000400fa,0x000000b8, + 0x000000b9,0x000000ba,0x000200f8,0x000000b9,0x000200f9,0x00000070,0x000200f8,0x000000ba, + 0x0004003d,0x0000006a,0x000000bc,0x0000006c,0x0004006f,0x00000006,0x000000bd,0x000000bc, + 0x0003003e,0x00000069,0x000000bd,0x000200f9,0x00000071,0x000200f8,0x00000071,0x0004003d, + 0x0000006a,0x000000be,0x0000006c,0x00050080,0x0000006a,0x000000bf,0x000000be,0x0000006d, + 0x0003003e,0x0000006c,0x000000bf,0x000200f9,0x0000006e,0x000200f8,0x00000070,0x0004003d, + 0x00000006,0x000000c0,0x00000069,0x000200fe,0x000000c0,0x00010038, +}; diff --git a/app/src/main/cpp/shaders/toon.frag b/app/src/main/cpp/shaders/toon.frag new file mode 100644 index 0000000000..f55323caa8 --- /dev/null +++ b/app/src/main/cpp/shaders/toon.frag @@ -0,0 +1,44 @@ +#version 450 + +// ============================================================================= +// Toon / cel edge-outline post effect. +// +// Ported verbatim from the OpenGL ToonEffect.java shader. GL derived uv from +// gl_FragCoord.xy / resolution; here fragTexCoord already spans [0,1] across +// the output, so it IS that uv. edgeThreshold/offset constants unchanged. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// Runs after FXAA in the canonical chain (stylize the clean image). +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in px +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +void main() { + vec2 uv = fragTexCoord; + + float edgeThreshold = 0.2; // edge-detect threshold + vec2 offset = vec2(1.0) / pc.resolution; // 1-texel neighbour offset + + vec3 colorCenter = texture(InputTexture, uv).rgb; + vec3 colorLeft = texture(InputTexture, uv - vec2(offset.x, 0.0)).rgb; + vec3 colorRight = texture(InputTexture, uv + vec2(offset.x, 0.0)).rgb; + vec3 colorUp = texture(InputTexture, uv - vec2(0.0, offset.y)).rgb; + vec3 colorDown = texture(InputTexture, uv + vec2(0.0, offset.y)).rgb; + + float diffHorizontal = length(colorRight - colorLeft); + float diffVertical = length(colorUp - colorDown); + + float edgeFactor = step(edgeThreshold, diffHorizontal + diffVertical); + vec3 outlineColor = mix(colorCenter, vec3(0.0), edgeFactor); + + outColor = vec4(outlineColor, 1.0); +} diff --git a/app/src/main/cpp/shaders/toon_color.frag b/app/src/main/cpp/shaders/toon_color.frag new file mode 100644 index 0000000000..58f12d5aa2 --- /dev/null +++ b/app/src/main/cpp/shaders/toon_color.frag @@ -0,0 +1,51 @@ +#version 450 + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; + vec2 resolution; + float brightness; + float contrast; + float gamma; + float saturation; +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +void main() { + vec2 uv = fragTexCoord; + vec2 offset = vec2(1.0) / pc.resolution; + + vec3 center = texture(InputTexture, uv).rgb; + vec3 left = texture( + InputTexture, uv - vec2(offset.x, 0.0)).rgb; + vec3 right = texture( + InputTexture, uv + vec2(offset.x, 0.0)).rgb; + vec3 up = texture( + InputTexture, uv - vec2(0.0, offset.y)).rgb; + vec3 down = texture( + InputTexture, uv + vec2(0.0, offset.y)).rgb; + + float horizontal = length(right - left); + float vertical = length(up - down); + float edge = step(0.2, horizontal + vertical); + + vec3 color = mix(center, vec3(0.0), edge); + + color = roundEven(clamp(color, 0.0, 1.0) * 255.0) / 255.0; + + color = clamp(color + pc.brightness, 0.0, 1.0); + color = (color - 0.5) * + clamp(pc.contrast + 1.0, 0.5, 2.0) + 0.5; + + vec3 grey = vec3( + dot(color, vec3(0.2126, 0.7152, 0.0722))); + + color = mix(grey, color, clamp(pc.saturation, 0.0, 2.0)); + color = max(color, vec3(0.0)); + color = pow(color, vec3(1.0 / pc.gamma)); + + outColor = vec4(color, 1.0); +} diff --git a/app/src/main/cpp/shaders/toon_color_frag.h b/app/src/main/cpp/shaders/toon_color_frag.h new file mode 100644 index 0000000000..43a42b0634 --- /dev/null +++ b/app/src/main/cpp/shaders/toon_color_frag.h @@ -0,0 +1,133 @@ + // 1116.3.0 + #pragma once +const uint32_t toon_color_code[] = { + 0x07230203,0x00010000,0x0008000b,0x000000a4,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000009e,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00030005,0x00000009,0x00007675,0x00060005,0x0000000b,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00040005,0x0000000d,0x7366666f,0x00007465,0x00030005,0x00000011, + 0x00004350,0x00040006,0x00000011,0x00000000,0x0063646e,0x00060006,0x00000011,0x00000001, + 0x6f736572,0x6974756c,0x00006e6f,0x00060006,0x00000011,0x00000002,0x67697262,0x656e7468, + 0x00007373,0x00060006,0x00000011,0x00000003,0x746e6f63,0x74736172,0x00000000,0x00050006, + 0x00000011,0x00000004,0x6d6d6167,0x00000061,0x00060006,0x00000011,0x00000005,0x75746173, + 0x69746172,0x00006e6f,0x00030005,0x00000013,0x00006370,0x00040005,0x0000001c,0x746e6563, + 0x00007265,0x00060005,0x00000020,0x75706e49,0x78655474,0x65727574,0x00000000,0x00040005, + 0x00000025,0x7466656c,0x00000000,0x00040005,0x00000032,0x68676972,0x00000074,0x00030005, + 0x0000003b,0x00007075,0x00040005,0x00000045,0x6e776f64,0x00000000,0x00050005,0x0000004e, + 0x69726f68,0x746e6f7a,0x00006c61,0x00050005,0x00000053,0x74726576,0x6c616369,0x00000000, + 0x00040005,0x00000058,0x65676465,0x00000000,0x00040005,0x0000005e,0x6f6c6f63,0x00000072, + 0x00040005,0x00000084,0x79657267,0x00000000,0x00050005,0x0000009e,0x4374756f,0x726f6c6f, + 0x00000000,0x00040047,0x0000000b,0x0000001e,0x00000000,0x00030047,0x00000011,0x00000002, + 0x00050048,0x00000011,0x00000000,0x00000023,0x00000000,0x00050048,0x00000011,0x00000001, + 0x00000023,0x00000010,0x00050048,0x00000011,0x00000002,0x00000023,0x00000018,0x00050048, + 0x00000011,0x00000003,0x00000023,0x0000001c,0x00050048,0x00000011,0x00000004,0x00000023, + 0x00000020,0x00050048,0x00000011,0x00000005,0x00000023,0x00000024,0x00040047,0x00000020, + 0x00000021,0x00000000,0x00040047,0x00000020,0x00000022,0x00000000,0x00040047,0x0000009e, + 0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016, + 0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008, + 0x00000007,0x00000007,0x00040020,0x0000000a,0x00000001,0x00000007,0x0004003b,0x0000000a, + 0x0000000b,0x00000001,0x0004002b,0x00000006,0x0000000e,0x3f800000,0x0005002c,0x00000007, + 0x0000000f,0x0000000e,0x0000000e,0x00040017,0x00000010,0x00000006,0x00000004,0x0008001e, + 0x00000011,0x00000010,0x00000007,0x00000006,0x00000006,0x00000006,0x00000006,0x00040020, + 0x00000012,0x00000009,0x00000011,0x0004003b,0x00000012,0x00000013,0x00000009,0x00040015, + 0x00000014,0x00000020,0x00000001,0x0004002b,0x00000014,0x00000015,0x00000001,0x00040020, + 0x00000016,0x00000009,0x00000007,0x00040017,0x0000001a,0x00000006,0x00000003,0x00040020, + 0x0000001b,0x00000007,0x0000001a,0x00090019,0x0000001d,0x00000006,0x00000001,0x00000000, + 0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000001e,0x0000001d,0x00040020, + 0x0000001f,0x00000000,0x0000001e,0x0004003b,0x0000001f,0x00000020,0x00000000,0x00040015, + 0x00000028,0x00000020,0x00000000,0x0004002b,0x00000028,0x00000029,0x00000000,0x00040020, + 0x0000002a,0x00000007,0x00000006,0x0004002b,0x00000006,0x0000002d,0x00000000,0x0004002b, + 0x00000028,0x0000003e,0x00000001,0x0004002b,0x00000006,0x00000059,0x3e4ccccd,0x0006002c, + 0x0000001a,0x00000060,0x0000002d,0x0000002d,0x0000002d,0x0004002b,0x00000006,0x00000068, + 0x437f0000,0x0004002b,0x00000014,0x0000006e,0x00000002,0x00040020,0x0000006f,0x00000009, + 0x00000006,0x0004002b,0x00000006,0x00000078,0x3f000000,0x0004002b,0x00000014,0x0000007b, + 0x00000003,0x0004002b,0x00000006,0x0000007f,0x40000000,0x0004002b,0x00000006,0x00000086, + 0x3e59b3d0,0x0004002b,0x00000006,0x00000087,0x3f371759,0x0004002b,0x00000006,0x00000088, + 0x3d93dd98,0x0006002c,0x0000001a,0x00000089,0x00000086,0x00000087,0x00000088,0x0004002b, + 0x00000014,0x0000008e,0x00000005,0x0004002b,0x00000014,0x00000097,0x00000004,0x00040020, + 0x0000009d,0x00000003,0x00000010,0x0004003b,0x0000009d,0x0000009e,0x00000003,0x00050036, + 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008, + 0x00000009,0x00000007,0x0004003b,0x00000008,0x0000000d,0x00000007,0x0004003b,0x0000001b, + 0x0000001c,0x00000007,0x0004003b,0x0000001b,0x00000025,0x00000007,0x0004003b,0x0000001b, + 0x00000032,0x00000007,0x0004003b,0x0000001b,0x0000003b,0x00000007,0x0004003b,0x0000001b, + 0x00000045,0x00000007,0x0004003b,0x0000002a,0x0000004e,0x00000007,0x0004003b,0x0000002a, + 0x00000053,0x00000007,0x0004003b,0x0000002a,0x00000058,0x00000007,0x0004003b,0x0000001b, + 0x0000005e,0x00000007,0x0004003b,0x0000001b,0x00000084,0x00000007,0x0004003d,0x00000007, + 0x0000000c,0x0000000b,0x0003003e,0x00000009,0x0000000c,0x00050041,0x00000016,0x00000017, + 0x00000013,0x00000015,0x0004003d,0x00000007,0x00000018,0x00000017,0x00050088,0x00000007, + 0x00000019,0x0000000f,0x00000018,0x0003003e,0x0000000d,0x00000019,0x0004003d,0x0000001e, + 0x00000021,0x00000020,0x0004003d,0x00000007,0x00000022,0x00000009,0x00050057,0x00000010, + 0x00000023,0x00000021,0x00000022,0x0008004f,0x0000001a,0x00000024,0x00000023,0x00000023, + 0x00000000,0x00000001,0x00000002,0x0003003e,0x0000001c,0x00000024,0x0004003d,0x0000001e, + 0x00000026,0x00000020,0x0004003d,0x00000007,0x00000027,0x00000009,0x00050041,0x0000002a, + 0x0000002b,0x0000000d,0x00000029,0x0004003d,0x00000006,0x0000002c,0x0000002b,0x00050050, + 0x00000007,0x0000002e,0x0000002c,0x0000002d,0x00050083,0x00000007,0x0000002f,0x00000027, + 0x0000002e,0x00050057,0x00000010,0x00000030,0x00000026,0x0000002f,0x0008004f,0x0000001a, + 0x00000031,0x00000030,0x00000030,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000025, + 0x00000031,0x0004003d,0x0000001e,0x00000033,0x00000020,0x0004003d,0x00000007,0x00000034, + 0x00000009,0x00050041,0x0000002a,0x00000035,0x0000000d,0x00000029,0x0004003d,0x00000006, + 0x00000036,0x00000035,0x00050050,0x00000007,0x00000037,0x00000036,0x0000002d,0x00050081, + 0x00000007,0x00000038,0x00000034,0x00000037,0x00050057,0x00000010,0x00000039,0x00000033, + 0x00000038,0x0008004f,0x0000001a,0x0000003a,0x00000039,0x00000039,0x00000000,0x00000001, + 0x00000002,0x0003003e,0x00000032,0x0000003a,0x0004003d,0x0000001e,0x0000003c,0x00000020, + 0x0004003d,0x00000007,0x0000003d,0x00000009,0x00050041,0x0000002a,0x0000003f,0x0000000d, + 0x0000003e,0x0004003d,0x00000006,0x00000040,0x0000003f,0x00050050,0x00000007,0x00000041, + 0x0000002d,0x00000040,0x00050083,0x00000007,0x00000042,0x0000003d,0x00000041,0x00050057, + 0x00000010,0x00000043,0x0000003c,0x00000042,0x0008004f,0x0000001a,0x00000044,0x00000043, + 0x00000043,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000003b,0x00000044,0x0004003d, + 0x0000001e,0x00000046,0x00000020,0x0004003d,0x00000007,0x00000047,0x00000009,0x00050041, + 0x0000002a,0x00000048,0x0000000d,0x0000003e,0x0004003d,0x00000006,0x00000049,0x00000048, + 0x00050050,0x00000007,0x0000004a,0x0000002d,0x00000049,0x00050081,0x00000007,0x0000004b, + 0x00000047,0x0000004a,0x00050057,0x00000010,0x0000004c,0x00000046,0x0000004b,0x0008004f, + 0x0000001a,0x0000004d,0x0000004c,0x0000004c,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x00000045,0x0000004d,0x0004003d,0x0000001a,0x0000004f,0x00000032,0x0004003d,0x0000001a, + 0x00000050,0x00000025,0x00050083,0x0000001a,0x00000051,0x0000004f,0x00000050,0x0006000c, + 0x00000006,0x00000052,0x00000001,0x00000042,0x00000051,0x0003003e,0x0000004e,0x00000052, + 0x0004003d,0x0000001a,0x00000054,0x0000003b,0x0004003d,0x0000001a,0x00000055,0x00000045, + 0x00050083,0x0000001a,0x00000056,0x00000054,0x00000055,0x0006000c,0x00000006,0x00000057, + 0x00000001,0x00000042,0x00000056,0x0003003e,0x00000053,0x00000057,0x0004003d,0x00000006, + 0x0000005a,0x0000004e,0x0004003d,0x00000006,0x0000005b,0x00000053,0x00050081,0x00000006, + 0x0000005c,0x0000005a,0x0000005b,0x0007000c,0x00000006,0x0000005d,0x00000001,0x00000030, + 0x00000059,0x0000005c,0x0003003e,0x00000058,0x0000005d,0x0004003d,0x0000001a,0x0000005f, + 0x0000001c,0x0004003d,0x00000006,0x00000061,0x00000058,0x00060050,0x0000001a,0x00000062, + 0x00000061,0x00000061,0x00000061,0x0008000c,0x0000001a,0x00000063,0x00000001,0x0000002e, + 0x0000005f,0x00000060,0x00000062,0x0003003e,0x0000005e,0x00000063,0x0004003d,0x0000001a, + 0x00000064,0x0000005e,0x00060050,0x0000001a,0x00000065,0x0000002d,0x0000002d,0x0000002d, + 0x00060050,0x0000001a,0x00000066,0x0000000e,0x0000000e,0x0000000e,0x0008000c,0x0000001a, + 0x00000067,0x00000001,0x0000002b,0x00000064,0x00000065,0x00000066,0x0005008e,0x0000001a, + 0x00000069,0x00000067,0x00000068,0x0006000c,0x0000001a,0x0000006a,0x00000001,0x00000002, + 0x00000069,0x00060050,0x0000001a,0x0000006b,0x00000068,0x00000068,0x00000068,0x00050088, + 0x0000001a,0x0000006c,0x0000006a,0x0000006b,0x0003003e,0x0000005e,0x0000006c,0x0004003d, + 0x0000001a,0x0000006d,0x0000005e,0x00050041,0x0000006f,0x00000070,0x00000013,0x0000006e, + 0x0004003d,0x00000006,0x00000071,0x00000070,0x00060050,0x0000001a,0x00000072,0x00000071, + 0x00000071,0x00000071,0x00050081,0x0000001a,0x00000073,0x0000006d,0x00000072,0x00060050, + 0x0000001a,0x00000074,0x0000002d,0x0000002d,0x0000002d,0x00060050,0x0000001a,0x00000075, + 0x0000000e,0x0000000e,0x0000000e,0x0008000c,0x0000001a,0x00000076,0x00000001,0x0000002b, + 0x00000073,0x00000074,0x00000075,0x0003003e,0x0000005e,0x00000076,0x0004003d,0x0000001a, + 0x00000077,0x0000005e,0x00060050,0x0000001a,0x00000079,0x00000078,0x00000078,0x00000078, + 0x00050083,0x0000001a,0x0000007a,0x00000077,0x00000079,0x00050041,0x0000006f,0x0000007c, + 0x00000013,0x0000007b,0x0004003d,0x00000006,0x0000007d,0x0000007c,0x00050081,0x00000006, + 0x0000007e,0x0000007d,0x0000000e,0x0008000c,0x00000006,0x00000080,0x00000001,0x0000002b, + 0x0000007e,0x00000078,0x0000007f,0x0005008e,0x0000001a,0x00000081,0x0000007a,0x00000080, + 0x00060050,0x0000001a,0x00000082,0x00000078,0x00000078,0x00000078,0x00050081,0x0000001a, + 0x00000083,0x00000081,0x00000082,0x0003003e,0x0000005e,0x00000083,0x0004003d,0x0000001a, + 0x00000085,0x0000005e,0x00050094,0x00000006,0x0000008a,0x00000085,0x00000089,0x00060050, + 0x0000001a,0x0000008b,0x0000008a,0x0000008a,0x0000008a,0x0003003e,0x00000084,0x0000008b, + 0x0004003d,0x0000001a,0x0000008c,0x00000084,0x0004003d,0x0000001a,0x0000008d,0x0000005e, + 0x00050041,0x0000006f,0x0000008f,0x00000013,0x0000008e,0x0004003d,0x00000006,0x00000090, + 0x0000008f,0x0008000c,0x00000006,0x00000091,0x00000001,0x0000002b,0x00000090,0x0000002d, + 0x0000007f,0x00060050,0x0000001a,0x00000092,0x00000091,0x00000091,0x00000091,0x0008000c, + 0x0000001a,0x00000093,0x00000001,0x0000002e,0x0000008c,0x0000008d,0x00000092,0x0003003e, + 0x0000005e,0x00000093,0x0004003d,0x0000001a,0x00000094,0x0000005e,0x0007000c,0x0000001a, + 0x00000095,0x00000001,0x00000028,0x00000094,0x00000060,0x0003003e,0x0000005e,0x00000095, + 0x0004003d,0x0000001a,0x00000096,0x0000005e,0x00050041,0x0000006f,0x00000098,0x00000013, + 0x00000097,0x0004003d,0x00000006,0x00000099,0x00000098,0x00050088,0x00000006,0x0000009a, + 0x0000000e,0x00000099,0x00060050,0x0000001a,0x0000009b,0x0000009a,0x0000009a,0x0000009a, + 0x0007000c,0x0000001a,0x0000009c,0x00000001,0x0000001a,0x00000096,0x0000009b,0x0003003e, + 0x0000005e,0x0000009c,0x0004003d,0x0000001a,0x0000009f,0x0000005e,0x00050051,0x00000006, + 0x000000a0,0x0000009f,0x00000000,0x00050051,0x00000006,0x000000a1,0x0000009f,0x00000001, + 0x00050051,0x00000006,0x000000a2,0x0000009f,0x00000002,0x00070050,0x00000010,0x000000a3, + 0x000000a0,0x000000a1,0x000000a2,0x0000000e,0x0003003e,0x0000009e,0x000000a3,0x000100fd, + 0x00010038 +}; diff --git a/app/src/main/cpp/shaders/upscale.vert b/app/src/main/cpp/shaders/upscale.vert new file mode 100644 index 0000000000..0be0bed0ab --- /dev/null +++ b/app/src/main/cpp/shaders/upscale.vert @@ -0,0 +1,23 @@ +#version 450 + +// Full-screen / sub-rect quad for the spatial-upscaler post passes (SGSR, FSR +// EASU/RCAS). Identical quad generation to window.vert, but the push-constant +// block is declared as a single vec4 `ndc` so it matches the leading member of +// the upscaler fragment shaders' push-constant blocks (cross-stage layout must +// agree). gl_VertexIndex 0..3 over a TRIANGLE_STRIP -> the rect; fragTexCoord +// spans [0,1] across that rect (= normalised output position). + +layout(push_constant) uniform PC { + vec4 ndc; // (x0, y0, x1, y1) destination rect in NDC +} pc; + +layout(location = 0) out vec2 fragTexCoord; + +void main() { + int xi = (gl_VertexIndex >> 1) & 1; + int yi = gl_VertexIndex & 1; + float x = xi == 1 ? pc.ndc.z : pc.ndc.x; + float y = yi == 1 ? pc.ndc.w : pc.ndc.y; + gl_Position = vec4(x, y, 0.0, 1.0); + fragTexCoord = vec2(float(xi), float(yi)); +} diff --git a/app/src/main/cpp/waylandcomp/src/ahb_swapchain.c b/app/src/main/cpp/waylandcomp/src/ahb_swapchain.c index c31915a45b..e91dfe7bcc 100644 --- a/app/src/main/cpp/waylandcomp/src/ahb_swapchain.c +++ b/app/src/main/cpp/waylandcomp/src/ahb_swapchain.c @@ -7,6 +7,7 @@ #include "droiddeck-ahb-v1-server-protocol.h" #include #include +#include #include #include #include @@ -133,10 +134,10 @@ static void handle_released(uint64_t id, int fd) { if (fd >= 0) { struct droiddeck_dma_buf_sync_file imp = {.flags = DROIDDECK_DMA_BUF_SYNC_READ, .fd = fd}; int dmabuf_fd = droiddeck_dmabuf_fd(ab->b); - if (!ab->display && dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &imp) == 0) { + if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &imp) == 0) { close(fd); } else { - if (!ab->display && !g_import_failed_logged) { + if (!g_import_failed_logged) { g_import_failed_logged = 1; droiddeck_log("layer", "zero-copy: DMA_BUF_IOCTL_IMPORT_SYNC_FILE failed (%s): releases wait for the display's fence here instead", strerror(errno)); @@ -145,6 +146,12 @@ static void handle_released(uint64_t id, int fd) { if (poll(&p, 1, 0) > 0) { close(fd); } 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_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; } @@ -152,6 +159,7 @@ static void handle_released(uint64_t id, int fd) { } } } + if (ab->fence_src) return; send_deferred_release(ab); maybe_free(ab); } diff --git a/app/src/main/cpp/waylandcomp/src/blend_pass.c b/app/src/main/cpp/waylandcomp/src/blend_pass.c index 9a4d48d0b8..5da97deaae 100644 --- a/app/src/main/cpp/waylandcomp/src/blend_pass.c +++ b/app/src/main/cpp/waylandcomp/src/blend_pass.c @@ -133,6 +133,24 @@ static void objects_destroy(void) { g_dsl = VK_NULL_HANDLE; g_sampler = VK_NULL_HANDLE; } +void blendp_destroy(void) { + if (g_dev) { + for (int i = 0; i < NSRC; i++) src_release(i); + for (int i = 0; i < NDST; i++) dst_release(i); + for (int i = 0; i < NFMT; i++) { + if (g_out[i].pipe) g_vk.DestroyPipeline(g_dev, g_out[i].pipe, NULL); + if (g_out[i].rp) g_vk.DestroyRenderPass(g_dev, g_out[i].rp, NULL); + } + objects_destroy(); + } + memset(g_src, 0, sizeof(g_src)); + memset(g_dst, 0, sizeof(g_dst)); + memset(g_out, 0, sizeof(g_out)); + g_ready = 0; + g_frame = 1; + g_dev = VK_NULL_HANDLE; +} + static int objects_ensure(void) { if (g_ready) return g_ready == 1 ? 0 : -1; g_ready = -1; diff --git a/app/src/main/cpp/waylandcomp/src/blend_pass.h b/app/src/main/cpp/waylandcomp/src/blend_pass.h index d6f5a8fff2..9b3a56b879 100644 --- a/app/src/main/cpp/waylandcomp/src/blend_pass.h +++ b/app/src/main/cpp/waylandcomp/src/blend_pass.h @@ -4,6 +4,7 @@ #include void blendp_bind_device(VkDevice dev); +void blendp_destroy(void); void blendp_forget_image(VkImage img); void blendp_begin_frame(void); diff --git a/app/src/main/cpp/waylandcomp/src/cardboard.c b/app/src/main/cpp/waylandcomp/src/cardboard.c index 982c3bc47c..2c8c7120e1 100644 --- a/app/src/main/cpp/waylandcomp/src/cardboard.c +++ b/app/src/main/cpp/waylandcomp/src/cardboard.c @@ -311,6 +311,16 @@ static void objects_destroy(void) { g_dsl = VK_NULL_HANDLE; g_sampler = VK_NULL_HANDLE; g_rp = VK_NULL_HANDLE; } +void vkp_cardboard_destroy(void) { + if (g_dev) objects_destroy(); + g_dev = VK_NULL_HANDLE; + g_ready = 0; + memset(&g_t, 0, sizeof(g_t)); + memset(g_src, 0, sizeof(g_src)); + g_nsrc = 0; + memset(&g_mp, 0, sizeof(g_mp)); +} + static int objects_ensure(void) { if (g_ready) return g_ready == 1 ? 0 : -1; if (!g_dev || !g_vk.CreateGraphicsPipelines) goto fail; diff --git a/app/src/main/cpp/waylandcomp/src/cardboard.h b/app/src/main/cpp/waylandcomp/src/cardboard.h index 2950faec2f..c659661540 100644 --- a/app/src/main/cpp/waylandcomp/src/cardboard.h +++ b/app/src/main/cpp/waylandcomp/src/cardboard.h @@ -26,6 +26,7 @@ void vkp_cardboard_set_pose_file(const char *path); void vkp_cardboard_set_render_height(int height); void vkp_cardboard_bind_device(VkDevice dev, const VkPhysicalDeviceMemoryProperties *memprops); +void vkp_cardboard_destroy(void); int vkp_cardboard_active(void); int vkp_cardboard_source(void); int vkp_cardboard_pose_changed(void); diff --git a/app/src/main/cpp/waylandcomp/src/compositor.c b/app/src/main/cpp/waylandcomp/src/compositor.c index 3cb6e5746b..03f33894cb 100644 --- a/app/src/main/cpp/waylandcomp/src/compositor.c +++ b/app/src/main/cpp/waylandcomp/src/compositor.c @@ -237,10 +237,15 @@ struct surface { int drawn; int64_t next_release_ns; int releases_pending; + int release_pace_open; enum surface_role role; struct wl_resource *idle_buffer; struct wl_listener idle_buffer_destroy; + struct surface_state *waiting; + struct wl_event_source *waiting_source, *waiting_timer; + int waiting_fd; + int64_t waiting_since_ns; uint32_t *idle_px; int idle_w, idle_h; struct wl_resource *xdg_surface, *xdg_toplevel; @@ -288,6 +293,7 @@ static int g_scene_queues; static int g_tick_held; static int64_t g_hold_missed_ns; #define HOLD_RETRY_NS 1000000000LL +#define RELEASE_PACE_DEPTH 8 #define PACE_BUFFERS 32 static struct { unsigned ticks, ticks_late_2ms, renders, commit_renders, null_attaches, reattaches, presented, replaced, undrawn, distinct; @@ -371,6 +377,8 @@ static struct { unsigned copy_scenes; unsigned releases, releases_held; int64_t release_ns, release_max_ns; + unsigned commit_waits, commit_wait_limits; + int64_t commit_wait_ns, commit_wait_max_ns; } g_perf; static void schedule_render(void); @@ -548,13 +556,25 @@ static int on_release_timer(int fd, uint32_t mask, void *data) { return 0; } +static void describe(const struct surface *s, char *out, size_t size); + static void release_buffer(struct surface *s, struct wl_resource *buffer, int64_t since_ns, struct surface *holder) { /* No allocation or immediate-release fallback is allowed for a quarantined * DMA-BUF. Existing queued releases stay held; their timer is disarmed. */ if (buffer_release_blocked(buffer)) return; const int limit = g_fps_limit; const int64_t interval = limit > 0 ? 1000000000LL / limit : g_refresh_ns; - const int paced = !g_release_unpaced && interval > 0 && g_release_timer_fd >= 0; + int paced = !g_release_unpaced && interval > 0 && g_release_timer_fd >= 0; + if (paced && s->releases_pending >= RELEASE_PACE_DEPTH) { + paced = 0; + if (!s->release_pace_open) { + char name[160]; + describe(s, name, sizeof(name)); + droiddeck_log("pace", "%s keeps drawing into new buffers instead of waiting for releases: " + "its releases beyond %d are no longer held for the frame limit", name, RELEASE_PACE_DEPTH); + s->release_pace_open = 1; + } + } if (!paced && !holder) { send_buffer_release(buffer); perf_note_release(since_ns); return; } int64_t now = now_ns(); int64_t at = now; @@ -682,6 +702,8 @@ static struct surface *g_key_target; static struct surface *g_ime_click; static int g_input_pipe[2] = {-1, -1}; struct input_msg { int type; int p1; int p2; int p3; int p4; }; +static atomic_int g_zoom_request_percent = 100; +static atomic_int g_zoom_request_pending = 0; struct surface; static void constraints_surface_gone(struct surface *s); @@ -830,6 +852,55 @@ static void on_pending_buffer_destroyed(struct wl_listener *l, void *data) { s->pending_buffer = NULL; } +struct surface_state { + struct wl_resource *buffer; + struct wl_listener buffer_destroy; + int attach; + int src_set, dst_set, opaque_set; + float src[4]; + int dst[2], opaque[4]; + struct damage_list damage_buf, damage_local; + struct wl_list frames, feedback; +}; + +static void on_state_buffer_destroyed(struct wl_listener *l, void *data) { + struct surface_state *st = wl_container_of(l, st, buffer_destroy); + wl_list_remove(&st->buffer_destroy.link); + wl_list_init(&st->buffer_destroy.link); + st->buffer = NULL; + st->attach = 0; +} + +static void surface_state_take(struct surface *s, struct surface_state *st) { + st->attach = s->pending_attach; + st->buffer = s->pending_buffer; + wl_list_init(&st->buffer_destroy.link); + if (st->buffer) { + wl_list_remove(&s->pending_buffer_destroy.link); + wl_list_init(&s->pending_buffer_destroy.link); + st->buffer_destroy.notify = on_state_buffer_destroyed; + wl_resource_add_destroy_listener(st->buffer, &st->buffer_destroy); + } + s->pending_buffer = NULL; + s->pending_attach = 0; + st->src_set = s->pending_src_set; + memcpy(st->src, s->pending_src, sizeof(st->src)); + st->dst_set = s->pending_dst_set; + memcpy(st->dst, s->pending_dst, sizeof(st->dst)); + st->opaque_set = s->pending_opaque_set; + memcpy(st->opaque, s->pending_opaque, sizeof(st->opaque)); + s->pending_src_set = s->pending_dst_set = s->pending_opaque_set = 0; + st->damage_buf = s->pending_damage_buf; + st->damage_local = s->pending_damage_local; + s->pending_damage_buf.n = s->pending_damage_local.n = 0; + wl_list_init(&st->frames); + wl_list_insert_list(&st->frames, &s->pending_frames); + wl_list_init(&s->pending_frames); + wl_list_init(&st->feedback); + wl_list_insert_list(&st->feedback, &s->pending_feedback); + wl_list_init(&s->pending_feedback); +} + static void fire_frames(struct wl_list *frames) { struct wl_resource *cb, *tmp; uint32_t t; @@ -1184,6 +1255,14 @@ static uint32_t nominal_refresh_ns(void) { return (uint32_t)(1000000000000LL / (int64_t)mhz); } +static uint32_t feedback_refresh_ns(void) { + const int limit = g_fps_limit; + const uint32_t panel = nominal_refresh_ns(); + if (limit <= 0 || g_release_unpaced) return panel; + const uint32_t paced = (uint32_t)(1000000000LL / limit); + return paced > panel ? paced : panel; +} + static int64_t presented_ns(int64_t render_ns) { int64_t tick = g_tick_vsync_ns; int64_t refresh = (int64_t)nominal_refresh_ns(); @@ -1202,7 +1281,7 @@ static void feedback_present_all(struct wl_list *list, int64_t t) { uint32_t nsec = (uint32_t)(t % 1000000000LL); wl_resource_for_each_safe(fb, tmp, list) { wp_presentation_feedback_send_presented(fb, (uint32_t)(sec >> 32), (uint32_t)sec, nsec, - nominal_refresh_ns(), 0, 0, + feedback_refresh_ns(), 0, 0, WP_PRESENTATION_FEEDBACK_KIND_VSYNC); wl_resource_destroy(fb); g_pace.presented++; @@ -1339,35 +1418,23 @@ static void surface_drop_idle(struct surface *s) { if (buffer) send_buffer_release(buffer); } -static void surface_commit(struct wl_client *c, struct wl_resource *r) { - struct surface *s = wl_resource_get_user_data(r); +static void surface_state_apply(struct surface *s, struct surface_state *st) { struct surface *child; - if (s->xdg_toplevel && !s->toplevel_committed) { - s->toplevel_committed = 1; - send_toplevel_configure(s); + if (st->src_set) { + s->src_set = st->src[2] > 0; + memcpy(s->src, st->src, sizeof(s->src)); } + if (st->dst_set) { + s->dst_set = st->dst[0] > 0; + memcpy(s->dst, st->dst, sizeof(s->dst)); + } + if (st->opaque_set) memcpy(s->opaque, st->opaque, sizeof(s->opaque)); - if (s->pending_src_set) { - s->src_set = s->pending_src[2] > 0; - memcpy(s->src, s->pending_src, sizeof(s->src)); - s->pending_src_set = 0; - } - if (s->pending_dst_set) { - s->dst_set = s->pending_dst[0] > 0; - memcpy(s->dst, s->pending_dst, sizeof(s->dst)); - s->pending_dst_set = 0; - } - if (s->pending_opaque_set) { - memcpy(s->opaque, s->pending_opaque, sizeof(s->opaque)); - s->pending_opaque_set = 0; - } - - s->damage_buf = s->pending_damage_buf; - s->damage_local = s->pending_damage_local; - s->pending_damage_buf.n = s->pending_damage_local.n = 0; - if (s->pending_attach) { - struct wl_resource *buffer = s->pending_buffer; + s->damage_buf = st->damage_buf; + s->damage_local = st->damage_local; + if (st->attach) { + struct wl_resource *buffer = st->buffer; struct dmabuf_buffer *db = get_dmabuf(buffer); struct wl_shm_buffer *shm = buffer && !db ? wl_shm_buffer_get(buffer) : NULL; uint8_t pixel[4]; @@ -1376,12 +1443,10 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) { if (!buffer) g_pace.null_attaches++; else if (!db) s->last_dmabuf = NULL; - if (buffer) { - wl_list_remove(&s->pending_buffer_destroy.link); - wl_list_init(&s->pending_buffer_destroy.link); - } - s->pending_buffer = NULL; - s->pending_attach = 0; + wl_list_remove(&st->buffer_destroy.link); + wl_list_init(&st->buffer_destroy.link); + st->buffer = NULL; + st->attach = 0; surface_drop_idle(s); buf_trace_attach(buffer); @@ -1418,10 +1483,10 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) { } } - wl_list_insert_list(s->frames.prev, &s->pending_frames); - wl_list_init(&s->pending_frames); - wl_list_insert_list(s->feedback.prev, &s->pending_feedback); - wl_list_init(&s->pending_feedback); + wl_list_insert_list(s->frames.prev, &st->frames); + wl_list_init(&st->frames); + wl_list_insert_list(s->feedback.prev, &st->feedback); + wl_list_init(&st->feedback); constraints_surface_commit(s); droiddeck_color_commit(s->resource); @@ -1431,6 +1496,186 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) { } schedule_render(); } + +#define COMMIT_WAIT_LIMIT_MS 1000 + +static struct surface *g_zero_copy_shown, *g_unwaited; + +static int state_unfinished_fd(const struct surface *s, const struct surface_state *st, int *unwaited) { + struct dmabuf_buffer *db = st->attach ? get_dmabuf(st->buffer) : NULL; + int fd = -1; + *unwaited = 0; + for (int i = 0; db && fd < 0 && i < db->n_planes; i++) { + if (db->fd[i] < 0) continue; + struct pollfd p = {.fd = db->fd[i], .events = POLLIN}; + int r; + do { r = poll(&p, 1, 0); } while (r < 0 && errno == EINTR); + if (r == 0) fd = db->fd[i]; + } + if (fd >= 0 && s == g_zero_copy_shown && ahb_swapchain_has_ahb(db)) { + *unwaited = 1; + return -1; + } + return fd; +} + +static void settle_unwaited(void) { + struct surface *s = g_unwaited; + if (!s) return; + g_unwaited = NULL; + struct dmabuf_buffer *db = s->dmabuf_buf; + const int64_t deadline = now_ns() + 100000000LL; + for (int i = 0; db && i < db->n_planes; i++) { + if (db->fd[i] < 0) continue; + struct pollfd p = {.fd = db->fd[i], .events = POLLIN}; + for (;;) { + const int64_t left = deadline - now_ns(); + const int r = poll(&p, 1, left > 0 ? (int)((left + 999999) / 1000000) : 0); + if (r >= 0 || errno != EINTR || left <= 0) break; + } + } +} + +static void surface_state_discard(struct surface_state *st) { + struct wl_resource *cb, *tmp; + wl_list_remove(&st->buffer_destroy.link); + wl_resource_for_each_safe(cb, tmp, &st->frames) wl_resource_destroy(cb); + feedback_discard_all(&st->feedback); + free(st); +} + +static void surface_state_merge(struct surface_state *older, struct surface_state *newer) { + if (older->attach && !newer->attach) { + newer->attach = 1; + newer->buffer = older->buffer; + wl_list_remove(&older->buffer_destroy.link); + wl_list_init(&older->buffer_destroy.link); + if (newer->buffer) { + newer->buffer_destroy.notify = on_state_buffer_destroyed; + wl_resource_add_destroy_listener(newer->buffer, &newer->buffer_destroy); + } + wl_list_insert_list(&newer->feedback, &older->feedback); + wl_list_init(&older->feedback); + } else if (older->attach) { + if (older->buffer && older->buffer != newer->buffer) send_buffer_release(older->buffer); + g_pace.replaced += feedback_discard_all(&older->feedback); + } + if (older->src_set && !newer->src_set) { + newer->src_set = 1; + memcpy(newer->src, older->src, sizeof(newer->src)); + } + if (older->dst_set && !newer->dst_set) { + newer->dst_set = 1; + memcpy(newer->dst, older->dst, sizeof(newer->dst)); + } + if (older->opaque_set && !newer->opaque_set) { + newer->opaque_set = 1; + memcpy(newer->opaque, older->opaque, sizeof(newer->opaque)); + } + for (int i = 0; i < older->damage_buf.n; i++) + note_damage(&newer->damage_buf, older->damage_buf.r[i][0], older->damage_buf.r[i][1], + older->damage_buf.r[i][2], older->damage_buf.r[i][3]); + for (int i = 0; i < older->damage_local.n; i++) + note_damage(&newer->damage_local, older->damage_local.r[i][0], older->damage_local.r[i][1], + older->damage_local.r[i][2], older->damage_local.r[i][3]); + wl_list_insert_list(&newer->frames, &older->frames); + wl_list_init(&older->frames); + surface_state_discard(older); +} + +static void surface_wait_stop(struct surface *s) { + if (s->waiting_source) wl_event_source_remove(s->waiting_source); + if (s->waiting_timer) wl_event_source_remove(s->waiting_timer); + if (s->waiting_fd >= 0) close(s->waiting_fd); + s->waiting_source = s->waiting_timer = NULL; + s->waiting_fd = -1; +} + +static void surface_wait_end(struct surface *s, int over_limit) { + struct surface_state *st = s->waiting; + if (!st) return; + surface_wait_stop(s); + s->waiting = NULL; + const int64_t waited = now_ns() - s->waiting_since_ns; + g_perf.commit_waits++; + g_perf.commit_wait_ns += waited; + if (waited > g_perf.commit_wait_max_ns) g_perf.commit_wait_max_ns = waited; + if (over_limit) g_perf.commit_wait_limits++; + if (st->attach && g_unwaited == s) g_unwaited = NULL; + surface_state_apply(s, st); + free(st); +} + +static int on_commit_ready(int fd, uint32_t mask, void *data) { + surface_wait_end(data, 0); + return 0; +} + +static int on_commit_wait_limit(void *data) { + static int said; + if (!said) { + said = 1; + droiddeck_log("compositor", "a client's GPU writes ran past %d ms; its frame is shown as it is", COMMIT_WAIT_LIMIT_MS); + } + surface_wait_end(data, 1); + return 0; +} + +static int surface_wait_start(struct surface *s, int fd, int timeout_ms) { + struct wl_event_loop *loop = wl_display_get_event_loop(g_display); + s->waiting_fd = fcntl(fd, F_DUPFD_CLOEXEC, 0); + if (s->waiting_fd >= 0) { + s->waiting_source = wl_event_loop_add_fd(loop, s->waiting_fd, WL_EVENT_READABLE, on_commit_ready, s); + s->waiting_timer = wl_event_loop_add_timer(loop, on_commit_wait_limit, s); + } + if (!s->waiting_source || !s->waiting_timer || + wl_event_source_timer_update(s->waiting_timer, timeout_ms) != 0) { + surface_wait_stop(s); + return -1; + } + return 0; +} + +static void surface_commit(struct wl_client *c, struct wl_resource *r) { + struct surface *s = wl_resource_get_user_data(r); + + if (s->xdg_toplevel && !s->toplevel_committed) { + s->toplevel_committed = 1; + send_toplevel_configure(s); + } + struct surface_state *st = calloc(1, sizeof(*st)); + if (!st) { + struct surface_state now; + surface_state_take(s, &now); + surface_state_apply(s, &now); + return; + } + surface_state_take(s, st); + const int was_waiting = s->waiting != NULL; + if (was_waiting) { + surface_wait_stop(s); + surface_state_merge(s->waiting, st); + s->waiting = NULL; + } + int unwaited; + const int fd = state_unfinished_fd(s, st, &unwaited); + if (!was_waiting) s->waiting_since_ns = now_ns(); + const int64_t left_ms = COMMIT_WAIT_LIMIT_MS - (now_ns() - s->waiting_since_ns) / 1000000; + if (fd >= 0 && left_ms > 0 && surface_wait_start(s, fd, (int)left_ms) == 0) { + s->waiting = st; + return; + } + const int attaches = st->attach; + if (was_waiting) { + s->waiting = st; + surface_wait_end(s, fd >= 0 && left_ms <= 0); + } else { + surface_state_apply(s, st); + free(st); + } + if (unwaited) g_unwaited = s; + else if (attaches && g_unwaited == s) g_unwaited = NULL; +} static void surface_set_buffer_transform(struct wl_client *c, struct wl_resource *r, int32_t t) {} static void surface_set_buffer_scale(struct wl_client *c, struct wl_resource *r, int32_t s) {} static void surface_damage_buffer(struct wl_client *c, struct wl_resource *r, @@ -1492,6 +1737,13 @@ static void surface_resource_destroy(struct wl_resource *r) { child->parent = NULL; } if (s->pending_buffer) wl_list_remove(&s->pending_buffer_destroy.link); + if (s->waiting) { + surface_wait_stop(s); + surface_state_discard(s->waiting); + s->waiting = NULL; + } + if (g_zero_copy_shown == s) g_zero_copy_shown = NULL; + if (g_unwaited == s) g_unwaited = NULL; pending_releases_forget_surface(s); drop_dmabuf(s, 0); ahb_swapchain_surface_gone(s); @@ -1555,6 +1807,7 @@ static void compositor_create_surface(struct wl_client *c, struct wl_resource *r wl_list_init(&s->child_link); wl_list_init(&s->toplevel_link); wl_list_init(&s->pending_buffer_destroy.link); + s->waiting_fd = -1; wl_list_init(&s->idle_buffer_destroy.link); wl_list_insert(&g_surfaces, &s->link); wl_resource_set_implementation(s->resource, &surface_impl, s, surface_resource_destroy); @@ -2478,7 +2731,13 @@ static int64_t scene_next_due(int64_t now, int64_t due, int limit) { static void render_scene(void) { g_scene_due_ns = scene_next_due(now_ns(), g_scene_due_ns, g_fps_limit); - if (atomic_load(&g_stream_on)) { g_dirty_since_ns = 0; render_stream(); return; } + if (atomic_load(&g_stream_on)) { + g_dirty_since_ns = 0; + g_zero_copy_shown = NULL; + settle_unwaited(); + render_stream(); + return; + } struct draw_list dl = {0}; struct surface *s; int w, h; @@ -2552,6 +2811,8 @@ static void render_scene(void) { } else { cursor_hdr_said = 0; } + g_zero_copy_shown = NULL; + if (hdr_route == 1 || hdr_route == 2) settle_unwaited(); if (hdr_route == 1) { static int fell_back; vkp_apply_window_request(); @@ -2585,6 +2846,7 @@ static void render_scene(void) { } if (hdr_route == 0 && vkp_quest_layer_presentation() && !framegen && !cardboard && !cursor_on && !ahb_only) { + settle_unwaited(); rendered = vkp_render(w, h, dl.d, dl.n) == 0; } else if (hdr_route == 0 || hdr_route == 3) { const int pass_on = fx_on || framegen; @@ -2634,6 +2896,7 @@ static void render_scene(void) { vkp_apply_window_request(); int r = -1; const int fg_pass = framegen && fx_on && li >= 0; + if (framegen && li >= 0) settle_unwaited(); const int generated = (framegen && li >= 0) ? sc_layer_present_generated(&dl.d[li], 1, NULL, w, h, fg_pass, ls ? droiddeck_surface_color(ls) : NULL) : 0; @@ -2647,6 +2910,8 @@ static void render_scene(void) { r = generated >= 0 ? 0 : -1; 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); + if (r == 0 && !fg_pass) g_zero_copy_shown = ls; + else settle_unwaited(); if (!fg_pass && generated >= 0 && r != 0 && li >= 0) r = fx_on ? sc_layer_present_pass(&dl.d[li], 1, w, h) : sc_layer_present(dl.d[li].img, w, h, ld, ls ? droiddeck_surface_color(ls) : NULL); @@ -2657,6 +2922,7 @@ static void render_scene(void) { 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) { + settle_unwaited(); sc_layer_hide(); rendered = vkp_render(w, h, dl.d, dl.n) == 0; copy = 1; @@ -2666,12 +2932,14 @@ static void render_scene(void) { g_scene_queues = sc_layer_queues(); } } else { + settle_unwaited(); sc_layer_hide(); rendered = vkp_render(w, h, dl.d, dl.n) == 0; copy = 1; hdr_copy = "its display layer was unavailable this frame"; } } else { + settle_unwaited(); sc_layer_hide(); rendered = vkp_render(w, h, dl.d, dl.n) == 0; copy = 1; @@ -3522,6 +3790,15 @@ static void pointer_input(double x, double y, int relative, uint32_t button, int if (k) confine_clamp(k, &x, &y); g_ptr_x = x; g_ptr_y = y; g_ptr_known = 1; + if (relative && !button && (dx != 0.0 || dy != 0.0)) { + int ow, oh; + double ox, oy; + vkp_output_size(&ow, &oh); + if (ow > 0 && oh > 0 && + vkp_scene_to_output(g_ptr_x, g_ptr_y, &ox, &oy) && + vkp_zoom_pan_cursor(ox, oy)) + schedule_render(); + } if (atomic_load(&g_cursor_composite)) schedule_render(); if (k) { target = k->surface; @@ -3590,15 +3867,38 @@ static void pointer_button(uint32_t button, int pressed) { } static void deliver_pointer(const struct input_msg *m) { + static int last_x, last_y, last_valid; int w, h, ow, oh; double x, y; + int moved = last_valid && (m->p2 != last_x || m->p3 != last_y); + last_x = m->p2; + last_y = m->p3; + last_valid = 1; scene_size(&w, &h); vkp_output_size(&ow, &oh); - if (ow <= 0 || oh <= 0 || - !vkp_output_to_scene((double)m->p2 * ow / INPUT_SPACE_W, (double)m->p3 * oh / INPUT_SPACE_H, &x, &y)) { + + if (ow <= 0 || oh <= 0) { x = (double)m->p2 * w / INPUT_SPACE_W; y = (double)m->p3 * h / INPUT_SPACE_H; + } else { + double ox = (double)m->p2 * ow / INPUT_SPACE_W; + double oy = (double)m->p3 * oh / INPUT_SPACE_H; + if (m->p1 == 1 && !pointer_locked_for_cursor() && + (moved || ox <= 0.0 || oy <= 0.0 || ox >= ow || oy >= oh) && + vkp_zoom_pan_cursor(ox, oy)) + schedule_render(); + if (!vkp_output_to_scene(ox, oy, &x, &y)) { + schedule_render(); + if (g_ptr_known) { + x = g_ptr_x; + y = g_ptr_y; + } else { + x = (double)m->p2 * w / INPUT_SPACE_W; + y = (double)m->p3 * h / INPUT_SPACE_H; + } + } } + if (x < 0) x = 0; if (y < 0) y = 0; if (x > w - 1) x = w - 1; @@ -3610,6 +3910,7 @@ static void input_output_to_scene(double px, double py, double *x, double *y) { int w, h, ow, oh; scene_size(&w, &h); vkp_output_size(&ow, &oh); + if (ow <= 0 || oh <= 0 || !vkp_output_to_scene(px * ow / INPUT_SPACE_W, py * oh / INPUT_SPACE_H, x, y)) { *x = px * w / INPUT_SPACE_W; @@ -3833,12 +4134,63 @@ static void touch_up(int id, double x, double y) { } static void deliver_touch(const struct input_msg *m) { + static int last_x[MAX_TOUCH_POINTS], last_y[MAX_TOUCH_POINTS]; + static int pan_start_x[MAX_TOUCH_POINTS], pan_start_y[MAX_TOUCH_POINTS]; + static unsigned char last_valid[MAX_TOUCH_POINTS]; + static unsigned char pan_started[MAX_TOUCH_POINTS]; double x, y; + int id = m->p2; + int valid_id = id >= 0 && id < MAX_TOUCH_POINTS; + + if (valid_id && m->p1 == 0) { + pan_start_x[id] = m->p3; + pan_start_y[id] = m->p4; + pan_started[id] = 0; + } + if (valid_id && g_touch_points[id].surface && + m->p1 == 1 && last_valid[id] && !pan_started[id]) { + int dx = m->p3 - pan_start_x[id]; + int dy = m->p4 - pan_start_y[id]; + if (dx * dx + dy * dy >= 400) + pan_started[id] = 1; + } + if (valid_id && g_touch_points[id].surface && + m->p1 == 1 && pan_started[id] && last_valid[id] && + (m->p3 != last_x[id] || m->p4 != last_y[id])) { + int ow, oh; + vkp_output_size(&ow, &oh); + if (ow > 0 && oh > 0 && + vkp_zoom_pan_cursor((double)m->p3 * ow / INPUT_SPACE_W, + (double)m->p4 * oh / INPUT_SPACE_H)) + schedule_render(); + } + input_output_to_scene(m->p3, m->p4, &x, &y); - if (m->p1 == 0) touch_down(m->p2, x, y); - else if (m->p1 == 1) touch_motion(m->p2, x, y); - else if (m->p1 == 2) touch_up(m->p2, x, y); - else if (m->p1 == 3) touch_cancel_all(); + if (m->p1 == 0) { + if (valid_id) { + last_x[id] = m->p3; + last_y[id] = m->p4; + last_valid[id] = 1; + } + touch_down(id, x, y); + } else if (m->p1 == 1) { + if (valid_id) { + last_x[id] = m->p3; + last_y[id] = m->p4; + last_valid[id] = 1; + } + touch_motion(id, x, y); + } else if (m->p1 == 2) { + touch_up(id, x, y); + if (valid_id) { + last_valid[id] = 0; + pan_started[id] = 0; + } + } else if (m->p1 == 3) { + touch_cancel_all(); + memset(last_valid, 0, sizeof(last_valid)); + memset(pan_started, 0, sizeof(pan_started)); + } publish_query_state(); } @@ -4045,12 +4397,20 @@ static int on_input_readable(int fd, uint32_t mask, void *data) { case 11: axis_event(m.p1, m.p2, 0); break; case 12: axis_event(m.p1, m.p2, 1); break; case 13: deliver_pen(&m); break; + case 14: + atomic_store(&g_zoom_request_pending, 1); + break; case 20: stream_take(); break; case 21: if (!m.p1) stream_forget_all(); schedule_render(); break; case 22: schedule_render(); break; default: deliver_pointer(&m); break; } } + if (atomic_exchange(&g_zoom_request_pending, 0)) { + int zoom_percent = atomic_load(&g_zoom_request_percent); + vk_present_set_zoom((float)zoom_percent / 100.0f); + schedule_render(); + } if (atomic_exchange(&g_output_refresh_pending, 0) && atomic_load(&g_output_refresh_mhz) != g_output_announced_refresh_mhz) { output_notify_mode(); @@ -4074,6 +4434,23 @@ void droiddeck_wayland_set_scale_mode(int mode, int alignment) { (void)n; } +void droiddeck_wayland_set_zoom(int zoom_percent) { + if (zoom_percent < 100) zoom_percent = 100; + if (zoom_percent > 300) zoom_percent = 300; + if (g_input_pipe[1] < 0) { + vk_present_set_zoom((float)zoom_percent / 100.0f); + return; + } + atomic_store(&g_zoom_request_percent, zoom_percent); + atomic_store(&g_zoom_request_pending, 1); + struct input_msg m = { 14, zoom_percent, 0, 0, 0 }; + ssize_t n; + do { + n = write(g_input_pipe[1], &m, sizeof(m)); + } while (n < 0 && errno == EINTR); + (void)n; +} + void droiddeck_wayland_send_pointer(int action, int x, int y) { if (g_input_pipe[1] < 0) return; struct input_msg m = { 0, action, x, y, 0 }; @@ -4211,11 +4588,12 @@ static int on_stats_timer(void *data) { unsigned aimed_next, aimed_later, aimed_even; sc_layer_aim_take(&aimed_next, &aimed_later, &aimed_even); #define PERF_MS(sum, n) ((n) ? (double)(sum) / 1e6 / (double)(n) : 0.0) - if (g_perf.scenes || vp.presents || g_perf.releases || drops) + if (g_perf.scenes || vp.presents || g_perf.releases || drops || g_perf.commit_waits) droiddeck_log("perf", "last 10 s: %u ticks, %u scenes, %u on screen (copy %u, zero-copy %u, layer copy %u) | " "render_scene %.2f/%.2f ms | base %u black kept, %u presented | acquire %.2f/%.2f ms | " "present %.2f/%.2f ms (%u) | fence wait %.2f/%.2f ms (%u, %u GPU release waits) | " - "release %.2f/%.2f ms (%u, %u held) | %u pool drops | layer frames timed for the next refresh %u, " + "release %.2f/%.2f ms (%u, %u held) | commits held for client writes %.2f/%.2f ms (%u, %u past the limit) | " + "%u pool drops | layer frames timed for the next refresh %u, " "the one after %u, held to an even step %u", g_perf.ticks, g_perf.scenes, g_stat_frames, g_perf.copy_scenes, zero_copy, layer_frames, PERF_MS(g_perf.scene_ns, g_perf.scenes), (double)g_perf.scene_max_ns / 1e6, @@ -4224,7 +4602,9 @@ static int on_stats_timer(void *data) { PERF_MS(vp.present_ns, vp.presents), (double)vp.present_max_ns / 1e6, vp.presents, PERF_MS(vp.wait_ns, vp.waits), (double)vp.wait_max_ns / 1e6, vp.waits, vp.gpu_release_waits, PERF_MS(g_perf.release_ns, g_perf.releases), (double)g_perf.release_max_ns / 1e6, - g_perf.releases, g_perf.releases_held, drops, aimed_next, aimed_later, aimed_even); + g_perf.releases, g_perf.releases_held, + PERF_MS(g_perf.commit_wait_ns, g_perf.commit_waits), (double)g_perf.commit_wait_max_ns / 1e6, + g_perf.commit_waits, g_perf.commit_wait_limits, drops, aimed_next, aimed_later, aimed_even); #undef PERF_MS memset(&g_perf, 0, sizeof(g_perf)); } diff --git a/app/src/main/cpp/waylandcomp/src/effects_chain.c b/app/src/main/cpp/waylandcomp/src/effects_chain.c index 385a46b322..a94d7b7906 100644 --- a/app/src/main/cpp/waylandcomp/src/effects_chain.c +++ b/app/src/main/cpp/waylandcomp/src/effects_chain.c @@ -3,6 +3,7 @@ #include "blend_pass.h" #include "vk_loader.h" #include "vk_present.h" +#include "framegen_bridge.h" #include #include #include @@ -17,12 +18,28 @@ #include "cas_frag.h" #include "color_frag.h" #include "fxaa_frag.h" -#include "smaa_frag.h" +#include "fxaa_toon_frag.h" +#include "smaa_edge_frag.h" +#include "smaa_weights_frag.h" +#include "smaa_blend_frag.h" #include "toon_frag.h" +#include "toon_color_frag.h" #include "hdr_frag.h" #include "ntsc_frag.h" #include "crt_frag.h" #include "deband_frag.h" +/* Half-precision upscaler/CAS set (shaders/gen_shaders.sh -DDD_HALF=1), ported from Bannerlator. */ +#include "sgsr_half_frag.h" +#include "sgsr_quality_half_frag.h" +#include "nis_luma_half_frag.h" +#include "nis3_half_frag.h" +#include "nis_coef.h" +#include "fsr_easu_half_frag.h" +#include "fsr_rcas_half_frag.h" +#include "cas_ffx_half_frag.h" +#ifdef __ANDROID__ +#include +#endif #define FX_FORMAT VK_FORMAT_R8G8B8A8_UNORM @@ -30,6 +47,7 @@ static VkFormat g_fx_fmt = FX_FORMAT, g_scene_fmt = FX_FORMAT; +static int g_scene_is_pq; #define FX_MAX_DIM 4096 @@ -52,6 +70,7 @@ static struct fx_settings g_set = { .gamma = 1.0f, .saturation = 1.0f, .s_raw = 100.0f, .look = "Off"}; static volatile int g_changed; static struct fx_settings g_cur; +static struct fx_settings g_generated_settings; static int g_cur_valid; static void set_begin(void) { pthread_mutex_lock(&g_lock); } @@ -104,10 +123,12 @@ static const char *scaling_name(int m) { } static int spatial_mode(int m) { return m >= 3 && m <= 8; } static int cas_active(const struct fx_settings *s) { return s->cas_on && s->cas_pct > 0; } +static int deband_active(const struct fx_settings *s) { return s->deband_on && s->deband_pct > 0; } static int effect_count(const struct fx_settings *s) { - return (s->aa_mode != 0) + s->toon + s->color_on + cas_active(s) + s->hdr_on + s->ntsc + s->crt + s->deband_on; + return (s->aa_mode != 0) + s->toon + s->color_on + cas_active(s) + s->hdr_on + s->ntsc + s->crt + deband_active(s); } + static void log_settings(const struct fx_settings *s) { char line[400]; int n; @@ -129,7 +150,7 @@ static void log_settings(const struct fx_settings *s) { if (s->hdr_on) n += snprintf(line + n, sizeof(line) - n, ", HDR on"); if (s->ntsc) n += snprintf(line + n, sizeof(line) - n, ", NTSC on"); if (s->crt) n += snprintf(line + n, sizeof(line) - n, ", CRT on"); - if (s->deband_on) n += snprintf(line + n, sizeof(line) - n, ", Deband on %d%%", s->deband_pct); + if (deband_active(s)) n += snprintf(line + n, sizeof(line) - n, ", Deband on %d%%", s->deband_pct); (void)n; droiddeck_log("effects", "%s", line); } @@ -176,6 +197,11 @@ struct pc_easu { float ndc[4]; uint32_t con0[4], con1[4], con2[4], con3[4]; flo 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_color { float ndc[4]; float b, c, g, s; }; +struct pc_toon_color { + float ndc[4]; float res[2]; float b, c, g, s; +}; +_Static_assert(sizeof(struct pc_toon_color) == 40, + "toon_color push constants layout mismatch"); #define PC_MAX_SIZE sizeof(struct pc_easu) static uint32_t packf(float f) { uint32_t u; memcpy(&u, &f, 4); return u; } @@ -204,17 +230,39 @@ static VkDevice g_dev; static VkPhysicalDevice g_pd; static VkPhysicalDeviceMemoryProperties g_mp; static int g_ready; -static VkRenderPass g_rp; +static VkRenderPass g_rp, g_smaa_rp; static VkDescriptorSetLayout g_dsl; static VkPipelineLayout g_pl; static VkDescriptorPool g_dpool; static VkSampler g_sampler; -enum { P_SGSR, P_SGSR_HQ, P_NIS, P_EASU, P_RCAS, P_CAS, P_COLOR, P_FXAA, P_SMAA, P_TOON, P_HDR, P_NTSC, P_CRT, P_DEBAND, P_COUNT }; +enum { P_SGSR, P_SGSR_HQ, P_NIS, P_EASU, P_RCAS, P_CAS, P_COLOR, P_FXAA, P_FXAA_TOON, P_SMAA_EDGE, P_SMAA_WEIGHTS, P_SMAA_BLEND, P_TOON, P_TOON_COLOR, P_HDR, P_NTSC, P_CRT, P_DEBAND, P_NIS_LUMA, P_COUNT }; static VkPipeline g_pipe[P_COUNT]; -static struct fx_target g_t[2], g_mid; +struct fx_context { + struct fx_target targets[2], mid, nissrc; + struct { VkImage img; VkImageView view; VkDescriptorSet ds; int w, h; } scene; +}; +#define FX_CONTEXTS (VKP_FG_MAX_GENERATIONS + 2) +static struct fx_context g_contexts[FX_CONTEXTS]; +static int g_context; +#define g_t (g_contexts[g_context].targets) +#define g_mid (g_contexts[g_context].mid) +#define g_nissrc (g_contexts[g_context].nissrc) +static struct fx_target g_smaa_edges, g_smaa_weights; +/* 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 + * at descriptor set 1 (g_pl_nis = {g_dsl, g_coef_dsl}, same push-constant range as g_pl). + * Old set (or no buffer): nis.frag on the scene, P_NIS_LUMA unused. */ +static int g_nis_fast; +static int g_nis_attempted; +static int g_upscale_half; +static VkDescriptorSetLayout g_coef_dsl; +static VkPipelineLayout g_pl_nis; +static VkDescriptorPool g_coef_pool; +static VkDescriptorSet g_coef_ds; +static VkBuffer g_coef_buf; +static VkDeviceMemory g_coef_mem; -static struct { VkImage img; VkImageView view; VkDescriptorSet ds; int w, h; } g_scene; -static uint32_t g_ntsc_frame; +#define g_scene (g_contexts[g_context].scene) void vkp_effects_bind_device(VkDevice dev, VkPhysicalDevice pd, const VkPhysicalDeviceMemoryProperties *memprops) { @@ -260,15 +308,20 @@ static void target_destroy(struct fx_target *t) { memset(t, 0, sizeof(*t)); } -static int target_ensure(struct fx_target *t, int w, int h, const char *what) { +#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) +#define FX_SCRATCH_USAGE (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT) + +static int target_ensure_format(struct fx_target *t, int w, int h, + VkImageUsageFlags usage, const char *what, + VkFormat format, VkRenderPass render_pass) { if (t->img && t->w == w && t->h == h) return 0; target_destroy(t); VkImageCreateInfo ii = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, .imageType = VK_IMAGE_TYPE_2D, - .format = g_fx_fmt, .extent = {(uint32_t)w, (uint32_t)h, 1}, .mipLevels = 1, + .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, - .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | - VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, + .usage = usage, .sharingMode = VK_SHARING_MODE_EXCLUSIVE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED}; VkResult r = g_vk.CreateImage(g_dev, &ii, NULL, &t->img); if (r != VK_SUCCESS) { droiddeck_log("error", "effects: %s image %dx%d: vkCreateImage %d", what, w, h, (int)r); return -1; } @@ -285,8 +338,8 @@ static int target_ensure(struct fx_target *t, int w, int h, const char *what) { target_destroy(t); return -1; } g_vk.BindImageMemory(g_dev, t->img, t->mem, 0); - if (!(t->view = make_view(t->img, g_fx_fmt))) { target_destroy(t); return -1; } - VkFramebufferCreateInfo fi = {.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .renderPass = g_rp, + 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, .attachmentCount = 1, .pAttachments = &t->view, .width = (uint32_t)w, .height = (uint32_t)h, .layers = 1}; if (g_vk.CreateFramebuffer(g_dev, &fi, NULL, &t->fb) != VK_SUCCESS) { target_destroy(t); return -1; } @@ -295,6 +348,11 @@ static int target_ensure(struct fx_target *t, int w, int h, const char *what) { return 0; } +static int target_ensure(struct fx_target *t, int w, int h, + VkImageUsageFlags usage, const char *what) { + return target_ensure_format(t, w, h, usage, what, g_fx_fmt, g_rp); +} + static void scene_release(void) { if (g_scene.ds) g_vk.FreeDescriptorSets(g_dev, g_dpool, 1, &g_scene.ds); if (g_scene.view) g_vk.DestroyImageView(g_dev, g_scene.view, NULL); @@ -302,7 +360,15 @@ static void scene_release(void) { } void vkp_effects_forget_image(VkImage img) { - if (img && g_scene.img == img) scene_release(); + int saved = g_context; + for (g_context = 0; g_context < FX_CONTEXTS; g_context++) + if (img && g_scene.img == img) scene_release(); + g_context = saved; +} + +void vkp_effects_release_generated_sources(void) { + for (g_context = 1; g_context < FX_CONTEXTS; g_context++) scene_release(); + g_context = 0; } static int scene_ensure(VkImage img, int w, int h) { @@ -321,7 +387,9 @@ static VkShaderModule shader(const uint32_t *code, size_t size) { return m; } -static VkPipeline post_pipeline(VkShaderModule vert, const uint32_t *frag_code, size_t frag_size, const char *name) { +static VkPipeline post_pipeline_for_renderpass(VkShaderModule vert, + const uint32_t *frag_code, size_t frag_size, VkRenderPass render_pass, + const char *name, VkPipelineLayout layout) { VkShaderModule frag = shader(frag_code, frag_size); if (!frag) { droiddeck_log("error", "effects: %s: vkCreateShaderModule failed", name); return VK_NULL_HANDLE; } VkPipelineShaderStageCreateInfo st[2] = { @@ -346,8 +414,8 @@ static VkPipeline post_pipeline(VkShaderModule vert, const uint32_t *frag_code, VkGraphicsPipelineCreateInfo pi = {.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, .stageCount = 2, .pStages = st, .pVertexInputState = &vi, .pInputAssemblyState = &ia, .pViewportState = &vp, .pRasterizationState = &rs, .pMultisampleState = &ms, - .pColorBlendState = &cb, .pDynamicState = &ds, .layout = g_pl, - .renderPass = g_rp, .subpass = 0}; + .pColorBlendState = &cb, .pDynamicState = &ds, .layout = layout, + .renderPass = render_pass, .subpass = 0}; VkPipeline p = VK_NULL_HANDLE; VkResult r = g_vk.CreateGraphicsPipelines(g_dev, VK_NULL_HANDLE, 1, &pi, NULL, &p); g_vk.DestroyShaderModule(g_dev, frag, NULL); @@ -355,23 +423,103 @@ static VkPipeline post_pipeline(VkShaderModule vert, const uint32_t *frag_code, return p; } +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_buf) g_vk.DestroyBuffer(g_dev, g_coef_buf, NULL); + if (g_coef_mem) g_vk.FreeMemory(g_dev, g_coef_mem, NULL); + if (g_pl_nis) g_vk.DestroyPipelineLayout(g_dev, g_pl_nis, NULL); + if (g_coef_dsl) g_vk.DestroyDescriptorSetLayout(g_dev, g_coef_dsl, NULL); + g_coef_pool = VK_NULL_HANDLE; g_coef_ds = VK_NULL_HANDLE; g_coef_buf = VK_NULL_HANDLE; + g_coef_mem = VK_NULL_HANDLE; g_pl_nis = VK_NULL_HANDLE; g_coef_dsl = VK_NULL_HANDLE; +} + +/* nis3's coefficient banks: a 4 KB host-visible uniform buffer (scale then usm), filled once. 0 = ok. */ +static int coef_create(void) { + VkDescriptorSetLayoutBinding b = {.binding = 0, .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, + .descriptorCount = 1, .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT}; + VkDescriptorSetLayoutCreateInfo dli = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .bindingCount = 1, .pBindings = &b}; + if (g_vk.CreateDescriptorSetLayout(g_dev, &dli, NULL, &g_coef_dsl) != VK_SUCCESS) goto fail; + VkDescriptorSetLayout sets[2] = {g_dsl, g_coef_dsl}; + VkPushConstantRange pcr = {.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, .offset = 0, .size = PC_MAX_SIZE}; + VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 2, .pSetLayouts = sets, + .pushConstantRangeCount = 1, .pPushConstantRanges = &pcr}; + if (g_vk.CreatePipelineLayout(g_dev, &pli, NULL, &g_pl_nis) != VK_SUCCESS) goto fail; + VkBufferCreateInfo bci = {.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .size = 4096, + .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((char *)p + sizeof(kNisCoefScale), kNisCoefUsm, sizeof(kNisCoefUsm)); + g_vk.UnmapMemory(g_dev, g_coef_mem); + VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1}; + VkDescriptorPoolCreateInfo dpi = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, .maxSets = 1, .poolSizeCount = 1, .pPoolSizes = &ps}; + if (g_vk.CreateDescriptorPool(g_dev, &dpi, NULL, &g_coef_pool) != VK_SUCCESS) goto fail; + VkDescriptorSetAllocateInfo ai = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, .descriptorPool = g_coef_pool, + .descriptorSetCount = 1, .pSetLayouts = &g_coef_dsl}; + if (g_vk.AllocateDescriptorSets(g_dev, &ai, &g_coef_ds) != VK_SUCCESS) goto fail; + VkDescriptorBufferInfo bi = {.buffer = g_coef_buf, .offset = 0, .range = 4096}; + VkWriteDescriptorSet wr = {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstSet = g_coef_ds, .dstBinding = 0, + .descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, .pBufferInfo = &bi}; + g_vk.UpdateDescriptorSets(g_dev, 1, &wr, 0, NULL); + return 0; +fail: + coef_destroy(); + return -1; +} + +/* 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. */ +static int fx_alpha_holds_luma(VkFormat f) { + return f == VK_FORMAT_R8G8B8A8_UNORM || f == VK_FORMAT_B8G8R8A8_UNORM || + f == VK_FORMAT_R16G16B16A16_SFLOAT || f == VK_FORMAT_R16G16B16A16_UNORM; +} + +/* The half-precision upscaler set unless debug.droiddeck.upscale.shaders is "old" (the fp32 + * shaders, for A/B comparisons). */ +static int upscale_half_set(void) { +#ifdef __ANDROID__ + char v[PROP_VALUE_MAX] = {0}; + if (__system_property_get("debug.droiddeck.upscale.shaders", v) > 0 && strcmp(v, "old") == 0) return 0; +#endif + return 1; +} + static void objects_destroy(void) { if (!g_dev) return; - scene_release(); - target_destroy(&g_t[0]); target_destroy(&g_t[1]); target_destroy(&g_mid); + int saved = g_context; + for (g_context = 0; g_context < FX_CONTEXTS; g_context++) { + scene_release(); + target_destroy(&g_t[0]); target_destroy(&g_t[1]); target_destroy(&g_mid); + target_destroy(&g_nissrc); + } + g_context = saved; + target_destroy(&g_smaa_edges); target_destroy(&g_smaa_weights); 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_pl) g_vk.DestroyPipelineLayout(g_dev, g_pl, NULL); + coef_destroy(); if (g_dsl) g_vk.DestroyDescriptorSetLayout(g_dev, g_dsl, NULL); if (g_sampler) g_vk.DestroySampler(g_dev, g_sampler, NULL); + if (g_smaa_rp) g_vk.DestroyRenderPass(g_dev, g_smaa_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_sampler = VK_NULL_HANDLE; g_rp = 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_smaa_rp = VK_NULL_HANDLE; + g_nis_fast = 0; g_nis_attempted = 0; g_upscale_half = 0; g_ready = 0; } void vkp_effects_destroy(void) { objects_destroy(); g_dev = VK_NULL_HANDLE; } -void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt) { +void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt, int scene_is_pq) { + g_scene_is_pq = scene_is_pq != 0; if (target_fmt != g_fx_fmt) { if (g_ready) objects_destroy(); g_fx_fmt = target_fmt; @@ -384,7 +532,9 @@ void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt) { : target_fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? "the HDR picture for frame generation" : "the HDR composition's picture: PQ, or tone-mapped SDR with HDR output off"); } else if (scene_fmt != g_scene_fmt) { - scene_release(); + int saved = g_context; + for (g_context = 0; g_context < FX_CONTEXTS; g_context++) scene_release(); + g_context = saved; g_scene_fmt = scene_fmt; } } @@ -413,6 +563,12 @@ static int objects_ensure(void) { .subpassCount = 1, .pSubpasses = &sub, .dependencyCount = 2, .pDependencies = deps}; if (g_vk.CreateRenderPass(g_dev, &rci, NULL, &g_rp) != VK_SUCCESS) goto fail; + VkAttachmentDescription smaa_att = att; + smaa_att.format = FX_FORMAT; + VkRenderPassCreateInfo smaa_rci = rci; + smaa_rci.pAttachments = &smaa_att; + if (g_vk.CreateRenderPass(g_dev, &smaa_rci, NULL, &g_smaa_rp) != VK_SUCCESS) goto fail; + VkSamplerCreateInfo sci = {.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, .magFilter = VK_FILTER_LINEAR, .minFilter = VK_FILTER_LINEAR, .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST, .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, @@ -425,36 +581,21 @@ static int objects_ensure(void) { 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; VkPushConstantRange pcr = {.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, .offset = 0, .size = PC_MAX_SIZE}; - VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 1, .pSetLayouts = &g_dsl, + VkDescriptorSetLayout set_layouts[2] = {g_dsl, g_dsl}; + VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 2, .pSetLayouts = set_layouts, .pushConstantRangeCount = 1, .pPushConstantRanges = &pcr}; if (g_vk.CreatePipelineLayout(g_dev, &pli, NULL, &g_pl) != VK_SUCCESS) goto fail; - VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 8}; + VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, FX_CONTEXTS * 5 + 2}; VkDescriptorPoolCreateInfo dpi = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, - .flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, .maxSets = 8, + .flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, .maxSets = FX_CONTEXTS * 5 + 2, .poolSizeCount = 1, .pPoolSizes = &ps}; if (g_vk.CreateDescriptorPool(g_dev, &dpi, NULL, &g_dpool) != VK_SUCCESS) goto fail; - VkShaderModule vert = shader(upscale_vert_code, sizeof(upscale_vert_code)); - if (!vert) goto fail; -#define MK(slot, code, name) do { g_pipe[slot] = post_pipeline(vert, code, sizeof(code), name); if (!g_pipe[slot]) { g_vk.DestroyShaderModule(g_dev, vert, NULL); goto fail; } } while (0) - MK(P_SGSR, sgsr_code, "sgsr"); - MK(P_SGSR_HQ, sgsr_quality_code, "sgsr_quality"); - MK(P_NIS, nis_code, "nis"); - MK(P_EASU, fsr_easu_code, "fsr_easu"); - MK(P_RCAS, fsr_rcas_code, "fsr_rcas"); - MK(P_CAS, cas_code, "cas"); - MK(P_COLOR, color_code, "color"); - MK(P_FXAA, fxaa_code, "fxaa"); - MK(P_SMAA, smaa_code, "smaa"); - MK(P_TOON, toon_code, "toon"); - MK(P_HDR, hdr_code, "hdr"); - MK(P_NTSC, ntsc_code, "ntsc"); - MK(P_CRT, crt_code, "crt"); - MK(P_DEBAND, deband_code, "deband"); -#undef MK - g_vk.DestroyShaderModule(g_dev, vert, NULL); + g_upscale_half = upscale_half_set(); + g_nis_fast = 0; + g_nis_attempted = 0; g_ready = 1; - droiddeck_log("effects", "chain ready: 14 pipelines (SGSR, SGSR HQ, NIS, FSR EASU+RCAS, CAS, colour, FXAA, SMAA, Toon, HDR, NTSC, CRT, deband) on %s", vkp_gpu_name()); + droiddeck_log("effects", "shared resources ready on %s; effect pipelines are created when needed", vkp_gpu_name()); return 0; fail: objects_destroy(); @@ -463,6 +604,95 @@ fail: return -1; } +static int chain_failed(void) { + objects_destroy(); + g_ready = -1; + droiddeck_log("error", "effects: the screen-effect chain could not be built on this driver; effects are off for this session"); + return -1; +} + +static int pipelines_ensure(int spatial, const struct fx_settings *s) { + VkShaderModule vert = VK_NULL_HANDLE; +#define MKL(needed, slot, code, name, render_pass, layout) do { \ + if ((needed) && !g_pipe[slot]) { \ + if (!vert && !(vert = shader(upscale_vert_code, sizeof(upscale_vert_code)))) goto fail; \ + g_pipe[slot] = post_pipeline_for_renderpass(vert, code, sizeof(code), render_pass, name, layout); \ + if (!g_pipe[slot]) goto fail; \ + } \ +} while (0) +#define MK(needed, slot, code, name) MKL(needed, slot, code, name, g_rp, g_pl) + if (spatial == 3) { + if (g_upscale_half) MK(1, P_SGSR, sgsr_half_code, "sgsr_half"); + else MK(1, P_SGSR, sgsr_code, "sgsr"); + } + if (spatial == 8) { + if (g_upscale_half) MK(1, P_SGSR_HQ, sgsr_quality_half_code, "sgsr_quality_half"); + else MK(1, P_SGSR_HQ, sgsr_quality_code, "sgsr_quality"); + } + if (spatial == 4 || spatial == 5) { + if (g_upscale_half) MK(1, P_EASU, fsr_easu_half_code, "fsr_easu_half"); + else MK(1, P_EASU, fsr_easu_code, "fsr_easu"); + if (s->sharp_pct != 0) { + if (g_upscale_half) MK(1, P_RCAS, fsr_rcas_half_code, "fsr_rcas_half"); + else MK(1, P_RCAS, fsr_rcas_code, "fsr_rcas"); + } + } + if (spatial == 6) { + if (g_upscale_half) MK(1, P_RCAS, fsr_rcas_half_code, "fsr_rcas_half"); + else MK(1, P_RCAS, fsr_rcas_code, "fsr_rcas"); + } + if (spatial == 7) { + if (g_upscale_half && !g_nis_attempted) { + g_nis_attempted = 1; + if (!fx_alpha_holds_luma(g_fx_fmt)) + droiddeck_log("effects", "NIS uses nis.frag: the chain format has no 8-bit alpha for the luma prepass"); + else if (coef_create() != 0) + droiddeck_log("effects", "NIS coefficient buffer unavailable; NIS uses nis.frag"); + else { + if (!vert && !(vert = shader(upscale_vert_code, sizeof(upscale_vert_code)))) goto fail; + g_pipe[P_NIS] = post_pipeline_for_renderpass(vert, nis3_half_code, sizeof(nis3_half_code), g_rp, "nis3_half", g_pl_nis); + if (g_pipe[P_NIS]) + g_pipe[P_NIS_LUMA] = post_pipeline_for_renderpass(vert, nis_luma_half_code, sizeof(nis_luma_half_code), g_rp, "nis_luma_half", g_pl); + if (g_pipe[P_NIS] && g_pipe[P_NIS_LUMA]) g_nis_fast = 1; + else { + if (g_pipe[P_NIS]) g_vk.DestroyPipeline(g_dev, g_pipe[P_NIS], NULL); + if (g_pipe[P_NIS_LUMA]) g_vk.DestroyPipeline(g_dev, g_pipe[P_NIS_LUMA], NULL); + g_pipe[P_NIS] = VK_NULL_HANDLE; + g_pipe[P_NIS_LUMA] = VK_NULL_HANDLE; + coef_destroy(); + droiddeck_log("effects", "fast NIS pipelines failed to build; NIS uses nis.frag"); + } + } + } + if (!g_nis_fast) MK(1, P_NIS, nis_code, "nis"); + else if (g_upscale_half) MK(1, P_SGSR, sgsr_half_code, "sgsr_half"); + } + if (cas_active(s)) { + if (g_upscale_half) MK(1, P_CAS, cas_ffx_half_code, "cas_ffx_half"); + else MK(1, P_CAS, cas_code, "cas"); + } + 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 == 2) { + 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_rp, g_pl); + 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"); + else if (s->toon) MK(1, P_TOON, toon_code, "toon"); + if (s->hdr_on) MK(1, P_HDR, hdr_code, "hdr"); + if (s->ntsc) MK(1, P_NTSC, ntsc_code, "ntsc"); + if (s->crt) MK(1, P_CRT, crt_code, "crt"); + if (deband_active(s)) MK(1, P_DEBAND, deband_code, "deband"); +#undef MK +#undef MKL + if (vert) g_vk.DestroyShaderModule(g_dev, vert, NULL); + return 0; +fail: + if (vert) g_vk.DestroyShaderModule(g_dev, vert, NULL); + return chain_failed(); +} + static void barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkImageLayout to, VkPipelineStageFlags src_stage, VkAccessFlags src_access, @@ -474,17 +704,35 @@ 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); } -static void pass(VkCommandBuffer cmd, VkPipeline p, struct fx_target *dst, VkDescriptorSet src, +static void pass_renderpass(VkCommandBuffer cmd, VkRenderPass render_pass, + VkPipeline p, struct fx_target *dst, VkDescriptorSet src, const void *pc, uint32_t pcsz) { - VkRenderPassBeginInfo rpi = {.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = g_rp, .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}}}; - VkViewport vp = {0, 0, (float)dst->w, (float)dst->h, 0, 1}; - VkRect2D sc = {{0, 0}, {(uint32_t)dst->w, (uint32_t)dst->h}}; g_vk.CmdBeginRenderPass(cmd, &rpi, VK_SUBPASS_CONTENTS_INLINE); - g_vk.CmdSetViewport(cmd, 0, 1, &vp); - g_vk.CmdSetScissor(cmd, 0, 1, &sc); g_vk.CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, p); 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 */ + 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.CmdDraw(cmd, 4, 1, 0, 0); + g_vk.CmdEndRenderPass(cmd); +} + +static void pass(VkCommandBuffer cmd, VkPipeline p, struct fx_target *dst, + VkDescriptorSet src, const void *pc, uint32_t 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); @@ -493,11 +741,27 @@ static void pass(VkCommandBuffer cmd, VkPipeline p, struct fx_target *dst, VkDes static const float FULL_NDC[4] = {-1.0f, -1.0f, 1.0f, 1.0f}; #define SET_NDC(pc) memcpy((pc).ndc, FULL_NDC, sizeof(FULL_NDC)) -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) { +struct fx_source_state { + VkImageLayout layout; + VkPipelineStageFlags stage; + VkAccessFlags access; +}; + +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, + VkImageLayout input_layout, const struct fx_settings *frozen, + struct fx_source_state *source_state) { + struct fx_settings snapshot; const struct fx_settings *s; - vkp_effects_sync(); - s = &g_cur; + if (frozen) { + snapshot = *frozen; + } else { + vkp_effects_sync(); + pthread_mutex_lock(&g_lock); + snapshot = g_cur; + pthread_mutex_unlock(&g_lock); + } + s = &snapshot; *res_w = scene_w; *res_h = scene_h; int cw = out_w > 0 ? out_w : scene_w, ch = out_h > 0 ? out_h : scene_h; @@ -508,21 +772,58 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce const int upscaling = cw > scene_w || ch > scene_h; int spatial = 0; if (spatial_mode(s->scaling) && (s->scaling == 6 || upscaling)) spatial = s->scaling; + /* 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; + const int was_nis_fallback = + __atomic_exchange_n(&last_nis_fallback, nis_fallback, __ATOMIC_RELAXED); + if (nis_fallback) { + spatial = 4; /* FSR fallback; keep the saved NIS selection unchanged. */ + if (!was_nis_fallback) + droiddeck_log("effects", "NIS unsupported for this output; FSR fallback active"); + } else if (was_nis_fallback && s->scaling == 7) { + droiddeck_log("effects", "NIS supported again; NIS active"); + } const int nfx = effect_count(s); const int resize = cw != scene_w || ch != scene_h; - const int npasses = ((spatial || resize) ? 1 : 0) + nfx; + const int fuse_toon_color = s->toon && s->color_on && g_fx_fmt == FX_FORMAT; + const int fuse_fxaa_toon = 0; + const int chain_passes = ((spatial || resize) ? 1 : 0) + + effect_count(s) - (fuse_toon_color ? 1 : 0) - + (fuse_fxaa_toon ? 1 : 0); + + if ((spatial || nfx) && objects_ensure() == 0 && pipelines_ensure(spatial, s) == 0 && scene_ensure(scene, scene_w, scene_h) == 0 && + target_ensure(&g_t[0], cw, ch, FX_TARGET_USAGE, "chain") == 0 && (chain_passes < 2 || target_ensure(&g_t[1], cw, ch, FX_TARGET_USAGE, "chain") == 0) && + (!(spatial == 4 || spatial == 5) || s->sharp_pct == 0 || + target_ensure(&g_mid, cw, ch, FX_SCRATCH_USAGE, "EASU") == 0)) { + if (s->aa_mode == 2 && + (target_ensure_format(&g_smaa_edges, cw, ch, FX_SCRATCH_USAGE, + "SMAA edges", FX_FORMAT, g_smaa_rp) != 0 || + target_ensure_format(&g_smaa_weights, cw, ch, FX_SCRATCH_USAGE, + "SMAA weights", FX_FORMAT, g_smaa_rp) != 0)) { + droiddeck_log("error", "effects: SMAA scratch allocation failed; falling back to FXAA"); + snapshot.aa_mode = 1; + s = &snapshot; + } - if ((spatial || nfx) && objects_ensure() == 0 && scene_ensure(scene, scene_w, scene_h) == 0 && - target_ensure(&g_t[0], cw, ch, "chain") == 0 && (npasses < 2 || target_ensure(&g_t[1], cw, ch, "chain") == 0) && - (!(spatial == 4 || spatial == 5) || target_ensure(&g_mid, cw, ch, "EASU") == 0)) { VkDescriptorSet cur_ds; struct fx_target *cur = NULL; #define FREE_TARGET() ((cur == &g_t[0]) ? &g_t[1] : &g_t[0]) const float sharp01 = (float)s->sharp_pct / 100.0f; + VkViewport chain_vp = {0, 0, (float)cw, (float)ch, 0, 1}; + VkRect2D chain_sc = {{0, 0}, {(uint32_t)cw, (uint32_t)ch}}; + g_vk.CmdSetViewport(cmd, 0, 1, &chain_vp); + g_vk.CmdSetScissor(cmd, 0, 1, &chain_sc); + if (spatial) { - barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, - VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, + if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT}; + barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT); struct fx_target *dst = FREE_TARGET(); if (spatial == 3 || spatial == 8 || spatial == 7) { @@ -531,7 +832,31 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce pc.vp[0] = 1.0f / (float)scene_w; pc.vp[1] = 1.0f / (float)scene_h; pc.vp[2] = (float)scene_w; pc.vp[3] = (float)scene_h; pc.edge = spatial == 7 ? sharp01 : 0.5f + sharp01 * 4.0f; - pass(cmd, g_pipe[spatial == 3 ? P_SGSR : spatial == 8 ? P_SGSR_HQ : P_NIS], dst, g_scene.ds, &pc, sizeof(pc)); + VkDescriptorSet src = g_scene.ds; + int nis_pipe = P_NIS; + if (spatial == 7 && g_nis_fast && + target_ensure(&g_nissrc, scene_w, scene_h, FX_SCRATCH_USAGE, "NIS luma") != 0) { + /* nis3 needs the prepass image; without it this frame takes SGSR from the scene + * instead of dropping every effect */ + static int warned; + if (!__atomic_exchange_n(&warned, 1, __ATOMIC_RELAXED)) + droiddeck_log("error", "effects: NIS luma target allocation failed; SGSR instead"); + nis_pipe = P_SGSR; + pc.edge = 0.5f + sharp01 * 4.0f; + } else if (spatial == 7 && g_nis_fast) { + /* NIS prepass: scene -> g_nissrc 1:1 (rgb + luma in alpha); only ndc is read. */ + struct pc_res pl = {0}; + SET_NDC(pl); + VkViewport scene_vp = {0, 0, (float)scene_w, (float)scene_h, 0, 1}; + VkRect2D scene_sc = {{0, 0}, {(uint32_t)scene_w, (uint32_t)scene_h}}; + g_vk.CmdSetViewport(cmd, 0, 1, &scene_vp); + g_vk.CmdSetScissor(cmd, 0, 1, &scene_sc); + pass(cmd, g_pipe[P_NIS_LUMA], &g_nissrc, g_scene.ds, &pl, sizeof(pl.ndc)); + g_vk.CmdSetViewport(cmd, 0, 1, &chain_vp); + g_vk.CmdSetScissor(cmd, 0, 1, &chain_sc); + src = g_nissrc.ds; + } + pass(cmd, g_pipe[spatial == 3 ? P_SGSR : spatial == 8 ? P_SGSR_HQ : nis_pipe], dst, src, &pc, sizeof(pc)); } else if (spatial == 6) { struct pc_rcas pc = {0}; SET_NDC(pc); @@ -546,46 +871,58 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce SET_NDC(e); easu_con(&e, (float)scene_w, (float)scene_h, (float)cw, (float)ch); e.outW = (float)cw; e.outH = (float)ch; - pass(cmd, g_pipe[P_EASU], &g_mid, g_scene.ds, &e, sizeof(e)); - SET_NDC(r); - rcas_con(&r, sharp01); - r.outW = (float)cw; r.outH = (float)ch; - pass(cmd, g_pipe[P_RCAS], dst, g_mid.ds, &r, sizeof(r)); + struct fx_target *easu_dst = sharp01 == 0.0f ? dst : &g_mid; + pass(cmd, g_pipe[P_EASU], easu_dst, g_scene.ds, &e, sizeof(e)); + if (sharp01 != 0.0f) { + SET_NDC(r); + rcas_con(&r, sharp01); + r.outW = (float)cw; r.outH = (float)ch; + pass(cmd, g_pipe[P_RCAS], dst, g_mid.ds, &r, sizeof(r)); + } } cur = dst; cur_ds = dst->ds; } else if (resize) { struct fx_target *dst = FREE_TARGET(); - barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, + if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT}; + barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT); barrier(cmd, dst->img, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT); VkImageBlit bl = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .srcOffsets = {{0, 0, 0}, {scene_w, scene_h, 1}}, .dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .dstOffsets = {{0, 0, 0}, {cw, ch, 1}}}; g_vk.CmdBlitImage(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst->img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - 1, &bl, vkp_effects_blit_filter()); + 1, &bl, s->scaling == 2 ? VK_FILTER_NEAREST : VK_FILTER_LINEAR); barrier(cmd, dst->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); cur = dst; cur_ds = dst->ds; } else { - barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, - VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, + if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT}; + barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT); cur = NULL; cur_ds = g_scene.ds; } - enum { FX_FXAA, FX_SMAA, FX_TOON, FX_COLOR, FX_CAS, FX_HDR, FX_NTSC, FX_CRT, FX_DEBAND }; + enum { FX_FXAA, FX_FXAA_TOON, FX_SMAA, FX_TOON, FX_COLOR, FX_TOON_COLOR, FX_CAS, FX_HDR, FX_NTSC, FX_CRT, FX_DEBAND }; int order[8], n = 0; - if (s->aa_mode == 1) order[n++] = FX_FXAA; + if (s->aa_mode == 1) + order[n++] = fuse_fxaa_toon ? FX_FXAA_TOON : FX_FXAA; else if (s->aa_mode == 2) order[n++] = FX_SMAA; - if (s->toon) order[n++] = FX_TOON; - if (s->color_on) order[n++] = FX_COLOR; + if (s->toon && s->color_on && g_fx_fmt == FX_FORMAT) { + order[n++] = FX_TOON_COLOR; + } else { + if (s->toon && !fuse_fxaa_toon) order[n++] = FX_TOON; + if (s->color_on) order[n++] = FX_COLOR; + } if (cas_active(s)) order[n++] = FX_CAS; if (s->hdr_on) order[n++] = FX_HDR; if (s->ntsc) order[n++] = FX_NTSC; if (s->crt) order[n++] = FX_CRT; - if (s->deband_on) order[n++] = FX_DEBAND; + if (deband_active(s)) order[n++] = FX_DEBAND; for (int i = 0; i < n; i++) { struct fx_target *dst = FREE_TARGET(); struct pc_res pr = {0}; @@ -593,8 +930,29 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce pr.res[0] = (float)cw; pr.res[1] = (float)ch; switch (order[i]) { case FX_FXAA: pass(cmd, g_pipe[P_FXAA], dst, cur_ds, &pr, sizeof(pr)); break; - case FX_SMAA: pass(cmd, g_pipe[P_SMAA], 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: + pass_renderpass(cmd, g_smaa_rp, g_pipe[P_SMAA_EDGE], + &g_smaa_edges, cur_ds, &pr, sizeof(pr)); + pass_renderpass(cmd, g_smaa_rp, g_pipe[P_SMAA_WEIGHTS], + &g_smaa_weights, g_smaa_edges.ds, &pr, sizeof(pr)); + pass_dual(cmd, g_pipe[P_SMAA_BLEND], dst, cur_ds, + g_smaa_weights.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: { + struct pc_toon_color pc = {0}; + SET_NDC(pc); + pc.res[0] = (float)cw; + pc.res[1] = (float)ch; + pc.b = s->brightness; + pc.c = s->contrast; + pc.g = s->gamma; + pc.s = s->saturation; + pass(cmd, g_pipe[P_TOON_COLOR], dst, cur_ds, + &pc, sizeof(pc)); + break; + } case FX_COLOR: { struct pc_color pc = {0}; SET_NDC(pc); @@ -605,7 +963,6 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce case FX_CAS: pr.extra = (float)s->cas_pct / 100.0f; pass(cmd, g_pipe[P_CAS], dst, cur_ds, &pr, sizeof(pr)); break; case FX_HDR: pass(cmd, g_pipe[P_HDR], dst, cur_ds, &pr, sizeof(pr)); break; case FX_NTSC: - pr.extra = (float)(g_ntsc_frame++ & 3u); pass(cmd, g_pipe[P_NTSC], dst, cur_ds, &pr, sizeof(pr)); break; case FX_CRT: pass(cmd, g_pipe[P_CRT], dst, cur_ds, &pr, sizeof(pr)); break; @@ -628,8 +985,54 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce return scene; } - barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, + if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT}; + barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT); return scene; } + +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) { + return effects_run(cmd, scene, scene_w, scene_h, out_w, out_h, res_w, res_h, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, NULL, NULL); +} + +int vkp_effects_prepare_generated(void) { + vkp_effects_sync(); + pthread_mutex_lock(&g_lock); + g_generated_settings = g_cur; + pthread_mutex_unlock(&g_lock); + return spatial_mode(g_generated_settings.scaling) && g_generated_settings.scaling != 6 && + effect_count(&g_generated_settings) == 0; +} + +VkImage vkp_effects_run_before_generated(VkCommandBuffer cmd, VkImage scene, int w, int h, + int *res_w, int *res_h) { + struct fx_settings settings = g_generated_settings; + settings.scaling = 0; + return effects_run(cmd, scene, w, h, w, h, res_w, res_h, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &settings, NULL); +} + +VkImage vkp_effects_run_generated(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h, + int out_w, int out_h, int slot, int *res_w, int *res_h) { + if (slot < 0 || slot > VKP_FG_MAX_GENERATIONS) { + *res_w = scene_w; *res_h = scene_h; + return scene; + } + g_context = slot + 1; + 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, + VK_IMAGE_LAYOUT_GENERAL, &g_generated_settings, &source_state); + 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_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT); + if (result != scene) + barrier(cmd, scene, source_state.layout, VK_IMAGE_LAYOUT_GENERAL, + source_state.stage, source_state.access, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT); + g_context = 0; + return result; +} diff --git a/app/src/main/cpp/waylandcomp/src/effects_chain.h b/app/src/main/cpp/waylandcomp/src/effects_chain.h index bb1ca5ae1f..99f2ad93d5 100644 --- a/app/src/main/cpp/waylandcomp/src/effects_chain.h +++ b/app/src/main/cpp/waylandcomp/src/effects_chain.h @@ -18,12 +18,18 @@ VkFilter vkp_effects_blit_filter(void); 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 vkp_effects_prepare_generated(void); +void vkp_effects_release_generated_sources(void); +VkImage vkp_effects_run_before_generated(VkCommandBuffer cmd, VkImage scene, int w, int h, + int *res_w, int *res_h); +VkImage vkp_effects_run_generated(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h, + int out_w, int out_h, int slot, int *res_w, int *res_h); void vkp_effects_destroy(void); void vkp_effects_forget_image(VkImage img); -void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt); +void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt, int scene_is_pq); void vkp_effects_set_scaling(int mode); void vkp_effects_set_upscale_sharpness(int pct); diff --git a/app/src/main/cpp/waylandcomp/src/framegen_bridge.c b/app/src/main/cpp/waylandcomp/src/framegen_bridge.c index d29b328a05..385475f950 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_bridge.c +++ b/app/src/main/cpp/waylandcomp/src/framegen_bridge.c @@ -1,6 +1,7 @@ #define _POSIX_C_SOURCE 200809L #include "framegen_bridge.h" #include "framegen_engine.h" +#include "effects_chain.h" #include "vk_loader.h" #include #include @@ -194,7 +195,31 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f fge_caps_ok(VKP_FG_ENGINE_DDFG) ? "available" : "unavailable"); } -void vkp_framegen_device_lost(void) { atomic_store(&g_dev_lost, 1); } +void vkp_framegen_device_lost(void) { + atomic_store(&g_dev_lost, 1); + atomic_store(&g_dev_ready, 0); + fge_device_lost(); + if (g_dev) { + for (uint32_t i = 0; i < g_ring_n; i++) { + if (g_ring[i].view && vk.DestroyImageView) vk.DestroyImageView(g_dev, g_ring[i].view, NULL); + if (g_ring[i].img && vk.DestroyImage) vk.DestroyImage(g_dev, g_ring[i].img, NULL); + if (g_ring[i].mem && vk.FreeMemory) vk.FreeMemory(g_dev, g_ring[i].mem, NULL); + } + } + memset(g_ring, 0, sizeof(g_ring)); + g_ring_n = g_ring_w = g_ring_h = 0; + g_ring_fmt = VK_FORMAT_UNDEFINED; + g_engine_ok = 0; + g_engine_kind = -1; + g_engine_cache_gen = -1; + g_built_w = g_built_h = 0; + g_built_fmt = VK_FORMAT_UNDEFINED; + g_planned = 0; + memset(&vk, 0, sizeof(vk)); + g_dev = VK_NULL_HANDLE; + g_queue = VK_NULL_HANDLE; + g_qfam = 0; +} static void destroy_ring(void) { @@ -202,7 +227,10 @@ static void destroy_ring(void) { if (vk.DeviceWaitIdle) vk.DeviceWaitIdle(g_dev); for (uint32_t i = 0; i < g_ring_n; i++) { if (g_ring[i].view) vk.DestroyImageView(g_dev, g_ring[i].view, NULL); - if (g_ring[i].img) vk.DestroyImage(g_dev, g_ring[i].img, NULL); + if (g_ring[i].img) { + vkp_effects_forget_image(g_ring[i].img); + vk.DestroyImage(g_dev, g_ring[i].img, NULL); + } if (g_ring[i].mem) vk.FreeMemory(g_dev, g_ring[i].mem, NULL); memset(&g_ring[i], 0, sizeof(g_ring[i])); } diff --git a/app/src/main/cpp/waylandcomp/src/framegen_engine.cpp b/app/src/main/cpp/waylandcomp/src/framegen_engine.cpp index be1b03e34a..ed16dd4c88 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_engine.cpp +++ b/app/src/main/cpp/waylandcomp/src/framegen_engine.cpp @@ -31,6 +31,7 @@ bool g_probed = false, g_ready = false; std::unique_ptr g_lsfg; std::unique_ptr g_ddfg; +std::vector> g_retained_ddfg; int g_kind = -1; char g_build[96] = ""; @@ -126,6 +127,30 @@ void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica (int)g_caps.storageOnSwapchainFormat); } +void fge_device_lost(void) { + g_lsfg.reset(); + if (g_ddfg) { + if (g_ddfg->destroy()) g_ddfg.reset(); + else g_retained_ddfg.push_back(std::move(g_ddfg)); + } + // The device is being torn down. Unknown-completion resources must not be + // passed to Vulkan destruction calls; the VkDevice teardown reclaims them. + for (auto& engine : g_retained_ddfg) engine->abandon(); + g_retained_ddfg.clear(); + g_kind = -1; + g_dev = VK_NULL_HANDLE; + g_queue = VK_NULL_HANDLE; + g_pd = VK_NULL_HANDLE; + g_qfam = 0; + g_ready = false; + g_probed = false; + g_table = {}; + g_caps = {}; + g_v12 = {}; + g_f2 = {}; + g_build[0] = 0; +} + int fge_caps_ok(int kind) { if (!g_ready) return 0; if (kind == 1) return g_caps.storageOnSwapchainFormat ? 1 : 0; @@ -176,9 +201,21 @@ int fge_start(int kind, const char *cache_path) { } void fge_stop(void) { - if ((g_lsfg || g_ddfg) && g_table.DeviceWaitIdle && g_dev) g_table.DeviceWaitIdle(g_dev); - g_lsfg.reset(); - g_ddfg.reset(); + if (g_lsfg) { + if (g_table.DeviceWaitIdle && g_dev) g_table.DeviceWaitIdle(g_dev); + g_lsfg.reset(); + } + for (auto it = g_retained_ddfg.begin(); it != g_retained_ddfg.end();) { + if ((*it)->destroy()) it = g_retained_ddfg.erase(it); + else ++it; + } + if (g_ddfg) { + if (g_ddfg->destroy()) g_ddfg.reset(); + else { + ELOGE("ddfg-native: retaining engine until GPU completion is known or device teardown"); + g_retained_ddfg.push_back(std::move(g_ddfg)); + } + } g_kind = -1; } diff --git a/app/src/main/cpp/waylandcomp/src/framegen_engine.h b/app/src/main/cpp/waylandcomp/src/framegen_engine.h index 4257a7592e..d52ce3ffd4 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_engine.h +++ b/app/src/main/cpp/waylandcomp/src/framegen_engine.h @@ -12,6 +12,7 @@ extern "C" { const void *fge_probe(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd, VkFormat ring_fmt); +void fge_device_lost(void); void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd, VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled); int fge_caps_ok(int kind); diff --git a/app/src/main/cpp/waylandcomp/src/framegen_engine_stub.c b/app/src/main/cpp/waylandcomp/src/framegen_engine_stub.c index 310e10c341..3d11228577 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_engine_stub.c +++ b/app/src/main/cpp/waylandcomp/src/framegen_engine_stub.c @@ -9,6 +9,7 @@ void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled) { (void)gipa; (void)inst; (void)pd; (void)dev; (void)queue; (void)qfam; (void)features_enabled; } +void fge_device_lost(void) {} int fge_caps_ok(int kind) { (void)kind; return 0; } const char *fge_caps_reason(void) { return "frame-generation engines not built into this compositor"; } int fge_format_ok(VkFormat fmt) { (void)fmt; return 0; } diff --git a/app/src/main/cpp/waylandcomp/src/gpu_busy.c b/app/src/main/cpp/waylandcomp/src/gpu_busy.c index 48d565c20a..d7835293bb 100644 --- a/app/src/main/cpp/waylandcomp/src/gpu_busy.c +++ b/app/src/main/cpp/waylandcomp/src/gpu_busy.c @@ -73,8 +73,19 @@ void vkp_gpu_busy_device(VkPhysicalDevice pd, VkDevice dev, uint32_t family) { } void vkp_gpu_busy_device_lost(void) { + pthread_mutex_lock(&g_lock); atomic_store(&g_lost, 1); atomic_store(&g_timing, 0); + if (g_v.device) { + gpuload_ring_release(&g_ring, &g_v); + g_ring.state = 0; + } + if (g_vk.QueueSubmit == timed_submit && g_submit) g_vk.QueueSubmit = g_submit; + g_submit = NULL; + memset(&g_v, 0, sizeof(g_v)); + g_family = g_bits = 0; + g_was_on = 0; + pthread_mutex_unlock(&g_lock); } JNIEXPORT jlong JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeGpuBusyNs(JNIEnv *env, jclass cls) { diff --git a/app/src/main/cpp/waylandcomp/src/sc_layer.c b/app/src/main/cpp/waylandcomp/src/sc_layer.c index 74cd5d6b45..018664f9c3 100644 --- a/app/src/main/cpp/waylandcomp/src/sc_layer.c +++ b/app/src/main/cpp/waylandcomp/src/sc_layer.c @@ -148,6 +148,7 @@ struct slot { uint32_t fmt; int release_fd; int busy; + uint64_t generation; }; struct layer { @@ -175,6 +176,7 @@ struct layer { int votes_rate; float fps_applied; int recreate_pending; + int pending_callbacks; int32_t ds_applied; @@ -222,6 +224,7 @@ struct complete_ctx { ASurfaceControl *sc; int layer; int prev_slot; + uint64_t prev_generation; void *prev_token; int retire; }; @@ -288,12 +291,16 @@ static void on_complete(void *context, ASurfaceTransactionStats *stats) { pthread_mutex_lock(&g_lock); if (ctx->layer >= 0 && ctx->layer < SC_LAYER_COUNT && ctx->prev_slot >= 0 && ctx->prev_slot < POOL_MAX) { struct slot *s = &g_layers[ctx->layer].slots[ctx->prev_slot]; - int fd = (stats && ctx->sc) ? api.prevReleaseFence(stats, ctx->sc) : -1; - if (s->release_fd >= 0) close(s->release_fd); - s->release_fd = fd; - s->busy = 0; + if (s->generation == ctx->prev_generation) { + int fd = (stats && ctx->sc) ? api.prevReleaseFence(stats, ctx->sc) : -1; + if (s->release_fd >= 0) close(s->release_fd); + s->release_fd = fd; + s->busy = 0; + } } if (g_pending_cb > 0) g_pending_cb--; + if (ctx->layer >= 0 && ctx->layer < SC_LAYER_COUNT && g_layers[ctx->layer].pending_callbacks > 0) + g_layers[ctx->layer].pending_callbacks--; pthread_mutex_unlock(&g_lock); if (ctx->prev_token) { int fd = (stats && ctx->sc) ? api.prevReleaseFence(stats, ctx->sc) : -1; @@ -308,9 +315,15 @@ static int add_complete_on(ASurfaceTransaction *tx, struct layer *l, ASurfaceCon struct complete_ctx *ctx = calloc(1, sizeof(*ctx)); if (!ctx) return -1; ctx->sc = sc; ctx->layer = (int)(l - g_layers); ctx->prev_slot = prev_slot; + if (prev_slot >= 0 && prev_slot < POOL_MAX) { + pthread_mutex_lock(&g_lock); + ctx->prev_generation = l->slots[prev_slot].generation; + pthread_mutex_unlock(&g_lock); + } ctx->prev_token = prev_token; ctx->retire = retire; pthread_mutex_lock(&g_lock); g_pending_cb++; + l->pending_callbacks++; pthread_mutex_unlock(&g_lock); api.setOnComplete(tx, ctx, on_complete); return 0; @@ -397,12 +410,16 @@ static void retire_sc(struct layer *l) { ASurfaceTransaction *tx = api.txCreate(); if (tx) { retire_ops(tx, l->sc); - if (add_complete(tx, l, l->cur_slot, l->cur_token, 1) != 0) api.release(l->sc); + if (add_complete(tx, l, l->cur_slot, l->cur_token, 1) != 0) { + api.txDelete(tx); + droiddeck_log("layer", "%s: retirement deferred because its release callback could not be allocated", l->name); + return; + } api.txApply(tx); api.txDelete(tx); } else { - if (l->cur_token) ahb_swapchain_layer_released(l->cur_token, -1); - api.release(l->sc); + droiddeck_log("layer", "%s: retirement deferred because a transaction could not be allocated", l->name); + return; } droiddeck_log("layer", "%s: SurfaceControl retired (window %p)", l->name, (void *)l->win); l->sc = NULL; l->win = NULL; @@ -421,20 +438,28 @@ static void drain_and_free_pools(void) { if (!pending || now_ns() > deadline) break; usleep(2000); } - pthread_mutex_lock(&g_lock); for (int i = 0; i < SC_LAYER_COUNT; i++) { + struct layer *l = &g_layers[i]; + pthread_mutex_lock(&g_lock); + const int pending = l->pending_callbacks; + if (pending || l->sc) { + pthread_mutex_unlock(&g_lock); + droiddeck_log("layer", "pool drain deferred for %s (%s)", l->name, + pending ? "SurfaceControl callbacks are pending" : "SurfaceControl retirement is deferred"); + continue; + } for (int j = 0; j < POOL_MAX; j++) { - struct slot *s = &g_layers[i].slots[j]; + struct slot *s = &l->slots[j]; if (s->release_fd >= 0) { struct pollfd p = {.fd = s->release_fd, .events = POLLIN}; poll(&p, 1, 100); close(s->release_fd); } if (s->img) vkp_image_destroy(s->img); if (s->ahb) AHardwareBuffer_release(s->ahb); memset(s, 0, sizeof(*s)); s->release_fd = -1; } - g_layers[i].first_logged = 0; - g_layers[i].logged_w = g_layers[i].logged_h = 0; + l->first_logged = 0; + l->logged_w = l->logged_h = 0; + pthread_mutex_unlock(&g_lock); } - pthread_mutex_unlock(&g_lock); } static int sniff_modifier(const struct droiddeck_native_handle *h, uint64_t *mod) { @@ -612,7 +637,10 @@ static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait if (pending < 0) pending = i; } if (idx < 0) idx = pending; - if (idx >= 0) { fd = l->slots[idx].release_fd; l->slots[idx].release_fd = -1; } + if (idx >= 0) { + fd = l->slots[idx].release_fd; l->slots[idx].release_fd = -1; + l->slots[idx].generation++; + } pthread_mutex_unlock(&g_lock); if (idx < 0) return -1; if (fd >= 0 && fence_signalled(fd)) { close(fd); fd = -1; } @@ -620,7 +648,8 @@ static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait if (s->ahb && (s->w != w || s->h != h || s->fmt != fmt)) { if (fd >= 0) { close(fd); fd = -1; } vkp_image_destroy(s->img); AHardwareBuffer_release(s->ahb); - memset(s, 0, sizeof(*s)); s->release_fd = -1; + const uint64_t generation = s->generation; + memset(s, 0, sizeof(*s)); s->release_fd = -1; s->generation = generation; } if (fd >= 0 && !vkp_can_wait_sync_fd()) { if (fence_wait(fd, 100) == 0) { slot_keep_fence(s, fd); return -1; } @@ -659,7 +688,13 @@ static int ensure_sc(struct layer *l) { if (load_api() != 0) return -1; ANativeWindow *win = vkp_window(); if (!win) return -1; - if (l->sc && l->win != win) retire_sc(l); + if (l->sc && l->win != win) { + retire_sc(l); + if (l->sc) { + droiddeck_log("layer", "%s: keeping the old SurfaceControl until retirement completes", l->name); + return -1; + } + } if (!l->sc) { l->sc = api.createFromWindow(win, l->name); if (!l->sc) { droiddeck_log("error", "layer: ASurfaceControl_createFromWindow(%s) failed", l->name); return -1; } @@ -818,6 +853,7 @@ static ASurfaceControl *swap_sc_begin(struct layer *l) { if (!win || win != l->win) return NULL; ASurfaceControl *fresh = api.createFromWindow(win, l->name); if (!fresh) { + l->recreate_pending = 1; droiddeck_log("error", "layer: %s: composition recovery could not create a new SurfaceControl", l->name); return NULL; } @@ -832,24 +868,45 @@ static ASurfaceControl *swap_sc_begin(struct layer *l) { return old; } +static void rollback_swap_sc(struct layer *l, ASurfaceControl *old, int was_shown, + int32_t ds_applied, uint32_t md_applied, float hr_applied) { + if (!old) return; + ASurfaceControl *fresh = l->sc; + l->sc = old; + l->shown = was_shown; + l->recreate_pending = 1; + l->geo_valid = 0; + l->fps_applied = -1.0f; + l->ds_applied = ds_applied; l->md_applied = md_applied; l->hr_applied = hr_applied; + if (fresh) api.release(fresh); +} + static int present_slot(struct layer *l, int idx, const int r[8], const struct droiddeck_color *color, int translucent) { struct slot *s = &l->slots[idx]; ASurfaceTransaction *tx = api.txCreate(); if (!tx) return -1; + const int was_shown = l->shown; + const int32_t ds_applied = l->ds_applied; + const uint32_t md_applied = l->md_applied; + const float hr_applied = l->hr_applied; ASurfaceControl *old = swap_sc_begin(l); if (old) api.setZOrder(tx, l->sc, l->z); api.setBuffer(tx, l->sc, s->ahb, -1); if (api.setEnableBackPressure) api.setEnableBackPressure(tx, l->sc, true); api.setBufferTransparency(tx, l->sc, translucent ? ASC_TRANSPARENCY_TRANSLUCENT : ASC_TRANSPARENCY_OPAQUE); + if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW); + if (old) retire_ops(tx, old); + if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot, l->cur_token, old ? 1 : 0) != 0) { + api.txDelete(tx); + rollback_swap_sc(l, old, was_shown, ds_applied, md_applied, hr_applied); + droiddeck_log("layer", "%s: frame transition skipped because its release callback could not be allocated", l->name); + return -1; + } apply_geometry(tx, l, r); apply_frame_rate(tx, l); apply_colour(tx, l, color); - if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW); - if (old) retire_ops(tx, old); - if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot, l->cur_token, old ? 1 : 0) != 0 && old) - api.release(old); pthread_mutex_lock(&g_lock); s->busy = 1; pthread_mutex_unlock(&g_lock); @@ -904,23 +961,27 @@ int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, voi } ASurfaceTransaction *tx = api.txCreate(); if (!tx) goto unavailable; + const int was_shown = l->shown; + const int32_t ds_applied = l->ds_applied; + const uint32_t md_applied = l->md_applied; + const float hr_applied = l->hr_applied; ASurfaceControl *old = swap_sc_begin(l); if (old) api.setZOrder(tx, l->sc, l->z); api.setBuffer(tx, l->sc, ahb, acquire_fd); if (api.setEnableBackPressure) api.setEnableBackPressure(tx, l->sc, true); api.setBufferTransparency(tx, l->sc, ASC_TRANSPARENCY_OPAQUE); - apply_geometry(tx, l, r); - apply_frame_rate(tx, l); - apply_colour(tx, l, color); if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW); if (old) retire_ops(tx, old); if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot, l->cur_token == token ? NULL : l->cur_token, old ? 1 : 0) != 0) { api.txDelete(tx); - if (old) api.release(old); - l->ds_applied = -1; l->md_applied = 0; l->hr_applied = -1.0f; + rollback_swap_sc(l, old, was_shown, ds_applied, md_applied, hr_applied); + droiddeck_log("layer", "zero-copy: frame transition skipped because its release callback could not be allocated"); return -1; } + apply_geometry(tx, l, r); + apply_frame_rate(tx, l); + apply_colour(tx, l, color); apply_present_time(tx, 1); api.txApply(tx); api.txDelete(tx); @@ -1167,15 +1228,26 @@ int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int transl return 0; } -static void hide_layer(struct layer *l) { - if (!l->sc || !l->shown || api.state != 1) return; +static int hide_layer(struct layer *l) { + if (!l->sc || !l->shown || api.state != 1) return 0; ASurfaceTransaction *tx = api.txCreate(); - if (!tx) return; - replace_with_blank(tx, l); + if (!tx) return -1; api.setVisibility(tx, l->sc, ASC_VISIBILITY_HIDE); - add_complete(tx, l, l->cur_slot, l->cur_token, 0); + if (add_complete(tx, l, l->cur_slot, l->cur_token, 0) != 0) { + /* + * Keep the current buffer attached when its release callback cannot + * be allocated. The hide can still apply without releasing the slot. + */ + api.txApply(tx); + api.txDelete(tx); + l->shown = 0; + droiddeck_log("layer", "%s: hidden; buffer release deferred because its callback could not be allocated", l->name); + return 0; + } + replace_with_blank(tx, l); api.txApply(tx); api.txDelete(tx); l->shown = 0; l->cur_slot = -1; l->cur_token = NULL; + return 0; } void sc_layer_hide(void) { @@ -1183,17 +1255,20 @@ void sc_layer_hide(void) { int said = g_layers[SC_LAYER_GAME].shown || g_layers[SC_LAYER_OVERLAY].sc; if (g_layers[SC_LAYER_OVERLAY].sc) sc_layer_hide_overlay(); if (g_layers[SC_LAYER_GAME].shown) hide_layer(&g_layers[SC_LAYER_GAME]); - if (said) droiddeck_log("layer", "layers hidden (scene is not a single fullscreen window)"); + if (said && !g_layers[SC_LAYER_GAME].shown && !g_layers[SC_LAYER_OVERLAY].shown) + droiddeck_log("layer", "layers hidden (scene is not a single fullscreen window)"); } void sc_layer_hide_overlay(void) { layers_init(); struct layer *l = &g_layers[SC_LAYER_OVERLAY]; if (!l->sc) return; - if (l->shown) hide_layer(l); + if (l->shown && hide_layer(l) != 0) return; retire_sc(l); - droiddeck_log("layer", "%s: gone (nothing is above the game any more)", l->name); - if (g_layers[SC_LAYER_GAME].sc) g_layers[SC_LAYER_GAME].recreate_pending = 1; + if (!l->sc) { + droiddeck_log("layer", "%s: gone (nothing is above the game any more)", l->name); + if (g_layers[SC_LAYER_GAME].sc) g_layers[SC_LAYER_GAME].recreate_pending = 1; + } } void sc_layer_window_gone(void) { diff --git a/app/src/main/cpp/waylandcomp/src/vk_loader.h b/app/src/main/cpp/waylandcomp/src/vk_loader.h index c0782140f0..a54cc2cf3f 100644 --- a/app/src/main/cpp/waylandcomp/src/vk_loader.h +++ b/app/src/main/cpp/waylandcomp/src/vk_loader.h @@ -15,9 +15,9 @@ X(GetPhysicalDeviceImageFormatProperties2) X(GetPhysicalDeviceProperties2) #define VK_DEVICE_FUNCS(X) \ - X(GetDeviceQueue) X(CreateSwapchainKHR) X(DestroySwapchainKHR) X(GetSwapchainImagesKHR) \ - X(CreateCommandPool) X(AllocateCommandBuffers) X(CreateSemaphore) X(CreateFence) \ - X(DeviceWaitIdle) X(CreateImage) X(GetImageMemoryRequirements) X(AllocateMemory) \ + X(DestroyDevice) X(GetDeviceQueue) X(CreateSwapchainKHR) X(DestroySwapchainKHR) X(GetSwapchainImagesKHR) \ + X(CreateCommandPool) X(DestroyCommandPool) X(AllocateCommandBuffers) X(CreateSemaphore) X(CreateFence) \ + X(DeviceWaitIdle) X(DestroyFence) X(CreateImage) X(GetImageMemoryRequirements) X(AllocateMemory) \ X(BindImageMemory) X(DestroyImage) X(FreeMemory) X(AcquireNextImageKHR) \ X(ResetCommandBuffer) X(BeginCommandBuffer) X(CmdPipelineBarrier) X(CmdBlitImage) \ X(EndCommandBuffer) X(ResetFences) X(QueueSubmit) X(QueuePresentKHR) X(WaitForFences) \ diff --git a/app/src/main/cpp/waylandcomp/src/vk_present.c b/app/src/main/cpp/waylandcomp/src/vk_present.c index e327152b46..a44dfe0b73 100644 --- a/app/src/main/cpp/waylandcomp/src/vk_present.c +++ b/app/src/main/cpp/waylandcomp/src/vk_present.c @@ -31,6 +31,15 @@ #define LOGE(...) droiddeck_log("error", __VA_ARGS__) #define MOD_INVALID VKP_MOD_INVALID +enum vkp_image_source { + VKP_IMAGE_SOURCE_NONE = 0, + VKP_IMAGE_SOURCE_DMABUF, + VKP_IMAGE_SOURCE_AHB_WLEGL, + VKP_IMAGE_SOURCE_AHB_SOURCE, + VKP_IMAGE_SOURCE_AHB_TARGET, + VKP_IMAGE_SOURCE_SHM +}; + struct vkp_image { VkImage image; VkDeviceMemory mem; @@ -47,14 +56,61 @@ struct vkp_image { VkBuffer linear_buf; VkDeviceMemory linear_mem; VkBufferImageCopy linear_copy; + enum vkp_image_source source_type; + int source_fd; + uint32_t source_drm_format, source_stride, source_offset; + uint64_t source_modifier; + uint8_t *recovery_pixels; + struct vkp_image *next; }; +static struct vkp_image *g_client_images; +static struct vkp_image *g_rb; +static int g_recovery_attempted; + +static void image_register(struct vkp_image *img) { + if (!img) return; + img->next = g_client_images; + g_client_images = img; +} + +static void image_unregister(struct vkp_image *img) { + struct vkp_image **p = &g_client_images; + while (*p && *p != img) p = &(*p)->next; + if (*p) *p = img->next; + if (img) img->next = NULL; +} + +static void image_track_dmabuf(struct vkp_image *img, int fd, uint32_t drm_format, + uint64_t modifier, uint32_t stride, uint32_t offset) { + img->source_fd = dup(fd); + img->source_type = img->source_fd >= 0 ? VKP_IMAGE_SOURCE_DMABUF : VKP_IMAGE_SOURCE_NONE; + img->source_drm_format = drm_format; + img->source_modifier = modifier; + img->source_stride = stride; + img->source_offset = offset; + image_register(img); + if (img->source_type == VKP_IMAGE_SOURCE_NONE) + droiddeck_log("gpu", "device recovery unavailable for one DMA-BUF: source FD could not be retained"); +} + +static void image_track_ahb(struct vkp_image *img, AHardwareBuffer *buffer, + enum vkp_image_source source_type) { + AHardwareBuffer_acquire(buffer); + img->android_buffer = buffer; + img->source_type = source_type; + image_register(img); +} + +static void destroy_image_objects(struct vkp_image *img); + static ANativeWindow *g_window; static int g_ahb_import; static int g_drm_modifiers; static char *g_driver_path, *g_library_name, *g_native_lib_dir; static int g_allow_driver_fallback; static int g_dev_state; +static int dev_init(void); static void device_lost(const char *where); static const char *vk_result_name(VkResult r); @@ -105,7 +161,9 @@ static uint32_t g_qfam; static VkCommandPool g_pool; #define MAX_PRESENTS (1 + VKP_FG_MAX_GENERATIONS) static VkCommandBuffer g_cmds[MAX_PRESENTS]; -static VkSemaphore g_acqs[MAX_PRESENTS], g_rnds[MAX_PRESENTS]; +static VkSemaphore g_acqs[MAX_PRESENTS]; +static VkSemaphore *g_rnds; +static uint32_t g_rnd_count; static VkFence g_fence; static int g_swap_extra; #define SCENE_FMT VK_FORMAT_R8G8B8A8_UNORM @@ -174,6 +232,16 @@ static VkResult timed_wait(VkFence fence, uint64_t timeout) { return g_dev_state == -2 ? VK_ERROR_DEVICE_LOST : VK_ERROR_UNKNOWN; int64_t t0 = perf_now(); VkResult r = g_vk.WaitForFences(g_dev, 1, &fence, VK_TRUE, timeout); + if (r == VK_TIMEOUT) { + droiddeck_log("gpu", "GPU fence delayed: retaining frame resources until completion"); + /* A scheduling delay does not invalidate the device. Keep this submission's + * resources and call stack alive, as the main render path already does. */ + do { + r = g_vk.WaitForFences(g_dev, 1, &fence, VK_TRUE, UINT64_MAX); + } while (r == VK_TIMEOUT); + if (r == VK_SUCCESS) + droiddeck_log("gpu", "GPU fence completed: continuing presentation"); + } perf_add(&g_perf.wait_ns, &g_perf.wait_max_ns, &g_perf.waits, perf_now() - t0); if (r != VK_SUCCESS && r != VK_ERROR_DEVICE_LOST) quarantine_pending_work(r, "fence wait"); @@ -212,13 +280,16 @@ static pthread_cond_t g_req_condition = PTHREAD_COND_INITIALIZER; static volatile int g_mode = VKP_MODE_STRETCH, g_align = VKP_ALIGN_CENTER; +static volatile float g_zoom = 1.0f; static struct { int scene_w, scene_h, out_w, out_h, mode, align; float kx, ky, off_x, off_y; + float base_kx, base_ky, base_off_x, base_off_y, zoom; int rx, ry, rw, rh; int valid; } g_map; +static pthread_mutex_t g_map_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t g_game_picture_lock = PTHREAD_MUTEX_INITIALIZER; static float g_game_picture_rect[4]; static int g_game_picture_placed; @@ -264,12 +335,44 @@ static void reset_sync(void) { VkSemaphoreCreateInfo semci = {.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO}; for (int k = 0; k < MAX_PRESENTS; k++) { if (g_acqs[k]) g_vk.DestroySemaphore(g_dev, g_acqs[k], NULL); - if (g_rnds[k]) g_vk.DestroySemaphore(g_dev, g_rnds[k], NULL); - g_vk.CreateSemaphore(g_dev, &semci, NULL, &g_acqs[k]); - g_vk.CreateSemaphore(g_dev, &semci, NULL, &g_rnds[k]); + g_acqs[k] = VK_NULL_HANDLE; + if (g_vk.CreateSemaphore(g_dev, &semci, NULL, &g_acqs[k]) != VK_SUCCESS) + droiddeck_log("error", "present: failed to recreate acquire semaphore %d", k); } } +static void destroy_present_semaphores(void) { + if (g_dev && g_vk.DestroySemaphore) { + for (uint32_t i = 0; i < g_rnd_count; i++) + if (g_rnds[i]) g_vk.DestroySemaphore(g_dev, g_rnds[i], NULL); + } + free(g_rnds); + g_rnds = NULL; + g_rnd_count = 0; +} + +static int create_present_semaphores(void) { + if (!g_nimg) return -1; + VkSemaphore *sems = calloc(g_nimg, sizeof(*sems)); + if (!sems) return -1; + VkSemaphoreCreateInfo semci = {.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO}; + for (uint32_t i = 0; i < g_nimg; i++) { + VkResult r = g_vk.CreateSemaphore(g_dev, &semci, NULL, &sems[i]); + if (r != VK_SUCCESS) { + droiddeck_log("error", "present: failed to create image semaphore %u (%s)", + i, vk_result_name(r)); + for (uint32_t j = 0; j < i; j++) + if (sems[j]) g_vk.DestroySemaphore(g_dev, sems[j], NULL); + free(sems); + return -1; + } + } + destroy_present_semaphores(); + g_rnds = sems; + g_rnd_count = g_nimg; + return 0; +} + static void destroy_swapchain(void) { g_base_black = 0; if (g_dev_state != 1) return; @@ -279,10 +382,11 @@ static void destroy_swapchain(void) { else quarantine_pending_work(idle, "swapchain idle"); return; } - reset_sync(); for (uint32_t i = 0; i < g_nimg; i++) blendp_forget_image(g_images[i]); if (g_swapchain) g_vk.DestroySwapchainKHR(g_dev, g_swapchain, NULL); g_swapchain = VK_NULL_HANDLE; + destroy_present_semaphores(); + reset_sync(); g_swap_md_identity = 0; if (g_surface) g_vk.DestroySurfaceKHR(g_inst, g_surface, NULL); g_surface = VK_NULL_HANDLE; @@ -373,8 +477,21 @@ int vkp_completion_unknown(void) { return g_dev_state == -3; } void vk_present_set_scale_mode(int mode, int alignment) { if (mode < VKP_MODE_OFF || mode > VKP_MODE_INTEGER) mode = VKP_MODE_FIT; if (alignment < VKP_ALIGN_CENTER || alignment > VKP_ALIGN_PICTURE_RIGHT) alignment = VKP_ALIGN_CENTER; + pthread_mutex_lock(&g_map_lock); g_mode = mode; g_align = alignment; + pthread_mutex_unlock(&g_map_lock); +} + +void vk_present_set_zoom(float zoom) { + if (!(zoom >= 1.0f)) zoom = 1.0f; + if (zoom > 3.0f) zoom = 3.0f; + zoom = 1.0f + roundf((zoom - 1.0f) * 4.0f) * 0.25f; + pthread_mutex_lock(&g_map_lock); + if (g_zoom != zoom) { + g_zoom = zoom; + } + pthread_mutex_unlock(&g_map_lock); } static const char *mode_name(int m) { @@ -400,13 +517,18 @@ static const char *align_name(int a) { } static void update_map(int scene_w, int scene_h) { + pthread_mutex_lock(&g_map_lock); int mode = g_mode, align = g_align; + float zoom = g_zoom; int W = (int)g_extent.width, H = (int)g_extent.height; if (g_map.valid && g_map.scene_w == scene_w && g_map.scene_h == scene_h && g_map.out_w == W && - g_map.out_h == H && g_map.mode == mode && g_map.align == align) + g_map.out_h == H && g_map.mode == mode && g_map.align == align && g_map.zoom == zoom) { + pthread_mutex_unlock(&g_map_lock); return; + } + g_map.valid = 0; g_map.scene_w = scene_w; g_map.scene_h = scene_h; g_map.out_w = W; g_map.out_h = H; - g_map.mode = mode; g_map.align = align; + g_map.mode = mode; g_map.align = align; g_map.zoom = zoom; int half = H / 2; switch (align) { @@ -439,6 +561,82 @@ static void update_map(int scene_w, int scene_h) { else if (align == VKP_ALIGN_PICTURE_BOTTOM) g_map.off_y = H - scene_h * g_map.ky; else if (align == VKP_ALIGN_PICTURE_LEFT) g_map.off_x = 0; else if (align == VKP_ALIGN_PICTURE_RIGHT) g_map.off_x = W - scene_w * g_map.kx; + + g_map.base_kx = g_map.kx; + g_map.base_ky = g_map.ky; + g_map.base_off_x = g_map.off_x; + g_map.base_off_y = g_map.off_y; + + if (!(g_map.base_kx > 0.0f) || !(g_map.base_ky > 0.0f) || + !isfinite(g_map.base_kx) || !isfinite(g_map.base_ky) || + !isfinite(g_map.base_off_x) || !isfinite(g_map.base_off_y)) { + pthread_mutex_lock(&g_game_picture_lock); + g_game_picture_placed = 0; + pthread_mutex_unlock(&g_game_picture_lock); + pthread_mutex_unlock(&g_map_lock); + return; + } + + if (zoom > 1.0f) { + float cx = (float)g_map.rx + (float)g_map.rw * 0.5f; + float cy = (float)g_map.ry + (float)g_map.rh * 0.5f; + float image_w, image_h; + + g_map.kx = g_map.base_kx * zoom; + g_map.ky = g_map.base_ky * zoom; + image_w = scene_w * g_map.kx; + image_h = scene_h * g_map.ky; + + g_map.off_x = cx + (g_map.base_off_x - cx) * zoom; + g_map.off_y = cy + (g_map.base_off_y - cy) * zoom; + + if (image_w >= g_map.rw) { + float min_x = (float)g_map.rx + g_map.rw - image_w; + if (g_map.off_x < min_x) g_map.off_x = min_x; + if (g_map.off_x > g_map.rx) g_map.off_x = (float)g_map.rx; + } else { + g_map.off_x = (float)g_map.rx + (g_map.rw - image_w) * 0.5f; + } + + if (image_h >= g_map.rh) { + 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 > g_map.ry) g_map.off_y = (float)g_map.ry; + } else { + g_map.off_y = (float)g_map.ry + (g_map.rh - image_h) * 0.5f; + } + } + + if (zoom > 1.0f && + (!(g_map.kx > 0.0f) || !(g_map.ky > 0.0f) || + !isfinite(g_map.kx) || !isfinite(g_map.ky) || + !isfinite(g_map.off_x) || !isfinite(g_map.off_y))) { + if (g_map.base_kx > 0.0f && g_map.base_ky > 0.0f && + isfinite(g_map.base_kx) && isfinite(g_map.base_ky) && + isfinite(g_map.base_off_x) && isfinite(g_map.base_off_y)) { + g_map.kx = g_map.base_kx; + g_map.ky = g_map.base_ky; + g_map.off_x = g_map.base_off_x; + g_map.off_y = g_map.base_off_y; + } else { + pthread_mutex_lock(&g_game_picture_lock); + g_game_picture_placed = 0; + pthread_mutex_unlock(&g_game_picture_lock); + pthread_mutex_unlock(&g_map_lock); + return; + } + } + + if (!(g_map.kx > 0.0f) || !(g_map.ky > 0.0f) || + !isfinite(g_map.kx) || !isfinite(g_map.ky) || + !isfinite(g_map.off_x) || !isfinite(g_map.off_y)) { + pthread_mutex_lock(&g_game_picture_lock); + g_game_picture_placed = 0; + pthread_mutex_unlock(&g_game_picture_lock); + pthread_mutex_unlock(&g_map_lock); + return; + } + g_map.valid = 1; pthread_mutex_lock(&g_game_picture_lock); g_game_picture_placed = mode == VKP_MODE_INTEGER || align == VKP_ALIGN_PICTURE_TOP || align == VKP_ALIGN_PICTURE_BOTTOM || align == VKP_ALIGN_PICTURE_LEFT || align == VKP_ALIGN_PICTURE_RIGHT; @@ -451,6 +649,7 @@ static void update_map(int scene_w, int scene_h) { mode_name(mode), align_name(align), scene_w, scene_h, (int)(scene_w * g_map.kx + 0.5f), (int)(scene_h * g_map.ky + 0.5f), (int)g_map.off_x, (int)g_map.off_y, W, H); + pthread_mutex_unlock(&g_map_lock); } int vkp_game_picture_rect(float rect[4]) { @@ -462,16 +661,26 @@ int vkp_game_picture_rect(float rect[4]) { } int vkp_output_to_scene(double ox, double oy, double *sx, double *sy) { - if (!g_map.valid || g_map.kx <= 0 || g_map.ky <= 0) return 0; + pthread_mutex_lock(&g_map_lock); + if (!g_map.valid || g_map.kx <= 0 || g_map.ky <= 0) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } *sx = (ox - g_map.off_x) / g_map.kx; *sy = (oy - g_map.off_y) / g_map.ky; + pthread_mutex_unlock(&g_map_lock); return 1; } int vkp_scene_to_output(double sx, double sy, double *ox, double *oy) { - if (!g_map.valid || g_map.kx <= 0 || g_map.ky <= 0) return 0; + pthread_mutex_lock(&g_map_lock); + if (!g_map.valid || g_map.kx <= 0 || g_map.ky <= 0) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } *ox = sx * g_map.kx + g_map.off_x; *oy = sy * g_map.ky + g_map.off_y; + pthread_mutex_unlock(&g_map_lock); return 1; } @@ -480,6 +689,99 @@ void vkp_output_size(int *w, int *h) { *h = (int)g_extent.height; } +int vkp_zoom_pan_cursor(double ox, double oy) { + double cursor_x, cursor_y; + float next_x, next_y; + float image_w, image_h; + int changed; + + pthread_mutex_lock(&g_map_lock); + if (!g_map.valid || g_map.zoom != g_zoom || g_map.mode != g_mode || + g_map.align != g_align || g_zoom <= 1.0f || g_zoom > 3.0f || + g_map.scene_w <= 0 || g_map.scene_h <= 0 || + g_map.rw <= 0 || g_map.rh <= 0 || + g_map.base_kx <= 0.0f || g_map.base_ky <= 0.0f || + g_map.kx <= 0.0f || g_map.ky <= 0.0f || + !isfinite(g_map.base_kx) || !isfinite(g_map.base_ky) || + !isfinite(g_map.kx) || !isfinite(g_map.ky) || + !isfinite(g_map.off_x) || !isfinite(g_map.off_y)) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } + + if (!isfinite(ox) || !isfinite(oy)) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } + + cursor_x = (ox - g_map.off_x) / g_map.kx; + cursor_y = (oy - g_map.off_y) / g_map.ky; + + if (cursor_x < 0.0) cursor_x = 0.0; + if (cursor_y < 0.0) cursor_y = 0.0; + if (cursor_x > g_map.scene_w - 1) cursor_x = g_map.scene_w - 1; + if (cursor_y > g_map.scene_h - 1) cursor_y = g_map.scene_h - 1; + + next_x = g_map.off_x; + next_y = g_map.off_y; + image_w = g_map.scene_w * g_map.kx; + image_h = g_map.scene_h * g_map.ky; + + if (image_w > g_map.rw) { + float left = ((float)g_map.rx - g_map.off_x) / g_map.kx; + float right = ((float)(g_map.rx + g_map.rw) - g_map.off_x) / g_map.kx; + float margin = (right - left) * 0.2f; + + if (cursor_x < left + margin) + next_x += (float)(left + margin - cursor_x) * g_map.kx * 0.5f; + else if (cursor_x > right - margin) + next_x -= (float)(cursor_x - (right - margin)) * g_map.kx * 0.5f; + + float min_x = (float)g_map.rx + g_map.rw - image_w; + if (next_x < min_x) next_x = min_x; + if (next_x > g_map.rx) next_x = (float)g_map.rx; + } + + if (image_h > g_map.rh) { + float top = ((float)g_map.ry - g_map.off_y) / g_map.ky; + float bottom = ((float)(g_map.ry + g_map.rh) - g_map.off_y) / g_map.ky; + float margin = (bottom - top) * 0.2f; + + if (cursor_y < top + margin) + next_y += (float)(top + margin - cursor_y) * g_map.ky * 0.5f; + else if (cursor_y > bottom - margin) + next_y -= (float)(cursor_y - (bottom - margin)) * g_map.ky * 0.5f; + + float min_y = (float)g_map.ry + g_map.rh - image_h; + if (next_y < min_y) next_y = min_y; + if (next_y > g_map.ry) next_y = (float)g_map.ry; + } + + if (!isfinite(next_x) || !isfinite(next_y)) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } + + changed = fabsf(next_x - g_map.off_x) >= 0.5f || + fabsf(next_y - g_map.off_y) >= 0.5f; + if (!changed) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } + + g_map.off_x = next_x; + g_map.off_y = next_y; + + pthread_mutex_lock(&g_game_picture_lock); + g_game_picture_rect[0] = g_map.off_x; + g_game_picture_rect[1] = g_map.off_y; + g_game_picture_rect[2] = g_map.off_x + g_map.scene_w * g_map.kx; + g_game_picture_rect[3] = g_map.off_y + g_map.scene_h * g_map.ky; + pthread_mutex_unlock(&g_game_picture_lock); + pthread_mutex_unlock(&g_map_lock); + return 1; +} + static void init_black_image(void); static int has_ext(VkExtensionProperties *e, uint32_t n, const char *name) { @@ -518,7 +820,7 @@ static void log_display_driver(void) { g_library_name); } -static int dev_init(void) { +static int dev_init_once(void) { if (g_dev_state != 0) return g_dev_state == 1 ? 0 : -1; if (vk_loader_open(g_driver_path, g_library_name, g_native_lib_dir) != 0) { @@ -720,6 +1022,189 @@ static int dev_init(void) { return 0; } +static void suspend_client_images(void) { + for (struct vkp_image *img = g_client_images; img; img = img->next) { + if (img->source_type == VKP_IMAGE_SOURCE_SHM && !img->recovery_pixels) + img->source_type = VKP_IMAGE_SOURCE_NONE; + if (img->map && g_vk.UnmapMemory && g_dev) g_vk.UnmapMemory(g_dev, img->mem); + img->map = NULL; + destroy_image_objects(img); + } +} + +static int restore_client_image(struct vkp_image *img) { + if (!img || img->source_type == VKP_IMAGE_SOURCE_NONE) return -1; + struct vkp_image *replacement = NULL; + switch (img->source_type) { + case VKP_IMAGE_SOURCE_DMABUF: + if (img->source_fd >= 0) + replacement = vkp_image_import_dmabuf(img->source_fd, img->source_drm_format, img->source_modifier, + img->w, img->h, img->source_stride, img->source_offset, + img->blit_dst); + break; + case VKP_IMAGE_SOURCE_AHB_WLEGL: + replacement = vkp_image_from_android_buffer(img->android_buffer); + break; + case VKP_IMAGE_SOURCE_AHB_SOURCE: + replacement = vkp_image_from_ahb(img->android_buffer); + break; + case VKP_IMAGE_SOURCE_AHB_TARGET: + replacement = vkp_image_import_ahb(img->android_buffer, NULL, 0); + break; + case VKP_IMAGE_SOURCE_SHM: + replacement = vkp_image_create_shm(img->w, img->h); + break; + default: + break; + } + if (!replacement) return -1; + + struct vkp_image *next = img->next; + const enum vkp_image_source old_type = img->source_type; + const int old_fd = img->source_fd; + AHardwareBuffer *old_ahb = img->android_buffer; + uint8_t *pixels = img->recovery_pixels; + image_unregister(replacement); + *img = *replacement; + img->next = next; + free(replacement); + if (old_type == VKP_IMAGE_SOURCE_DMABUF && old_fd >= 0) close(old_fd); + if (old_ahb) AHardwareBuffer_release(old_ahb); + if (old_type == VKP_IMAGE_SOURCE_SHM && pixels && img->map) { + const size_t row_bytes = (size_t)img->w * 4; + for (int y = 0; y < img->h; y++) + memcpy((uint8_t *)img->map + img->offset + (size_t)y * img->row_pitch, + pixels + (size_t)y * row_bytes, row_bytes); + img->recovery_pixels = pixels; + pixels = NULL; + } + free(pixels); + return 0; +} + +static int restore_client_images(void) { + int failed = 0; + for (struct vkp_image *img = g_client_images; img; ) { + struct vkp_image *next = img->next; + if (restore_client_image(img) != 0) { + failed++; + droiddeck_log("error", "GPU recovery: could not re-import a retained %dx%d client buffer", + img->w, img->h); + } + img = next; + } + return failed ? -1 : 0; +} + +static void release_lost_device(void) { + vkp_pass_abort(); + blendp_destroy(); + vkp_effects_destroy(); + hdrc_destroy(); + vkp_cardboard_destroy(); + vkp_framegen_device_lost(); + vkp_gpu_busy_device_lost(); + suspend_client_images(); + + if (g_rb) { + vkp_image_destroy(g_rb); + g_rb = NULL; + } + if (g_scene.img) g_vk.DestroyImage(g_dev, g_scene.img, NULL); + if (g_scene.mem) g_vk.FreeMemory(g_dev, g_scene.mem, NULL); + memset(&g_scene, 0, sizeof(g_scene)); + struct vkp_img_slot *slots[] = {&g_mixed, &g_hdrscene, &g_fgscene}; + for (size_t i = 0; i < sizeof(slots) / sizeof(slots[0]); i++) { + if (slots[i]->img) g_vk.DestroyImage(g_dev, slots[i]->img, NULL); + if (slots[i]->mem) g_vk.FreeMemory(g_dev, slots[i]->mem, NULL); + memset(slots[i], 0, sizeof(*slots[i])); + } + if (g_black_img) g_vk.DestroyImage(g_dev, g_black_img, NULL); + if (g_black_mem) g_vk.FreeMemory(g_dev, g_black_mem, NULL); + g_black_img = VK_NULL_HANDLE; + g_black_mem = VK_NULL_HANDLE; + g_black_state = 0; + + for (int i = 0; i < MAX_PRESENTS; i++) { + if (g_acqs[i]) g_vk.DestroySemaphore(g_dev, g_acqs[i], NULL); + if (g_rnds[i]) g_vk.DestroySemaphore(g_dev, g_rnds[i], NULL); + g_acqs[i] = g_rnds[i] = VK_NULL_HANDLE; + } + if (g_wait_sem) g_vk.DestroySemaphore(g_dev, g_wait_sem, NULL); + g_wait_sem = VK_NULL_HANDLE; + if (g_fence) g_vk.DestroyFence(g_dev, g_fence, NULL); + g_fence = VK_NULL_HANDLE; + if (g_pool) g_vk.DestroyCommandPool(g_dev, g_pool, NULL); + g_pool = VK_NULL_HANDLE; + memset(g_cmds, 0, sizeof(g_cmds)); + + if (g_swapchain) g_vk.DestroySwapchainKHR(g_dev, g_swapchain, NULL); + g_swapchain = VK_NULL_HANDLE; + free(g_images); + g_images = NULL; + g_nimg = 0; + if (g_surface) g_vk.DestroySurfaceKHR(g_inst, g_surface, NULL); + g_surface = VK_NULL_HANDLE; + if (g_dev) g_vk.DestroyDevice(g_dev, NULL); + g_dev = VK_NULL_HANDLE; + if (g_inst) g_vk.DestroyInstance(g_inst, NULL); + g_inst = VK_NULL_HANDLE; + vk_loader_close(); + + g_pd = VK_NULL_HANDLE; + g_queue = VK_NULL_HANDLE; + g_qfam = 0; + memset(&g_memprops, 0, sizeof(g_memprops)); + memset(&g_map, 0, sizeof(g_map)); + memset(&g_extent, 0, sizeof(g_extent)); + memset(&g_caps_extent, 0, sizeof(g_caps_extent)); + g_surface_transform_known = 0; + g_surface_checked_ns = 0; + g_ahb_import = 0; + g_drm_modifiers = 0; + g_colorspace_ext = 0; + g_import_sem_fd = NULL; + g_ahb_properties = NULL; + g_set_hdr_metadata = NULL; + g_swap_extra = 0; + g_swap_is_hdr = 0; + g_swap_fmt = VK_FORMAT_UNDEFINED; + g_swap_md_identity = 0; + g_swap_retry_at_ns = 0; + g_swap_fail_logged = 0; + g_base_black = 0; + g_dev_state = 0; +} + +static int dev_init(void) { + if (g_dev_state != -2) return dev_init_once(); + if (g_recovery_attempted) return -1; + g_recovery_attempted = 1; + droiddeck_log("gpu", "VK_ERROR_DEVICE_LOST: attempting one in-process compositor recovery"); + release_lost_device(); + if (dev_init_once() != 0) { + if (g_dev_state == -3) { + droiddeck_log("error", "GPU recovery initialization left completion unknown; retaining resources"); + return -1; + } + release_lost_device(); + g_dev_state = -2; + droiddeck_log("error", "GPU recovery failed while recreating the Vulkan device; restart the session"); + set_fault("the display GPU was lost and in-process recovery failed"); + return -1; + } + if (restore_client_images() != 0) { + release_lost_device(); + g_dev_state = -2; + droiddeck_log("error", "GPU recovery could not restore every client buffer; restart the session"); + set_fault("the display GPU was lost and some client buffers could not be restored"); + return -1; + } + g_recovery_attempted = 0; + droiddeck_log("gpu", "Vulkan device and retained client buffers recovered"); + return 0; +} + int vkp_ready(void) { return dev_init(); } static int swap_init_locked(void); @@ -925,12 +1410,35 @@ static int swap_init_locked(void) { SWLOGE("present: vkCreateSwapchainKHR failed (%d)", (int)cr); return -1; } - g_vk.GetSwapchainImagesKHR(g_dev, g_swapchain, &g_nimg, NULL); + cr = g_vk.GetSwapchainImagesKHR(g_dev, g_swapchain, &g_nimg, NULL); + if (cr != VK_SUCCESS || !g_nimg) { + SWLOGE("present: vkGetSwapchainImagesKHR count failed (%s)", vk_result_name(cr)); + g_nimg = 0; + return -1; + } g_images = calloc(g_nimg, sizeof(VkImage)); - g_vk.GetSwapchainImagesKHR(g_dev, g_swapchain, &g_nimg, g_images); + if (!g_images) { + SWLOGE("present: failed to allocate swapchain image list"); + g_nimg = 0; + return -1; + } + cr = g_vk.GetSwapchainImagesKHR(g_dev, g_swapchain, &g_nimg, g_images); + if (cr != VK_SUCCESS) { + SWLOGE("present: vkGetSwapchainImagesKHR failed (%s)", vk_result_name(cr)); + free(g_images); + g_images = NULL; + g_nimg = 0; + return -1; + } + if (create_present_semaphores() != 0) { + SWLOGE("present: failed to initialize per-image present semaphores"); + return -1; + } droiddeck_log("gpu", "screen output %ux%u, %u buffers, vsync%s", g_extent.width, g_extent.height, g_nimg, g_swap_extra ? " (frame generation: several presents per frame)" : ""); + droiddeck_log("gpu", "present synchronization: %u render-finished semaphores, one per swapchain image", + g_rnd_count); return 0; } @@ -1216,6 +1724,8 @@ struct vkp_image *vkp_image_from_android_buffer(AHardwareBuffer *buffer) { if (result != VK_SUCCESS) goto fail; AHardwareBuffer_acquire(buffer); img->android_buffer = buffer; + img->source_type = VKP_IMAGE_SOURCE_AHB_WLEGL; + image_register(img); return img; fail: LOGE("android_wlegl: Vulkan buffer import failed: %s", vk_result_name(result)); @@ -1372,6 +1882,7 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t if (linear_size && import_linear_dmabuf(img, fd, &linear_copy, linear_size) == 0) { if (padded_target) droiddeck_log("gpu", "linear layer target %dx%d writes at pitch %u via DMA-BUF", w, h, stride); + image_track_dmabuf(img, fd, drm_format, modifier, stride, offset); return img; } if (padded_target) { free(img); return NULL; } @@ -1441,11 +1952,12 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t g_vk.FreeMemory(g_dev, img->mem, NULL); g_vk.DestroyImage(g_dev, img->image, NULL); free(img); return NULL; } + image_track_dmabuf(img, fd, drm_format, modifier, stride, offset); return img; } void vkp_wait_idle(void) { - if (g_dev && g_vk.DeviceWaitIdle) g_vk.DeviceWaitIdle(g_dev); + if (g_dev_state == 1 && g_dev && g_vk.DeviceWaitIdle) g_vk.DeviceWaitIdle(g_dev); } struct vkp_image *vkp_image_from_ahb(AHardwareBuffer *ahb) { @@ -1495,6 +2007,7 @@ struct vkp_image *vkp_image_from_ahb(AHardwareBuffer *ahb) { if (img->mem) g_vk.FreeMemory(g_dev, img->mem, NULL); g_vk.DestroyImage(g_dev, img->image, NULL); free(img); return NULL; } + image_track_ahb(img, ahb, VKP_IMAGE_SOURCE_AHB_SOURCE); return img; } @@ -1590,6 +2103,7 @@ struct vkp_image *vkp_image_import_ahb(struct AHardwareBuffer *ahb, char *info, if (info && info_n) snprintf(info, info_n, "VkFormat %d, %llu bytes, memory type %d of memoryTypeBits %#x", (int)fp.format, (unsigned long long)hp.allocationSize, idx, hp.memoryTypeBits); + image_track_ahb(img, ahb, VKP_IMAGE_SOURCE_AHB_TARGET); return img; } @@ -1643,13 +2157,34 @@ struct vkp_image *vkp_image_create_shm(int w, int h) { if (g_vk.MapMemory(g_dev, img->mem, 0, req.size, 0, &img->map) != VK_SUCCESS) { vkp_image_destroy(img); return NULL; } + img->source_type = VKP_IMAGE_SOURCE_SHM; + image_register(img); return img; } void vkp_image_upload_shm(struct vkp_image *img, const void *data, int stride) { - if (g_dev_state != 1 || !img || !img->map || !data) return; - size_t rowbytes = (size_t)img->w * 4; + if (!img || !data || img->w <= 0 || img->h <= 0 || stride <= 0 || + (size_t)img->w > SIZE_MAX / 4) + return; + + const size_t full_rowbytes = (size_t)img->w * 4; + size_t rowbytes = full_rowbytes; if ((size_t)stride < rowbytes) rowbytes = (size_t)stride; + + if (img->source_type == VKP_IMAGE_SOURCE_SHM && !img->recovery_pixels) { + if ((size_t)img->h <= SIZE_MAX / full_rowbytes) { + const size_t bytes = full_rowbytes * (size_t)img->h; + img->recovery_pixels = calloc(1, bytes); + } + if (!img->recovery_pixels) img->source_type = VKP_IMAGE_SOURCE_NONE; + } + if (img->source_type == VKP_IMAGE_SOURCE_SHM && img->recovery_pixels) { + for (int y = 0; y < img->h; y++) + memcpy(img->recovery_pixels + (size_t)y * full_rowbytes, + (const uint8_t *)data + (size_t)y * stride, rowbytes); + } + + if (g_dev_state != 1 || !img->map) return; for (int y = 0; y < img->h; y++) memcpy((uint8_t *)img->map + img->offset + (size_t)y * img->row_pitch, (const uint8_t *)data + (size_t)y * stride, rowbytes); @@ -1666,7 +2201,10 @@ void vkp_image_destroy(struct vkp_image *img) { if (img->map) g_vk.UnmapMemory(g_dev, img->mem); destroy_image_objects(img); } + image_unregister(img); + if (img->source_type == VKP_IMAGE_SOURCE_DMABUF && img->source_fd >= 0) close(img->source_fd); if (img->android_buffer) AHardwareBuffer_release(img->android_buffer); + free(img->recovery_pixels); free(img); } @@ -1930,14 +2468,23 @@ static int compose_hdr(VkCommandBuffer cmd, const struct vkp_draw *draws, int n, } static void device_lost(const char *where) { - if (g_dev_state == -2) return; + if (g_dev_state == -2 || g_dev_state == -3) return; + + if (g_dev_state == 1) { + VkResult idle = g_vk.DeviceWaitIdle ? g_vk.DeviceWaitIdle(g_dev) : VK_ERROR_UNKNOWN; + if (idle != VK_SUCCESS && idle != VK_ERROR_DEVICE_LOST) { + quarantine_pending_work(idle, "device-loss idle"); + return; + } + } + g_dev_state = -2; g_base_black = 0; vkp_framegen_device_lost(); vkp_gpu_busy_device_lost(); - droiddeck_log("error", "GPU device lost (VK_ERROR_DEVICE_LOST in %s): the compositor has stopped presenting; " - "restart the session", where); - set_fault("the display GPU was lost (VK_ERROR_DEVICE_LOST in %s)", where); + droiddeck_log("error", "GPU device lost (VK_ERROR_DEVICE_LOST in %s): the compositor will try one in-process recovery", + where); + set_fault("the display GPU was lost (VK_ERROR_DEVICE_LOST in %s); recovery pending", where); for (uint32_t i = 0; i < g_nimg; i++) blendp_forget_image(g_images[i]); if (g_swapchain) g_vk.DestroySwapchainKHR(g_dev, g_swapchain, NULL); g_swapchain = VK_NULL_HANDLE; @@ -2162,11 +2709,10 @@ static void send_hdr_metadata(const struct droiddeck_color *c) { static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, int n, const struct vkp_hdr_frame *hf, int *how) { if (how) *how = 0; - if (g_dev_state < 0) return -1; + if (g_dev_state == -1 || g_dev_state == -3) return -1; vkp_apply_window_request(); sc_layer_hide_base(); check_surface_changed(); - if (g_dev_state == -2) return -1; if (dev_init() != 0 || !g_window || scene_w <= 0 || scene_h <= 0) return -1; if (g_swapchain && vkp_framegen_extra_images() != g_swap_extra) { @@ -2218,6 +2764,21 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i pass_n = 1; overlay_start = source_end; } + 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 post_upscale = fx && fg && !hf && !cb && vkp_effects_upscaling() && + vkp_effects_prepare_generated() && + (upscale_w > input_w || upscale_h > input_h); + if (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 || + upscale_w != last_output_w || upscale_h != last_output_h) { + droiddeck_log("framegen", "post-upscale: interpolate %dx%d, spatial filter each present to %dx%d", + input_w, input_h, upscale_w, upscale_h); + last_input_w = input_w; last_input_h = input_h; + last_output_w = upscale_w; last_output_h = upscale_h; + } + } const int deep = hf && n > 0 && fg && g_swap_is_hdr && !hf->tonemap && vkp_framegen_format_ok(FG_HDR_FMT) && ensure_img(&g_fgscene, scene_w, scene_h, FG_HDR_FMT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | @@ -2314,11 +2875,15 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i int drawn = 0; int hdr_how = 0; - if (hf && pass && n > 0 && + const int hdr_compose_requested = hf && pass && n > 0; + int hdr_unconverted = 0; + if (hdr_compose_requested && compose_hdr(cmd, draws, n, hf, scene_w, scene_h, scene_img, scene_fmt, g_swap_is_hdr ? HDRC_OUT_PQ : HDRC_OUT_SDR) == 0) { hdr_how = g_swap_is_hdr ? 1 : 2; drawn = n; + } else if (hdr_compose_requested) { + hdr_unconverted = 1; } for (int i = 0; i < draw_n && !hdr_how; i++) { VkImageBlit blit; @@ -2349,8 +2914,11 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i if (fx) { int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f); if (fg && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; } - vkp_effects_set_formats(scene_fmt, scene_fmt); - result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h, &rw, &rh); + if (post_upscale) { mapped_w = input_w; mapped_h = input_h; } + vkp_effects_set_formats(scene_fmt, scene_fmt, hdr_how == 1 || hdr_unconverted); + result = post_upscale + ? vkp_effects_run_before_generated(cmd, scene_img, input_w, input_h, &rw, &rh) + : vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h, &rw, &rh); effects_overlay_draws(cmd, result, rw, rh, scene_w, scene_h, draws ? draws + overlay_start : NULL, n - overlay_start); release_external_client_draws(cmd, draws, n); @@ -2373,7 +2941,12 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i if (ngen > VKP_FG_MAX_GENERATIONS) ngen = VKP_FG_MAX_GENERATIONS; } - record_screen_blit(cmd, ngen ? gens[0] : result, rw, rh, scene_w, scene_h, img, blit_filter, cb); + VkImage screen = ngen ? gens[0] : result; + int screen_w = rw, screen_h = rh; + if (post_upscale) + screen = vkp_effects_run_generated(cmd, screen, rw, rh, upscale_w, upscale_h, + 0, &screen_w, &screen_h); + record_screen_blit(cmd, screen, screen_w, screen_h, scene_w, scene_h, img, blit_filter, cb); } g_vk.EndCommandBuffer(cmd); @@ -2397,14 +2970,27 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i VkCommandBuffer ck = g_cmds[k]; g_vk.ResetCommandBuffer(ck, 0); g_vk.BeginCommandBuffer(ck, &bi); - record_screen_blit(ck, k < ngen ? gens[k] : result, rw, rh, scene_w, scene_h, img, blit_filter, cb); + VkImage screen = k < ngen ? gens[k] : result; + int screen_w = rw, screen_h = rh; + if (post_upscale) + screen = vkp_effects_run_generated(ck, screen, rw, rh, upscale_w, upscale_h, + k, &screen_w, &screen_h); + record_screen_blit(ck, screen, screen_w, screen_h, scene_w, scene_h, img, blit_filter, cb); g_vk.EndCommandBuffer(ck); } const int last = (k + 1 == presents); VkPipelineStageFlags wait = VK_PIPELINE_STAGE_TRANSFER_BIT; + /* A present-wait semaphore is reused only after this exact swapchain image + * has been acquired again; a frame-slot fence cannot prove present completion. */ + if (img >= g_rnd_count || !g_rnds[img]) { + droiddeck_log("error", "present: image index %u exceeds semaphore count %u", + img, g_rnd_count); + destroy_swapchain(); + return -1; + } VkSubmitInfo si = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .waitSemaphoreCount = 1, .pWaitSemaphores = &g_acqs[k], .pWaitDstStageMask = &wait, .commandBufferCount = 1, - .pCommandBuffers = &g_cmds[k], .signalSemaphoreCount = 1, .pSignalSemaphores = &g_rnds[k]}; + .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); if (qr != VK_SUCCESS) { if (qr == VK_ERROR_DEVICE_LOST) device_lost("submit"); @@ -2414,7 +3000,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i } fence_submitted = last; VkPresentInfoKHR pi = {.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, .waitSemaphoreCount = 1, - .pWaitSemaphores = &g_rnds[k], .swapchainCount = 1, + .pWaitSemaphores = &g_rnds[img], .swapchainCount = 1, .pSwapchains = &g_swapchain, .pImageIndices = &img}; const int64_t t_pres = perf_now(); pr = g_vk.QueuePresentKHR(g_queue, &pi); @@ -2435,6 +3021,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i VkResult fr = timed_wait(g_fence, UINT64_MAX); if (fr == VK_ERROR_DEVICE_LOST || pr == VK_ERROR_DEVICE_LOST) { device_lost("present"); return -1; } if (fr != VK_SUCCESS) return -1; + vkp_effects_release_generated_sources(); if (fg) vkp_framegen_presented(presented_gen); if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) { droiddeck_log("gpu", "screen surface %s on present: rebuilding the swapchain", vk_result_name(pr)); @@ -2507,7 +3094,7 @@ void vkp_signal_first_frame(void) { } int vkp_update_map(int scene_w, int scene_h) { - if (g_dev_state == -2 || dev_init() != 0 || !g_window || scene_w <= 0 || scene_h <= 0) return -1; + if (dev_init() != 0 || !g_window || scene_w <= 0 || scene_h <= 0) return -1; if (vkp_quest_layer_presentation()) { int w = ANativeWindow_getWidth(g_window), h = ANativeWindow_getHeight(g_window); if (w <= 0 || h <= 0) return -1; @@ -2581,7 +3168,7 @@ static void blit_to_layer(VkCommandBuffer cmd, VkImage src, VkImageLayout src_la } int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) { - if (!src || src->blit_dst || !dst || !dst->blit_dst || g_dev_state == -2 || dev_init() != 0) { + if (!src || src->blit_dst || !dst || !dst->blit_dst || dev_init() != 0) { if (wait_fd >= 0) close(wait_fd); return -1; } @@ -2644,11 +3231,9 @@ int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) { -static struct vkp_image *g_rb; - int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px) { if (!src || src->blit_dst || !out || src->w <= 0 || src->h <= 0 || src->w * src->h > max_px || - g_dev_state == -2 || dev_init() != 0) + dev_init() != 0) return -1; if (g_rb && (g_rb->w != src->w || g_rb->h != src->h)) { vkp_image_destroy(g_rb); g_rb = NULL; } if (!g_rb) { @@ -2874,7 +3459,7 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw g_vk.EndCommandBuffer(cmd); return -1; } - if (vkp_effects_active()) vkp_effects_set_formats(scene_fmt, scene_fmt); + if (vkp_effects_active()) vkp_effects_set_formats(scene_fmt, scene_fmt, !hf->tonemap); } else { VkClearColorValue black = {.float32 = {0.0f, 0.0f, 0.0f, 1.0f}}; g_vk.CmdClearColorImage(cmd, g_scene.img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &black, 1, &range); @@ -2889,7 +3474,7 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw record_draw(cmd, &pass_draws[i], &blit, g_scene.img, SCENE_FMT, input_w, input_h, VK_FILTER_LINEAR); } - if (vkp_effects_active()) vkp_effects_set_formats(VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM); + if (vkp_effects_active()) vkp_effects_set_formats(VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, 0); } int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f); diff --git a/app/src/main/cpp/waylandcomp/src/vk_present.h b/app/src/main/cpp/waylandcomp/src/vk_present.h index 69af7dca23..bc35ac8b49 100644 --- a/app/src/main/cpp/waylandcomp/src/vk_present.h +++ b/app/src/main/cpp/waylandcomp/src/vk_present.h @@ -20,6 +20,8 @@ enum vkp_align { VKP_ALIGN_CENTER = 0, VKP_ALIGN_TOP = 1, VKP_ALIGN_BOTTOM = 2, VKP_ALIGN_PICTURE_TOP = 3, VKP_ALIGN_PICTURE_BOTTOM = 4, VKP_ALIGN_PICTURE_LEFT = 5, VKP_ALIGN_PICTURE_RIGHT = 6 }; void vk_present_set_scale_mode(int mode, int alignment); +void vk_present_set_zoom(float zoom); +int vkp_zoom_pan_cursor(double ox, double oy); int vkp_game_picture_rect(float rect[4]); int vkp_output_to_scene(double ox, double oy, double *sx, double *sy); int vkp_scene_to_output(double sx, double sy, double *ox, double *oy); diff --git a/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c b/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c index 308332f9b1..d070b8fd6f 100644 --- a/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c +++ b/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c @@ -22,6 +22,7 @@ extern int droiddeck_wayland_run(void); extern void droiddeck_wayland_set_scale_mode(int mode, int alignment); +extern void droiddeck_wayland_set_zoom(int zoom_percent); extern void droiddeck_wayland_send_pointer(int action, int x, int y); extern void droiddeck_wayland_send_touch(int action, int pointer_id, int x, int y); extern void droiddeck_wayland_send_pen(int flags, int x, int y); @@ -511,6 +512,15 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetScaleMode(JNIEnv __android_log_print(ANDROID_LOG_INFO, TAG, "scale mode %d alignment %d", mode, alignment); } +JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetZoom(JNIEnv *env, jclass clazz, jfloat zoom) { + (void)env; + (void)clazz; + if (!(zoom >= 1.0f)) zoom = 1.0f; + if (zoom > 3.0f) zoom = 3.0f; + droiddeck_wayland_set_zoom((int)(zoom * 100.0f + 0.5f)); +} + JNIEXPORT jboolean JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeGamePictureRect(JNIEnv *env, jclass clazz, jfloatArray out) { diff --git a/app/src/main/java/com/droiddeck/launcher/App.kt b/app/src/main/java/com/droiddeck/launcher/App.kt index 58e7e12b2c..53a0c89298 100644 --- a/app/src/main/java/com/droiddeck/launcher/App.kt +++ b/app/src/main/java/com/droiddeck/launcher/App.kt @@ -55,7 +55,7 @@ class App : Application() { com.droiddeck.launcher.session.QuestExperimental.initialize(this) com.droiddeck.launcher.session.SessionPrefs.applyNtsyncDefault(this) com.droiddeck.launcher.session.SessionPrefs.settleGpuDriverMode(this) - com.droiddeck.launcher.session.SessionPrefs.settleStoresTabOrder(this, com.droiddeck.launcher.stores.Store.entries.map { it.id }) + com.droiddeck.launcher.session.SessionPrefs.settleStoresTabOrder(this, com.droiddeck.launcher.stores.Store.tabbed.map { it.id }) com.droiddeck.launcher.update.AppUpdates.init(this) com.droiddeck.launcher.update.UpdateWatch.sync(this, com.droiddeck.launcher.update.AppUpdates.follow(this, null)) com.droiddeck.launcher.core.DownloadSource.init(this) @@ -80,6 +80,7 @@ class App : Application() { com.droiddeck.launcher.stores.ea.EaBackend.app = this com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.ea.EaBackend) com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.rockstar.RockstarBackend) + com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.steam.SteamBackend) } private fun prefetchAddonPacks() { diff --git a/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt b/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt index 925884b3c3..94b0e6c744 100644 --- a/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt +++ b/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt @@ -430,21 +430,28 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl */ private fun useMaliFallback(missing: String?): String { val oldVulkan = com.droiddeck.launcher.session.VenusComponent.hostVulkanTooOld(activity) - val venus = oldVulkan == null && com.droiddeck.launcher.session.VenusComponent.available(activity) + val venusByUser = venusExplicit() + val venus = MaliAutoRoute.venusStandsIn( + com.droiddeck.launcher.session.VenusComponent.available(activity), oldVulkan == null, + SessionPrefs.venus(activity), venusByUser, gpu.name, + ) if (oldVulkan != null) Log.i(TAG, "auto: Mali driver reports Vulkan $oldVulkan; Venus needs 1.2, the bridge stands in") val ownership = MaliAutoRoute.fallbackOwnership( venus, SessionPrefs.vkBridge(activity), bridgeExplicit(), - SessionPrefs.venus(activity), venusExplicit(), + SessionPrefs.venus(activity), venusByUser, ) if (venus && !SessionPrefs.venus(activity)) { SessionPrefs.setVenus(activity, true) if (SessionPrefs.vkBridge(activity) && !bridgeExplicit()) SessionPrefs.setVkBridge(activity, false) SessionPrefs.setMaliFallbackByAuto(activity, ownership) - } else if (!venus && !SessionPrefs.vkBridge(activity)) { - SessionPrefs.setVkBridge(activity, true) - SessionPrefs.setMaliFallbackByAuto(activity, ownership) + } else if (!venus) { + val venusOff = SessionPrefs.venus(activity) && !venusByUser + val bridgeOn = !SessionPrefs.vkBridge(activity) + if (venusOff) SessionPrefs.clearVenus(activity) + if (bridgeOn) SessionPrefs.setVkBridge(activity, true) + if (venusOff || bridgeOn || ownership != MaliAutoRoute.NONE) SessionPrefs.setMaliFallbackByAuto(activity, ownership) } else if (ownership != MaliAutoRoute.NONE) { SessionPrefs.setMaliFallbackByAuto(activity, ownership) } @@ -467,7 +474,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl /** A pair is installed for this Mali: the route Auto switched on in its place goes off again. */ private fun endMaliFallback() { when (SessionPrefs.maliFallbackByAuto(activity)) { - "venus" -> SessionPrefs.setVenus(activity, false) + "venus" -> SessionPrefs.clearVenus(activity) "bridge" -> SessionPrefs.setVkBridge(activity, false) else -> return } diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index 56cb921e0f..0a4fbb3b5c 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -1259,6 +1259,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } private fun startAfterSession(next: Intent) { + if (com.droiddeck.launcher.stores.steam.SteamStore.blocksSession(next)) { + android.widget.Toast.makeText(this, R.string.steam_store_session_wait, android.widget.Toast.LENGTH_SHORT).show() + return + } SessionService.stop(this) awaitSessionEnd(next, android.os.SystemClock.uptimeMillis() + SESSION_SWITCH_WAIT_MS) } @@ -1345,6 +1349,9 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet val shortcutsFilter = android.content.IntentFilter(SteamIntegration.SHORTCUTS_STATUS) if (android.os.Build.VERSION.SDK_INT >= 33) registerReceiver(shortcutsInstallStatus, shortcutsFilter, RECEIVER_NOT_EXPORTED) else registerReceiver(shortcutsInstallStatus, shortcutsFilter) + if (GameLaunchIntent.accepts(intent.action) && + GameLaunchIntent.replayed(intent, savedInstanceState != null, savedInstanceState?.getString(STATE_PROCESS), PROCESS)) + clearGameLinkIntent(intent) readGameIntent(intent) // A Lab build is usually the agent's work, so the app comes back where the agent is. if (savedInstanceState == null && navRequest == null && com.droiddeck.launcher.lab.LabOverlay.promoted && com.droiddeck.launcher.agent.AgentTab.visible) navRequest = "agent" @@ -1986,11 +1993,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } } - val askAllFiles = Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.files.AllFilesAccess.missing() && - !SessionPrefs.allFilesAsked(this) - if (savedInstanceState == null) { - if (!askAllFiles) ui.post { startSteamAtStartupIfEnabled(cold = true) } - } + if (savedInstanceState == null) ui.post { startSteamAtStartupIfEnabled(cold = true) } saved?.let { state -> restoreCompatLaunch(state) pendingSwitch = savedIntent(state, KEY_PENDING_SWITCH) @@ -1998,13 +2001,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } val wanted = ArrayList() - if (Build.VERSION.SDK_INT >= 30) { - // From targetSdk 30, shared storage outside the app's own folders is all-files access or nothing. - if (askAllFiles) { - SessionPrefs.setAllFilesAsked(this) - com.droiddeck.launcher.files.AllFilesAccess.open(this) - } - } else if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + // From Android 11, shared storage outside the app's own folders is all-files access, which the file picker asks for when a shared drive is opened. + if (Build.VERSION.SDK_INT < 30 && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { wanted.add(Manifest.permission.WRITE_EXTERNAL_STORAGE) } if (SessionPrefs.micEnabled(this) && !SessionPrefs.micAsked(this) @@ -2013,6 +2011,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet SessionPrefs.setMicAsked(this) } if (wanted.isNotEmpty()) requestPermissions(wanted.toTypedArray(), 1) + com.droiddeck.launcher.session.Onboarding.onFirstRunReady = firstRunReady Thread({ com.droiddeck.launcher.stores.StoreAccounts.encryptAll(this) }, "store-credentials").start() if (!SessionState.running) Thread({ com.droiddeck.launcher.session.LogMigration.run(this) @@ -2104,7 +2103,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet override fun onWindowFocusChanged(hasFocus: Boolean) { super.onWindowFocusChanged(hasFocus) - if (!hasFocus) triggerKeys.cancel() + if (!hasFocus) { + triggerKeys.cancel() + stopRightStickScroll() + } if (hasFocus) { com.droiddeck.launcher.ui.DualScreenPanel.yieldTo(taskId, false) applyLauncherFullscreen() @@ -2201,15 +2203,114 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } private val triggerKeys = com.droiddeck.launcher.input.TriggerKeys { dispatchKeyEvent(it) } + private val rightStickLayouts = HashMap() + private val rightStickScrollHandler = android.os.Handler(android.os.Looper.getMainLooper()) + private var rightStickScrollDeviceId = -1 + private var rightStickScrollDeflection = 0f + private var rightStickScrollScheduled = false + private var rightStickNextDispatchAt = 0L + private val rightStickScrollTick = object : Runnable { + override fun run() { + val deviceId = rightStickScrollDeviceId + if (!hasWindowFocus() || (compatLaunch != null && !compatLaunch!!.loading.ended) || + deviceId == -1 || + android.view.InputDevice.getDevice(deviceId) == null || + kotlin.math.abs(rightStickScrollDeflection) < 0.55f) { + stopRightStickScroll() + return + } + rightStickScrollScheduled = false + dispatchRightStickScroll(rightStickScrollDeflection, deviceId) + rightStickNextDispatchAt = android.os.SystemClock.uptimeMillis() + 130L + rightStickScrollHandler.postDelayed(this, 130L) + rightStickScrollScheduled = true + } + } + + private fun stopRightStickScroll() { + rightStickScrollHandler.removeCallbacks(rightStickScrollTick) + rightStickScrollDeviceId = -1 + rightStickScrollDeflection = 0f + rightStickScrollScheduled = false + } + + private fun dispatchRightStickScroll(value: Float, deviceId: Int) { + val now = android.os.SystemClock.uptimeMillis() + val root = window.decorView + if (root.width <= 0 || root.height <= 0) return + val properties = android.view.MotionEvent.PointerProperties().apply { + id = 0 + toolType = android.view.MotionEvent.TOOL_TYPE_MOUSE + } + val coordinates = android.view.MotionEvent.PointerCoords().apply { + x = root.width * 0.65f + y = root.height * 0.5f + setAxisValue(android.view.MotionEvent.AXIS_VSCROLL, -value * 3f) + } + val scroll = android.view.MotionEvent.obtain( + now, now, android.view.MotionEvent.ACTION_SCROLL, 1, + arrayOf(properties), arrayOf(coordinates), 0, 0, 1f, 1f, + deviceId, 0, android.view.InputDevice.SOURCE_MOUSE, 0, + ) + try { + super.dispatchGenericMotionEvent(scroll) + } finally { + scroll.recycle() + } + } + + private fun scrollPageWithRightStick(event: android.view.MotionEvent) { + if (event.actionMasked != android.view.MotionEvent.ACTION_MOVE || + !com.droiddeck.launcher.input.PadBridge.isControllerMotionEvent(event)) return + val device = event.device ?: return + val rxRy = com.droiddeck.launcher.input.PadBridge.rightStickUsesRxRy(event, device, rightStickLayouts) + ?: run { + if (rightStickScrollDeviceId == event.deviceId) stopRightStickScroll() + return + } + val axis = if (rxRy) android.view.MotionEvent.AXIS_RY else android.view.MotionEvent.AXIS_RZ + val value = event.getAxisValue(axis) + if (kotlin.math.abs(value) < 0.55f) { + if (rightStickScrollDeviceId == event.deviceId) stopRightStickScroll() + return + } + rightStickScrollDeviceId = event.deviceId + rightStickScrollDeflection = value + if (!rightStickScrollScheduled) { + val delay = (rightStickNextDispatchAt - android.os.SystemClock.uptimeMillis()).coerceAtLeast(0L) + rightStickScrollHandler.postDelayed(rightStickScrollTick, delay) + rightStickScrollScheduled = true + } + } override fun dispatchGenericMotionEvent(event: android.view.MotionEvent): Boolean { if (compatLaunch != null && !compatLaunch!!.loading.ended && - com.droiddeck.launcher.input.PadBridge.isControllerMotionEvent(event)) return true + com.droiddeck.launcher.input.PadBridge.isControllerMotionEvent(event)) { + stopRightStickScroll() + return true + } triggerKeys.onMotion(event) + scrollPageWithRightStick(event) return super.dispatchGenericMotionEvent(event) } + @Volatile private var inFront = false + private var autoSteamPending = false + + /** Runs on the worker thread that finishes setup, so the foreground state is read as setup completes, not when the UI thread gets to it. */ + private val firstRunReady: () -> Unit = { + val front = inFront + runOnUiThread { if (front) autoStartSteam() } + } + + private fun autoStartSteam() { + if (isFinishing || isDestroyed || SessionState.running || !inFront) return + if (busy) autoSteamPending = true else playSteam() + } + override fun onPause() { + inFront = false + stopRightStickScroll() compatLaunchVisible = false if (android.os.Build.VERSION.SDK_INT >= 29) com.droiddeck.launcher.ui.DualScreenPanel.ownerPaused(taskId, true) super.onPause() @@ -2217,6 +2318,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet override fun onResume() { super.onResume() + inFront = true if (!homeChoiceOpen) { HomeApp.releaseUnusedHomeEntry(this) refreshHomeAppState() @@ -2308,6 +2410,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } private fun saveLauncherState(outState: Bundle) { + outState.putString(STATE_PROCESS, PROCESS) outState.putBoolean(STATE_HOME_CHOICE_OPEN, homeChoiceOpen) outState.putBoolean(STATE_GAME_SPACE_OFFERED, gameSpaceOffered) pendingSessionLogExport?.let { outState.putString(KEY_PENDING_SESSION_LOG_EXPORT, it.absolutePath) } @@ -2351,6 +2454,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet override fun onDestroy() { // The queued launch was saved before this; a restored activity keeps its copy, and this one must not start it too. + if (com.droiddeck.launcher.session.Onboarding.onFirstRunReady === firstRunReady) com.droiddeck.launcher.session.Onboarding.onFirstRunReady = null queuedLaunchRunner.destroy() triggerKeys.cancel() launchCoordinator.cancelAll() @@ -3096,6 +3200,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet return } val target = com.droiddeck.launcher.frontend.GameRemoval.steamFiles(g) ?: return + if (Library.fromSteamClient(g)) { + com.droiddeck.launcher.stores.steam.SteamStore.uninstall(this, g.appId, target.manifest, fallback = { com.droiddeck.launcher.frontend.GameRemoval.delete(target) }) { refreshAddedGames(); refresh() } + return + } Thread({ com.droiddeck.launcher.frontend.GameRemoval.delete(target) ui.post { refreshAddedGames(); refresh() } @@ -3471,6 +3579,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet android.widget.Toast.makeText(this, R.string.storage_cleanup_busy, android.widget.Toast.LENGTH_SHORT).show() return false } + if (!SessionState.running && com.droiddeck.launcher.stores.steam.SteamStore.blocksSession(intent)) { + android.widget.Toast.makeText(this, R.string.steam_store_session_wait, android.widget.Toast.LENGTH_SHORT).show() + return false + } refreshPhantomStatus() if (steamSession && PhantomProcessLimit.blocksSteam(phantomProcessStatus)) { if (queueIfBlocked) queuedLaunch.queue(intent, System.currentTimeMillis()) @@ -3533,9 +3645,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet retryMs = GATE_LAUNCH_RETRY_MS, ) - /** The conditions under which a Steam start waits instead of being refused: setup, a runtime or desktop install, or a storage cleanup. */ + /** The conditions under which a Steam start waits instead of being refused: setup, a runtime or desktop install, a storage cleanup, or a Steam store download. */ private fun steamStartBusy(): Boolean = busy || LinuxRuntimeInstaller.isBusy() || com.droiddeck.launcher.session.Onboarding.settling() || - (SessionState.installing != null && !SessionState.running) || com.droiddeck.launcher.storage.StorageState.cleaning + (SessionState.installing != null && !SessionState.running) || com.droiddeck.launcher.storage.StorageState.cleaning || + (!SessionState.running && com.droiddeck.launcher.stores.steam.SteamStore.downloading()) private fun refreshPhantomStatus() { phantomProcessStatus = PhantomProcessLimit.read(this) @@ -3641,6 +3754,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet refresh() com.droiddeck.launcher.agent.AgentHost.refresh(this) if (ok == true && LinuxRuntime.isInstalled(this)) { protons.checkUpdates(); protons.ensureSteamClient() } + if (autoSteamPending) { autoSteamPending = false; autoStartSteam() } } }, "runtime-operation").start() } @@ -3671,6 +3785,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } companion object { + private val PROCESS = java.util.UUID.randomUUID().toString() + private const val STATE_PROCESS = "process" private const val REQUEST_NOTIFICATIONS = 7103 private const val EXTRA_RESTARTED = "com.droiddeck.launcher.extra.RESTARTED" private const val STATE_HOME_CHOICE_OPEN = "home_choice_open" diff --git a/app/src/main/java/com/droiddeck/launcher/MaliAutoRoute.kt b/app/src/main/java/com/droiddeck/launcher/MaliAutoRoute.kt index f4ebf2f0f7..1906b6aa51 100644 --- a/app/src/main/java/com/droiddeck/launcher/MaliAutoRoute.kt +++ b/app/src/main/java/com/droiddeck/launcher/MaliAutoRoute.kt @@ -26,6 +26,12 @@ internal object MaliAutoRoute { fun userChoice(keyStored: Boolean, owner: String, route: String): Boolean = keyStored && owner != route + fun venusStandsIn(available: Boolean, hostVulkanOk: Boolean, venusOn: Boolean, venusExplicit: Boolean, gpuName: String): Boolean = + available && hostVulkanOk && if (venusExplicit) venusOn else !venusStallsOn(gpuName) + + // Steam's web helper dies on its first window through Venus on these (#2879), so the bridge stands in. + fun venusStallsOn(gpuName: String): Boolean = gpuName.contains("G2-Ultra", ignoreCase = true) + fun shouldEnd(ownsRoute: String, mali: Boolean, installedPair: Boolean): Boolean = mali && installedPair && ownsRoute != NONE } diff --git a/app/src/main/java/com/droiddeck/launcher/QuestSteamVrWatch.kt b/app/src/main/java/com/droiddeck/launcher/QuestSteamVrWatch.kt new file mode 100644 index 0000000000..eab1ee2f37 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/QuestSteamVrWatch.kt @@ -0,0 +1,36 @@ +package com.droiddeck.launcher + +import com.droiddeck.launcher.gpu.SteamVr + +internal class QuestSteamVrWatch(start: Long) { + private var startupDeadline = start + STARTUP_MS + private var lastRunning: Long? = null + private var graceUntil = start + private var wasPaused = false + + // A frozen guest cannot answer the status call, so a status read during a freeze, or one that + // started before it, says nothing about SteamVR. + fun stopped(now: Long, status: SteamVr.Status, paused: Boolean): Boolean { + if (paused) { + wasPaused = true + return false + } + if (wasPaused) { + wasPaused = false + graceUntil = now + RESUME_GRACE_MS + } + if (status == SteamVr.Status.RUNNING) { + lastRunning = now + graceUntil = now + return false + } + val deadline = lastRunning?.plus(RUNNING_GRACE_MS) ?: startupDeadline + return now >= maxOf(deadline, graceUntil) + } + + companion object { + const val STARTUP_MS = 30_000L + const val RUNNING_GRACE_MS = 5_000L + const val RESUME_GRACE_MS = 15_000L + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/QuestXrActivity.kt b/app/src/main/java/com/droiddeck/launcher/QuestXrActivity.kt index 98e5a0b227..5bde3ef872 100644 --- a/app/src/main/java/com/droiddeck/launcher/QuestXrActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/QuestXrActivity.kt @@ -52,18 +52,17 @@ class QuestXrActivity : NativeActivity() { if (!closing) leaveXr("SteamVR start failed", sessionAlive()) return@Thread } - val startupDeadline = SystemClock.elapsedRealtime() + 30_000 - var lastRunning: Long? = null + val watch = QuestSteamVrWatch(SystemClock.elapsedRealtime()) while (!closing) { if (!sessionAlive()) { leaveXr("Steam session ended", false) break } - steamVrStatus = SteamVr.status(this) - val now = SystemClock.elapsedRealtime() - if (steamVrStatus == SteamVr.Status.RUNNING) lastRunning = now - val deadline = lastRunning?.plus(5_000) ?: startupDeadline - if (steamVrStatus != SteamVr.Status.RUNNING && now >= deadline) { + val pausedBefore = guestPaused() + val status = SteamVr.status(this) + val paused = pausedBefore || guestPaused() + if (!paused) steamVrStatus = status + if (watch.stopped(SystemClock.elapsedRealtime(), status, paused)) { leaveXr("SteamVR stopped or did not finish starting", true) break } @@ -81,6 +80,8 @@ class QuestXrActivity : NativeActivity() { } } + private fun guestPaused() = SessionState.suspending || SessionState.suspended || SessionState.resuming + private fun sessionAlive() = SessionState.running && !SessionState.stopRequested && sessionId != null && SessionState.sessionId == sessionId diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index f7468607dd..8473957bcd 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -179,6 +179,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private var quickButtons by mutableStateOf>(emptyMap()) private var picturePosition by mutableStateOf("center") private var integerScaling by mutableStateOf(false) + private var gameZoom by mutableStateOf(SessionState.gameZoom) private var avoidNotch = false private fun applyNotchInset(insets: android.view.WindowInsets? = window.decorView.rootWindowInsets) { @@ -265,6 +266,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde InputCommand.KEYBOARD -> if (role == InputRole.PRIMARY || secondScreenPresentation?.showKeyboard() != true) togglePcKeyboard() InputCommand.STEAM -> tapSteamButton() InputCommand.QUICK_ACCESS -> tapQam() + InputCommand.GAME_ZOOM_IN -> { + gameZoom = (gameZoom + 0.25f).coerceAtMost(3.0f) + SessionState.gameZoom = gameZoom + runCatching { WaylandCompositor.nativeSetZoom(gameZoom) } + } + InputCommand.GAME_ZOOM_OUT -> { + gameZoom = (gameZoom - 0.25f).coerceAtLeast(1.0f) + SessionState.gameZoom = gameZoom + runCatching { WaylandCompositor.nativeSetZoom(gameZoom) } + } } } } @@ -344,7 +355,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private lateinit var threeFingerTap: com.droiddeck.launcher.input.ThreeFingerTap private lateinit var touchscreenGestures: TouchscreenGestures private var gestureConfig = com.droiddeck.launcher.input.TouchGestureConfig() - private var gestureGame: String? = null + private var gestureGame by mutableStateOf(null) private var gameStarts by mutableIntStateOf(0) private var gestureSettingsOpen by mutableStateOf(false) private var steamImportAsk by mutableStateOf(null) @@ -450,13 +461,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde return true } private val uiHandler = Handler(Looper.getMainLooper()) - private var pendingBackAction: Runnable? = null + private var backTapOpenedDrawer = false + private val backTapsAtOnce: Boolean get() = SessionState.mode != SessionService.MODE_STEAM || !backActionsInverted + private val backTaps = com.droiddeck.launcher.input.BackTaps( + windowMs = { backDoubleTapMs.toLong() }, + atOnce = { backTapsAtOnce }, + onTap = { performBackAction(double = it) }, + sameAction = { SessionState.mode != SessionService.MODE_STEAM }, + ) private val backQamInput = com.droiddeck.launcher.input.BackQamInput( setPressed = { padBridge?.setBackQamPressed(it) }, onTap = { performBackAction(double = it) }, doubleTapMs = { backDoubleTapMs.toLong() }, onCancel = { padBridge?.cancelBackQam() }, holds = { backHold }, + atOnce = { backTapsAtOnce }, + sameAction = { SessionState.mode != SessionService.MODE_STEAM }, ) private val mouseBackInput = com.droiddeck.launcher.input.MouseBackInput( sendRight = { down -> heldButtons.set(32, PointerGestures.BTN_RIGHT, down) }, @@ -703,6 +723,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde @Volatile private var frameGenInventoryLastAttemptAt = 0L private val frameGenInventoryRetryScheduled = java.util.concurrent.atomic.AtomicBoolean() private val frameGenInventoryRefreshScheduled = java.util.concurrent.atomic.AtomicBoolean() + @Volatile private var frameGenInventoryRefreshDue = false + @Volatile private var frameGenInventoryMissedAppId = 0L @Volatile private var appliedFrameGenMode: FrameGen.Mode? = null @Volatile private var appliedFrameGenHz: Float? = null @@ -842,6 +864,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde finish() return } + if (!SessionState.running && com.droiddeck.launcher.stores.steam.SteamStore.blocksSession(intent)) { + runtimeRemovalBlocked = true + android.widget.Toast.makeText(this, R.string.steam_store_session_wait, android.widget.Toast.LENGTH_SHORT).show() + finish() + return + } + if (savedInstanceState == null && !SessionState.running && !com.droiddeck.launcher.stores.steam.SteamStore.downloading()) { + // The Steam client signs in itself; the store's own sign-in must not overlap it. + Thread({ com.droiddeck.launcher.stores.steam.SteamEngine.forget() }, "steam-store-signout").start() + } if (!SessionState.running && SessionState.phase in setOf(SessionPhase.IDLE, SessionPhase.FAILED)) { val mode = intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM SessionState.programArgs = intent.getStringArrayExtra(SessionService.EXTRA_PROGRAM_ARGS)?.toList().orEmpty() @@ -892,6 +924,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onCapturedPointer(event) || super.dispatchCapturedPointerEvent(event) override fun dispatchPointerCaptureChanged(hasCapture: Boolean) { super.dispatchPointerCaptureChanged(hasCapture) + capturedTouchpad.cancel() + heldButtons.release(64) Log.i(TAG, "pointer capture " + if (hasCapture) "on" else "off") if (hasCapture) { pointerCaptureRefused = false @@ -1115,11 +1149,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde when { ::loading.isInitialized && loading.ended -> finish() inputSettingsOpen -> inputSettingsOpen = false - dockedTouchOnly -> routeBackAction() + dockedTouchOnly || backTaps.pending -> backTaps.tap() drawerOpen -> drawerOpen = false achievementsOpen -> closeAchievements() pcKeyboardOpen -> pcKeyboardOpen = false - else -> routeBackAction() + else -> backTaps.tap() } } }) @@ -1131,6 +1165,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde isFocusableInTouchMode = true defaultFocusHighlightEnabled = false setContent { + androidx.compose.runtime.LaunchedEffect(SessionState.running, SessionState.sessionId) { + if (SessionState.running) { + gameZoom = SessionState.gameZoom + runCatching { WaylandCompositor.nativeSetZoom(gameZoom) } + } else { + gameZoom = 1.0f + SessionState.gameZoom = 1.0f + runCatching { WaylandCompositor.nativeSetZoom(1.0f) } + } + } + val activeEffectsProfileId = currentScreenEffectsProfileId() val effectsEditorTarget = if (drawerOpen) screenEffectsTarget else null val effectsEditorProfileId = activeEffectsProfileId.takeIf { @@ -1198,6 +1243,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde CursorOverlay({ cursorPos }, cursorVisible && (!cursorHidden || onlyPcKeyboardOpen()) && !bottomOutputActive, resources.displayMetrics.density, cursorImage, cursorHotX, cursorHotY, cursorImageScale) + if (memoryHud.text.isNotEmpty()) HudText(memoryHud.text, hudColor, hudOpacity) if (bottomOutputActive && !loading.visible) SwappedTopPanel() val phonePanel = glassesOutputActive && !loading.visible && !drawerOpen && !pcKeyboardOpen @@ -1301,6 +1347,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (nextGame != null) gameStarts++ gestureGame = nextGame refreshGestureConfig() + restoreGamePanel(nextGame) } if ( SessionState.mode == SessionService.MODE_STEAM && @@ -1315,8 +1362,15 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde LaunchedEffect(drawerOpen, menuOwnsController, pcKeyboardOpen, achievementsOpen, gestureSettingsOpen, inputSettingsOpen, pipUi, SessionState.suspended, resumed, appTextFocus) { updateOnScreenControls() padBridge?.setInputEnabled(resumed && !menuOwnsController && !pcKeyboardOpen && !achievementsOpen && !gestureSettingsOpen && !inputSettingsOpen && !pipUi && !appTextFocus && !SessionState.suspended) - if (drawerOpen || pcKeyboardOpen || achievementsOpen || gestureSettingsOpen || inputSettingsOpen || pipUi || appTextFocus || SessionState.suspended) { - backQamInput.cancel() + if (!drawerOpen && backTapOpenedDrawer) { + backTaps.cancel() + backQamInput.cancelTap() + backTapOpenedDrawer = false + } + val otherPanel = pcKeyboardOpen || achievementsOpen || gestureSettingsOpen || inputSettingsOpen || pipUi || appTextFocus || SessionState.suspended + if (drawerOpen || otherPanel) { + if (otherPanel || !backTapOpenedDrawer) backTaps.cancel() + backQamInput.cancel(keepTap = backTapOpenedDrawer && !otherPanel) com.droiddeck.launcher.input.HomeButtonShortcuts.cancel(this@SessionActivity) cancelTouchGestures() } @@ -1370,7 +1424,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (drawerOpen) { syncLossless() if (menuOwnsController) { - releasePads() + releasePads(keepBackTap = backTapOpenedDrawer) androidx.compose.runtime.withFrameNanos { } val requested = focusDrawer() Log.i(TAG, "drawer root focus requested=$requested docked=$drawerDocked") @@ -1409,6 +1463,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde LaunchedEffect(pcKeyboardOpen, drawerOpen, achievementsOpen) { if (pcKeyboardOpen || drawerOpen || achievementsOpen) padMouse.reset() } + val panelShown = panelOverGame + LaunchedEffect(panelShown) { boostGpuClock(panelShown && resumed) } if (pcKeyboardOpen) com.droiddeck.launcher.ui.PcKeyboard( sendKey = { code, down -> if (CompositorHost.isStarted) sendGuestKey(code, down, 32) }, onAndroidKeyboard = { pcKeyboardOpen = false; togglePrimaryKeyboard() }, @@ -1563,6 +1619,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onHudReset = { hudConfig = DroidDeckHudConfig.reset(this@SessionActivity); hud.applyConfig() }, onHudOrderReset = { hudConfig = DroidDeckHudConfig.clearOrder(this@SessionActivity); hud.applyConfig() }, onHudExport = { exportHudDiagnostics() }, + gameZoomAvailable = SessionState.running, + gameZoom = gameZoom, + onGameZoom = { value -> + gameZoom = value.coerceIn(1.0f, 3.0f) + SessionState.gameZoom = gameZoom + runCatching { WaylandCompositor.nativeSetZoom(gameZoom) } + }, integerScaling = integerScaling, onIntegerScaling = { enabled -> SessionPrefs.setIntegerScaling(this@SessionActivity, enabled) @@ -1757,6 +1820,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde wowChat = wowChat.remembered, onWowChat = wowChat::choose, controller = controllerSettings, + onControllerSize = { percent -> updateControllerPrefs { ControllerPrefs.setSize(this@SessionActivity, percent) } }, onRumble = { on -> updateControllerPrefs { ControllerPrefs.setRumble(this@SessionActivity, on) } }, onSteamMenu = if (SessionState.mode == SessionService.MODE_STEAM) ({ sendSteamGuide() }) else null, onQam = if (SessionState.mode == SessionService.MODE_STEAM) ({ triggerSteamQam() }) else null, @@ -2098,27 +2162,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde change() controllerSettings = ControllerPrefs.read(this) onScreenControls?.reload() - } - - private fun routeBackAction() { - pendingBackAction?.let { pending -> - uiHandler.removeCallbacks(pending) - pendingBackAction = null - performBackAction(double = true) - return - } - val pending = Runnable { - pendingBackAction = null - performBackAction(double = false) - } - pendingBackAction = pending - uiHandler.postDelayed(pending, backDoubleTapMs.toLong()) + bottomInputControls?.reload() + unfoldedPanel?.reload() } private fun performBackAction(double: Boolean) { val isSteam = SessionState.mode == SessionService.MODE_STEAM val opensQam = isSteam && (double xor backActionsInverted) - if (opensQam) triggerSteamQam() else if (!dockedTouchOnly) drawerOpen = !drawerOpen + if (opensQam) triggerSteamQam() else if (!dockedTouchOnly) { + drawerOpen = !drawerOpen + backTapOpenedDrawer = drawerOpen && !double + } } private fun handleHomeGuideIntent(incoming: Intent?) { @@ -2603,6 +2657,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun gpuClockHeld() = SessionPrefs.gpuClockPin(this) && !GpuClockPin.failed + private val panelOverGame: Boolean get() = ((drawerOpen && !drawerDocked) || achievementsOpen || gestureSettingsOpen || inputSettingsOpen) && !pipUi + + private fun boostGpuClock(on: Boolean) { + if (!GpuClockPin.boost(on)) return + Thread { GpuClockPin.sync(applicationContext)?.let { Log.i(TAG, it) } }.start() + } + private fun readPrefs() { pipAutoEnter = SessionPrefs.pipAutoEnter(this) unfoldedControls = SessionPrefs.unfoldedControls(this) @@ -2834,7 +2895,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun installProton(): String? { uiHandler.post { loading.percent = -1; loading.say(getString(PROTON_LINES.downloading), PROTON_LINES.topic, readable = true) } - if (com.droiddeck.launcher.session.SessionPrefs.ownProtonFirst(this)) return installOwnProton() val catalog = com.droiddeck.launcher.runtime.DesktopCatalog val cancellation = com.droiddeck.launcher.core.Downloader.Cancellation { SessionState.stopRequested } SessionState.installCancellation = cancellation @@ -2847,24 +2907,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } - private fun installOwnProton(): String? { - val extras = com.droiddeck.launcher.session.ProtonExtras - while ((extras.prefetching || extras.installInProgress) && !SessionState.stopRequested) { - try { Thread.sleep(250) } catch (_: InterruptedException) { Thread.currentThread().interrupt(); return "interrupted" } - } - if (SessionState.stopRequested) return "cancelled" - if (!com.droiddeck.launcher.runtime.DesktopCatalog.ownProtonMissing(this)) return null - val cancellation = com.droiddeck.launcher.core.Downloader.Cancellation { SessionState.stopRequested } - SessionState.installCancellation = cancellation - return try { - extras.install(this, extras.tools.first { it.id == extras.OWN }, cancellation) { label, percent -> - uiHandler.post { loading.percent = percent; loading.say(label, PROTON_LINES.topic, readable = true) } - }.also { if (it == null) com.droiddeck.launcher.session.Onboarding.recheck(this) } - } finally { - if (SessionState.installCancellation === cancellation) SessionState.installCancellation = null - } - } - override fun surfaceCreated(holder: SurfaceHolder) { if (holder !== outputHolder()) return if (installingRuntime || SessionState.stopRequested || ended) return @@ -2874,6 +2916,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val runtimeDir = File(filesDir, ".wayland-rt").apply { mkdirs() } FileUtils.copyAsset(this, "wayland/keymap.xkb", File(runtimeDir, "keymap.xkb")) com.droiddeck.launcher.input.VrControllers.publish(this) + com.droiddeck.launcher.session.QuestSteamVrLaunch.publish(this) val turnip = TurnipDriver(this) com.droiddeck.launcher.gpu.DriverSetupLog.write(this, "surface.driver-setup") @@ -2940,7 +2983,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val on = SessionState.hdrCapable && SessionPrefs.hdr(this, mode) SessionState.hdr = on WaylandCompositor.nativeSetHdrOutput(on) - WaylandCompositor.nativeSetZeroCopy(on || SessionPrefs.zeroCopy(this, mode)) + WaylandCompositor.nativeSetZeroCopy(on || SessionPrefs.zeroCopy(this, mode) && composedOutputFree()) Log.i(TAG, "hdr: " + (if (on) "on" else "off") + " for this $mode session") } com.droiddeck.launcher.gpu.DriverSetupLog.write(this, "compositor.start driver=$driverId") @@ -3181,6 +3224,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } + private fun scheduleFrameGenInventoryRefresh() { + if (!frameGenInventoryRefreshScheduled.compareAndSet(false, true)) return + uiHandler.postDelayed({ + frameGenInventoryRefreshScheduled.set(false) + if (frameGenActivityActive && !isFinishing && !isDestroyed) { + frameGenInventoryRefreshDue = true + applyFrameGen() + } + }, 15_000L) + } + private fun frameGenModeForActiveGame(request: Int): FrameGen.Mode { if (SessionState.mode == SessionService.MODE_RUN) { val activeAppId = ( @@ -3194,7 +3248,26 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde .mapNotNull { it.profileKey.toLongOrNull() } .toSet() + if (frameGenInventoryRefreshDue) { + val focusedAppId = AgentGuest.focus(this)?.let { snapshot -> + snapshot.optLong("focusedApp").takeIf { snapshot.has("focusedApp") } + } + val stillKnown = synchronized(frameGenInventoryLock) { + frameGenInventoryRefreshDue = false + val known = frameGenInventoryIds + val keep = known != null && focusedAppId != null && + AgentGuest.focusedInstalledSteamAppId(focusedAppId, cachedIds + known) != null + if (!keep) { + frameGenInventoryIds = null + frameGenInventoryLastAttemptAt = 0L + } + keep + } + if (stillKnown) scheduleFrameGenInventoryRefresh() + } + var inventoryRevision = drawerGameInventoryRevision + var scannedNow = false var ids = synchronized(frameGenInventoryLock) { if (frameGenInventoryRevision != inventoryRevision) { frameGenInventoryIds = null @@ -3254,21 +3327,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde ids = cachedIds + currentIds frameGenInventoryIds = ids published = true + scannedNow = true } } if (published) { - if (frameGenInventoryRefreshScheduled.compareAndSet(false, true)) { - uiHandler.postDelayed({ - frameGenInventoryRefreshScheduled.set(false) - if (frameGenActivityActive && !isFinishing && !isDestroyed) { - synchronized(frameGenInventoryLock) { - frameGenInventoryIds = null - frameGenInventoryLastAttemptAt = 0L - } - applyFrameGen() - } - }, 15_000L) - } + scheduleFrameGenInventoryRefresh() if (frameGenRequests.get() != request) { applyFrameGen() } @@ -3286,7 +3349,24 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val activeAppId = AgentGuest.activeSteamAppId( this, cachedIds + (ids ?: emptySet()) ) - if (activeAppId == null) return FrameGen.Mode.OFF + if (activeAppId == null) { + val focusedAppId = AgentGuest.focus(this)?.optLong("focusedApp", 0L) ?: 0L + val rescan = !scannedNow && focusedAppId > 0 && synchronized(frameGenInventoryLock) { + val retained = frameGenInventoryIds + if (retained != null && focusedAppId !in retained && + focusedAppId != frameGenInventoryMissedAppId + ) { + frameGenInventoryMissedAppId = focusedAppId + frameGenInventoryIds = null + frameGenInventoryLastAttemptAt = 0L + true + } else { + false + } + } + if (rescan) uiHandler.post { if (!isFinishing && !isDestroyed) applyFrameGen() } + return FrameGen.Mode.OFF + } return FrameGen.mode(this, activeAppId.toString()) } @@ -3453,11 +3533,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde focusEndedScreen() } - private fun releasePads() { + private fun releasePads(keepBackTap: Boolean = false) { inputMotion.stop() physicalInputBindings?.release() com.droiddeck.launcher.input.HomeButtonShortcuts.cancel(this) - backQamInput.cancel() + backQamInput.cancel(keepTap = keepBackTap) padBridge?.releaseAll() joyConVr?.releaseButtons() } @@ -3617,8 +3697,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde !pcKeyboardOpen && !achievementsOpen && !gestureSettingsOpen && !inputSettingsOpen, steam = SessionState.mode == SessionService.MODE_STEAM, ) { action -> - pendingBackAction?.let(uiHandler::removeCallbacks) - pendingBackAction = null + backTaps.cancel() if (!dockedMenuIdle) drawerControllerActive = true Log.i(TAG, "physical shortcut ${action.name} device=${event.deviceId} key=${event.keyCode} scan=${event.scanCode}") when (action) { @@ -3650,16 +3729,23 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } if (mouseBackHandled) return true - val backToQam = !pipUi && !appTextFocus && !menuOwnsController && !pcKeyboardOpen && !achievementsOpen && + val backToQam = !pipUi && !appTextFocus && (!menuOwnsController || backQamInput.awaitingTap) && !pcKeyboardOpen && !achievementsOpen && !inputSettingsOpen && !gestureSettingsOpen && SessionState.mode == SessionService.MODE_STEAM && SessionState.running && SessionState.firstFrameSeen && !SessionState.suspended && padBridge?.canHoldQam() == true if (backQamInput.onKeyEvent(event, backToQam)) { - pendingBackAction?.let(uiHandler::removeCallbacks) - pendingBackAction = null + backTaps.cancel() return true } if (pipUi) return true + if (event.keyCode == KeyEvent.KEYCODE_BACK && backTapOpenedDrawer && backTaps.pending) { + when { + event.action == KeyEvent.ACTION_DOWN -> backTaps.hold() + event.action == KeyEvent.ACTION_UP && !event.isCanceled -> backTaps.tap() + event.action == KeyEvent.ACTION_UP -> backTaps.cancel() + } + return true + } val pad = com.droiddeck.launcher.input.JoyCon.normalize(event) if (pad !== event) return dispatchKeyEvent(pad) val fromController = PadBridge.isControllerKeyEvent(event) @@ -3802,7 +3888,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } else -> return super.dispatchGenericMotionEvent(event) } - if (event.isFromSource(android.view.InputDevice.SOURCE_MOUSE) && !drawerOpen) { + if ((event.isFromSource(android.view.InputDevice.SOURCE_MOUSE) || + event.isFromSource(android.view.InputDevice.SOURCE_TOUCHPAD)) && !drawerOpen) { if (appUiOwnsPointer()) { if (super.dispatchGenericMotionEvent(event)) return true if (touchEditorOpen) return false @@ -3956,6 +4043,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val presentation = secondScreenPresentation ?: return presentation.showMenu(false) if (secondScreenMode == SecondScreenMode.NONE) closeSecondScreen(reset = false) else updateKeyboardRoute() + if (gamePanelPending) uiHandler.post { restoreGamePanel(gestureGame) } } @@ -3985,7 +4073,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde steamSession = SessionState.mode == SessionService.MODE_STEAM, steamDesktopUi = SessionState.steamUi == "desktop", )) == com.droiddeck.launcher.input.TouchRouter.Route.TOUCHPAD - val mode = com.droiddeck.launcher.input.TouchGestureConfig.gamescopeRelativeMouse(wanted, mouseAttached(), touchpadRoute) + val mode = com.droiddeck.launcher.input.TouchGestureConfig.gamescopeRelativeMouse(wanted, pointerAttached(), touchpadRoute) if (appliedRelativeMouseMode == mode) return if (AgentGuest.setGamescopeConvar(this, "relative_mouse", mode)) appliedRelativeMouseMode = mode else if (relativeMouseRetries++ < RELATIVE_MOUSE_MAX_RETRIES) uiHandler.postDelayed({ requestRelativeMouse() }, 2_000) @@ -4116,6 +4204,27 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } + private val capturedTouchpadListener: PointerGestures.Listener = object : PointerGestures.Listener by pointerListener { + override fun onMove(x: Float, y: Float) { + val rect = drawnRect() ?: return + val scale = sceneScale(rect) + capturedTouchpad.place(CAPTURED_PAD_CENTRE, CAPTURED_PAD_CENTRE) + onRelativeMouse((x - CAPTURED_PAD_CENTRE) * scale, (y - CAPTURED_PAD_CENTRE) * scale) + } + override fun onButton(button: Int, pressed: Boolean, x: Float, y: Float) { + heldButtons.set(64, button, pressed) + } + override fun onThreeFingerTap(): Boolean = false + } + + private val capturedTouchpad: TouchpadGestures by lazy { + TouchpadGestures(PointerGestures.slop(this), capturedTouchpadListener, holdDrags = false).apply { + bounds = android.graphics.RectF(0f, 0f, CAPTURED_PAD_CENTRE * 2f, CAPTURED_PAD_CENTRE * 2f) + place(CAPTURED_PAD_CENTRE, CAPTURED_PAD_CENTRE) + } + } + private val capturedPadMatrix = android.graphics.Matrix() + private val scrollListener = object : ScrollTouchGestures.Listener { override fun onMove(x: Float, y: Float) { val rect = pointerSurfaceRect() ?: return @@ -4395,8 +4504,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (secondScreenMode == SecondScreenMode.DECK_CONTROLS && !SessionState.deckPad) selectSecondScreenMode(secondScreenMode) } - private fun openingPanel() = SecondScreenMode.opening(SessionPrefs.secondScreenPanel(this, desktopSession), SessionState.deckPad, - bottomPages().isNotEmpty(), com.droiddeck.launcher.session.BottomDesktop.available()) + private fun openingPanel(): SecondScreenMode { + val saved = bottomGameKey()?.let { SessionPrefs.gameSecondScreenPanel(this, it) } + // A game's own panel counts as applied, so the next game without one returns to the global choice. + if (saved != null) gamePanelApplied = true + return SecondScreenMode.opening(saved ?: SessionPrefs.secondScreenPanel(this, desktopSession), SessionState.deckPad, + bottomPages().isNotEmpty(), com.droiddeck.launcher.session.BottomDesktop.available(), SessionState.mode == SessionService.MODE_STEAM) + } private fun openingSurface() = openingPanel().takeIf { it != SecondScreenMode.MENU } ?: SecondScreenMode.KEYBOARD_TRACKPAD @@ -4422,9 +4536,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde typingReturnMode = null automaticPanel = false SessionPrefs.setSecondScreenPanel(this, desktopSession, SecondScreenMode.MENU.id) + bottomGameKey()?.let { SessionPrefs.setGameSecondScreenPanel(this, it, SecondScreenMode.MENU.id) } + gamePanelApplied = bottomGameKey() != null drawerOpen = true } + /** What bottom-screen memory is kept under: the game id in direct-run mode when there is one, else the focused game. */ + private fun bottomGameKey(): String? = + if (SessionState.mode == SessionService.MODE_RUN) SessionState.gameId?.takeIf { it.isNotBlank() }?.let { "game:$it" } ?: gestureGame + else gestureGame + private fun settleDualScreenControls() { if (!dualControlsProvisional || pipUi || !started || (::loading.isInitialized && loading.visible)) return dualControlsProvisional = false @@ -4542,10 +4663,36 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde typingReturnMode = null automaticPanel = false SessionState.bottomMenu = false - if (mode != SecondScreenMode.NONE) SessionPrefs.setSecondScreenPanel(this, desktopSession, mode.id) + if (mode != SecondScreenMode.NONE) { + SessionPrefs.setSecondScreenPanel(this, desktopSession, mode.id) + bottomGameKey()?.let { SessionPrefs.setGameSecondScreenPanel(this, it, mode.id) } + gamePanelApplied = bottomGameKey() != null + } selectSecondScreenMode(mode) } + private var gamePanelApplied = false + private var gamePanelPending = false + + private fun restoreGamePanel(game: String?) { + if (secondScreenMode == SecondScreenMode.NONE || pipUi) return + // The bottom menu or field keyboard is in the way; the panel is restored once it closes. + if (typingReturnMode != null || menuShownOnBottom()) { + gamePanelPending = true + return + } + gamePanelPending = false + val remembered = game?.let { bottomGameKey() }?.let { SessionPrefs.gameSecondScreenPanel(this, it) } + val wanted = when { + remembered != null -> SecondScreenMode.opening(remembered, SessionState.deckPad, bottomPages().isNotEmpty(), + com.droiddeck.launcher.session.BottomDesktop.available(), SessionState.mode == SessionService.MODE_STEAM) + gamePanelApplied -> openingPanel() + else -> return + } + gamePanelApplied = remembered != null + if (wanted != SecondScreenMode.MENU && wanted != secondScreenMode) selectSecondScreenMode(wanted) + } + private fun bottomScreenPicker(mode: SecondScreenMode) = com.droiddeck.launcher.ui.ScreenPicker( com.droiddeck.launcher.ui.secondScreenModes(false, SessionState.deckPad, bottomPages().isNotEmpty(), com.droiddeck.launcher.session.BottomDesktop.available()), @@ -4561,6 +4708,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onKeyboardClosed = ::bottomKeyboardClosed, onMenu = { drawerOpen = true }, picker = ::bottomScreenPicker, + panel = ::bottomPanel, onMenuTouched = { if (drawerPinned) { drawerPinned = false @@ -4597,7 +4745,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde BottomDashboard( bottomPages(), com.droiddeck.launcher.ui.SessionBottomTab.picked(SessionState.sessionId), gameStarts = gameStarts, - onPage = { com.droiddeck.launcher.ui.SessionBottomTab.pick(SessionState.sessionId, it) }, + gamePage = { bottomGameKey()?.let { SessionPrefs.gameBottomPage(this@SessionActivity, it) } }, + onPage = { + com.droiddeck.launcher.ui.SessionBottomTab.pick(SessionState.sessionId, it) + bottomGameKey()?.let { game -> SessionPrefs.setGameBottomPage(this@SessionActivity, game, it) } + }, strip = { pageId -> com.droiddeck.launcher.ui.SessionBottomStrip(pageId) { if (::hud.isInitialized) hud.liveFps else null } }, @@ -4606,11 +4758,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde }), ) - private fun bottomPages(): List = sessionBottomPages(BottomPageActions( + private fun bottomPages(): List = sessionBottomPages(bottomActions()) + + private fun bottomPanel(mode: SecondScreenMode): (@androidx.compose.runtime.Composable () -> Unit)? = + if (!mode.sessionPanel) null else ({ DroidDeckTheme { com.droiddeck.launcher.ui.BottomSessionPanel(mode, bottomActions()) } }) + + private fun bottomActions() = BottomPageActions( takeScreenshot = ::captureScreenshot, fps = { if (::hud.isInitialized) hud.liveFps else null }, runningGame = { gestureGame }, - )) + gameKey = ::bottomGameKey, + copyRegion = ::copyGameRegion, + sourceAspect = { gameSource()?.takeIf { it.width > 0 && it.height > 0 }?.let { it.width.toFloat() / it.height } ?: (16f / 9f) }, + holdComposed = ::holdComposedOutput, + maskRegion = ::maskGameRegion, + ) private fun captureScreenshot(onDone: (Boolean) -> Unit) = copyGameFrame { bitmap -> if (bitmap == null) { @@ -4659,6 +4821,46 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } + private fun gameSource(): android.view.SurfaceView? = if (glassesOutputActive) glassesScreen?.surfaceView + else if (bottomOutputActive) bottomGame?.surfaceView else if (::surfaceView.isInitialized) surfaceView else null + + private fun copyGameRegion(region: android.graphics.RectF?, outWidth: Int, outHeight: Int, onFrame: (android.graphics.Bitmap?) -> Unit) { + val source = gameSource() + val width = source?.width ?: 0 + val height = source?.height ?: 0 + if (source == null || width <= 0 || height <= 0 || outWidth <= 0 || outHeight <= 0 || source.holder.surface?.isValid != true) { + onFrame(null) + return + } + val r = region ?: android.graphics.RectF(0f, 0f, 1f, 1f) + val src = android.graphics.Rect((r.left * width).toInt(), (r.top * height).toInt(), (r.right * width).toInt(), (r.bottom * height).toInt()) + if (src.width() <= 0 || src.height() <= 0) { + onFrame(null) + return + } + val bitmap = try { + android.graphics.Bitmap.createBitmap(outWidth, outHeight, android.graphics.Bitmap.Config.ARGB_8888) + } catch (_: OutOfMemoryError) { + onFrame(null) + return + } + withPictureFrame { done -> + try { + android.view.PixelCopy.request(source, src, bitmap, { result -> + done() + if (result == android.view.PixelCopy.SUCCESS) onFrame(bitmap) else { + bitmap.recycle() + onFrame(null) + } + }, uiHandler) + } catch (_: IllegalArgumentException) { + done() + bitmap.recycle() + onFrame(null) + } + } + } + /** PixelCopy reads the last queued buffer, which black frame insertion makes black every other refresh. */ private fun withPictureFrame(copy: (done: () -> Unit) -> Unit) { if (!CompositorHost.holdPicture()) return copy {} @@ -4961,7 +5163,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde com.droiddeck.launcher.ui.SessionTyping.returnFocus(this, taskId) val mode = typingReturnMode ?: return typingReturnMode = null - uiHandler.post { if (secondScreenMode == SecondScreenMode.KEYBOARD_TRACKPAD) selectSecondScreenMode(mode) } + uiHandler.post { + if (secondScreenMode == SecondScreenMode.KEYBOARD_TRACKPAD) selectSecondScreenMode(mode) + if (gamePanelPending) restoreGamePanel(gestureGame) + } } private fun updateKeyboardRoute() { @@ -5196,7 +5401,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun handleTouch(event: MotionEvent): Boolean { val pen = PenStream.penIndex(event) val penRouted = if (pen >= 0) routePen(event, pen).takeIf { it != PenRouter.Route.TOUCH } else null - if (penRouted == null && event.isFromSource(android.view.InputDevice.SOURCE_MOUSE)) return onMouse(event) + if (penRouted == null && (event.isFromSource(android.view.InputDevice.SOURCE_MOUSE) || + event.isFromSource(android.view.InputDevice.SOURCE_TOUCHPAD))) return onMouse(event) when (event.actionMasked) { MotionEvent.ACTION_DOWN -> { sessionTouchDown = true @@ -5442,7 +5648,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun isHardwareMouse(d: InputDevice?): Boolean = d != null && !d.isVirtual && !d.supportsSource(InputDevice.SOURCE_STYLUS) && - (d.supportsSource(InputDevice.SOURCE_MOUSE) || d.supportsSource(InputDevice.SOURCE_MOUSE_RELATIVE)) + (d.supportsSource(InputDevice.SOURCE_MOUSE) || d.supportsSource(InputDevice.SOURCE_MOUSE_RELATIVE) || + d.supportsSource(InputDevice.SOURCE_TOUCHPAD)) + + private fun isTouchpad(d: InputDevice?): Boolean = + d?.supportsSource(InputDevice.SOURCE_TOUCHPAD) == true /** Android also sends the Back and Forward buttons as key events, so they are handled as keys. */ private fun guestMouseButton(actionButton: Int): Int? = when (actionButton) { @@ -5452,9 +5662,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde else -> PointerGestures.BTN_LEFT } + private fun pointerAttached(): Boolean = usbMouse.active || InputDevice.getDeviceIds().any { id -> + isHardwareMouse(InputDevice.getDevice(id)) + } + private fun mouseAttached(): Boolean = usbMouse.active || InputDevice.getDeviceIds().any { id -> val d = InputDevice.getDevice(id) - isHardwareMouse(d) && d?.supportsSource(InputDevice.SOURCE_TOUCHPAD) != true + isHardwareMouse(d) && !isTouchpad(d) } private fun externalMouseAttached(): Boolean { @@ -5472,7 +5686,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun updatePointerCapture() { if (!::surfaceView.isInitialized) return val view = window.decorView - val want = (pointerLocked || relativeMouseAttached()) && sessionOwnsInput() && hasWindowFocus() && mouseAttached() + val want = (pointerLocked || relativeMouseAttached()) && sessionOwnsInput() && hasWindowFocus() && pointerAttached() releaseDesktopMouseGrab() updateUsbMouse(want) if (want == view.hasPointerCapture()) return @@ -5525,7 +5739,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private fun dropMouseCursor() { - if (!mouseOwnsCursor || mouseAttached()) return + if (!mouseOwnsCursor || pointerAttached()) return mouseOwnsCursor = false uiHandler.removeCallbacks(cursorResync) cursorVisible = false @@ -5576,20 +5790,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private fun onCapturedPointer(event: MotionEvent): Boolean { - if (!event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE)) return false + if (!com.droiddeck.launcher.input.PointerCapture.accepts(event)) return false notePress(event) + val pad = com.droiddeck.launcher.input.PointerCapture.isTouchpad(event) + when (event.actionMasked) { + MotionEvent.ACTION_BUTTON_PRESS, MotionEvent.ACTION_BUTTON_RELEASE -> { + if (pad && event.actionMasked == MotionEvent.ACTION_BUTTON_PRESS) capturedTouchpad.buttonPressed() + guestMouseButton(event.actionButton)?.let { heldButtons.set(8, it, event.actionMasked == MotionEvent.ACTION_BUTTON_PRESS) } + } + else -> if (pad) return onCapturedTouchpad(event) + } when (event.actionMasked) { MotionEvent.ACTION_MOVE -> { - var dx = event.x - var dy = event.y - for (i in 0 until event.historySize) { - dx += event.getHistoricalX(i) - dy += event.getHistoricalY(i) - } - onRelativeMouse(dx, dy) + val delta = com.droiddeck.launcher.input.PointerCapture.delta(event) + onRelativeMouse(delta[0], delta[1]) } - MotionEvent.ACTION_BUTTON_PRESS, MotionEvent.ACTION_BUTTON_RELEASE -> - guestMouseButton(event.actionButton)?.let { heldButtons.set(8, it, event.actionMasked == MotionEvent.ACTION_BUTTON_PRESS) } + MotionEvent.ACTION_BUTTON_PRESS, MotionEvent.ACTION_BUTTON_RELEASE -> {} MotionEvent.ACTION_SCROLL -> { val v = event.getAxisValue(MotionEvent.AXIS_VSCROLL) if (v != 0f) sendSceneWheel(-Math.round(v)) @@ -5600,6 +5816,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde return true } + private fun onCapturedTouchpad(event: MotionEvent): Boolean { + if (event.actionMasked == MotionEvent.ACTION_DOWN) { + val metrics = resources.displayMetrics + val scale = com.droiddeck.launcher.input.PointerCapture.touchpadScale(event, metrics.xdpi / 25.4f, metrics.widthPixels) + capturedPadMatrix.setScale(scale, scale) + capturedTouchpad.desktop = SessionState.mode == SessionService.MODE_DESKTOP + if (::touchpad.isInitialized) capturedTouchpad.sensitivity = touchpad.sensitivity + } + val scaled = MotionEvent.obtain(event) + scaled.transform(capturedPadMatrix) + val handled = capturedTouchpad.onTouch(scaled) + scaled.recycle() + return handled + } + private fun logInputDevice(what: String, deviceId: Int) { val d = InputDevice.getDevice(deviceId) ?: return if (!PadBridge.isFromController(d)) return @@ -5892,7 +6123,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (zeroCopyActive()) { WaylandCompositor.nativeSetZeroCopy(false) val restore = java.util.concurrent.atomic.AtomicBoolean(false) - val back = { if (restore.compareAndSet(false, true)) WaylandCompositor.nativeSetZeroCopy(true) } + pauseCaptures++ + val back = { + if (restore.compareAndSet(false, true)) { + pauseCaptures-- + if (!isDestroyed) WaylandCompositor.nativeSetZeroCopy(composedOutputFree()) + } + } uiHandler.postDelayed({ capturePausedFrame(manual = true, onDone = back) }, ZERO_COPY_SETTLE_MS) uiHandler.postDelayed({ back() }, ZERO_COPY_RESTORE_MS) } else { @@ -5901,6 +6138,53 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde SessionService.pause(this) } + private var composedHolds = 0 + private var pauseCaptures = 0 + + private fun composedOutputFree() = composedHolds == 0 && pauseCaptures == 0 + private var mirrorMask: android.view.View? = null + private var maskedRegion: android.graphics.RectF? = null + private var maskDim = false + private val maskLayout = android.view.View.OnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> placeMirrorMask() } + + private fun maskGameRegion(region: android.graphics.RectF?, dim: Boolean) { + maskedRegion = region + maskDim = dim + if (region != null && mirrorMask == null && ::sessionRoot.isInitialized && ::surfaceView.isInitialized) { + val mask = android.view.View(this).apply { + isClickable = false + isFocusable = false + importantForAccessibility = android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO + } + sessionRoot.addView(mask, sessionRoot.indexOfChild(surfaceView) + 1, FrameLayout.LayoutParams(0, 0)) + surfaceView.addOnLayoutChangeListener(maskLayout) + mirrorMask = mask + } + placeMirrorMask() + } + + private fun placeMirrorMask() { + val mask = mirrorMask ?: return + val r = maskedRegion + if (r == null || glassesOutputActive || bottomOutputActive || surfaceView.width <= 0) { + mask.visibility = android.view.View.GONE + return + } + mask.setBackgroundColor(if (maskDim) 0xB3000000.toInt() else android.graphics.Color.BLACK) + val w = surfaceView.width + val h = surfaceView.height + mask.layoutParams = FrameLayout.LayoutParams(((r.right - r.left) * w).toInt(), ((r.bottom - r.top) * h).toInt(), Gravity.TOP or Gravity.START).apply { + leftMargin = surfaceView.left - sessionRoot.paddingLeft + (r.left * w).toInt() + topMargin = surfaceView.top - sessionRoot.paddingTop + (r.top * h).toInt() + } + mask.visibility = android.view.View.VISIBLE + } + + private fun holdComposedOutput(hold: Boolean) { + composedHolds = (composedHolds + if (hold) 1 else -1).coerceAtLeast(0) + if (zeroCopyActive()) WaylandCompositor.nativeSetZeroCopy(composedOutputFree()) + } + private fun zeroCopyActive(): Boolean = CompositorHost.isStarted && !SessionState.hdr && SessionPrefs.zeroCopy(this, SessionState.mode) @@ -5943,8 +6227,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde drawerOpen = false pcKeyboardOpen = false achievementsOpen = false - pendingBackAction?.let(uiHandler::removeCallbacks) - pendingBackAction = null + backTaps.cancel() releaseDrawerDirection() onScreenControls?.releaseAll() bottomInputControls?.releaseAll() @@ -6089,6 +6372,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } if (CompositorHost.isStarted) applyFrameGen(force = true) applyFollowOrientation(resources.configuration) + uiHandler.removeCallbacks(questSteamVrRequest) + if (com.droiddeck.launcher.session.QuestExperimental.isSupported()) uiHandler.post(questSteamVrRequest) if (runtimeRemovalBlocked) return if (!SessionState.suspended) pausedFrame = null com.droiddeck.launcher.ui.Motion.refresh(this) @@ -6107,6 +6392,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onScreenControls?.reload() controllerSettings = ControllerPrefs.read(this) resumed = true + boostGpuClock(panelOverGame) updateKeyboardRoute() retryFieldKeyboard(hasWindowFocus()) updateDesktopKeyboardButton() @@ -6147,16 +6433,26 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } override fun onPause() { + uiHandler.removeCallbacks(questSteamVrRequest) departureCleanup() super.onPause() } + private val questSteamVrRequest = object : Runnable { + override fun run() { + if (com.droiddeck.launcher.session.QuestSteamVrLaunch.takeRequest(this@SessionActivity) && + SessionState.running && SessionState.mode == SessionService.MODE_STEAM) steamVrAction("start") + uiHandler.postDelayed(this, 1000) + } + } + private fun departureCleanup() { com.droiddeck.launcher.input.SystemKeyCapture.detach(this) com.droiddeck.launcher.input.HomeButtonShortcuts.detach(this) if (runtimeRemovalBlocked) return physicalShortcuts.clear() backQamInput.cancel() + backTaps.cancel() mouseBackInput.cancel() capturePausedFrame() padBridge?.setInputEnabled(false) @@ -6190,6 +6486,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (::scrollTouch.isInitialized) scrollTouch.cancel() if (::padMouse.isInitialized) padMouse.reset() resumed = false + boostGpuClock(false) updateKeyboardRoute() updatePointerCapture() updatePadMotion() @@ -6618,11 +6915,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde modifier = Modifier.fillMaxWidth().weight(1f), ) } + secondScreenMode.sessionPanel -> androidx.compose.foundation.layout.Column(Modifier.fillMaxSize()) { + com.droiddeck.launcher.ui.BottomScreenBar(bar(getString(secondScreenMode.label))) + androidx.compose.foundation.layout.Box(Modifier.fillMaxWidth().weight(1f)) { + com.droiddeck.launcher.ui.BottomSessionPanel(secondScreenMode, bottomActions()) + } + } pages.isEmpty() -> com.droiddeck.launcher.ui.BottomScreenBar(bar(null)) else -> BottomDashboard( pages, com.droiddeck.launcher.ui.SessionBottomTab.picked(SessionState.sessionId), gameStarts = gameStarts, - onPage = { com.droiddeck.launcher.ui.SessionBottomTab.pick(SessionState.sessionId, it) }, + gamePage = { bottomGameKey()?.let { SessionPrefs.gameBottomPage(this@SessionActivity, it) } }, + onPage = { + com.droiddeck.launcher.ui.SessionBottomTab.pick(SessionState.sessionId, it) + bottomGameKey()?.let { game -> SessionPrefs.setGameBottomPage(this@SessionActivity, game, it) } + }, bar = bar(getString(R.string.second_mode_dashboard)), strip = { pageId -> com.droiddeck.launcher.ui.SessionBottomStrip(pageId) { if (::hud.isInitialized) hud.liveFps else null } @@ -6762,13 +7069,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde super.onWindowFocusChanged(hasFocus) if (!hasFocus) com.droiddeck.launcher.input.HomeButtonShortcuts.cancel(this) if (!hasFocus) backQamInput.cancel() + if (!hasFocus) backTaps.cancel() if (!hasFocus) mouseBackInput.cancel() if (!hasFocus && ::padMouse.isInitialized) padMouse.reset() if (runtimeRemovalBlocked) return if (!hasFocus) { - if (::touchscreenGestures.isInitialized) touchscreenGestures.cancel() - if (::touchpad.isInitialized) touchpad.cancel() - if (::scrollTouch.isInitialized) scrollTouch.cancel() + cancelTouchGestures() releaseHeldGuestInput() } if (hasFocus && !pipUi) { @@ -6837,8 +7143,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (runtimeRemovalBlocked) { super.onDestroy(); return } watching = false releaseDrawerDirection() - pendingBackAction?.let(uiHandler::removeCallbacks) - pendingBackAction = null + backTaps.cancel() if (::pip.isInitialized) pip.destroyed() closeSecondScreen(reset = false) glassesScope.cancel() @@ -6970,6 +7275,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private const val PAD_SCROLL_POINTER_X = 0.985f private const val PAD_SCROLL_HEIGHTS_PER_S = 3f private const val AXIS_UNITS_PER_PIXEL = 3f + private const val CAPTURED_PAD_CENTRE = 1_000_000f private const val KEY_LEFTCTRL = 29 private const val KEY_RIGHTCTRL = 97 private const val KEY_A = 30 diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt index 80667afef0..566cfde355 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt @@ -1,7 +1,6 @@ package com.droiddeck.launcher.agent import android.content.Context -import android.os.Environment import android.os.Handler import android.os.Looper import android.os.SystemClock @@ -564,7 +563,7 @@ object AgentHost { (if (connectAdb) "adb start-server >/dev/null 2>&1; adb connect \"\$ADB_SERIAL\" >/dev/null 2>&1; " else "") + "cd \"$1\" 2>/dev/null; shift; exec \"$@\"", "sh", workdir, ) - val proot = LinuxRuntime.command(app, null, null, Environment.getExternalStorageDirectory(), null, env + shell + command, fakeRoot) + val proot = LinuxRuntime.command(app, null, null, LinuxRuntime.sharedStorage(app), null, env + shell + command, fakeRoot) return ProcessBuilder(proot).redirectErrorStream(true).apply { environment().apply { remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH") diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt index 573814f00c..aa2ad40ae7 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt @@ -8,8 +8,11 @@ import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue +import com.droiddeck.launcher.R +import com.droiddeck.launcher.core.WirelessAdbFix import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.session.OrphanReaper +import com.droiddeck.launcher.session.QuestExperimental import java.io.File import java.util.concurrent.TimeUnit @@ -88,6 +91,8 @@ object AgentSetup { private fun completedKey(harness: AgentHarness) = "setup_completed_${harness.id}" private val main = Handler(Looper.getMainLooper()) + /** Advanced by every Allow, so a connection check started before it cannot overwrite what it found. */ + private var connectionGeneration = 0 private const val REPO = "https://github.com/Droid-Deck/DroidDeck.git" private const val CHECKOUT = "/root/DroidDeck" private val HELPERS = listOf("android-open", "dd-gh-login", "droiddeckctl", "droiddeck-scenario") @@ -104,6 +109,7 @@ object AgentSetup { val harness = AgentHost.harness keys = harness.keys(LinuxRuntime.rootDir(app)) val probes = mutableListOf>>() + val generation = connectionGeneration for (step in Step.entries) if (status[step] != Status.WORKING) { when (step) { Step.INSTALL -> set(step, if (harness.files.all { AgentHost.guestFileExists(app, it) }) Status.DONE else Status.TODO) @@ -114,7 +120,9 @@ object AgentSetup { detail.remove(step) Thread({ val live = com.droiddeck.launcher.core.WirelessAdbFix.liveConnectAddress(app) != null - set(step, if (live) Status.DONE else Status.TODO) + main.post { + if (generation == connectionGeneration && status[step] != Status.WORKING) status[step] = if (live) Status.DONE else Status.TODO + } }, "agent-connection").start() } else probes += step to listOf("sh", "-c", "for i in 1 2 3; do adb connect \"\$ADB_SERIAL\" >/dev/null 2>&1; " + @@ -123,14 +131,40 @@ object AgentSetup { Step.GITHUB -> probes += step to listOf("gh", "auth", "status") } } - Thread({ for ((step, command) in probes) probe(app, harness, step, command) }, "agent-checks").start() + Thread({ for ((step, command) in probes) probe(app, harness, step, command, generation) }, "agent-checks").start() } + /** The last failed refresh ends the script: the installs after it would run from stale indexes and could report success. */ + internal fun installScript(harnessInstall: String) = "set -e; export DEBIAN_FRONTEND=noninteractive; " + + "apt() { apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 \"\$@\"; }; " + + "dpkg --configure -a || echo 'Some packages are not configured yet; repairing dependencies'; " + + "for i in 1 2 3; do apt -o APT::Update::Error-Mode=any update -q && break; " + + "[ \$i = 3 ] && { echo 'Some package sources could not be refreshed'; exit 1; }; " + + "echo 'Some package sources could not be refreshed; retrying'; sleep 3; done; " + + "apt -f install -y --fix-missing; " + + "apt install -y --no-install-recommends git gh adb curl ca-certificates python3; $harnessInstall" + fun runsAsRoot(step: Step) = step == Step.INSTALL /** Runs [step]'s action. [CONNECTION] is the app's own pairing flow, so the caller opens it. */ fun run(context: Context, step: Step) = run(context, step, null) + /** The [Step.CONNECTION] action on a Quest, which has no pairing screen; see [WirelessAdbFix.trustOnDevice]. */ + fun trustOnDevice(context: Context) { + val app = context.applicationContext + connectionGeneration++ + status[Step.CONNECTION] = Status.WORKING + detail[Step.CONNECTION] = app.getString(R.string.agent_connection_quest_waiting) + Thread({ + val ok = runCatching { WirelessAdbFix.trustOnDevice(app) }.isSuccess + main.post { + status[Step.CONNECTION] = if (ok) Status.DONE else Status.FAILED + if (ok) detail.remove(Step.CONNECTION) else detail[Step.CONNECTION] = app.getString(R.string.agent_connection_quest_failed) + if (ok) check(app) + } + }, "agent-quest-trust").start() + } + /** Opens the page where a provider's key is made, as the sign-in of a harness that takes pasted keys. */ fun openKeyPage(context: Context, page: String) = run(context, Step.SIGN_IN, listOf("/root/.local/bin/android-open", page)) @@ -140,12 +174,7 @@ object AgentSetup { val command = override ?: when (step) { Step.CONNECTION -> return Step.INSTALL -> { - listOf("sh", "-c", "set -e; export DEBIAN_FRONTEND=noninteractive; " + - "apt() { apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 \"\$@\"; }; " + - "dpkg --configure -a || echo 'Some packages are not configured yet; repairing dependencies'; " + - "for i in 1 2 3; do apt -o APT::Update::Error-Mode=any update -q && break; echo 'Some package sources could not be refreshed; retrying'; sleep 3; done; " + - "apt -f install -y --fix-missing; " + - "apt install -y --no-install-recommends git gh adb curl ca-certificates python3; ${harness.install}") + listOf("sh", "-c", installScript(harness.install)) } Step.SIGN_IN -> harness.signIn Step.GITHUB -> listOf("dd-gh-login") @@ -211,7 +240,7 @@ object AgentSetup { detail.clear() } - private fun probe(app: Context, harness: AgentHarness, step: Step, command: List) { + private fun probe(app: Context, harness: AgentHarness, step: Step, command: List, generation: Int) { var output = "" val ok = runCatching { val child = AgentHost.guest(app, command, connectAdb = step == Step.CONNECTION).start() @@ -227,11 +256,14 @@ object AgentSetup { }.onFailure { output = it.message.orEmpty() }.getOrDefault(false) main.post { if (AgentHost.harness != harness) return@post + // A running or newer Allow owns the row, including the instructions it shows while it waits. + if (step == Step.CONNECTION && (generation != connectionGeneration || status[step] == Status.WORKING)) return@post if (status[step] != Status.WORKING) status[step] = if (ok) Status.DONE else Status.TODO val last = output.lines().lastOrNull { it.isNotBlank() && !noise(it.trim()) }?.trim()?.take(160) when { ok -> detail.remove(step) - step == Step.CONNECTION -> detail[step] = app.getString(com.droiddeck.launcher.R.string.agent_connection_off) + step == Step.CONNECTION -> detail[step] = app.getString( + if (QuestExperimental.isSupported()) R.string.agent_connection_quest_off else R.string.agent_connection_off) step.required && last != null -> detail[step] = last } if (ready) AgentHost.prefs(app).edit().putBoolean(completedKey(harness), true).apply() diff --git a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt index 9cf1871e10..db8ab970a2 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt @@ -62,6 +62,7 @@ object DeviceReport { 14 -> "FREEZER" 15 -> "PACKAGE_STATE_CHANGE" 16 -> "PACKAGE_UPDATED" + 17 -> "MEMORY_LIMITER" else -> "REASON_$reason" } diff --git a/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt b/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt index 55e7e61284..711a50eca3 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt @@ -61,7 +61,19 @@ object GameEnvironment { } fun effective(config: Config, preset: String, scope: String, forceSsbs: Boolean = false): Map = - defaults(preset, forceSsbs) + config.shared + if (scope.isEmpty()) emptyMap() else config.games[scope].orEmpty() + defaults(preset, forceSsbs) + config.shared + if (scope.isEmpty()) emptyMap() else knownGames[scope].orEmpty() + config.games[scope].orEmpty() + + /** + * What some Steam games need here whatever the shared settings say; the game's own settings still win. + * GTA III dies at 0042A703 when a new game starts with FEX's reduced x87 precision, as the Rockstar store copy does. + */ + val knownGames: Map> = mapOf( + "12100" to mapOf("FEX_X87REDUCEDPRECISION" to "0"), + ) + + /** [config] with [knownGames] folded under each game's own settings, for the guest to read. */ + fun withKnownGames(config: Config): Config = + config.copy(games = config.games + knownGames.mapValues { (scope, known) -> known + config.games[scope].orEmpty() }) fun hasOverride(config: Config, scope: String, name: String): Boolean = scope.isNotEmpty() && config.entries(scope).containsKey(name) @@ -78,7 +90,7 @@ object GameEnvironment { val entries = config.games[scope].orEmpty() if (FexPreset.environmentKeys.none(entries::containsKey)) return null return FexPreset.all.firstOrNull { preset -> - val expected = FexPreset.environment(preset.id) + val expected = presetFor(scope, preset.id) FexPreset.environmentKeys.all { key -> entries.containsKey(key) && entries[key] == expected[key] } }?.id ?: CUSTOM_FEX_PRESET } @@ -88,12 +100,16 @@ object GameEnvironment { require(preset == null || FexPreset.all.any { it.id == preset }) val entries = config.entries(scope).filterKeys { it !in FexPreset.environmentKeys }.toMutableMap() if (preset != null) { - val values = FexPreset.environment(preset) + val values = presetFor(scope, preset) FexPreset.environmentKeys.forEach { key -> entries[key] = values[key] } } return config.withEntries(scope, entries) } + /** A FEX preset as a game gets it: picking one never undoes a fix the game is known to need. */ + private fun presetFor(scope: String, preset: String): Map = + FexPreset.environment(preset) + knownGames[scope].orEmpty().filterKeys { it in FexPreset.environmentKeys } + const val CUSTOM_FEX_PRESET = "__custom__" val syncBackends = listOf(SessionPrefs.SYNC_NTSYNC, SessionPrefs.SYNC_FSYNC, SessionPrefs.SYNC_ESYNC, SessionPrefs.SYNC_WINESERVER) diff --git a/app/src/main/java/com/droiddeck/launcher/core/GlobalSettings.kt b/app/src/main/java/com/droiddeck/launcher/core/GlobalSettings.kt index 3e4bb53051..1daf377fb7 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/GlobalSettings.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/GlobalSettings.kt @@ -1,6 +1,7 @@ package com.droiddeck.launcher.core import android.content.Context +import android.content.pm.PackageManager import android.net.Uri import android.provider.Settings @@ -19,4 +20,14 @@ object GlobalSettings { fun developerOptionsOn(context: Context): Boolean = isOn(context, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED) fun wirelessDebuggingOn(context: Context): Boolean = isOn(context, "adb_wifi_enabled") + + /** + * True when it was off and is now on. Quest only, where Settings has no switch for it; it needs + * WRITE_SECURE_SETTINGS granted over adb. + */ + fun turnOnWirelessDebugging(context: Context): Boolean { + if (!com.droiddeck.launcher.session.QuestExperimental.isSupported() || wirelessDebuggingOn(context)) return false + if (context.checkSelfPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) != PackageManager.PERMISSION_GRANTED) return false + return runCatching { Settings.Global.putInt(context.contentResolver, "adb_wifi_enabled", 1) }.getOrDefault(false) + } } diff --git a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt index 5c8b32f7ba..64087a24f3 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt @@ -22,6 +22,9 @@ object WirelessAdbFix { private const val HOST_FILE = "wireless-adb-host.txt" private const val CONNECTION_FILE = "wireless-adb-connection.txt" const val LOOPBACK = "127.0.0.1" + private const val TCP_PORT = 5555 + private const val WIRELESS_START_MS = 2_000L + private const val NETWORK_PROMPT_MS = 30_000L private data class SavedConnection(val host: String, val port: Int?) @@ -55,6 +58,23 @@ object WirelessAdbFix { writeAtomically(context, File(context.noBackupFilesDir, CONNECTION_FILE), ByteArray(0)) } + /** + * Quest has no pairing screen. adbd in TCP mode (`adb tcpip 5555`) asks "Allow debugging?" for an + * unknown key, and Wireless debugging accepts a key allowed there, so this stands in for pairing. + * Blocks until the prompt is answered or times out. + */ + fun trustOnDevice(context: Context) { + val app = context.applicationContext + // Already trusted, as after a reboot: Wireless debugging takes the key, and port 5555 is closed by then. + val live = if (savedConnection(app) != null) liveConnectAddress(app) else null + if (live != null && acceptsKey(app, live.substringBeforeLast(':').trim('[', ']'), live.substringAfterLast(':').toInt())) return + GlobalSettings.turnOnWirelessDebugging(app) + loadOrCreateIdentity(app) + Kadb.create(LOOPBACK, TCP_PORT, 2_000, 120_000).use { check(it.shell("true").exitCode == 0) } + writeAtomically(app, File(app.noBackupFilesDir, HOST_FILE), LOOPBACK.toByteArray()) + writeAtomically(app, File(app.noBackupFilesDir, CONNECTION_FILE), ByteArray(0)) + } + private fun savedConnection(context: Context): SavedConnection? { val directory = context.applicationContext.noBackupFilesDir if (!File(directory, CERT_FILE).isFile || !File(directory, KEY_FILE).isFile) return null @@ -78,10 +98,17 @@ object WirelessAdbFix { fun liveConnectAddress(context: Context): String? { val app = context.applicationContext val saved = savedConnection(app) ?: return null + val turnedOn = GlobalSettings.turnOnWirelessDebugging(app) val host = if (':' in saved.host) "[${saved.host}]" else saved.host - saved.port?.takeIf { answers(saved.host, it) }?.let { return "$host:$it" } + if (!turnedOn) saved.port?.takeIf { answers(saved.host, it) }?.let { return "$host:$it" } val loopback = runCatching { InetAddress.getByName(saved.host).isLoopbackAddress }.getOrDefault(false) - val port = if (loopback) loopbackAdbPort(app) else findConnectPort(app, saved.host, accept = { answers(saved.host, it) }) + // Turning it on can first ask "Allow wireless debugging on this network?", so keep looking while that is answered. + val deadline = android.os.SystemClock.elapsedRealtime() + if (turnedOn) NETWORK_PROMPT_MS else 0L + var port: Int? + do { + if (turnedOn) Thread.sleep(WIRELESS_START_MS) + port = if (loopback) loopbackAdbPort(app) else findConnectPort(app, saved.host, accept = { answers(saved.host, it) }) + } while (port == null && android.os.SystemClock.elapsedRealtime() < deadline) port ?: return null saveConnection(app, saved.host, port) return "$host:$port" @@ -105,10 +132,12 @@ object WirelessAdbFix { } }.apply { start() } }.forEach { it.join() } + return open.sorted().firstOrNull { port -> acceptsKey(app, LOOPBACK, port) } + } + + private fun acceptsKey(app: Context, host: String, port: Int): Boolean { loadOrCreateIdentity(app) - return open.sorted().firstOrNull { port -> - runCatching { Kadb.create(LOOPBACK, port, 1_000, 3_000).use { it.shell("true").exitCode == 0 } }.getOrDefault(false) - } + return runCatching { Kadb.create(host, port, 1_000, 3_000).use { it.shell("true").exitCode == 0 } }.getOrDefault(false) } private val EPHEMERAL_PORTS = 32768..60999 diff --git a/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt b/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt index de95eea354..2c9529f4ed 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt @@ -8,9 +8,18 @@ import android.os.Environment import android.provider.Settings object AllFilesAccess { + private val VOLUME = Regex("^(/storage/emulated/\\d+|/storage/[^/]+|/sdcard)(/.*)?$") + private val APP_FOLDERS = listOf("/Android/data", "/Android/obb") + fun missing(sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): Boolean = sdk >= Build.VERSION_CODES.R && !granted() + /** Whether reading [path] takes all-files access: shared storage, outside the per-app folders directly under a volume's root, which Android always lets the app use. */ + fun covers(path: String): Boolean { + val inside = VOLUME.matchEntire(path)?.groupValues?.get(2) ?: return false + return APP_FOLDERS.none { inside == it || inside.startsWith("$it/") } + } + fun open(context: Context) { val app = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, Uri.parse("package:" + context.packageName)) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) diff --git a/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt b/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt index 7025769d87..c872096533 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt @@ -504,13 +504,15 @@ fun FileManagerScreen( } val drives = remember(storageTick) { StorageRoots.list(context) } var accessDrive by remember { mutableStateOf(null) } + var accessWasMissing by remember { mutableStateOf(AllFilesAccess.missing()) } + var accessDeclined by remember { mutableStateOf(false) } fun unreadable(drive: StorageRoot) { if (AllFilesAccess.missing()) accessDrive = drive.label else Toast.makeText(context, context.getString(R.string.fm_drive_not_readable, drive.label), Toast.LENGTH_SHORT).show() } accessDrive?.let { label -> OutlinedAlertDialog( - onDismissRequest = { accessDrive = null }, + onDismissRequest = { accessDrive = null; accessDeclined = true }, title = { Text(stringResource(R.string.fm_drive_access_title, label)) }, text = { Text(stringResource(R.string.fm_drive_access_text)) }, confirmButton = { @@ -519,9 +521,17 @@ fun FileManagerScreen( AllFilesAccess.open(context) }, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.upd_open_settings)) } }, - dismissButton = { TextButton(onClick = { accessDrive = null }, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.common_cancel)) } }, + dismissButton = { TextButton(onClick = { accessDrive = null; accessDeclined = true }, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.common_cancel)) } }, ) } + LaunchedEffect(currentDir, storageTick) { + if (!AllFilesAccess.missing()) { + if (accessWasMissing) { accessWasMissing = false; loadDirectory(currentDir, resetScroll = false, record = false) } + } else { + accessWasMissing = true + if (!accessDeclined && accessDrive == null && AllFilesAccess.covers(currentDir.path)) accessDrive = drives.firstOrNull { currentDir.path.startsWith(it.dir.path) }?.label ?: context.getString(R.string.fm_drive_internal) + } + } val linuxRoot = remember(storageTick) { com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context).takeIf { File(it, "usr").isDirectory } } diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt index 7009e0e68f..b26c2536cc 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt @@ -233,14 +233,14 @@ object AddedGames { if (folder.name.lowercase() in steamInstalls || isSteamLibraryFolder(folder.name)) continue if (folder.path in removed) continue if (folder.name == "Games" && StoreInstallRoot.roots(context).any { it.absolutePath == folder.absolutePath }) continue - for (game in expand(folder, entries, reuse = true)) if (game.path !in removed) scanGame(context, game, out, reuse = true) + timed(folder) { for (game in expand(folder, entries, reuse = true)) if (game.path !in removed) scanGame(context, game, out, reuse = true) } } } for (entry in AddedExes.list(context)) { val folder = File(entry.folder) if (folder.path in removed || !folder.isDirectory) continue if (StoreGameSidecar.read(folder)?.isInstalled == false) continue - scanGame(context, folder, out, single = entry, reuse = true) + timed(folder) { scanGame(context, folder, out, single = entry, reuse = true) } } for (folder in libraryDepotInstalls(context)) if (folder.path !in removed) scanGame(context, folder, out, reuse = true) for (folder in StoreInstallRoot.gameFolders(context)) if (StoreInstallRoot.isFinished(folder)) scanGame(context, folder, out, reuse = true) @@ -250,6 +250,15 @@ object AddedGames { return out.distinctBy { it.folder.canonicalPath } } + private const val SLOW_FOLDER_MS = 1_000L + + private inline fun timed(folder: File, block: () -> Unit) { + val began = android.os.SystemClock.elapsedRealtime() + block() + val took = android.os.SystemClock.elapsedRealtime() - began + if (took >= SLOW_FOLDER_MS) Log.i(TAG, "games: scanning ${folder.path} took ${took}ms") + } + fun single(context: Context, folderPath: String, reuse: Boolean = false): Game? { val folder = File(folderPath) if (!folder.isDirectory || folderPath in SessionPrefs.removedAddedGames(context)) return null @@ -490,6 +499,7 @@ object AddedGames { launchOptions = when { sidecar == null -> SessionPrefs.addedGameLaunch(context, folder.path) sidecar.store == Store.UBISOFT -> com.droiddeck.launcher.stores.ubisoft.UbisoftConnect.launchOptions(context) + sidecar.store == Store.EA -> SessionPrefs.addedGameLaunch(context, folder.path) else -> "" }, single = single != null, steamProgram = steamProgram)) @@ -564,8 +574,10 @@ object AddedGames { class Listed(val appId: Long, val name: String, val launchOptions: String) + fun listingFile(context: Context): File = File(context.filesDir, "session/added-games.json") + fun listed(context: Context): List? = runCatching { - val file = File(context.filesDir, "session/added-games.json") + val file = listingFile(context) if (!file.isFile) return null val entries = org.json.JSONArray(file.readText()) (0 until entries.length()).mapNotNull { i -> @@ -575,7 +587,7 @@ object AddedGames { fun writeListing(context: Context, games: List, extra: List = listOfNotNull(com.droiddeck.launcher.stores.epic.EpicClient.steamListing(context))): File { - val file = File(context.filesDir, "session/added-games.json").apply { parentFile?.mkdirs() } + val file = listingFile(context).apply { parentFile?.mkdirs() } val json = StringBuilder("[") games.forEachIndexed { i, g -> if (i > 0) json.append(',') @@ -596,10 +608,24 @@ object AddedGames { if (games.isNotEmpty() || i > 0) json.append(',') json.append(entry.toString()) } - file.writeText(json.append(']').toString()) + val text = json.append(']').toString() + synchronized(listing) { + val partial = File(file.parentFile, file.name + ".part") + try { + partial.writeText(text) + java.nio.file.Files.move(partial.toPath(), file.toPath(), + java.nio.file.StandardCopyOption.ATOMIC_MOVE, java.nio.file.StandardCopyOption.REPLACE_EXISTING) + } catch (e: java.io.IOException) { + Log.w(TAG, "games: listing not replaced: ${e.message}") + partial.delete() + if (!file.isFile) file.writeText(text) + } + } return file } + private val listing = Any() + private fun artGuestPath(context: Context, file: File): String? { val files = context.filesDir.absolutePath if (file.absolutePath.startsWith("$files/")) return file.absolutePath diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGamesPublisher.kt b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGamesPublisher.kt index c70b2a895a..f2a4ef27e3 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGamesPublisher.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGamesPublisher.kt @@ -1,17 +1,31 @@ package com.droiddeck.launcher.frontend import android.content.Context +import android.os.SystemClock import android.util.Log import androidx.annotation.VisibleForTesting +import com.droiddeck.launcher.session.SessionPhase +import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.session.SessionState +import com.droiddeck.launcher.stores.SteamLiveShortcuts +import java.io.File +import java.util.concurrent.Callable import java.util.concurrent.Executors object AddedGamesPublisher { private const val TAG = "AddedGamesPublisher" + private const val CLIENT_WAIT_MS = 600_000L + private const val POLL_MS = 1_000L + private const val RETRY_MS = 5_000L @VisibleForTesting @Volatile internal var now = false + @VisibleForTesting + @Volatile + internal var live: (Context, List, (AddedGames.Game) -> Boolean) -> Boolean = SteamLiveShortcuts::sync + private val worker = Executors.newSingleThreadExecutor { r -> Thread(r, "added-games-publish") } fun later(context: Context, live: () -> Unit = {}) { @@ -23,10 +37,56 @@ object AddedGamesPublisher { if (now) work.run() else worker.execute(work) } - fun republish(context: Context) { + fun republish(context: Context): List { val games = AddedGames.scan(context) AddedGames.writeListing(context, games) - val arch = com.droiddeck.launcher.session.SessionPrefs.activeSteamClientArch(context) + val arch = SessionPrefs.activeSteamClientArch(context) LibraryCache.save(context, Library.launchableGames(context, added = games, arch = arch), arch == "x86_64") + return games } + + fun sessionListing(context: Context): File { + val app = context.applicationContext + val started = AddedGames.listed(app)?.map { it.appId }?.toSet() + ?: return AddedGames.writeListing(app, AddedGames.scan(app).also { log(it) }) + val session = SessionState.sessionId + val work = Runnable { + try { + val began = SystemClock.elapsedRealtime() + val games = serial { republish(app) } + Log.i(TAG, "session refresh: ${games.size} game(s) in ${SystemClock.elapsedRealtime() - began} ms") + log(games) + val fresh = games.filter { (it.appId and 0xFFFFFFFFL) !in started } + if (fresh.isNotEmpty()) deliver(app, session, fresh) + } catch (e: Exception) { + Log.w(TAG, "session refresh: ${e.message}") + } + } + if (now) work.run() else Thread(work, "added-games-refresh").apply { priority = Thread.MIN_PRIORITY }.start() + return AddedGames.listingFile(app) + } + + internal fun log(games: List) { + if (games.isNotEmpty()) Log.i(TAG, "added games: " + games.joinToString { "${it.name} (${it.exe.name})" }) + } + + private fun deliver(app: Context, session: String?, games: List) { + val until = SystemClock.uptimeMillis() + CLIENT_WAIT_MS + while (current(session)) { + val ready = SessionState.phase == SessionPhase.READY + if (ready && serial { !current(session) || (SessionState.phase == SessionPhase.READY && syncUnremoved(app, games)) }) return + if (now || SystemClock.uptimeMillis() >= until) return + Thread.sleep(if (ready) RETRY_MS else POLL_MS) + } + } + + private fun current(session: String?): Boolean = + SessionState.running && !SessionState.stopRequested && SessionState.sessionId == session + + private fun syncUnremoved(app: Context, games: List): Boolean { + val removed = SessionPrefs.removedAddedGames(app).toSet() + return live(app, games) { it.folder.path !in removed } + } + + private fun serial(block: () -> T): T = if (now) block() else worker.submit(Callable { block() }).get() } diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/GameExePicker.kt b/app/src/main/java/com/droiddeck/launcher/frontend/GameExePicker.kt index 2466c8df8b..2b1356b069 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/GameExePicker.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/GameExePicker.kt @@ -51,11 +51,12 @@ object GameExePicker { val entries = dir.listFiles()?.sortedBy { it.name.lowercase() } ?: continue for (f in entries) { if (visited >= WALK_BUDGET) break@walk - if (isLink(f)) continue - if (f.isDirectory) { + val attrs = attributes(f) ?: continue + if (attrs.isSymbolicLink) continue + if (attrs.isDirectory) { visited++ if (depth < MAX_DEPTH && !skipDir(f, f.relativeTo(folder).invariantSeparatorsPath)) next.add(f) - } else if (f.isFile && f.name.endsWith(".exe", ignoreCase = true)) { + } else if (attrs.isRegularFile && f.name.endsWith(".exe", ignoreCase = true)) { visited++ if (!JUNK_EXE_RE.matches(f.nameWithoutExtension)) found.add(f to depth) } @@ -98,7 +99,9 @@ object GameExePicker { return SKIP_PATHS.any { rel == it || rel.endsWith("/$it") } } - private fun isLink(f: File): Boolean = runCatching { java.nio.file.Files.isSymbolicLink(f.toPath()) }.getOrDefault(false) + private fun attributes(f: File): java.nio.file.attribute.BasicFileAttributes? = runCatching { + java.nio.file.Files.readAttributes(f.toPath(), java.nio.file.attribute.BasicFileAttributes::class.java, java.nio.file.LinkOption.NOFOLLOW_LINKS) + }.getOrNull() private fun key(s: String) = s.lowercase().filter { it.isLetterOrDigit() } } diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/GameLaunchIntent.kt b/app/src/main/java/com/droiddeck/launcher/frontend/GameLaunchIntent.kt index 3e5d4ae0dd..91349aa6f1 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/GameLaunchIntent.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/GameLaunchIntent.kt @@ -11,6 +11,10 @@ object GameLaunchIntent { fun accepts(action: String?): Boolean = action == Intent.ACTION_VIEW || action == ACTION || action == GAMENATIVE_ACTION + fun replayed(intent: Intent, restored: Boolean, savedProcess: String?, process: String): Boolean = + !(intent.data?.scheme == "droiddeck" && intent.data?.host == "settings") && + (intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY != 0 || restored && savedProcess != process) + fun read(context: Context, intent: Intent): GameRequest? = when (intent.action) { Intent.ACTION_VIEW -> GameFiles.readIntent(context, intent) ACTION, GAMENATIVE_ACTION -> readExtras(intent) diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/SocNames.kt b/app/src/main/java/com/droiddeck/launcher/gpu/SocNames.kt index 25682ca064..7916c01467 100644 --- a/app/src/main/java/com/droiddeck/launcher/gpu/SocNames.kt +++ b/app/src/main/java/com/droiddeck/launcher/gpu/SocNames.kt @@ -7,17 +7,21 @@ object SocNames { "SM8150" to "Snapdragon 855", "SM8250" to "Snapdragon 865", "SM8250-AC" to "Snapdragon 870", "SM8350" to "Snapdragon 888", "SM8450" to "Snapdragon 8 Gen 1", "SM8475" to "Snapdragon 8+ Gen 1", "SM8550" to "Snapdragon 8 Gen 2", "QCS8550" to "Snapdragon 8 Gen 2", "SM8650" to "Snapdragon 8 Gen 3", + "SM8635" to "Snapdragon 8s Gen 3", "SM8735" to "Snapdragon 8s Gen 4", "SM8750" to "Snapdragon 8 Elite", "SM8750P" to "Snapdragon 8 Elite", "SM8850" to "Snapdragon 8 Elite Gen 5", "SM8975" to "Snapdragon 8 Elite Extreme Gen 6", "SM7325" to "Snapdragon 778G", "SM7450" to "Snapdragon 7 Gen 1", "SM7550" to "Snapdragon 7 Gen 3", + "SM7675" to "Snapdragon 7+ Gen 3", "SM6375" to "Snapdragon 695", + // Handheld parts: AYANEO Pocket FIT (SG8350P), Retroid Pocket Duo (CQ7790S). + "SG8350P" to "Snapdragon G3 Gen 3", "CQ7790S" to "Dragonwing Q-7790", ) private val PLATFORMS = mapOf( "msmnile" to "Snapdragon 855/860", "kona" to "Snapdragon 865/870", "lahaina" to "Snapdragon 888", "taro" to "Snapdragon 8 Gen 1", "cape" to "Snapdragon 8+ Gen 1", "kalama" to "Snapdragon 8 Gen 2", - "pineapple" to "Snapdragon 8 Gen 3", "sun" to "Snapdragon 8 Elite", + "pineapple" to "Snapdragon 8 Gen 3", "sun" to "Snapdragon 8 Elite", "canoe" to "Snapdragon 8 Elite Gen 5", ) fun model(prop: (String) -> String = GpuInfo::systemProperty): String { @@ -30,8 +34,16 @@ object SocNames { internal fun normalizedModel(model: String): String = model.trim().uppercase().removePrefix("QTI ").trim() - fun name(model: String, platform: String = GpuInfo.systemProperty("ro.board.platform")): String? = - MODELS[normalizedModel(model)] ?: PLATFORMS[platform.lowercase()]?.let { "$it family" } + /** + * The exact model's name; the board platform's family only for an empty model or a phone "SM" part, since + * different chips share a platform (the Retroid Pocket Duo's CQ7790S and the Snapdragon 8 Elite are both "sun"). + */ + fun name(model: String, platform: String = GpuInfo.systemProperty("ro.board.platform")): String? { + val m = normalizedModel(model) + MODELS[m]?.let { return it } + if (m.isNotEmpty() && !m.startsWith("SM")) return null + return PLATFORMS[platform.lowercase()]?.let { "$it family" } + } // Without label's platform-family guess: a rebadged chip such as the Duo's CQ7790S reports a platform it is not. fun plainName(model: String = model(), maker: String = manufacturer()): String = diff --git a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt index 719aae8d7f..fbd14aea93 100644 --- a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt +++ b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt @@ -5,7 +5,7 @@ import com.droiddeck.launcher.session.SessionPrefs internal object DroidDeckHudConfig { val DEFAULTS: Map = linkedMapOf( - "hudSize" to "minimal", "hudLocked" to "1", "hudHold" to "collapse", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid", + "hudSize" to "minimal", "hudLocked" to "0", "hudHold" to "collapse", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid", "hudOutline" to "40", "hudOutlineAccent" to "1", "showGpuModel" to "1", "showGPULoad" to "1", "showCPUUsage" to "1", "showCPULoad" to "1", "showPerCore" to "1", "showTemp" to "1", "showBatteryTemp" to "1", "showGpuTemp" to "0", diff --git a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt index bd04d149a2..f58320bc8e 100644 --- a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt +++ b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt @@ -349,7 +349,7 @@ class DroidDeckHudView(context: Context) : View(context) { showProton = switchOn("showProton") showSession = switchOn("showSession") tempDisplay = HudMetrics.TempDisplay.from(cfg) - lockController.setLocked(cfg.get("hudLocked", "1") == "1") + lockController.setLocked(cfg.get("hudLocked", "0") == "1") lockController.setHoldLocks(cfg.get("hudHold", "collapse") == DroidDeckHudConfig.HOLD_LOCKS) dock = DroidDeckHudDock.from(cfg.get("hudDock", "none")) diff --git a/app/src/main/java/com/droiddeck/launcher/input/BackQamInput.kt b/app/src/main/java/com/droiddeck/launcher/input/BackQamInput.kt index 54ae373ae2..3925109a28 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/BackQamInput.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/BackQamInput.kt @@ -6,18 +6,15 @@ import android.os.Looper class BackQamInput(private val setPressed: (Boolean) -> Unit, private val onTap: (Boolean) -> Unit, private val doubleTapMs: () -> Long = { 500 }, private val onCancel: () -> Unit = {}, - private val holds: () -> Boolean = { true }) { + private val holds: () -> Boolean = { true }, atOnce: () -> Boolean = { false }, sameAction: () -> Boolean = { false }) { private class Press(val hold: Runnable, var held: Boolean = false, var used: Boolean = false) private val handler = Handler(Looper.getMainLooper()) private val presses = mutableMapOf() private val cancelled = mutableSetOf() - private var tapPending = false - private val singleTap = Runnable { tapPending = false; onTap(false) } + private val taps = BackTaps(doubleTapMs, atOnce, onTap, sameAction) + val awaitingTap: Boolean get() = taps.pending - private fun cancelTap() { - handler.removeCallbacks(singleTap) - tapPending = false - } + fun cancelTap() = taps.cancel() fun onChordInput() { if (presses.isEmpty()) return @@ -46,7 +43,7 @@ class BackQamInput(private val setPressed: (Boolean) -> Unit, private val onTap: cancelled.remove(device) if (!enabled || event.isCanceled) return false if (device in presses) return true - handler.removeCallbacks(singleTap) + taps.hold() val hold = Runnable { val press = presses[device] ?: return@Runnable if (!holds()) { press.used = true; cancelTap(); return@Runnable } @@ -66,10 +63,8 @@ class BackQamInput(private val setPressed: (Boolean) -> Unit, private val onTap: if (press != null) { handler.removeCallbacks(press.hold) if (press.held && presses.values.none { it.held }) setPressed(false) - if (!press.used && !event.isCanceled) { - if (tapPending) { cancelTap(); onTap(true) } - else { tapPending = true; handler.postDelayed(singleTap, doubleTapMs()) } - } else if (event.isCanceled) cancelTap() + if (!press.used && !event.isCanceled) taps.tap() + else if (event.isCanceled) cancelTap() } press != null || wasCancelled || enabled } @@ -77,8 +72,8 @@ class BackQamInput(private val setPressed: (Boolean) -> Unit, private val onTap: } } - fun cancel() { - cancelTap() + fun cancel(keepTap: Boolean = false) { + if (!keepTap) cancelTap() val wasHeld = presses.values.any { it.held } presses.values.forEach { handler.removeCallbacks(it.hold) } cancelled.addAll(presses.keys) diff --git a/app/src/main/java/com/droiddeck/launcher/input/BackTaps.kt b/app/src/main/java/com/droiddeck/launcher/input/BackTaps.kt new file mode 100644 index 0000000000..4328148bea --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/input/BackTaps.kt @@ -0,0 +1,39 @@ +package com.droiddeck.launcher.input + +import android.os.Handler +import android.os.Looper + +class BackTaps( + private val windowMs: () -> Long, + private val atOnce: () -> Boolean, + private val onTap: (Boolean) -> Unit, + private val sameAction: () -> Boolean = { false }, +) { + private val handler = Handler(Looper.getMainLooper()) + private var deferred = false + var pending = false + private set + private val expire = Runnable { + pending = false + if (deferred) onTap(false) + } + + fun tap() { + if (pending) { + cancel() + if (deferred || !sameAction()) onTap(true) + return + } + pending = true + deferred = !atOnce() + handler.postDelayed(expire, windowMs()) + if (!deferred) onTap(false) + } + + fun hold() = handler.removeCallbacks(expire) + + fun cancel() { + handler.removeCallbacks(expire) + pending = false + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt b/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt index 5231a753ac..83ae4abc47 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt @@ -20,7 +20,7 @@ object ControllerPrefs { val opacities = listOf(40, 60, 80, 100) - val sizes = listOf(80, 90, 100, 110, 125) + val sizes = listOf(80, 85, 90, 95, 100, 105, 110, 115, 120, 125) val deadZones = listOf(0, 5, 8, 12, 15, 20, 25) const val DEFAULT_DEAD_ZONE_PERCENT = 12 diff --git a/app/src/main/java/com/droiddeck/launcher/input/DirectTouchHold.kt b/app/src/main/java/com/droiddeck/launcher/input/DirectTouchHold.kt index 7a64caaac6..db78da807f 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/DirectTouchHold.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/DirectTouchHold.kt @@ -2,6 +2,7 @@ package com.droiddeck.launcher.input import android.os.Handler import android.os.Looper +import android.os.SystemClock import android.view.MotionEvent import kotlin.math.abs @@ -24,6 +25,7 @@ class DirectTouchHold( private var delayMs = 0L private var holdBehavior = TouchGestureConfig.MOUSE_BEHAVIOR_CLICK private var forwarded = false + private var forwardedAt = 0L private var held = false private var pressing = false private var upX = 0f @@ -125,8 +127,11 @@ class DirectTouchHold( upX = event.x upY = event.y liftId = event.getPointerId(event.actionIndex) - liftPending = true - handler.postDelayed(lift, LIFT_MS) + val wait = MIN_PRESS_MS - (SystemClock.uptimeMillis() - forwardedAt) + if (wait > 0L) { + liftPending = true + handler.postDelayed(lift, wait) + } else lift.run() } MotionEvent.ACTION_CANCEL -> cancel() } @@ -136,9 +141,10 @@ class DirectTouchHold( private fun forwardDown() { touch.down(downId, downX, downY) forwarded = true + forwardedAt = SystemClock.uptimeMillis() } private companion object { - const val LIFT_MS = 50L + const val MIN_PRESS_MS = 50L } } diff --git a/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java b/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java index dc847e90ad..8d4cde566b 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java +++ b/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java @@ -149,6 +149,8 @@ public class FakeInputWriter { private static native void nativeStoreFence(); + private static native void nativeWake(ByteBuffer ring, int offset); + public static void storeFence() { nativeStoreFence(); } @@ -455,6 +457,7 @@ public class FakeInputWriter { writeSnapshotLocked(ring); nativeStoreFence(); ring.putLong(RING_WRITE_SEQ_OFFSET, writeSeq); + nativeWake(ring, RING_WRITE_SEQ_OFFSET); } return true; } diff --git a/app/src/main/java/com/droiddeck/launcher/input/InputProfile.kt b/app/src/main/java/com/droiddeck/launcher/input/InputProfile.kt index f17076e7ca..e988c39d92 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/InputProfile.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/InputProfile.kt @@ -21,7 +21,7 @@ enum class InputControl(val id: String, val label: String, val dimensions: Int = } } -enum class InputCommand { MENU, KEYBOARD, STEAM, QUICK_ACCESS } +enum class InputCommand { MENU, KEYBOARD, STEAM, QUICK_ACCESS, GAME_ZOOM_IN, GAME_ZOOM_OUT } sealed interface InputAction { data class Native(val target: InputControl? = null) : InputAction diff --git a/app/src/main/java/com/droiddeck/launcher/input/LegacyGamepadLayout.kt b/app/src/main/java/com/droiddeck/launcher/input/LegacyGamepadLayout.kt index a944ec28ef..328489445e 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/LegacyGamepadLayout.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/LegacyGamepadLayout.kt @@ -5,7 +5,7 @@ import android.graphics.Rect import kotlin.math.* internal class LegacyGamepadLayout(private val context: Context, private val width: Int, private val height: Int, private val safe: Rect = Rect(), - private val scale: Float = 1f) { + private val scale: Float = 1f, private val sizeOverride: Int? = null) { private val resources get() = context.resources private val settings = ControllerPrefs.read(context) private var fit = 1f @@ -41,7 +41,7 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid private fun dp(value: Float) = value * resources.displayMetrics.density - private fun scaled(value: Float) = dp(value) * settings.size / 100f * scale * fit + private fun scaled(value: Float) = dp(value) * (sizeOverride ?: settings.size) / 100f * scale * fit private fun fitScale(): Float { val metrics = resources.displayMetrics diff --git a/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt b/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt index ad5d8e2701..e8490f624f 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt @@ -44,7 +44,7 @@ object OnScreenLayout { val (reference, matched) = reference(context, layout, width, height) if (buttonsOnly && dock == null) return generator.buttonsOnly(stored) + fit(stored.filter { it.alwaysShown }, reference.first, reference.second, width, height, safe) if (dock?.portrait == true && !dock.grips && !matched && layout.aspect > 0f && layout.aspect < 1f && stored.any(::isGamepad)) - return cluster(stored.filterNot { it.alwaysShown || isGamepad(it) && (it.id == KEYBOARD_ID || it.control in BAR) }, layout.aspect, width, height, safe) + return scaleDocked(context, cluster(stored.filterNot { it.alwaysShown || isGamepad(it) && (it.id == KEYBOARD_ID || it.control in BAR) }, layout.aspect, width, height, safe), ControllerPrefs.read(context).size / 100f, width, height, safe) val generated = matched || PadKit.forOverlay(context, layout) != null && stored.any(::isGamepad) && (dock != null || height > width && layout.aspect >= 1f || height <= width && layout.aspect > 0f && layout.aspect < 1f) val gamepad = if (generated) stored.filter(::isGamepad) else emptyList() @@ -57,22 +57,144 @@ object OnScreenLayout { val placed = regenerated + gamepad.filter { g -> dock == null && optional(g) && regenerated.none { it.id == g.id } } val byId = (placed + others).associateBy { it.id } val ordered = stored.mapNotNull { byId[it.id] } + placed.filter { p -> stored.none { it.id == p.id } } - val kit = PadKit.forOverlay(context, layout) ?: return ordered + val kit = PadKit.forOverlay(context, layout) ?: return if (dock == null) ordered else scaleDocked(context, ordered, ControllerPrefs.read(context).size / 100f, width, height, safe) + val controllerScale = layout.scale * ControllerPrefs.read(context).size / 100f if (generated && ControllerPrefs.layout(context, reference.first.toInt(), reference.second.toInt()).isEmpty() && ControllerPrefs.layout(context, width, height).isEmpty()) { if (dock != null || height > width) { - return ControllerPortraitGeometry(width.toFloat(), height.toFloat(), safe, context.resources.displayMetrics.density) - .place(ordered, kit, dock != null, layout.scale, rearButtons == true, trackpads == true) + val placed = ControllerPortraitGeometry(width.toFloat(), height.toFloat(), safe, context.resources.displayMetrics.density) + .place(ordered, kit, dock != null, controllerScale, rearButtons == true, trackpads == true) + return if (dock != null) { + scaleDocked(context, placed, ControllerPrefs.read(context).size / 100f, width, height, safe) + } else placed } - return ControllerOverlayGeometry(width, height, safe, context.resources.displayMetrics, layout.scale) + return ControllerOverlayGeometry(width, height, safe, context.resources.displayMetrics, controllerScale) .place(ordered, kit, rearButtons == true, trackpads == true) } - if (dock != null || !kit.steam) return ordered + if (dock != null || !kit.steam) { + if (dock == null) return ordered + return scaleDocked(context, ordered, ControllerPrefs.read(context).size / 100f, width, height, safe) + } return FloatingSteamOverlay(width, height, safe, context.resources.displayMetrics.density) .place(ordered, lowerShortcuts = generated, rearButtons = rearButtons, trackpads = trackpads) } + private fun scaleDocked(context: Context, elements: List, scale: Float, width: Int, height: Int, safe: Rect): List { + val usableWidth = (width - safe.left - safe.right).coerceAtLeast(1).toFloat() / width + val usableHeight = (height - safe.top - safe.bottom).coerceAtLeast(1).toFloat() / height + val leftBound = safe.left.toFloat() / width + val rightBound = (width - safe.right).toFloat() / width + val topBound = safe.top.toFloat() / height + val bottomBound = (height - safe.bottom).toFloat() / height + val scaled = elements.map { element -> + if (!isGamepad(element)) return@map element + val w = (element.width * scale).coerceIn(min(.001f, usableWidth), usableWidth) + val h = (element.height * scale).coerceIn(min(.001f, usableHeight), usableHeight) + val x = (element.x + element.width / 2f - w / 2f) + .coerceIn(leftBound, (rightBound - w).coerceAtLeast(leftBound)) + val y = (element.y + element.height / 2f - h / 2f) + .coerceIn(topBound, (bottomBound - h).coerceAtLeast(topBound)) + element.copy(x = x, y = y, width = w, height = h) + }.toMutableList() + if (scale > 1f) { + val gap = 4f / width + fun spacePair(leftControl: InputControl, rightControl: InputControl) { + val li = scaled.indexOfFirst { isGamepad(it) && it.control == leftControl } + val ri = scaled.indexOfFirst { isGamepad(it) && it.control == rightControl } + if (li < 0 || ri < 0) return + var left = scaled[li] + var right = scaled[ri] + val available = (rightBound - leftBound).coerceAtLeast(.001f) + var gapSize = gap.coerceAtMost(available / 4f) + if (left.width + right.width + gapSize > available) { + val factor = ((available - gapSize).coerceAtLeast(0f) / (left.width + right.width)).coerceAtMost(1f) + left = left.copy(width = left.width * factor) + right = right.copy(width = right.width * factor) + } + val total = left.width + gapSize + right.width + val center = ((left.x + left.width / 2f) + (right.x + right.width / 2f)) / 2f + val start = (center - total / 2f).coerceIn(leftBound, (rightBound - total).coerceAtLeast(leftBound)) + scaled[li] = left.copy(x = start) + scaled[ri] = right.copy(x = start + left.width + gapSize) + } + spacePair(InputControl.LT, InputControl.LB) + spacePair(InputControl.RB, InputControl.RT) + } + if (scale > 1f && ControllerPrefs.layout(context, width, height).isEmpty()) { + repeat(scaled.size) { + for (i in scaled.indices) { + if (!isGamepad(scaled[i])) continue + for (j in i + 1 until scaled.size) { + if (!isGamepad(scaled[j])) continue + val a = scaled[i] + val b = scaled[j] + val overlapX = min(a.x + a.width, b.x + b.width) - max(a.x, b.x) + val overlapY = min(a.y + a.height, b.y + b.height) - max(a.y, b.y) + if (overlapX <= 0f || overlapY <= 0f) continue + + val centerAX = a.x + a.width / 2f + val centerBX = b.x + b.width / 2f + val centerAY = a.y + a.height / 2f + val centerBY = b.y + b.height / 2f + if (overlapX / min(a.width, b.width) <= overlapY / min(a.height, b.height)) { + val gapX = 2f / width + val available = (rightBound - leftBound).coerceAtLeast(.001f) + val leftFirst = centerAX <= centerBX + val factor = ((available - gapX).coerceAtLeast(0f) / (a.width + b.width)).coerceIn(0f, 1f) + val aw = a.width * factor + val ah = a.height * factor + val bw = b.width * factor + val bh = b.height * factor + val total = aw + gapX + bw + val center = ((centerAX + centerBX) / 2f).coerceIn( + leftBound + total / 2f, + (rightBound - total / 2f).coerceAtLeast(leftBound + total / 2f)) + val firstX = center - total / 2f + val secondX = firstX + (if (leftFirst) aw else bw) + gapX + scaled[i] = if (leftFirst) { + a.copy(x = firstX, y = centerAY - ah / 2f, width = aw, height = ah) + } else { + a.copy(x = secondX, y = centerAY - ah / 2f, width = aw, height = ah) + } + scaled[j] = if (leftFirst) { + b.copy(x = secondX, y = centerBY - bh / 2f, width = bw, height = bh) + } else { + b.copy(x = firstX, y = centerBY - bh / 2f, width = bw, height = bh) + } + } else { + val gapY = 2f / height + val available = (bottomBound - topBound).coerceAtLeast(.001f) + val topFirst = centerAY <= centerBY + val factor = ((available - gapY).coerceAtLeast(0f) / (a.height + b.height)).coerceIn(0f, 1f) + val aw = a.width * factor + val ah = a.height * factor + val bw = b.width * factor + val bh = b.height * factor + val total = ah + gapY + bh + val center = ((centerAY + centerBY) / 2f).coerceIn( + topBound + total / 2f, + (bottomBound - total / 2f).coerceAtLeast(topBound + total / 2f)) + val firstY = center - total / 2f + val secondY = firstY + (if (topFirst) ah else bh) + gapY + scaled[i] = if (topFirst) { + a.copy(x = centerAX - aw / 2f, y = firstY, width = aw, height = ah) + } else { + a.copy(x = centerAX - aw / 2f, y = secondY, width = aw, height = ah) + } + scaled[j] = if (topFirst) { + b.copy(x = centerBX - bw / 2f, y = secondY, width = bw, height = bh) + } else { + b.copy(x = centerBX - bw / 2f, y = firstY, width = bw, height = bh) + } + } + } + } + } + } + return scaled + } + fun oriented(layout: SavedInputLayout, width: Int, height: Int): SavedInputLayout = oriented(layout, height > width) private fun oriented(layout: SavedInputLayout, portrait: Boolean): SavedInputLayout { @@ -181,7 +303,14 @@ object OnScreenLayout { ?.let { (it * height).roundToInt().coerceAtLeast(1) to height } for ((w, h) in listOfNotNull(named, width to height, aspectSize, long to short, short to long).distinct()) { val generator = LegacyGamepadLayout(display, w, h, scale = layout.scale) - if (matches(gamepad, generator.elements()) || matches(gamepad, generator.elements(previousStickGeometry = true))) return (w.toFloat() to h.toFloat()) to true + val sizedGenerator = LegacyGamepadLayout( + display, w, h, scale = layout.scale, + sizeOverride = ControllerPrefs.read(context).size + ) + if (matches(gamepad, generator.elements()) || matches(gamepad, generator.elements(previousStickGeometry = true)) || + matches(gamepad, sizedGenerator.elements()) || matches(gamepad, sizedGenerator.elements(previousStickGeometry = true))) { + return (w.toFloat() to h.toFloat()) to true + } } } val aspect = layout.aspect.takeIf { it > 0f } ?: (long.toFloat() / short) diff --git a/app/src/main/java/com/droiddeck/launcher/input/PadBridge.java b/app/src/main/java/com/droiddeck/launcher/input/PadBridge.java index 666a9d1ceb..81a84fcdba 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/PadBridge.java +++ b/app/src/main/java/com/droiddeck/launcher/input/PadBridge.java @@ -59,7 +59,7 @@ public final class PadBridge { private final PadState[] playerStates = new PadState[SLOTS]; private final float[][] rawSticks = new float[SLOTS][4]; private final Map rightStickLayouts = new HashMap<>(); - private final boolean[][] keyTriggers = new boolean[SLOTS][2]; + private final TriggerKey[][] keyTriggers = TriggerKey.slots(SLOTS); private final int[] retainedSticks = new int[SLOTS]; private final PadState effectiveState = new PadState(); private final PadState homeGuideReport = new PadState(); @@ -273,7 +273,8 @@ public final class PadBridge { static boolean isSystemVirtualInputName(String name) { if (name == null) return false; String lower = name.trim().toLowerCase(java.util.Locale.ROOT); - return lower.startsWith("uinput-") || lower.startsWith("uinput_"); + // Xiaomi's "ui-input-xiaomi" is a system uinput device that also reports gamepad sources. + return lower.startsWith("uinput-") || lower.startsWith("uinput_") || lower.equals("ui-input-xiaomi"); } public static boolean isFromController(InputDevice device) { @@ -483,7 +484,7 @@ public final class PadBridge { stateFor(slot).clear(); retainedSticks[slot] = 0; Arrays.fill(rawSticks[slot], 0f); - Arrays.fill(keyTriggers[slot], false); + for (TriggerKey key : keyTriggers[slot]) key.reset(); } private void mutateState(java.util.function.Consumer mutation) { @@ -529,7 +530,7 @@ public final class PadBridge { float lx = event.getAxisValue(MotionEvent.AXIS_X); float ly = event.getAxisValue(MotionEvent.AXIS_Y); boolean wired = wiredXboxLayout(device, event.getSource()); - boolean rxRyStick = rightStickUsesRxRy(event, device, rightStickLayouts); + boolean rxRyStick = Boolean.TRUE.equals(rightStickUsesRxRy(event, device, rightStickLayouts)); float rx = event.getAxisValue(rxRyStick ? MotionEvent.AXIS_RX : MotionEvent.AXIS_Z); float ry = event.getAxisValue(rxRyStick ? MotionEvent.AXIS_RY : MotionEvent.AXIS_RZ); retainStick(slot, JoyCon.LEFT, lx, ly); @@ -569,26 +570,76 @@ public final class PadBridge { return true; } - static float keyTrigger(float current, boolean pressed, int repeatCount, boolean analog, boolean[] held, int side) { + static final class TriggerKey { + static final float RELEASE_FROM_PEAK = 0.05f; + boolean held; + boolean handoff; + boolean axisLive; + boolean axisMovedWhilePressed; + float peak; + float axis; + + static TriggerKey[][] slots(int count) { + TriggerKey[][] keys = new TriggerKey[count][2]; + for (TriggerKey[] pair : keys) { + pair[0] = new TriggerKey(); + pair[1] = new TriggerKey(); + } + return keys; + } + + void reset() { + held = false; + handoff = false; + axisLive = false; + axisMovedWhilePressed = false; + peak = 0f; + axis = 0f; + } + } + + static float keyTrigger(float current, boolean pressed, int repeatCount, boolean analog, TriggerKey[] keys, int side) { + TriggerKey key = keys[side]; if (repeatCount > 0) return current; if (!analog) { - held[side] = pressed; + key.held = pressed; return pressed ? 1f : 0f; } if (pressed) { - if (current != 0f) return current; - held[side] = true; + key.axisMovedWhilePressed = false; + if (key.axisLive || current != 0f) return current; + key.held = true; return 1f; } - if (!held[side]) return current; - held[side] = false; + if (!key.axisMovedWhilePressed) key.axisLive = false; + if (key.handoff) { + key.handoff = false; + return key.axis; + } + if (!key.held) return current; + key.held = false; return 0f; } - static float axisTrigger(float value, boolean[] held, int side) { - if (!held[side]) return value; - if (value == 0f) return 1f; - held[side] = false; + static float axisTrigger(float value, TriggerKey[] keys, int side) { + TriggerKey key = keys[side]; + key.axis = value; + if (value != 0f) { + key.axisLive = true; + key.axisMovedWhilePressed = true; + } + if (key.held) { + if (value == 0f) return 1f; + key.held = false; + key.handoff = true; + key.peak = value; + return 1f; + } + if (key.handoff) { + key.peak = Math.max(key.peak, value); + if (value > key.peak - TriggerKey.RELEASE_FROM_PEAK) return 1f; + key.handoff = false; + } return value; } @@ -603,14 +654,14 @@ public final class PadBridge { return false; } - static boolean rightStickUsesRxRy(MotionEvent event, InputDevice device, Map layouts) { + public static Boolean rightStickUsesRxRy(MotionEvent event, InputDevice device, Map layouts) { int source = event.getSource(); if (wiredXboxLayout(device, source)) return true; boolean hasRxRy = hasAxis(device, source, MotionEvent.AXIS_RX) && hasAxis(device, source, MotionEvent.AXIS_RY); boolean hasZRz = hasAxis(device, source, MotionEvent.AXIS_Z) && hasAxis(device, source, MotionEvent.AXIS_RZ); - if (!hasRxRy) return false; + if (!hasRxRy) return hasZRz ? false : null; if (!hasZRz) return true; Boolean cached = layouts.get(event.getDeviceId()); if (cached != null) return cached; @@ -618,7 +669,7 @@ public final class PadBridge { && nearCentre(device, source, event, MotionEvent.AXIS_RX, MotionEvent.AXIS_RY); boolean zRzEvidence = atMinimum(device, source, event, MotionEvent.AXIS_RX, MotionEvent.AXIS_RY) && nearCentre(device, source, event, MotionEvent.AXIS_Z, MotionEvent.AXIS_RZ); - if (rxRyEvidence == zRzEvidence) return false; + if (rxRyEvidence == zRzEvidence) return null; boolean useRxRy = rxRyEvidence; layouts.put(event.getDeviceId(), useRxRy); return useRxRy; diff --git a/app/src/main/java/com/droiddeck/launcher/input/PadMouse.kt b/app/src/main/java/com/droiddeck/launcher/input/PadMouse.kt index dccba8a1b6..8f21ad67de 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/PadMouse.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/PadMouse.kt @@ -90,7 +90,7 @@ class PadMouse(private val listener: Listener, private val clock: () -> Long = S val sticks = physical.getOrPut(event.deviceId) { Sticks() } val device = event.device val wired = wiredLayout.getOrPut(event.deviceId) { PadBridge.wiredXboxLayout(device, event.source) } - val rxRyStick = PadBridge.rightStickUsesRxRy(event, device, rightStickLayouts) + val rxRyStick = PadBridge.rightStickUsesRxRy(event, device, rightStickLayouts) ?: false sticks.leftX = event.getAxisValue(MotionEvent.AXIS_X) sticks.leftY = event.getAxisValue(MotionEvent.AXIS_Y) sticks.rightX = scrollAxis(event, if (rxRyStick) MotionEvent.AXIS_RX else MotionEvent.AXIS_Z) diff --git a/app/src/main/java/com/droiddeck/launcher/input/PointerCapture.kt b/app/src/main/java/com/droiddeck/launcher/input/PointerCapture.kt new file mode 100644 index 0000000000..d598a1bc05 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/input/PointerCapture.kt @@ -0,0 +1,33 @@ +package com.droiddeck.launcher.input + +import android.view.InputDevice +import android.view.MotionEvent + +object PointerCapture { + fun accepts(event: MotionEvent): Boolean = + event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE) || + event.isFromSource(InputDevice.SOURCE_TOUCHPAD) + + fun isTouchpad(event: MotionEvent): Boolean = event.isFromSource(InputDevice.SOURCE_TOUCHPAD) + + fun delta(event: MotionEvent): FloatArray { + var dx = event.x + var dy = event.y + for (i in 0 until event.historySize) { + dx += event.getHistoricalX(i) + dy += event.getHistoricalY(i) + } + return floatArrayOf(dx, dy) + } + + fun touchpadScale(unitsPerMm: Float, padWidth: Float, pixelsPerMm: Float, screenWidth: Int): Float = when { + unitsPerMm > 0f && pixelsPerMm > 0f -> pixelsPerMm / unitsPerMm + padWidth > 0f && screenWidth > 0 -> screenWidth / padWidth + else -> 1f + } + + fun touchpadScale(event: MotionEvent, pixelsPerMm: Float, screenWidth: Int): Float { + val range = event.device?.getMotionRange(MotionEvent.AXIS_X, InputDevice.SOURCE_TOUCHPAD) + return touchpadScale(range?.resolution ?: 0f, range?.range ?: 0f, pixelsPerMm, screenWidth) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt b/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt index 476ac443ac..536493572e 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt @@ -15,17 +15,24 @@ enum class SecondScreenMode(val id: String, @StringRes val label: Int, val bindi DECK_CONTROLS("deck-controls", R.string.second_mode_deck_controls, InputStockLayouts.DECK), CUSTOM_CONTROLS("custom-controls", R.string.input_profile_controls_mode), DASHBOARD("dashboard", R.string.second_mode_dashboard), + GUIDES("guides", R.string.bottom_page_guides), + MIRROR("mirror", R.string.bottom_page_mirror), + STEAM_QAM("steam-qam", R.string.bottom_qam_title), + ART("art", R.string.bottom_art_title), DESKTOP("desktop", R.string.second_mode_desktop); + val sessionPanel: Boolean get() = this == GUIDES || this == MIRROR || this == STEAM_QAM || this == ART + val controls: Boolean get() = this == CUSTOM_CONTROLS || bindings != null fun panel(context: Context): String? = if (this == DECK_CONTROLS) SessionPrefs.deckPanel(context).bindings else bindings companion object { /** The mode the bottom screen opens in: the one picked last if it is still available, else the DroidDeck menu. */ - fun opening(remembered: String?, deckPad: Boolean, dashboard: Boolean = false, bottomDesktop: Boolean = false): SecondScreenMode = + fun opening(remembered: String?, deckPad: Boolean, dashboard: Boolean = false, bottomDesktop: Boolean = false, + steam: Boolean = false): SecondScreenMode = entries.firstOrNull { - it != NONE && it.id == remembered && (it != DECK_CONTROLS || deckPad) && (it != DASHBOARD || dashboard) && + it != NONE && it.id == remembered && (it != DECK_CONTROLS || deckPad) && (it != DASHBOARD && !it.sessionPanel || dashboard) && (it != STEAM_QAM && it != ART || steam) && (it != DESKTOP || bottomDesktop) } ?: MENU } diff --git a/app/src/main/java/com/droiddeck/launcher/input/TouchpadGestures.kt b/app/src/main/java/com/droiddeck/launcher/input/TouchpadGestures.kt index 659b99c0ce..a044469f3b 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/TouchpadGestures.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/TouchpadGestures.kt @@ -9,6 +9,7 @@ import kotlin.math.hypot class TouchpadGestures( private val slopPx: Float, private val listener: PointerGestures.Listener, + private val holdDrags: Boolean = true, ) { var x = 0f private set @@ -33,6 +34,7 @@ class TouchpadGestures( private var held = false private var secondDownAt = 0L private var secondWasTap = false + private var pressed = false private var twoFingers = false private var scrollAnchorX = 0f private var scrollAnchorY = 0f @@ -90,6 +92,15 @@ class TouchpadGestures( lastTapAt = 0L } + fun buttonPressed() { + pressed = true + handler.removeCallbacks(longPress) + releaseClick() + travelled = slopPx + 1f + secondWasTap = false + lastTapAt = 0L + } + fun place(px: Float, py: Float) { x = px.coerceIn(bounds.left, bounds.right) y = py.coerceIn(bounds.top, bounds.bottom) @@ -115,7 +126,7 @@ class TouchpadGestures( releaseClick() lastX = event.x; lastY = event.y downAt = event.eventTime - travelled = 0f; held = false; twoFingers = false; scrolled = false; secondWasTap = false + travelled = 0f; held = false; twoFingers = false; scrolled = false; secondWasTap = false; pressed = false fingers = 1; pinching = false anchorId = event.getPointerId(0); moverId = -1; holdDrag = false; scrollLocked = false if (clicks && event.eventTime - lastTapAt < TouchTiming.DOUBLE_TAP_MS) { @@ -123,7 +134,7 @@ class TouchpadGestures( press(PointerGestures.BTN_LEFT) } else { dragging = false - if (clicks) handler.postDelayed(longPress, TouchTiming.HOLD_MS) + if (clicks && holdDrags) handler.postDelayed(longPress, TouchTiming.HOLD_MS) } return true } @@ -142,7 +153,7 @@ class TouchpadGestures( if (holdDrag) return true twoFingers = true secondDownAt = event.eventTime - secondWasTap = true + secondWasTap = !pressed scrollAnchorX = (event.getX(0) + event.getX(1)) / 2f scrollAnchorY = (event.getY(0) + event.getY(1)) / 2f pinchSpan = span(event) @@ -153,7 +164,7 @@ class TouchpadGestures( val mi = if (moverId == -1) -1 else event.findPointerIndex(moverId) if (ai >= 0 && mi >= 0) { val mx = event.getX(mi); val my = event.getY(mi) - if (!holdDrag && !scrolled && !scrollLocked) { + if (holdDrags && !holdDrag && !scrolled && !scrollLocked) { val anchorMoved = abs(event.getX(ai) - anchorStartX) + abs(event.getY(ai) - anchorStartY) val moverMoved = abs(mx - moverStartX) + abs(my - moverStartY) if (anchorMoved >= slopPx) { diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt index 2c5fbad51e..6c0936e679 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt @@ -1,7 +1,6 @@ package com.droiddeck.launcher.runtime import android.content.Context -import android.os.Environment import com.droiddeck.launcher.core.DownloadSource import com.droiddeck.launcher.core.HostProcess import com.droiddeck.launcher.session.OrphanReaper @@ -37,7 +36,7 @@ object GuestCommand { SessionFiles.stage(context, root) LinuxNetworkLinkComponent(context, root).publish() val runtimeDir = File(context.filesDir, ".flatpak-rt").apply { mkdirs() } - val binds = LinuxRuntime.binds(context, null, runtimeDir, Environment.getExternalStorageDirectory(), extraBinds) + val binds = LinuxRuntime.binds(context, null, runtimeDir, LinuxRuntime.sharedStorage(context), extraBinds) val native = NativeGuest.forSession(context) val fastPathKey = if (!native && fastPath && !fakeRoot && linkDir == null && ProotFastPath.enabled(context)) ProotFastPath.key(root, binds) else null val guest = mutableListOf( diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt index b76172edb1..1f5d1a4d56 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt @@ -302,9 +302,9 @@ class LinuxNetworkLinkComponent( val etc = File(rootDir, "etc") replace(File(etc, "resolv.conf"), text) val hosts = File(etc, "hosts") - if (!hosts.isFile || !hosts.readText().contains("localhost")) { - hosts.writeText("127.0.0.1 localhost\n::1 localhost\n") - } + val existing = if (hosts.isFile) hosts.readText() else null + val wanted = hostsText(existing) + if (wanted != existing) replace(hosts, wanted) Log.i(TAG, "resolver: " + servers.joinToString(" ")) } catch (e: IOException) { Log.w(TAG, "Could not write the resolver", e) @@ -338,6 +338,42 @@ class LinuxNetworkLinkComponent( companion object { private val WRITES = Any() + private const val HOSTS_BLOCK_START = "# DroidDeck: Unity telemetry is refused (start)" + private const val HOSTS_BLOCK_END = "# DroidDeck: Unity telemetry is refused (end)" + + // Unity 5's player seeds its bundled OpenSSL before its first HTTPS request, and that code jumps + // to a bad address under FEX (Windlands, 428370). Refusing these telemetry hosts makes the request + // fail before TLS starts; the games run without them. + internal val UNITY_TELEMETRY_HOSTS = listOf( + "config.uca.cloud.unity3d.com", "api.uca.cloud.unity3d.com", "cdp.cloud.unity3d.com", + "stats.unity3d.com", "perf-events.cloud.unity3d.com", + ) + + internal fun hostsText(existing: String?): String { + val kept = mutableListOf() + var block: MutableList? = null + for (line in existing.orEmpty().lines()) { + when { + line == HOSTS_BLOCK_START -> { + block?.let(kept::addAll) + block = mutableListOf() + } + line == HOSTS_BLOCK_END -> block = null + block != null -> block!!.add(line) + else -> kept.add(line) + } + } + block?.let(kept::addAll) + kept.removeAll { it.isBlank() } + return buildString { + if (kept.none { it.substringBefore('#').contains("localhost") }) append("127.0.0.1 localhost\n::1 localhost\n") + kept.forEach { append(it).append('\n') } + append(HOSTS_BLOCK_START).append('\n') + append("0.0.0.0 ").append(UNITY_TELEMETRY_HOSTS.joinToString(" ")).append('\n') + append(HOSTS_BLOCK_END).append('\n') + } + } + internal fun gateways(properties: LinkProperties?, capabilities: NetworkCapabilities?): List = listOf(Inet4Address::class.java, Inet6Address::class.java).mapNotNull { family -> properties?.routes.orEmpty() diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java index f0e959d0c7..142d4e90bc 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java +++ b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java @@ -185,7 +185,12 @@ public final class LinuxRuntime { public static List lastBinds(Context context) { List binds = lastBinds; if (binds != null) return binds; - return binds(context, null, null, android.os.Environment.getExternalStorageDirectory(), null); + return binds(context, null, null, sharedStorage(context), null); + } + + /** The phone's shared storage, or null when it should stay out of the container. */ + public static File sharedStorage(Context context) { + return SessionPrefs.mountSharedStorage(context) ? android.os.Environment.getExternalStorageDirectory() : null; } public static List prootPrefix(Context context, File root, String cwd) { @@ -199,6 +204,7 @@ public final class LinuxRuntime { } public static List prootPrefix(Context context, File root, String cwd, boolean fakeRoot) { + NativeGuest.relinkAfterProot(root); List cmd = new ArrayList<>(); cmd.addAll(com.droiddeck.launcher.core.HostProcess.dataExecutable(prootBinary(context).getPath())); cmd.add("--kill-on-exit"); @@ -511,7 +517,7 @@ public final class LinuxRuntime { public static List cpuTempZones() { java.util.Map replaced = replacedZoneTypes(); List zones = new ArrayList<>(); - for (java.util.Map.Entry zone : new java.util.TreeMap<>(thermalZones()).entrySet()) { + for (java.util.Map.Entry zone : thermalZones().entrySet()) { String type = zone.getKey(); if (type.contains("cpu") && !type.contains("gpu") && !replaced.containsKey(zone.getValue().getName())) { zones.add(zone.getValue()); @@ -554,23 +560,31 @@ public final class LinuxRuntime { private static String thermalZone(String sensor) { java.util.Map zones = thermalZones(); File zone = zones.get(sensor); - for (java.util.Map.Entry e : new java.util.TreeMap<>(zones).entrySet()) { + for (java.util.Map.Entry e : zones.entrySet()) { if (zone == null && e.getKey().contains(sensor)) zone = e.getValue(); } return zone != null ? new File(zone, "temp").getPath() : null; } - private static java.util.Map thermalZones() { + private static volatile java.util.SortedMap thermalZoneTypes; + + private static java.util.SortedMap thermalZones() { + java.util.SortedMap known = thermalZoneTypes; + if (known != null) return known; java.util.Map byType = new java.util.HashMap<>(); File[] zones = new File("/sys/class/thermal").listFiles((dir, n) -> n.startsWith("thermal_zone")); - if (zones == null) return byType; + if (zones == null) return java.util.Collections.emptySortedMap(); + boolean complete = true; for (File zone : zones) { try (java.io.BufferedReader r = new java.io.BufferedReader(new java.io.FileReader(new File(zone, "type")))) { byType.putIfAbsent(String.valueOf(r.readLine()).trim().toLowerCase(java.util.Locale.ROOT), zone); - } catch (IOException ignored) { + } catch (IOException e) { + complete = false; } } - return byType; + java.util.SortedMap sorted = java.util.Collections.unmodifiableSortedMap(new java.util.TreeMap<>(byType)); + if (complete && !sorted.isEmpty()) thermalZoneTypes = sorted; + return sorted; } private static void bindSystemFonts(List cmd, File root) { diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt b/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt index 61f91598d5..babaae550a 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt @@ -112,8 +112,9 @@ object NativeGuest { File(BwrapSpawner.hostPath(binds.map { BwrapSpawner.Bind.parse(it) }, root.path, cwd)).takeIf { it.isDirectory } ?: root /** A process for [guest] (argv) started as proot would with [binds], in guest directory [cwd]. */ - fun processBuilder(context: Context, root: File, binds: List, guest: List, cwd: String = "/root"): ProcessBuilder = - ProcessBuilder(command(root, guest.first(), guest.drop(1))) + fun processBuilder(context: Context, root: File, binds: List, guest: List, cwd: String = "/root"): ProcessBuilder { + if (sessionMode == null) prepare(context, root) + return ProcessBuilder(command(root, guest.first(), guest.drop(1))) .directory(workingDirectory(root, binds, cwd)) .also { builder -> builder.environment().apply { @@ -121,6 +122,7 @@ object NativeGuest { putAll(sessionEnvironment(root, binds, guest.first(), SessionPrefs.guestHostname(context))) } } + } private const val RUNPATH_CONF = "etc/ld.so.conf.d/zz-droiddeck-native.conf" private val SCAN_DIRS = listOf("usr/lib", "usr/local/lib", "opt") @@ -149,6 +151,7 @@ object NativeGuest { } /** What a rootfs needs before anything runs in it natively; cheap once done. */ + @Synchronized fun prepare(context: Context, root: File) { val relinked = relinkAbsoluteSymlinks(context, root) if (relinked > 0) android.util.Log.i(TAG, "native userland: $relinked absolute symlinks made relative") @@ -169,8 +172,15 @@ object NativeGuest { } } + private const val RELINK_STAMP = "etc/droiddeck/native-symlinks" + + @JvmStatic + fun relinkAfterProot(root: File) { + File(root, RELINK_STAMP).delete() + } + private val HOST_LINK_TARGETS = listOf("/proc", "/dev", "/sys", "/sdcard", "/storage", "/data", "/system", "/vendor", "/apex", - "/system_ext", "/product", "/odm", "/linkerconfig", "/mnt") + "/system_ext", "/product", "/odm", "/linkerconfig", "/mnt", "/root/Storage") /** * Symbolic links the kernel follows by itself (ld.so, Steam, anything that skips the hook) read @@ -178,9 +188,9 @@ object NativeGuest { * which reads the target inside the rootfs, so each is rewritten as a relative link, which * resolves the same way under proot and without it. Rerun when the runtime changes. */ - fun relinkAbsoluteSymlinks(context: Context, root: File): Int { - val stamp = File(root, "etc/droiddeck/native-symlinks") - val version = com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.installedVersion(context).orEmpty() + "/2" + fun relinkAbsoluteSymlinks(context: Context, root: File, commands: () -> Sequence> = ::procCommands): Int { + val stamp = File(root, RELINK_STAMP) + val version = com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.installedVersion(context).orEmpty() + "/3" if (stamp.isFile && stamp.readText() == version) return 0 val rootPath = root.toPath() var rewritten = 0 @@ -206,11 +216,20 @@ object NativeGuest { override fun visitFileFailed(file: java.nio.file.Path, exc: java.io.IOException) = java.nio.file.FileVisitResult.CONTINUE }) - stamp.parentFile?.mkdirs() - stamp.writeText(version) + if (!prootRunning(LinuxRuntime.prootBinary(context).path, commands())) { + stamp.parentFile?.mkdirs() + stamp.writeText(version) + } return rewritten } + internal fun prootRunning(proot: String, commands: Sequence>): Boolean = + commands.any { args -> args.take(2).any { it == proot } } + + private fun procCommands(): Sequence> = (File("/proc").listFiles() ?: emptyArray()).asSequence() + .filter { it.name.all(Char::isDigit) } + .mapNotNull { runCatching { File(it, "cmdline").readText().split('\u0000') }.getOrNull() } + /** * The guest path that host path [target] stands for in a session with [binds] ("src:dst"), or null * when it is a guest path already: the rootfs, or the longest mount source holding it (the first diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/UserApps.kt b/app/src/main/java/com/droiddeck/launcher/runtime/UserApps.kt index efc460ee04..ea9b0ba699 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/UserApps.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/UserApps.kt @@ -14,6 +14,7 @@ import com.droiddeck.launcher.R import com.droiddeck.launcher.core.Downloader import com.droiddeck.launcher.core.FileUtils import com.droiddeck.launcher.core.Hashes +import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.store.FlathubApi import org.json.JSONArray import org.json.JSONObject @@ -184,9 +185,10 @@ object UserApps { fun binds(context: Context): List { val internal = Environment.getExternalStorageDirectory().canonicalPath + val mounted = SessionPrefs.mountSharedStorage(context) return root(context).listFiles().orEmpty().mapNotNull { dir -> val target = runCatching { Os.readlink(File(dir, "files").path) }.getOrNull() ?: return@mapNotNull null - target.takeIf { !it.startsWith("$internal/") && File(it).isDirectory } + target.takeIf { !(mounted && it.startsWith("$internal/")) && File(it).isDirectory } }.distinct() } @@ -475,7 +477,8 @@ object UserApps { if (!file.isFile) return context.getString(R.string.user_apps_file_gone) if (!FlatpakManager.ready(context)) FlatpakManager.setup(context, onProgress)?.let { return it } val shared = Environment.getExternalStorageDirectory().canonicalPath - val copy = File(LinuxRuntime.rootDir(context), "tmp/droiddeck-bundle.flatpak").takeIf { !file.canonicalPath.startsWith("$shared/") } + val copy = File(LinuxRuntime.rootDir(context), "tmp/droiddeck-bundle.flatpak") + .takeIf { !SessionPrefs.mountSharedStorage(context) || !file.canonicalPath.startsWith("$shared/") } try { if (copy != null) { onProgress(context.getString(R.string.user_apps_copying, file.name), -1) diff --git a/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt b/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt index b25ed487a2..a8b76934ee 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt @@ -40,6 +40,7 @@ object BottomDesktop { val generation: Int, val installed: Boolean, val nativeUserland: Boolean, + val sharedStorage: File?, ) @Volatile private var launch: Launch? = null @@ -91,10 +92,11 @@ object BottomDesktop { sessionDir: File, generation: Int, nativeUserland: Boolean, + sharedStorage: File?, stillCurrent: () -> Boolean, ) { val prepared = Launch(ArrayList(guest), ArrayList(binds), sessionRoot, hostEnvironment.copyOf(), root, sessionDir, generation, - DesktopCatalog.desktopInstalled(root), nativeUserland) + DesktopCatalog.desktopInstalled(root), nativeUserland, sharedStorage) synchronized(launchLock) { if (stillCurrent()) launch = prepared } } @@ -313,7 +315,7 @@ object BottomDesktop { val runtime = runtimeDir(context).apply { mkdirs() } val imeDir = File(current.sessionRoot, "bottom-desktop-ime") main.post { if (generation == guestGeneration) watchIme(imeDir) } - val binds = LinuxRuntime.binds(context, current.sessionRoot, runtime, Environment.getExternalStorageDirectory(), current.binds) + val binds = LinuxRuntime.binds(context, current.sessionRoot, runtime, current.sharedStorage, current.binds) val guest = ArrayList(current.guest).apply { add("DD_WIDTH=$width") add("DD_HEIGHT=$height") diff --git a/app/src/main/java/com/droiddeck/launcher/session/BuildWatermarkSetting.kt b/app/src/main/java/com/droiddeck/launcher/session/BuildWatermarkSetting.kt index 98239f8eb0..cf31b02404 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/BuildWatermarkSetting.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/BuildWatermarkSetting.kt @@ -39,6 +39,10 @@ internal object BuildWatermarkSetting { throw error } } + notifyChanged(context) + } + + fun notifyChanged(context: Context) { context.sendBroadcast(Intent(CHANGED).setPackage(context.packageName)) } } diff --git a/app/src/main/java/com/droiddeck/launcher/session/CdpPage.kt b/app/src/main/java/com/droiddeck/launcher/session/CdpPage.kt new file mode 100644 index 0000000000..3d460f24a2 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/CdpPage.kt @@ -0,0 +1,63 @@ +package com.droiddeck.launcher.session + +import org.json.JSONObject +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicInteger +import java.util.concurrent.CompletableFuture +import kotlin.concurrent.thread + +class CdpPage(port: Int, path: String, private val onEvent: (String, JSONObject) -> Unit) : AutoCloseable { + private val ws = LoopbackWebSocket(port, path, connectTimeoutMs = 2_000) + private val ids = AtomicInteger() + private val pending = ConcurrentHashMap>() + private val sender = Executors.newSingleThreadExecutor { r -> Thread(r, "cdp-send").apply { isDaemon = true } } + @Volatile var closed = false + private set + private val tornDown = java.util.concurrent.atomic.AtomicBoolean(false) + + init { + thread(name = "cdp-read", isDaemon = true) { + try { + while (true) { + val m = JSONObject(ws.receive() ?: break) + if (m.has("id")) pending.remove(m.optInt("id"))?.complete(m) + else onEvent(m.optString("method"), m.optJSONObject("params") ?: JSONObject()) + } + } catch (_: Exception) { + } + close() + } + } + + fun send(method: String, params: JSONObject = JSONObject()) { + if (closed) return + val id = ids.incrementAndGet() + val text = JSONObject().put("id", id).put("method", method).put("params", params).toString() + runCatching { sender.execute { runCatching { ws.send(text) } } } + } + + fun call(method: String, params: JSONObject = JSONObject(), timeoutMs: Long = 3_000): JSONObject? { + if (closed) return null + val id = ids.incrementAndGet() + val future = CompletableFuture() + pending[id] = future + val text = JSONObject().put("id", id).put("method", method).put("params", params).toString() + runCatching { sender.execute { runCatching { ws.send(text) }.onFailure { future.complete(JSONObject()) } } } + .onFailure { future.complete(JSONObject()) } + return runCatching { future.get(timeoutMs, TimeUnit.MILLISECONDS) }.getOrNull().also { pending.remove(id) } + } + + fun evaluate(expression: String): Any? = + call("Runtime.evaluate", JSONObject().put("expression", expression).put("returnByValue", true)) + ?.optJSONObject("result")?.optJSONObject("result")?.opt("value") + + override fun close() { + closed = true + if (!tornDown.compareAndSet(false, true)) return + pending.values.forEach { it.complete(JSONObject()) } + sender.shutdown() + runCatching { ws.close() } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt b/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt index d4bdce833e..099cf7f46d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt @@ -13,6 +13,7 @@ object GameEnvironmentStore { private const val TAG = "GameEnvironmentStore" private const val SETTINGS = "game-environment.json" private const val GUEST_FILE = "root/.config/droiddeck/game-environment.json" + private const val GAME_CORES_FILE = "root/.config/droiddeck/game-cores" const val DXVK_CONFIG = "dxvkConfig" const val DXVK_CONFIG_GAMES = "dxvkConfigGames" const val GAME_DEBUG_LOGS = "gameDebugLogs" @@ -108,10 +109,12 @@ object GameEnvironmentStore { @Synchronized fun publish( context: Context, - config: GameEnvironment.Config = read(context), + config: GameEnvironment.Config? = null, gameDebugLogsOverride: Boolean? = null, ) { - val resolved = config.copy(shared = GameEnvironment.defaults(SessionPrefs.fexPreset(context), SessionPrefs.forceSsbs(context)) + config.shared) + publishGameCores(context) + val stored = config ?: read(context) + val resolved = GameEnvironment.withKnownGames(stored).copy(shared = GameEnvironment.defaults(SessionPrefs.fexPreset(context), SessionPrefs.forceSsbs(context)) + stored.shared) val json = encode(resolved) val dxvk = TextureFiltering.dxvkOptions( SessionPrefs.textureAnisotropy(context), SessionPrefs.textureLodBias(context), @@ -140,6 +143,26 @@ object GameEnvironmentStore { write(File(LinuxRuntime.rootDir(context), GUEST_FILE), json.toString()) } + @Synchronized + fun publishGameCores(context: Context) { + val file = File(LinuxRuntime.rootDir(context), GAME_CORES_FILE) + val pending = File(file.path + ".new") + try { + check(file.parentFile!!.isDirectory || file.parentFile!!.mkdirs()) + java.io.FileOutputStream(pending).use { + it.write((com.droiddeck.launcher.core.CpuCores.restrictionOrEmpty(SessionPrefs.gameCpus(context)) + "\n").toByteArray(Charsets.UTF_8)) + it.fd.sync() + } + java.nio.file.Files.move( + pending.toPath(), file.toPath(), + java.nio.file.StandardCopyOption.ATOMIC_MOVE, java.nio.file.StandardCopyOption.REPLACE_EXISTING, + ) + } catch (error: Exception) { + Log.e(TAG, "Could not update game cores", error) + if (!file.delete() && file.exists()) Log.e(TAG, "Could not remove outdated game cores") + } + } + private fun write(file: File, text: String) { check(file.parentFile!!.isDirectory || file.parentFile!!.mkdirs()) val atomic = AtomicFile(file) diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameLinks.kt b/app/src/main/java/com/droiddeck/launcher/session/GameLinks.kt new file mode 100644 index 0000000000..0115819cb3 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/GameLinks.kt @@ -0,0 +1,284 @@ +package com.droiddeck.launcher.session + +import android.content.Context +import org.json.JSONArray +import org.json.JSONObject +import java.io.File +import java.net.HttpURLConnection +import java.net.URL +import java.net.URLEncoder + +object GameLinks { + enum class Kind { WIKI, STRATEGYWIKI, PCGAMINGWIKI, GAMEFAQS, IGN, HOWLONGTOBEAT, MAPGENIE } + + data class Link(val kind: Kind, val url: String) + + data class Search(val id: String, val url: String) + + internal fun sparql(appId: Long): String = """ + SELECT ?fandom ?pcgw ?gamefaqs ?ign ?hltb ?sw WHERE { + ?g wdt:P1733 "$appId". + OPTIONAL { ?g wdt:P4073 ?fandom } + OPTIONAL { ?g wdt:P6337 ?pcgw } + OPTIONAL { ?g wdt:P4769 ?gamefaqs } + OPTIONAL { ?g wdt:P5385 ?ign } + OPTIONAL { ?g wdt:P2816 ?hltb } + OPTIONAL { ?g wdt:P9075 ?sw } + } LIMIT 50 + """.trimIndent() + + internal fun parse(json: String): List { + val rows = JSONObject(json).optJSONObject("results")?.optJSONArray("bindings") ?: return emptyList() + val values = HashMap>() + for (i in 0 until rows.length()) { + val row = rows.optJSONObject(i) ?: continue + for (key in row.keys()) { + val v = row.optJSONObject(key)?.optString("value").orEmpty() + if (v.isNotEmpty() && v !in values.getOrPut(key) { mutableListOf() }) values.getValue(key) += v + } + } + fun first(key: String) = values[key]?.firstOrNull() + // Wikidata is editable by anyone, and this id becomes a URL host. + val fandomId = Regex("[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)?") + val fandom = values["fandom"]?.filter(fandomId::matches)?.let { all -> all.firstOrNull { '.' !in it } ?: all.firstOrNull() } + return listOfNotNull( + fandom?.let { id -> if ('.' in id) id.split('.', limit = 2).let { (lang, wiki) -> "https://$wiki.fandom.com/$lang/" } else "https://$id.fandom.com/" } + ?.let { Link(Kind.WIKI, it) }, + first("sw")?.let { Link(Kind.STRATEGYWIKI, "https://strategywiki.org/wiki/" + path(it)) }, + first("pcgw")?.let { Link(Kind.PCGAMINGWIKI, "https://www.pcgamingwiki.com/wiki/" + path(it)) }, + first("gamefaqs")?.takeIf { it.all(Char::isDigit) }?.let { Link(Kind.GAMEFAQS, "https://gamefaqs.gamespot.com/-/$it-") }, + first("ign")?.let { Link(Kind.IGN, "https://www.ign.com/games/" + path(it)) }, + first("hltb")?.takeIf { it.all(Char::isDigit) }?.let { Link(Kind.HOWLONGTOBEAT, "https://howlongtobeat.com/game/$it") }, + ) + } + + /** Site slugs to try for a game name, longest first: "Bully: Scholarship Edition" gives bully-scholarship-edition, then bully. */ + internal fun slugs(name: String): List { + fun slug(s: String) = s.lowercase().replace("&", "and").replace(Regex("['’™®©]"), "") + .replace(Regex("[^a-z0-9]+"), "-").trim('-') + val short = name.split(Regex(":| - | – |\\("), limit = 2).first() + return listOf(slug(name), slug(short)).filter { it.isNotEmpty() }.distinct() + } + + /** Direct pages for what Wikidata has no ID for, found from each site's own routes rather than a web search. */ + internal fun direct(name: String, found: List, exists: (String) -> Boolean, strategyWiki: (String) -> String?): List = + merge(found, discover(name, found, exists, strategyWiki)) + + /** Wikidata's links with the discovered ones; a discovered IGN wiki replaces Wikidata's IGN game page. */ + internal fun merge(found: List, extra: List): List = + found.filterNot { it.kind == Kind.IGN && extra.any { e -> e.kind == Kind.IGN } } + + extra.filterNot { e -> e.kind != Kind.IGN && found.any { it.kind == e.kind } } + + internal fun discover(name: String, found: List, exists: (String) -> Boolean, strategyWiki: (String) -> String?): List { + val have = found.map { it.kind }.toSet() + val slugs = slugs(name) + fun first(urls: List) = urls.firstOrNull(exists) + val ignWiki = found.firstOrNull { it.kind == Kind.IGN }?.url?.substringAfter("/games/", "")?.takeIf { it.isNotEmpty() } + val extra = listOfNotNull( + first(slugs.map { "https://mapgenie.io/$it" })?.let { Link(Kind.MAPGENIE, it) }, + first((listOfNotNull(ignWiki) + slugs).distinct().map { "https://www.ign.com/wikis/$it" })?.let { Link(Kind.IGN, it) }, + // Fandom answers pages with a bot check, but its API with 200 for a wiki that exists and 404 for one that does not. + if (Kind.WIKI in have) null else slugs.map { it.replace("-", "") }.distinct() + .firstOrNull { exists("https://$it.fandom.com/api.php?action=query&meta=siteinfo&format=json") } + ?.let { Link(Kind.WIKI, "https://$it.fandom.com/") }, + if (Kind.STRATEGYWIKI in have) null else strategyWiki(name.split(":").first().trim())?.let { Link(Kind.STRATEGYWIKI, it) }, + ) + return extra + } + + internal fun parseOpenSearch(json: String, title: String): String? = runCatching { + val a = JSONArray(json) + val titles = a.getJSONArray(1) + val urls = a.getJSONArray(3) + (0 until titles.length()).firstOrNull { titles.getString(it).equals(title, ignoreCase = true) }?.let { urls.getString(it) } + }.getOrNull() + + /** Whether the page exists, or null when the site could not be asked. */ + private fun exists(url: String): Boolean? = runCatching { + val c = URL(url).openConnection() as HttpURLConnection + c.instanceFollowRedirects = false + c.connectTimeout = 6_000 + c.readTimeout = 6_000 + c.setRequestProperty("User-Agent", BROWSER) + try { c.responseCode.takeIf { it < 500 }?.let { it in 200..399 } } finally { c.disconnect() } + }.getOrNull() + + private fun strategyWiki(title: String): Result = runCatching { + parseOpenSearch(get("https://strategywiki.org/w/api.php?action=opensearch&namespace=0&limit=5&format=json&search=" + + URLEncoder.encode(title, "UTF-8")), title) + } + + fun links(context: Context, appId: Long, name: String? = null): List { + val cache = File(context.cacheDir, "game-links/$appId.json") + val fresh = cache.isFile && System.currentTimeMillis() - cache.lastModified() < CACHE_MS + val text = if (fresh) runCatching { cache.readText() }.getOrNull() else null + val fetched = text ?: runCatching { + get("https://query.wikidata.org/sparql?format=json&query=" + URLEncoder.encode(sparql(appId), "UTF-8")) + }.getOrNull()?.also { runCatching { cache.parentFile?.mkdirs(); cache.writeText(it) } } + val json = fetched ?: runCatching { cache.readText() }.getOrNull() + val wikidata = json?.let { runCatching { parse(it) }.getOrNull() }.orEmpty() + val withFixes = if (wikidata.any { it.kind == Kind.PCGAMINGWIKI }) wikidata + else wikidata + Link(Kind.PCGAMINGWIKI, "https://www.pcgamingwiki.com/api/appid.php?appid=$appId") + if (name.isNullOrBlank()) return withFixes + // Only the discovered pages are cached, and only when every site answered, so an offline lookup is retried. + val directCache = File(context.cacheDir, "game-links/$appId-direct-v3.json") + val cached = directCache.takeIf { it.isFile && System.currentTimeMillis() - it.lastModified() < CACHE_MS } + ?.let { runCatching { readLinks(it.readText()) }.getOrNull() } + if (cached != null) return merge(withFixes, cached) + var complete = fetched != null + val extra = discover(name, withFixes, { url -> exists(url).also { if (it == null) complete = false } == true }) { title -> + strategyWiki(title).onFailure { complete = false }.getOrNull() + } + if (complete) runCatching { directCache.parentFile?.mkdirs(); directCache.writeText(writeLinks(extra)) } + return merge(withFixes, extra) + } + + internal fun writeLinks(links: List): String = + JSONArray(links.map { JSONObject().put("kind", it.kind.name).put("url", it.url) }).toString() + + internal fun readLinks(json: String): List = JSONArray(json).let { a -> + (0 until a.length()).map { a.getJSONObject(it) }.map { Link(Kind.valueOf(it.getString("kind")), it.getString("url")) } + } + + fun protonTier(appId: Long): String? = runCatching { + parseTier(get("https://www.protondb.com/api/v1/reports/summaries/$appId.json")) + }.getOrNull() + + internal fun parseTier(json: String): String? = + JSONObject(json).optString("tier").takeIf { it in TIERS } + + /** Searches on the sites themselves, for what has no direct page. */ + fun searches(name: String, found: List): List { + val q = URLEncoder.encode(name, "UTF-8") + return listOfNotNull( + Search("youtube", "https://m.youtube.com/results?search_query=$q+walkthrough"), + Search("gamefaqs", "https://gamefaqs.gamespot.com/search?game=$q").takeIf { found.none { it.kind == Kind.GAMEFAQS } }, + ) + } + + private fun path(id: String) = id.replace(' ', '_') + + private fun get(url: String): String { + val c = URL(url).openConnection() as HttpURLConnection + c.connectTimeout = 10_000 + c.readTimeout = 15_000 + c.setRequestProperty("User-Agent", "DroidDeck (bottom screen guides)") + c.setRequestProperty("Accept", "application/sparql-results+json, application/json") + try { + if (c.responseCode != 200) throw java.io.IOException("HTTP ${c.responseCode}") + return c.inputStream.bufferedReader().use { it.readText() } + } finally { + c.disconnect() + } + } + + val TIERS = listOf("platinum", "gold", "silver", "bronze", "borked") + private const val CACHE_MS = 7L * 24 * 3600 * 1000 + private const val BROWSER = "Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0 Mobile Safari/537.36" +} + +object GuideLibrary { + data class Saved(val file: File, val title: String, val url: String) + + data class PinnedMap(val file: File, val markers: List>) + + private fun dir(context: Context, game: String, kind: String) = + File(context.filesDir, "guides/${game.replace(Regex("[^A-Za-z0-9._-]"), "_")}/$kind") + + fun savedFile(context: Context, game: String): File = dir(context, game, "saved").apply { mkdirs() }.let { File(it, "${System.currentTimeMillis()}.mht") } + + fun recordSaved(file: File, title: String, url: String) { + runCatching { File(file.path.removeSuffix(".mht") + ".json").writeText(JSONObject().put("title", title).put("url", url).toString()) } + } + + fun saved(context: Context, game: String): List = dir(context, game, "saved").listFiles { f -> f.name.endsWith(".mht") && f.length() > 0 } + .orEmpty().sortedByDescending { it.lastModified() }.map { f -> + val meta = runCatching { JSONObject(File(f.path.removeSuffix(".mht") + ".json").readText()) }.getOrNull() + Saved(f, meta?.optString("title").orEmpty().ifEmpty { f.nameWithoutExtension }, meta?.optString("url").orEmpty()) + } + + fun isSaved(context: Context, file: File): Boolean = + file.canonicalPath.startsWith(File(context.filesDir, "guides").canonicalPath + File.separator) && file.name.endsWith(".mht") + + fun delete(file: File) { + file.delete() + File(file.path.removeSuffix(".mht") + ".json").delete() + File(file.path + ".markers.json").delete() + } + + fun maps(context: Context, game: String): List = dir(context, game, "maps") + .listFiles { f -> f.extension in IMAGE_TYPES.values }.orEmpty().sortedByDescending { it.lastModified() } + .map { PinnedMap(it, markers(it)) } + + fun markers(map: File): List> = runCatching { + val arr = JSONArray(File(map.path + ".markers.json").readText()) + List(arr.length()) { i -> arr.getJSONArray(i).let { it.getDouble(0).toFloat() to it.getDouble(1).toFloat() } } + }.getOrDefault(emptyList()) + + fun saveMarkers(map: File, markers: List>) { + runCatching { File(map.path + ".markers.json").writeText(JSONArray(markers.map { JSONArray(listOf(it.first.toDouble(), it.second.toDouble())) }).toString()) } + } + + /** Follows redirects itself so the page's cookies reach only the host they were read for. */ + private const val MAX_REDIRECTS = 5 + + private fun openMap(url: String, cookies: String?): HttpURLConnection? { + val home = URL(url).host + var target = URL(url) + repeat(MAX_REDIRECTS + 1) { + val c = target.openConnection() as HttpURLConnection + c.instanceFollowRedirects = false + c.connectTimeout = 10_000 + c.readTimeout = 30_000 + c.setRequestProperty("User-Agent", "Mozilla/5.0 (Linux; Android) DroidDeck") + if (target.host.equals(home, ignoreCase = true)) cookies?.takeIf { it.isNotEmpty() }?.let { c.setRequestProperty("Cookie", it) } + if (c.responseCode !in 300..399) return c + val next = c.getHeaderField("Location")?.let { runCatching { URL(target, it) }.getOrNull() } + c.disconnect() + if (next == null || (next.protocol != "https" && next.protocol != "http")) return null + target = next + } + return null + } + + fun pin(context: Context, game: String, url: String, cookies: String?): File? = runCatching { + if (!url.startsWith("https://") && !url.startsWith("http://")) return null + val c = openMap(url, cookies) ?: return null + try { + if (c.responseCode != 200) return null + val ext = IMAGE_TYPES[c.contentType?.substringBefore(';')?.trim()?.lowercase()] ?: return null + if (c.contentLengthLong > MAX_MAP_BYTES) return null + val out = File(dir(context, game, "maps").apply { mkdirs() }, "${System.currentTimeMillis()}.$ext") + // Written beside the map and renamed when complete, so the Maps list never shows a partial image. + val part = File(out.path + ".part") + try { + c.inputStream.use { input -> + part.outputStream().use { output -> + val buf = ByteArray(64 * 1024) + var total = 0L + while (true) { + val n = input.read(buf) + if (n < 0) break + total += n + if (total > MAX_MAP_BYTES) return null + output.write(buf, 0, n) + } + } + } + if (!part.renameTo(out)) return null + } finally { + part.delete() + } + out + } finally { + c.disconnect() + } + }.getOrNull() + + fun clear(context: Context, game: String) { + File(context.filesDir, "guides/${game.replace(Regex("[^A-Za-z0-9._-]"), "_")}").deleteRecursively() + } + + private val IMAGE_TYPES = mapOf("image/png" to "png", "image/jpeg" to "jpg", "image/webp" to "webp", "image/gif" to "gif") + private const val MAX_MAP_BYTES = 40L * 1024 * 1024 +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt b/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt index ed1d357b32..7784f1f9f9 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt @@ -22,6 +22,11 @@ object GameProfileManager { clear("component packages") { ComponentsManager.clearGameComponents(context, scope) } clear("texture filtering") { SessionPrefs.clearGameTextureFiltering(context, scope) } clear("Windows components") { WinComponents.setPicks(context, scope, emptyList()) } + clear("bottom screen") { SessionPrefs.clearGameBottomScreen(context, scope) } + clear("guides") { + SteamGuides.clear(context, scope) + GuideLibrary.clear(context, scope) + } if (failures.isNotEmpty()) { val names = failures.joinToString { it.first } diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt b/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt index 263860334c..3c2d722c06 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt @@ -59,13 +59,18 @@ object GameStorage { return when { pref == SessionPrefs.GAME_STORAGE_OFF -> null pref.isEmpty() -> options(context).firstOrNull()?.let { Option(it.name, it.path) } - else -> Option(SessionPrefs.gameStorageLabel(context), pref).takeIf { attached(File(pref)) } + else -> reachable(pref).let { path -> Option(SessionPrefs.gameStorageLabel(context), path).takeIf { attached(File(path)) } } } } fun disconnected(context: Context): Boolean { val pref = SessionPrefs.gameStorage(context) - return pref.isNotEmpty() && pref != SessionPrefs.GAME_STORAGE_OFF && !attached(File(pref)) + return pref.isNotEmpty() && pref != SessionPrefs.GAME_STORAGE_OFF && !attached(File(reachable(pref))) + } + + internal fun reachable(path: String, usable: (File) -> Boolean = { it.isDirectory && it.canWrite() }): String { + val alias = UsbLink.storagePath(path) + return if (alias != path && !usable(File(path)) && usable(File(alias))) alias else path } internal fun attached( diff --git a/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt b/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt index e02b3e7bfa..1e0d30828e 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt @@ -18,10 +18,24 @@ object GpuClockPin { var failed = false private set - val supported: Boolean by lazy { File(KGSL_NODE).exists() } + var supported: Boolean = File(KGSL_NODE).exists() + internal set + + internal var turbo: (Boolean) -> Unit = { WaylandCompositor.nativeSetGpuTurbo(it) } private var live = false + @Volatile + private var boosted = false + + private fun wanted(context: Context) = boosted || SessionPrefs.gpuClockPin(context) + + fun boost(on: Boolean): Boolean { + if (boosted == on) return false + boosted = on + return true + } + @Synchronized fun start(context: Context): String { live = true @@ -30,11 +44,11 @@ object GpuClockPin { private fun hold(context: Context): String { failed = false - if (!SessionPrefs.gpuClockPin(context)) return "gpu clock: governed" + if (!wanted(context)) return "gpu clock: governed" if (!supported) return "gpu clock: no $KGSL_NODE, left governed" return try { File(context.filesDir, MARKER).createNewFile() - WaylandCompositor.nativeSetGpuTurbo(true) + turbo(true) pinned = true "gpu clock: held at its top" } catch (t: Throwable) { @@ -48,13 +62,14 @@ object GpuClockPin { @Synchronized fun sync(context: Context): String? { if (!live) return null - if (!SessionPrefs.gpuClockPin(context) && pinned) clear(context) + if (!wanted(context) && pinned) clear(context) return hold(context) } @Synchronized fun stop(context: Context) { live = false + boosted = false if (pinned) clear(context) } @@ -66,7 +81,7 @@ object GpuClockPin { private fun clear(context: Context) { if (supported) { try { - WaylandCompositor.nativeSetGpuTurbo(false) + turbo(false) } catch (t: Throwable) { Log.w(TAG, "clear", t) } diff --git a/app/src/main/java/com/droiddeck/launcher/session/GuestLeftovers.kt b/app/src/main/java/com/droiddeck/launcher/session/GuestLeftovers.kt new file mode 100644 index 0000000000..f1e7454e7e --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/GuestLeftovers.kt @@ -0,0 +1,54 @@ +package com.droiddeck.launcher.session + +import java.io.File + +/** Finds the processes a session left running, also once proot is gone and they belong to init. */ +object GuestLeftovers { + private const val MARKER = "DD_DEBUG_DIR=" + + fun find(rootfs: String, ended: File?, skip: Set): Set { + val marker = ended?.let { MARKER + it.path } + val parents = HashMap() + val matched = HashSet() + File("/proc").listFiles { f -> f.name.all { it.isDigit() } }?.forEach { proc -> + val pid = proc.name.toIntOrNull() ?: return@forEach + parentOf(proc)?.let { parents[pid] = it } + if (pid in skip) return@forEach + val exe = runCatching { File(proc, "exe").canonicalPath }.getOrNull() + // proot runs a guest through its loader, which is then the process's executable + if (exe?.startsWith(rootfs) == true || + marker != null && carries(runCatching { File(proc, "environ").readBytes() }.getOrNull(), marker)) { + matched.add(pid) + } + } + return withDescendants(matched, parents) - skip + } + + internal fun carries(environ: ByteArray?, marker: String): Boolean { + if (environ == null) return false + val wanted = marker.toByteArray() + var start = 0 + while (start < environ.size) { + var end = start + while (end < environ.size && environ[end] != 0.toByte()) end++ + if (end - start == wanted.size && (0 until wanted.size).all { environ[start + it] == wanted[it] }) return true + start = end + 1 + } + return false + } + + internal fun withDescendants(roots: Set, parents: Map): Set { + val out = HashSet(roots) + var grew = true + while (grew) { + grew = false + for ((pid, ppid) in parents) if (pid > 1 && ppid in out && out.add(pid)) grew = true + } + return out + } + + private fun parentOf(proc: File): Int? { + val stat = runCatching { File(proc, "stat").readText() }.getOrNull() ?: return null + return stat.substringAfterLast(") ").split(' ').getOrNull(1)?.toIntOrNull() + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/LoopbackWebSocket.kt b/app/src/main/java/com/droiddeck/launcher/session/LoopbackWebSocket.kt new file mode 100644 index 0000000000..0a789b21ca --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/LoopbackWebSocket.kt @@ -0,0 +1,135 @@ +package com.droiddeck.launcher.session + +import java.io.ByteArrayOutputStream +import java.io.DataInputStream +import java.io.IOException +import java.io.InputStream +import java.io.OutputStream +import java.net.InetSocketAddress +import java.net.Socket +import java.security.MessageDigest +import java.security.SecureRandom +import java.util.Base64 + +class LoopbackWebSocket(port: Int, path: String = "/", connectTimeoutMs: Int = 1_000, readTimeoutMs: Int = 0) : AutoCloseable { + private val socket = Socket() + private val out: OutputStream + private val input: DataInputStream + private val random = SecureRandom() + + init { + try { + socket.connect(InetSocketAddress("127.0.0.1", port), connectTimeoutMs) + socket.soTimeout = UPGRADE_TIMEOUT_MS + socket.tcpNoDelay = true + out = socket.getOutputStream() + input = DataInputStream(socket.getInputStream().buffered()) + val key = Base64.getEncoder().encodeToString(ByteArray(16).also(random::nextBytes)) + out.write(("GET $path HTTP/1.1\r\nHost: 127.0.0.1:$port\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n" + + "Sec-WebSocket-Key: $key\r\nSec-WebSocket-Version: 13\r\n\r\n").toByteArray()) + out.flush() + val status = line(input) ?: throw IOException("no upgrade response") + if (status.split(' ').getOrNull(1) != "101") throw IOException("upgrade refused: $status") + val headers = HashMap() + while (true) { + val header = line(input) ?: throw IOException("upgrade cut short") + if (header.isEmpty()) break + val colon = header.indexOf(':') + if (colon > 0) headers[header.substring(0, colon).trim().lowercase()] = header.substring(colon + 1).trim() + } + if (!headers["upgrade"].equals("websocket", ignoreCase = true) || + headers["connection"]?.split(',')?.none { it.trim().equals("upgrade", ignoreCase = true) } != false || + headers["sec-websocket-accept"] != accept(key) + ) throw IOException("bad upgrade headers") + socket.soTimeout = readTimeoutMs + } catch (e: Exception) { + runCatching { socket.close() } + throw e + } + } + + @Synchronized + fun send(text: String) = frame(0x1, text.toByteArray()) + + fun receive(): String? { + val message = ByteArrayOutputStream() + while (true) { + val b0 = input.read().takeIf { it >= 0 } ?: return null + val b1 = input.read().takeIf { it >= 0 } ?: return null + var length = (b1 and 0x7F).toLong() + if (length == 126L) length = input.readUnsignedShort().toLong() else if (length == 127L) length = input.readLong() + if (length < 0 || length > MAX_FRAME) throw IOException("frame too large") + val mask = if (b1 and 0x80 != 0) ByteArray(4).also(input::readFully) else null + val data = ByteArray(length.toInt()).also(input::readFully) + if (mask != null) for (i in data.indices) data[i] = (data[i].toInt() xor mask[i % 4].toInt()).toByte() + when (b0 and 0x0F) { + 0x8 -> { + sendClose(data.copyOf(minOf(2, data.size))) + return null + } + 0x9 -> synchronized(this) { frame(0xA, data) } + 0x0, 0x1, 0x2 -> { + message.write(data) + if (message.size() > MAX_FRAME) throw IOException("message too large") + if (b0 and 0x80 != 0) return message.toString(Charsets.UTF_8.name()) + } + } + } + } + + private fun frame(opcode: Int, payload: ByteArray) { + val mask = ByteArray(4).also(random::nextBytes) + val frame = ByteArrayOutputStream(payload.size + 14) + frame.write(0x80 or opcode) + when { + payload.size < 126 -> frame.write(0x80 or payload.size) + payload.size < 65536 -> { + frame.write(0x80 or 126) + frame.write(payload.size ushr 8) + frame.write(payload.size and 0xFF) + } + else -> { + frame.write(0x80 or 127) + for (k in 7 downTo 0) frame.write(((payload.size.toLong() ushr (8 * k)) and 0xFF).toInt()) + } + } + frame.write(mask) + for (i in payload.indices) frame.write((payload[i].toInt() xor mask[i % 4].toInt()) and 0xFF) + out.write(frame.toByteArray()) + out.flush() + } + + private fun line(s: InputStream): String? { + val buf = ByteArrayOutputStream() + while (true) { + val b = s.read() + if (b < 0) return if (buf.size() == 0) null else buf.toString(Charsets.UTF_8.name()) + if (b == '\n'.code) return buf.toString(Charsets.UTF_8.name()).trimEnd('\r') + if (buf.size() > 8192) throw IOException("header line too long") + buf.write(b) + } + } + + private var closeSent = false + + private fun sendClose(payload: ByteArray) { + synchronized(this) { + if (closeSent) return + closeSent = true + runCatching { frame(0x8, payload) } + } + } + + override fun close() { + sendClose(ByteArray(0)) + runCatching { socket.close() } + } + + internal companion object { + const val MAX_FRAME = 16L * 1024 * 1024 + const val UPGRADE_TIMEOUT_MS = 3_000 + + fun accept(key: String): String = Base64.getEncoder().encodeToString( + MessageDigest.getInstance("SHA-1").digest((key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").toByteArray())) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt b/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt index 2d18a84a30..bbfa7bfc29 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt @@ -29,6 +29,10 @@ object Onboarding { /** The setup screens belong to the first run; later runtime, Proton and Steam client updates keep the usual Play button. */ val firstRun = MutableStateFlow(true) + /** Called once, when this process finishes the first-run downloads itself; not when everything was already in place. */ + @Volatile var onFirstRunReady: (() -> Unit)? = null + @Volatile private var worked = false + fun attach(context: Context) { appContext = context.applicationContext val prefs = context.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE) @@ -52,8 +56,10 @@ object Onboarding { private fun markFirstRunDone() { val context = appContext ?: return + val live = firstRun.value && worked context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean(KEY_FIRST_RUN_DONE, true).apply() firstRun.value = false + if (live) onFirstRunReady?.invoke() } /** Keeps the process in the foreground, with one notification, while a step downloads and the runtime installer is not already doing so. */ @@ -90,6 +96,7 @@ object Onboarding { } fun report(step: Step, label: String, percent: Int) { + worked = true failed.value = failed.value - step active.value = active.value + (step to Progress(label, percent)) keepAlive() diff --git a/app/src/main/java/com/droiddeck/launcher/session/QuestSteamVrLaunch.kt b/app/src/main/java/com/droiddeck/launcher/session/QuestSteamVrLaunch.kt new file mode 100644 index 0000000000..8f619b86b3 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/QuestSteamVrLaunch.kt @@ -0,0 +1,35 @@ +package com.droiddeck.launcher.session + +import android.content.Context +import java.io.File + +/** + * On a Quest, SteamVR has to run inside the immersive activity. A launch from Steam's library happens in the + * guest, so the guest's SteamVR helper leaves a request in the shared runtime directory for the session to act on. + */ +object QuestSteamVrLaunch { + private const val DIR = ".wayland-rt/droiddeck-steamvr" + private const val MARKER = "quest-immersive" + private const val REQUEST = "xr-request" + + fun publish(context: Context) { + val dir = File(context.filesDir, DIR) + val marker = File(dir, MARKER) + if (!QuestExperimental.isSupported()) { + marker.delete() + return + } + runCatching { + dir.mkdirs() + marker.writeText("") + } + } + + /** A request left by an earlier session must not open the immersive view in this one. */ + fun clearRequest(context: Context) { + File(context.filesDir, "$DIR/$REQUEST").delete() + } + + fun takeRequest(context: Context): Boolean = + QuestExperimental.isSupported() && File(context.filesDir, "$DIR/$REQUEST").delete() +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/SecondaryLibrary.kt b/app/src/main/java/com/droiddeck/launcher/session/SecondaryLibrary.kt index 53fc319c26..08fa86f608 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SecondaryLibrary.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SecondaryLibrary.kt @@ -46,7 +46,16 @@ object SecondaryLibrary { } fun privateRoot(files: File, library: File): File { - val digest = MessageDigest.getInstance("SHA-256").digest(library.canonicalPath.toByteArray()) + val own = privateDir(files, library.canonicalPath) + if (own.exists()) return own + val raw = UsbLink.rawPath(library.absolutePath) + val alias = if (raw != library.absolutePath) raw else UsbLink.storagePath(library.absolutePath) + if (alias == library.absolutePath) return own + return privateDir(files, runCatching { File(alias).canonicalPath }.getOrDefault(alias)).takeIf { it.exists() } ?: own + } + + private fun privateDir(files: File, path: String): File { + val digest = MessageDigest.getInstance("SHA-256").digest(path.toByteArray()) .joinToString("") { "%02x".format(it.toInt() and 255) } return File(files, "steam-libraries/$digest") } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt index 03c9fddcae..68cb9b4976 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt @@ -667,10 +667,18 @@ object SessionArtifacts { val am = context.getSystemService(android.app.ActivityManager::class.java) ?: return false am.getHistoricalProcessExitReasons(context.packageName, 0, 3) .firstOrNull { it.processName == context.packageName } - ?.reason == android.app.ApplicationExitInfo.REASON_LOW_MEMORY + ?.let { memoryKill(it.reason, it.description) } == true }.getOrDefault(false) } + // ApplicationExitInfo.REASON_MEMORY_LIMITER (API 37.2), newer than compileSdk. + private const val REASON_MEMORY_LIMITER = 17 + + // The Android 17 behavior changes page instead documents REASON_OTHER with the limiter named in the description. + internal fun memoryKill(reason: Int, description: String?): Boolean = + reason == android.app.ApplicationExitInfo.REASON_LOW_MEMORY || reason == REASON_MEMORY_LIMITER || + reason == android.app.ApplicationExitInfo.REASON_OTHER && description?.contains("MemoryLimiter") == true + private fun exitReasons(context: Context): String { if (android.os.Build.VERSION.SDK_INT < 30) return "" return runCatching { @@ -691,6 +699,7 @@ object SessionArtifacts { private fun reasonName(reason: Int): String = when (reason) { android.app.ApplicationExitInfo.REASON_LOW_MEMORY -> "LOW_MEMORY (killed for memory)" + REASON_MEMORY_LIMITER -> "MEMORY_LIMITER (over the app memory limit)" android.app.ApplicationExitInfo.REASON_SIGNALED -> "SIGNALED" android.app.ApplicationExitInfo.REASON_CRASH -> "CRASH" android.app.ApplicationExitInfo.REASON_CRASH_NATIVE -> "CRASH_NATIVE" diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt index a3b368632e..0858e6fefd 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt @@ -35,6 +35,7 @@ object SessionFiles { "usr/local/bin/kwin_wayland_wrapper" to "usr/local/bin/kwin_wayland_wrapper", "usr/lib/firefox/defaults/pref/droiddeck.js" to "usr/lib/firefox/defaults/pref/droiddeck.js", "etc/xdg/autostart/droiddeck-clipboard.desktop" to "etc/xdg/autostart/droiddeck-clipboard.desktop", + "usr/share/applications/droiddeck-return-gaming.desktop" to "usr/share/applications/droiddeck-return-gaming.desktop", "etc/xdg/fastfetch/config.jsonc" to "etc/xdg/fastfetch/config.jsonc", ) @@ -147,6 +148,7 @@ object SessionFiles { "usr/local/bin/droiddeck-login1" to "usr/local/bin/droiddeck-login1", "usr/local/bin/droiddeck-documents" to "usr/local/bin/droiddeck-documents", "usr/local/bin/droiddeck-steam-launch" to "usr/local/bin/droiddeck-steam-launch", + "usr/local/bin/droiddeck-qam-relay" to "usr/local/bin/droiddeck-qam-relay", "usr/local/bin/droiddeck-desktop-games" to "usr/local/bin/droiddeck-desktop-games", "usr/local/bin/droiddeck-desktop-programs" to "usr/local/bin/droiddeck-desktop-programs", "usr/local/bin/droiddeck-desktop-bookmarks" to "usr/local/bin/droiddeck-desktop-bookmarks", diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPaths.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPaths.kt index 69cb7d4fae..d8117ae714 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPaths.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPaths.kt @@ -26,6 +26,9 @@ object SessionPaths { @Volatile private var startedAt = 0L + @Volatile + private var debugLogsContext: Context? = null + @Synchronized fun beginOrCurrent(context: Context, label: String? = null): File { dir?.let { if (it.isDirectory) return it } @@ -44,6 +47,7 @@ object SessionPaths { startedAt = System.currentTimeMillis() if (!made.isDirectory && !made.mkdirs()) Log.e(TAG, "could not create $made") dir = made + debugLogsContext = if (SessionPrefs.gameDebugLogsEnabled(context)) context.applicationContext else null if (enhanced && !EnhancedDiagnostics.consumeInto(context, made)) { Log.e(TAG, "could not activate enhanced diagnostics for $made") } @@ -65,6 +69,9 @@ object SessionPaths { val taken = dir dir = null if (taken != null) ended = taken + val expiring = debugLogsContext + debugLogsContext = null + if (taken != null && expiring != null) SessionPrefs.expireGameDebugLogs(expiring) return taken } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt index b5794eff94..a040ef9de8 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -142,6 +142,55 @@ object SessionPrefs { private fun secondScreenPanelKey(desktop: Boolean) = if (desktop) "secondScreenPanel.desktop" else "secondScreenPanel.game" + fun gameSecondScreenPanel(context: Context, game: String): String? = prefs(context).getString("secondScreenPanel.app.$game", null) + + fun setGameSecondScreenPanel(context: Context, game: String, mode: String) { + prefs(context).edit().putString("secondScreenPanel.app.$game", mode).apply() + } + + fun gameBottomPage(context: Context, game: String): String? = prefs(context).getString("bottomPage.app.$game", null) + + fun setGameBottomPage(context: Context, game: String, page: String) { + prefs(context).edit().putString("bottomPage.app.$game", page).apply() + } + + /** The bottom screen's brightness in percent, or null to follow the system. */ + fun bottomBrightness(context: Context): Int? = prefs(context).getInt("bottomBrightness", -1).takeIf { it >= 0 } + + fun setBottomBrightness(context: Context, percent: Int) { + prefs(context).edit().putInt("bottomBrightness", percent).apply() + } + + fun bottomAutoDim(context: Context): Boolean = prefs(context).getBoolean("bottomAutoDim", true) + + fun setBottomAutoDim(context: Context, on: Boolean) { + prefs(context).edit().putBoolean("bottomAutoDim", on).apply() + } + + fun mirrorRegion(context: Context, game: String): String? = prefs(context).getString("mirrorRegion.app.$game", null) + + fun setMirrorRegion(context: Context, game: String, region: String) { + prefs(context).edit().putString("mirrorRegion.app.$game", region).apply() + } + + fun mirrorHide(context: Context, game: String): String = prefs(context).getString("mirrorHide.app.$game", null) ?: "off" + + fun setMirrorHide(context: Context, game: String, mode: String) { + prefs(context).edit().putString("mirrorHide.app.$game", mode).apply() + } + + /** How Steam's Quick Access menu sits on the bottom screen: full, left, center or right. */ + fun quickAccessLayout(context: Context): String? = prefs(context).getString("bottomQamLayout", null) + + fun setQuickAccessLayout(context: Context, id: String) { + prefs(context).edit().putString("bottomQamLayout", id).apply() + } + + fun clearGameBottomScreen(context: Context, game: String) { + prefs(context).edit().remove("secondScreenPanel.app.$game").remove("bottomPage.app.$game").remove("mirrorRegion.app.$game") + .remove("mirrorHide.app.$game").apply() + } + /** The bottom-screen desktop takes touch as a trackpad unless the user switched it to direct touch. */ fun bottomDesktopDirectTouch(context: Context): Boolean = prefs(context).getBoolean("bottomDesktopDirectTouch", false) @@ -911,12 +960,6 @@ object SessionPrefs { fun micAsked(context: Context): Boolean = prefs(context).getBoolean("micAsked", false) - fun allFilesAsked(context: Context): Boolean = prefs(context).getBoolean("allFilesAsked", false) - - fun setAllFilesAsked(context: Context) { - prefs(context).edit().putBoolean("allFilesAsked", true).apply() - } - fun bluetoothAsked(context: Context): Boolean = prefs(context).getBoolean("bluetoothAsked", false) fun setBluetoothAsked(context: Context) { @@ -959,6 +1002,7 @@ object SessionPrefs { fun setGameCpus(context: Context, list: String) { prefs(context).edit().putString("gameCpus", list).apply() + GameEnvironmentStore.publishGameCores(context) } fun noXalia(context: Context): Boolean = prefs(context).getBoolean("noXalia", true) @@ -1040,6 +1084,14 @@ object SessionPrefs { fun gameThreadHints(context: Context): Boolean = prefs(context).getBoolean("gameThreadHints", true) + /** Whether the phone's shared storage (/sdcard) is mounted into the Linux container. */ + @JvmStatic + fun mountSharedStorage(context: Context): Boolean = prefs(context).getBoolean("mountSharedStorage", true) + + fun setMountSharedStorage(context: Context, on: Boolean) { + prefs(context).edit().putBoolean("mountSharedStorage", on).apply() + } + fun prootNoSeccomp(context: Context): Boolean = prefs(context).getBoolean("prootNoSeccomp", false) fun setProotNoSeccomp(context: Context, on: Boolean) { @@ -1177,6 +1229,11 @@ object SessionPrefs { prefs(context).edit().putBoolean("venus", on).apply() } + /** Venus off with no choice stored, so that Auto turning it off does not read as the user's own choice. */ + fun clearVenus(context: Context) { + prefs(context).edit().remove("venus").apply() + } + fun setVkBridge(context: Context, on: Boolean) { prefs(context).edit().putBoolean("vkBridge", on).putBoolean("bridgeFellBack", false).apply() } @@ -1228,7 +1285,7 @@ object SessionPrefs { oldValue = logsEnabled(context), newValue = on, newEffective = gameDebugLogsEffective(context, on, gameDebugLogsEnabled(context)), - ) + ).also { if (it) BuildWatermarkSetting.notifyChanged(context) } } fun gameDebugLogsEnabled(context: Context): Boolean = @@ -1241,7 +1298,13 @@ object SessionPrefs { oldValue = gameDebugLogsEnabled(context), newValue = on, newEffective = gameDebugLogsEffective(context, logsEnabled(context), on), - ) + ).also { if (it) BuildWatermarkSetting.notifyChanged(context) } + } + + /** The setting lasts for the session that started with it on; the next session's start republishes the environment. */ + internal fun expireGameDebugLogs(context: Context) { + prefs(context).edit().putBoolean("gameDebugLogsEnabled", false).apply() + runCatching { BuildWatermarkSetting.notifyChanged(context) } } private fun setLogPreference( @@ -1679,6 +1742,7 @@ object SessionPrefs { signal = p.getInt("customThemeSignal", defaults.signal), good = p.getInt("customThemeGood", defaults.good), error = p.getInt("customThemeError", defaults.error), + warning = p.getInt("customThemeWarning", defaults.warning), ) } @@ -1699,6 +1763,7 @@ object SessionPrefs { .putInt("customThemeSignal", colors.signal) .putInt("customThemeGood", colors.good) .putInt("customThemeError", colors.error) + .putInt("customThemeWarning", colors.warning) .apply() } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index 38fe0b65d9..56c4f27f57 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -417,9 +417,11 @@ class SessionService : Service() { SessionPrefs.screenEffectsProfileId(SessionState.mode, resolvedGameId, SessionState.program), ) com.droiddeck.launcher.stores.battlenet.BattleNetClient.clearRequests(LinuxRuntime.sessionRoot(this)) + QuestSteamVrLaunch.clearRequest(this) val gen = synchronized(SessionState.startLock) { synchronized(stopLock) { SessionState.steamClientArch = null + SessionState.gameZoom = 1.0f SessionState.running = true ++sessionGen } @@ -693,12 +695,14 @@ class SessionService : Service() { .onFailure { Log.w(TAG, "Epic install directory setup failed", it) } } if (steamHere || noSteamGame) { - val added = SessionEvents.step("added-games-scan") { com.droiddeck.launcher.frontend.AddedGames.scan(this) } - val listing = SessionEvents.step("added-games-listing") { com.droiddeck.launcher.frontend.AddedGames.writeListing(this, added) } + val listing = if (steamHere) SessionEvents.step("added-games-listing") { com.droiddeck.launcher.frontend.AddedGamesPublisher.sessionListing(this) } else { + val added = SessionEvents.step("added-games-scan") { com.droiddeck.launcher.frontend.AddedGames.scan(this) } + com.droiddeck.launcher.frontend.AddedGamesPublisher.log(added) + SessionEvents.step("added-games-listing") { com.droiddeck.launcher.frontend.AddedGames.writeListing(this, added) } + } guest.add("DD_ADDED_GAMES=" + listing.path) if (OfflineMode.active(this)) guest.add("DD_STEAM_OFFLINE=1") if (com.droiddeck.launcher.gpu.Lossless.owned(this)) guest.add("DD_LOSSLESS_OWNED=1") - if (added.isNotEmpty()) Log.i(TAG, "added games: " + added.joinToString { "${it.name} (${it.exe.name})" }) } guest.add("DD_LAUNCH_DIR=" + sessionRoot.path) // Proton builds up to 11.12 report X11 text fields under this name. @@ -739,14 +743,15 @@ class SessionService : Service() { SessionEvents.step("shm-clear") { FileUtils.clear(File(LinuxRuntime.liveDir(this), "shm")) } - val binds = sessionBinds(controllersOn, fakeInputDir, sessionDir, guest, sessionRoot, runtimeDir) + val sharedStorage = LinuxRuntime.sharedStorage(this) + val binds = sessionBinds(controllersOn, fakeInputDir, sessionDir, guest, sessionRoot, runtimeDir, sharedStorage) val nativeUserland = com.droiddeck.launcher.runtime.NativeGuest.enabled(this) synchronized(stopLock) { if (gen == sessionGen && SessionState.running) com.droiddeck.launcher.runtime.NativeGuest.sessionMode = nativeUserland } val fastPathKey = if (ProotFastPath.enabled(this)) { val prootBinds = LinuxRuntime.binds( - this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, + this, sessionRoot, runtimeDir, sharedStorage, binds, ) val root = LinuxRuntime.rootDir(this) ProotFastPath.key(root, prootBinds)?.also { key -> @@ -760,12 +765,12 @@ class SessionService : Service() { } } else null - val sessionBindSpecs = LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds) + val sessionBindSpecs = LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds) val command = if (nativeUserland) { LinuxRuntime.rememberSessionBinds(sessionBindSpecs) com.droiddeck.launcher.runtime.NativeGuest.command(root, guest.first(), guest.drop(1)) } else { - LinuxRuntime.command(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, guest) + LinuxRuntime.command(this, sessionRoot, runtimeDir, sharedStorage, binds, guest) } val prootEnv = HostEnvironment() @@ -794,7 +799,7 @@ class SessionService : Service() { val terminalCommand = if (nativeUserland) { com.droiddeck.launcher.runtime.NativeGuest.command(root, shellGuest.first(), shellGuest.drop(1)) } else { - LinuxRuntime.command(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, shellGuest) + LinuxRuntime.command(this, sessionRoot, runtimeDir, sharedStorage, binds, shellGuest) } val terminalHostEnvironment = LinkedHashMap(System.getenv()) hostEnv.asArray().forEach { entry -> @@ -805,7 +810,7 @@ class SessionService : Service() { SessionTerminal.prepare(terminalCommand, terminalHostEnvironment.map { (key, value) -> "$key=$value" }.toTypedArray(), root, gen) val (fastPathName, _) = ProotFastPath.hostEnv("") BottomDesktop.prepare(desktopGuest, binds, sessionRoot, - prootEnv.asArray().filterNot { it.startsWith("$fastPathName=") }.toTypedArray(), root, sessionDir, gen, nativeUserland, + prootEnv.asArray().filterNot { it.startsWith("$fastPathName=") }.toTypedArray(), root, sessionDir, gen, nativeUserland, sharedStorage, ) { gen == sessionGen && SessionState.running } } @@ -1253,6 +1258,7 @@ class SessionService : Service() { guest: MutableList, sessionRoot: File, runtimeDir: File, + sharedStorage: File?, ): ArrayList { val binds = ArrayList() if (controllersOn) binds.add(fakeInputDir.path + ":/dev/input") @@ -1296,7 +1302,17 @@ class SessionService : Service() { if (controllersOn) components.add(RumbleComponent().also { it.attach(this) }) val home = File(LinuxRuntime.rootDir(this), "root") File(home, "Storage").mkdirs() - binds.add(Environment.getExternalStorageDirectory().path + ":/root/Storage") + if (sharedStorage != null) { + binds.add(sharedStorage.path + ":/root/Storage") + } else { + for (folder in com.droiddeck.launcher.frontend.AddedExes.list(this).map { File(it.folder) }.distinctBy { it.path }) { + val guest = com.droiddeck.launcher.frontend.AddedGames.guestPath(this, folder) ?: continue + if (!guest.startsWith("/root/Storage/") || !folder.isDirectory) continue + File(LinuxRuntime.rootDir(this), guest.removePrefix("/")).mkdirs() + binds.add(folder.path + ":" + guest) + Log.i(TAG, "added game: $folder -> $guest (shared storage not mounted)") + } + } val library = GameStorage.effective(this) steamLibraryMounts = emptyMap() var storageDiagnosticLibrary: File? = null @@ -1370,7 +1386,7 @@ class SessionService : Service() { val gamesLibraries = GameStorage.gamesFolderLibraries(this) if (gamesLibraries.isNotEmpty()) { var room = if (ProotFastPath.enabled(this)) { - ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds).size + ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE for (games in gamesLibraries) { if (games.host.path + ":" + games.guest !in binds) continue @@ -1412,7 +1428,7 @@ class SessionService : Service() { } try { val room = if (ProotFastPath.enabled(this)) { - ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds).size + ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val content = SecondaryLibrary.contentPath(entry.host) val extra = SecondaryLibrary.binds(filesDir, entry.host, listOf(entry.guest), content = content) @@ -1441,7 +1457,7 @@ class SessionService : Service() { Log.w(TAG, "x86-64 steam library: $problem") } else try { val room = if (ProotFastPath.enabled(this)) { - ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds).size + ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val extra = SecondaryLibrary.binds(filesDir, x64, listOf(GameStorage.X64_CARD_GUEST)).drop(1) if (extra.size > room) { @@ -1463,7 +1479,7 @@ class SessionService : Service() { } try { val room = if (ProotFastPath.enabled(this)) { - ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds).size + ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val extra = SecondaryLibrary.binds(filesDir, entry.x64Host, listOf(entry.x64Guest)).drop(1) if (extra.size > room) { @@ -1499,7 +1515,7 @@ class SessionService : Service() { val listing = File(filesDir, "session/desktop-volumes.json").apply { parentFile?.mkdirs() } val volumes = org.json.JSONArray() var room = if (ProotFastPath.enabled(this)) { - ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds).size + ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE for (root in com.droiddeck.launcher.files.StorageRoots.list(this)) { if (!root.removable || !root.readable) continue @@ -1727,6 +1743,7 @@ class SessionService : Service() { var startupWasSuspended = false var seen = false var goneSince = 0L + var gamePid: String? = null while (token == gameExitWatchToken && gen == sessionGen && SessionState.running && !SessionState.stopRequested) { val now = android.os.SystemClock.elapsedRealtime() val startupSuspended = SessionState.suspended || SessionState.suspending || SessionState.phase != SessionPhase.READY @@ -1742,7 +1759,8 @@ class SessionService : Service() { lastStartupCheck = now } } - if (steamGameRunning(gameId)) { + gamePid = SteamGameProcess.runningPid(gameId, gamePid) + if (gamePid != null) { if (!seen) { Log.i(TAG, "game $gameId started; tracking its exit") mainHandler.post { @@ -1884,21 +1902,11 @@ class SessionService : Service() { File(directory, STEAM_GAME_REQUEST + ".tmp").delete() } - private fun killGuestLeftovers() { - val me = android.os.Process.myPid() + private fun killGuestLeftovers(ended: File?) { val rootfs = try { File(filesDir, "linuxfs").canonicalPath } catch (e: Exception) { return } + "/" - val procs = File("/proc").listFiles { f -> f.name.all { it.isDigit() } } ?: return - val spared = OrphanReaper.spared() - var killed = 0 - for (proc in procs) { - val pid = proc.name.toIntOrNull() ?: continue - if (pid == me || pid in spared) continue - val exe = try { File(proc, "exe").canonicalPath } catch (e: Exception) { continue } - if (!exe.startsWith(rootfs)) continue - android.os.Process.killProcess(pid) - killed++ - } - if (killed > 0) Log.w(TAG, "killed $killed guest process(es) proot no longer tracked") + val leftovers = GuestLeftovers.find(rootfs, ended, OrphanReaper.spared() + android.os.Process.myPid()) + leftovers.forEach { android.os.Process.killProcess(it) } + if (leftovers.isNotEmpty()) Log.w(TAG, "killed ${leftovers.size} guest process(es) proot no longer tracked") } private fun killStragglers() { @@ -2384,7 +2392,7 @@ class SessionService : Service() { com.droiddeck.launcher.stores.gog.GogComet.end(stoppedSession) auxiliary.forEach { (pid, started) -> teardown(pid, started) } if (prootPid > 1) teardown(prootPid) - killGuestLeftovers() + killGuestLeftovers(ended) pruneSystemVulkanRuntime() finishSessionStop(status, stoppedGen, collectEnded) if (launcherEnded) importLauncherGames() diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt index 92255febec..ac62bde46c 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt @@ -47,6 +47,9 @@ object SessionState { @Volatile var running = false + /** Zoom level retained across activity recreation for the active session. */ + @Volatile + var gameZoom = 1.0f @Volatile var activityDisplayId = 0 @Volatile diff --git a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt index 0c1d8ddb1b..dcac4fef89 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt @@ -22,7 +22,7 @@ object SettingsReset { "gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop", "tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "paceCores", "directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus", - "noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "nativeUserland", "cursorComposite", + "noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "nativeUserland", "cursorComposite", "mountSharedStorage", "guestHostname", "fexPreset", "forceSsbs", "logs", "gameDebugLogsEnabled", "enhancedDiagnosticsNext", "storageDiagnostics", "buildWatermark", "upscaler", "upscaleSharpness", "screenEffects", "blackFrameInsertion", "textureAnisotropy", "textureLodBias", "steamDownloadsInBackground", "steam_offline", "steam_offline_auto", "steam_offline_by_network", "bootMovie", "bootMovieSound", "bootMovieVolume", "bootMovieSeconds", "skipBootMovie", diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamGameProcess.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamGameProcess.kt index 6b7ecda60c..5aa20cb693 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SteamGameProcess.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamGameProcess.kt @@ -55,12 +55,15 @@ object SteamGameProcess { return false } - fun running(gameId: String, proc: File = File("/proc")): Boolean = - proc.listFiles()?.any { p -> - p.name.all(Char::isDigit) && - runCatching { File(p, "cmdline").readBytes() } - .getOrNull()?.let { matches(it, gameId) } == true - } == true + fun running(gameId: String, proc: File = File("/proc")): Boolean = runningPid(gameId, null, proc) != null + + fun runningPid(gameId: String, known: String?, proc: File = File("/proc")): String? { + if (known != null && runs(File(proc, known), gameId)) return known + return proc.listFiles()?.firstOrNull { p -> p.name.all(Char::isDigit) && runs(p, gameId) }?.name + } + + private fun runs(process: File, gameId: String): Boolean = + runCatching { File(process, "cmdline").readBytes() }.getOrNull()?.let { matches(it, gameId) } == true // A front end that resumes a player by launching the same game again would otherwise have Steam // start it a second time, which Steam answers with "Game already running". diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamGuides.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamGuides.kt new file mode 100644 index 0000000000..90905abe80 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamGuides.kt @@ -0,0 +1,98 @@ +package com.droiddeck.launcher.session + +import android.content.Context +import android.text.Html +import java.net.HttpURLConnection +import java.net.URL + +object SteamGuides { + class Guide(val id: String, val title: String, val author: String, val summary: String, val preview: String?, val stars: Int) { + val url: String get() = "https://steamcommunity.com/sharedfiles/filedetails/?id=$id" + } + + class Place(val url: String, val scroll: Float) + + val TAGS = listOf("Walkthroughs", "Achievements", "Secrets", "Maps or Levels") + + internal fun listUrl(appId: Long, tag: String?, language: String? = null): String = + "https://steamcommunity.com/app/$appId/guides/?browsefilter=toprated&browsesort=toprated" + + listOfNotNull(tag, language).joinToString("") { "&requiredtags%5B%5D=" + java.net.URLEncoder.encode(it, "UTF-8") } + + internal fun language(locale: java.util.Locale): String { + val tag = locale.toLanguageTag() + return when { + tag.startsWith("zh-Hant") || locale.country in setOf("TW", "HK", "MO") && locale.language == "zh" -> "tchinese" + locale.language == "zh" -> "schinese" + locale.language == "pt" && locale.country == "BR" -> "brazilian" + locale.language == "es" && locale.country.isNotEmpty() && locale.country != "ES" -> "latam" + else -> LANGUAGES[locale.language] ?: "english" + } + } + + fun list(appId: Long, cookies: String?, tag: String? = null, language: String? = language(java.util.Locale.getDefault())): List? { + val found = fetch(appId, cookies, tag, language) + return if (language != null && found != null && found.isEmpty()) fetch(appId, cookies, tag, null) else found + } + + private fun fetch(appId: Long, cookies: String?, tag: String?, language: String?): List? = runCatching { + val connection = URL(listUrl(appId, tag, language)).openConnection() as HttpURLConnection + connection.connectTimeout = 10_000 + connection.readTimeout = 15_000 + connection.setRequestProperty("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) DroidDeck") + cookies?.takeIf { it.isNotEmpty() }?.let { connection.setRequestProperty("Cookie", it) } + try { + if (connection.responseCode != 200) return null + parse(connection.inputStream.bufferedReader().use { it.readText() }) + } finally { + connection.disconnect() + } + }.getOrNull() + + internal fun parse(html: String): List = html.split("class=\"workshopItemCollectionContainer\"").drop(1).mapNotNull { card -> + val id = ID.find(card)?.groupValues?.get(1) ?: return@mapNotNull null + val title = TITLE.find(card)?.groupValues?.get(1)?.let(::text)?.takeIf { it.isNotEmpty() } ?: return@mapNotNull null + Guide( + id, title, + AUTHOR.find(card)?.groupValues?.get(1)?.let(::text).orEmpty(), + SUMMARY.find(card)?.groupValues?.get(1)?.let(::text).orEmpty(), + PREVIEW.find(card)?.groupValues?.get(1)?.let { Html.fromHtml(it, Html.FROM_HTML_MODE_LEGACY).toString() }, + STARS.find(card)?.groupValues?.get(1)?.toIntOrNull() ?: 0, + ) + }.distinctBy { it.id } + + fun place(context: Context, game: String): Place? { + val prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE) + val url = prefs.getString("$game.url", null)?.takeIf(::isGuide) ?: return null + return Place(url, prefs.getFloat("$game.scroll", 0f)) + } + + fun savePlace(context: Context, game: String, url: String, scroll: Float) { + if (!isGuide(url)) return + context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit() + .putString("$game.url", url).putFloat("$game.scroll", scroll.coerceIn(0f, 1f)).apply() + } + + fun clear(context: Context, game: String) { + context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().remove("$game.url").remove("$game.scroll").apply() + } + + internal fun isGuide(url: String): Boolean = GUIDE_URL.matches(url) + + private fun text(html: String): String = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY).toString().trim().replace(Regex("\\s+"), " ") + + private val LANGUAGES = mapOf( + "en" to "english", "de" to "german", "fr" to "french", "it" to "italian", "es" to "spanish", "pt" to "portuguese", + "ru" to "russian", "pl" to "polish", "ja" to "japanese", "ko" to "koreana", "tr" to "turkish", "uk" to "ukrainian", + "nl" to "dutch", "sv" to "swedish", "da" to "danish", "fi" to "finnish", "nb" to "norwegian", "no" to "norwegian", + "cs" to "czech", "hu" to "hungarian", "ro" to "romanian", "bg" to "bulgarian", "el" to "greek", "th" to "thai", + "vi" to "vietnamese", "id" to "indonesian", "in" to "indonesian", "ar" to "arabic", + ) + private const val PREFS = "steam_guides" + private val GUIDE_URL = Regex("https://steamcommunity\\.com/sharedfiles/filedetails/\\?id=\\d+(#[\\w-]*)?") + private val ID = Regex("""filedetails/\?id=(\d+)""") + private val TITLE = Regex("""class="workshopItemTitle">(.*?)""", RegexOption.DOT_MATCHES_ALL) + private val AUTHOR = Regex("""class="workshopItemAuthorName">(.*?)""", RegexOption.DOT_MATCHES_ALL) + private val SUMMARY = Regex("""class="workshopItemShortDesc">(.*?)""", RegexOption.DOT_MATCHES_ALL) + private val PREVIEW = Regex("""class="workshopItemPreviewImage" src="([^"]+)"""") + private val STARS = Regex("""/(\d)-star\.png""") +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamLocalConfig.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamLocalConfig.kt new file mode 100644 index 0000000000..ad6196d2ab --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamLocalConfig.kt @@ -0,0 +1,70 @@ +package com.droiddeck.launcher.session + +import com.droiddeck.launcher.frontend.AddedGames +import java.io.File + +object SteamLocalConfig { + class AppStats(val playtimeMinutes: Long, val lastPlayed: Long) + + fun appStats(steamRoot: File, appId: Int): AppStats? { + val config = AddedGames.accountConfig(steamRoot) ?: return null + val text = runCatching { File(config, "localconfig.vdf").readText() }.getOrNull() ?: return null + return appStats(text, appId) + } + + internal fun appStats(text: String, appId: Int): AppStats? { + val apps = blocks(text, "apps").firstNotNullOfOrNull { blocks(it, appId.toString(), topLevel = true).firstOrNull() } ?: return null + val minutes = PLAYTIME.find(apps)?.groupValues?.get(1)?.toLongOrNull() ?: 0L + val last = LAST_PLAYED.find(apps)?.groupValues?.get(1)?.toLongOrNull() ?: 0L + return AppStats(minutes, last) + } + + private fun blocks(text: String, key: String, topLevel: Boolean = false): List { + val out = mutableListOf() + val quoted = "\"$key\"" + var depth = 0 + var i = 0 + while (i < text.length) { + when (val c = text[i]) { + '{' -> depth++ + '}' -> depth-- + '"' -> { + val end = text.indexOf('"', i + 1).takeIf { it > 0 } ?: return out + if ((!topLevel || depth == 0) && text.regionMatches(i, quoted, 0, quoted.length) && end == i + quoted.length - 1) { + val open = text.indexOfFirst(end + 1) { !it.isWhitespace() } + if (open >= 0 && text[open] == '{') { + val close = matching(text, open) + if (close > open) out += text.substring(open + 1, close) + } + } + i = end + } + else -> if (c == '/' && text.startsWith("//", i)) i = text.indexOf('\n', i).takeIf { it > 0 } ?: text.length + } + i++ + } + return out + } + + private fun matching(text: String, open: Int): Int { + var depth = 0 + var i = open + while (i < text.length) { + when (text[i]) { + '{' -> depth++ + '}' -> if (--depth == 0) return i + '"' -> i = text.indexOf('"', i + 1).takeIf { it > 0 } ?: return -1 + } + i++ + } + return -1 + } + + private inline fun String.indexOfFirst(from: Int, predicate: (Char) -> Boolean): Int { + for (i in from until length) if (predicate(this[i])) return i + return -1 + } + + private val PLAYTIME = Regex(""""Playtime"\s*"(\d+)"""") + private val LAST_PLAYED = Regex(""""LastPlayed"\s*"(\d+)"""") +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt new file mode 100644 index 0000000000..578f1c5cb4 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt @@ -0,0 +1,249 @@ +package com.droiddeck.launcher.session + +import android.content.Context +import com.droiddeck.launcher.agent.AgentGuest +import org.json.JSONArray +import org.json.JSONObject +import java.io.File + +// Steam renders the quick access menu only while it is open. While the app holds it, the menu is kept open with its +// 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. +object SteamQam { + data class Target(val port: Int, val path: String) + + const val QUICK_ACCESS = 2 + const val LEASE_MS = 5_000 + private const val TAG = "SteamQam" + private const val EVAL_MS = 6_000L + + private val owners = java.util.concurrent.atomic.AtomicLong(0) + + /** A new panel's lease owner: later panels get larger numbers, also across app restarts. */ + fun newOwner(): Long = owners.updateAndGet { maxOf(it + 1, System.currentTimeMillis()) } + + /** + * 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. + */ + 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 (aspect > 0f) " g.__ddQamAspect = $aspect;" else "") + " }" + 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. */ + internal fun script(on: Boolean, aspect: Float = 0f, owner: Long = 0): String = """(() => { + const g = globalThis, QAM = 2; + const W = SteamUIStore.WindowStore.SteamUIWindows[0]; + const m = W.MenuStore, c = W.m_CompositionStateStore; + const nav = W.m_FocusNavContext; + const popup = g_PopupManager.GetExistingPopup("SP BPM_uid0"); + const held = () => g.__ddQamUntil > Date.now(); + const ours = () => held() && m.m_eOpenSideMenu === QAM && !g.__ddQamTop; + const width = (h) => g.__ddQamAspect > 0 ? Math.round(h * g.__ddQamAspect) : 0; + if (!c.__ddQam) { + c.__ddQam = c.ComputeOverallMinimumRequestedComposition; + m.__ddQam = m.OnMenuDeactivated; + m.OnMenuDeactivated = function (d) { if (d === QAM && held() && !g.__ddQamTop) return; return m.__ddQam.call(this, d); }; + } + if (c.__ddQamV !== 2) { + c.__ddQamV = 2; + // Only the menu's own overlay request is lowered: a dialog over the game still needs Steam to take input. + c.ComputeOverallMinimumRequestedComposition = function (...a) { + const v = c.__ddQam.apply(this, a); + if (v !== 2 || !ours()) return v; + m.IsSideMenuVisible = () => false; + m.IsSideMenuInteractable = () => false; + let without; + try { without = c.__ddQam.apply(this, a); } finally { delete m.IsSideMenuVisible; delete m.IsSideMenuInteractable; } + return without >= 2 ? v : 1; + }; + } + const views = () => popup?.m_rgChildBrowserViews || []; + const backdrop = (hide) => { + const doc = popup?.m_popup?.document; + if (!doc) return; + for (const e of doc.querySelectorAll("div")) { + if (e.dataset.ddQam) { if (!hide) { e.style.removeProperty("visibility"); delete e.dataset.ddQam; } continue; } + if (!hide) continue; + const s = getComputedStyle(e), r = e.getBoundingClientRect(), v = doc.defaultView; + if (s.backdropFilter && s.backdropFilter !== "none" && r.width >= v.innerWidth - 2 && r.height >= v.innerHeight - 2) { + e.dataset.ddQam = "1"; + e.style.setProperty("visibility", "hidden", "important"); + } + } + }; + const keep = () => { + for (const v of views()) { + if (v.__ddQam) continue; + v.__ddQam = v.SetBounds; + v.SetBounds = function (x, y, w, h, ...r) { + v.__ddAsked = [x, y, w, h]; + if (w > 0 && ours()) { x = popup.m_popup.innerWidth + 64; w = width(h) || w; } + v.__ddAt = x; + v.__ddW = w; + return v.__ddQam.call(this, x, y, w, h, ...r); + }; + } + if (!held()) { + const parked = !g.__ddQamTop; + g.__ddQamTop = false; + g.__ddQamPress = undefined; + if (!g.__ddQamOn) return; + g.__ddQamOn = false; + backdrop(false); + if (parked && m.m_eOpenSideMenu === QAM) m.CloseSideMenus(); + c.EnsureCorrectComposition?.(); + return; + } + // Steam sends the pad to an open side menu, so a dialog over the game would get no input: step aside until it closes. + const dialog = nav?.m_rgGamepadNavigationTrees?.some(t => t.m_ID?.startsWith("ModalDialogOverlay") && t.m_Root?.m_element?.isConnected); + if (dialog && !g.__ddQamTop) { + g.__ddQamPress = W.m_flLastQuickAccessPressMS || 0; + if (m.m_eOpenSideMenu === QAM) m.CloseSideMenus(); + if (g.__ddQamOn) { g.__ddQamOn = false; backdrop(false); c.EnsureCorrectComposition?.(); } + return; + } + // The Quick Access button shows the menu on the top screen as usual; closing it there parks it again. + const press = W.m_flLastQuickAccessPressMS || 0; + if (g.__ddQamPress === undefined) g.__ddQamPress = press; + if (press !== g.__ddQamPress) { + g.__ddQamPress = press; + g.__ddQamTop = !g.__ddQamTop; + if (!g.__ddQamTop) { if (m.m_eOpenSideMenu === QAM) m.CloseSideMenus(); return; } + backdrop(false); + if (m.m_eOpenSideMenu !== QAM) m.OpenQuickAccessMenu(g.__ddQamTab ?? undefined); + for (const v of views()) if (v.__ddAsked?.[2] > 0) { v.__ddAt = v.__ddAsked[0]; v.__ddW = v.__ddAsked[2]; v.__ddQam.call(v, ...v.__ddAsked); } + c.EnsureCorrectComposition?.(); + return; + } + if (g.__ddQamTop) { + if (m.m_eOpenSideMenu === QAM) { + if (m.m_eQuickAccessTab != null) g.__ddQamTab = m.m_eQuickAccessTab; + return; + } + g.__ddQamTop = false; + } + 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. + if (m.m_eOpenSideMenu === QAM && decky && !g.__ddQamDecky) { g.__ddQamDecky = true; m.CloseSideMenus(); return; } + if (m.m_eOpenSideMenu === 0) { + m.OpenQuickAccessMenu(g.__ddQamTab ?? undefined); + g.__ddQamDecky = decky; + c.EnsureCorrectComposition?.(); + } + if (m.m_eOpenSideMenu !== QAM) return; + if (m.m_eQuickAccessTab != null) g.__ddQamTab = m.m_eQuickAccessTab; + if (!g.__ddQamOn) { g.__ddQamOn = true; c.EnsureCorrectComposition?.(); } + for (const v of views()) { + if (!v.__ddAsked) { + 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; } + } + const a = v.__ddAsked; + if (a?.[2] > 0 && (v.__ddAt < popup.m_popup.innerWidth || (width(a[3]) && v.__ddW !== width(a[3])))) v.SetBounds(...a); + } + const main = nav?.m_rgGamepadNavigationTrees?.find(t => t.m_ID === "GamepadUI_Full_Root"); + if (main && nav.m_LastActiveNavTree?.m_ID?.startsWith("QuickAccess")) nav.SetActiveNavTree(main); + backdrop(true); + }; + ${leaseScript(on, owner, aspect)} + keep(); + if (held() && !g.__ddQamTimer) { + g.__ddQamTimer = setInterval(() => { + keep(); + if (!held() && !g.__ddQamOn) { clearInterval(g.__ddQamTimer); g.__ddQamTimer = 0; } + }, 250); + } + return JSON.stringify([m.m_eOpenSideMenu, g.__ddQamTop ? 1 : 0]); + })()""" + + /** [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) + + fun hold(context: Context, aspect: Float, owner: Long): Hold? = eval(context, script(true, aspect, owner))?.let(::parseHold) + + internal fun parseHold(text: String): Hold? = runCatching { + val a = JSONArray(text) + Hold(a.getInt(0), a.getInt(1) == 1) + }.getOrNull() + + fun release(context: Context, relayPort: Int, owner: Long) { + eval(context, script(false, owner = owner)) + stopRelay(context, relayPort) + } + + fun stopRelay(context: Context, relayPort: Int) { + if (relayPort > 0) helper(context, "stop", relayPort.toString()) + } + + /** Starts the guest relay to Steam's DevTools and finds the menu's page; the relay is stopped again when there is none. */ + fun target(context: Context): Target? = runCatching { + val devtools = File(AgentGuest.dir(context), "cdp-port").readText().trim().toInt() + val (relay, secret) = parseRelay(helper(context, "start", devtools.toString())) ?: return null + val found = runCatching { parseTarget(relay, get(relay, "/$secret/json"))?.let { it.copy(path = "/$secret${it.path}") } } + if (found.getOrNull() == null) helper(context, "stop", relay.toString()) + found.getOrThrow() + }.onFailure { android.util.Log.e(TAG, "no quick access target: $it") }.getOrNull() + + internal fun parseRelay(text: String?): Pair? { + val parts = text?.trim()?.split(' ') ?: return null + val port = parts.getOrNull(0)?.toIntOrNull() ?: return null + val secret = parts.getOrNull(1)?.takeIf { it.matches(Regex("[0-9a-f]{16,64}")) } ?: return null + return port to secret + } + + private fun helper(context: Context, vararg args: String): String? = runCatching { + val request = JSONObject().put("kind", "exec").put("argv", JSONArray(listOf("droiddeck-qam-relay") + args)).put("timeout", 5.0) + val answer = AgentGuest.call(context, request, 8_000, trusted = true) + if (answer.optInt("exitCode", -1) == 0) answer.optJSONObject("stdout")?.optString("text") ?: answer.optString("stdout") else null + }.getOrNull() + + private fun get(port: Int, path: String): String = java.net.Socket().use { s -> + s.connect(java.net.InetSocketAddress("127.0.0.1", port), 2_000) + s.soTimeout = 3_000 + s.getOutputStream().apply { + write("GET $path HTTP/1.1\r\nHost: 127.0.0.1:$port\r\nAccept: */*\r\nConnection: close\r\n\r\n".toByteArray()) + flush() + } + httpBody(s.getInputStream()) + } + + /** Reads one response, by its Content-Length when it has one: DevTools does not always close the connection. */ + internal fun httpBody(input: java.io.InputStream): String { + val head = StringBuilder() + while (!head.endsWith("\r\n\r\n")) { + val b = input.read() + check(b >= 0 && head.length < 16_384) { "devtools answered ${head.take(80)}" } + head.append(b.toChar()) + } + check(head.startsWith("HTTP/1.1 200")) { "devtools answered ${head.take(80)}" } + val length = Regex("(?im)^content-length:\\s*(\\d+)").find(head)?.groupValues?.get(1)?.toInt() + val body = if (length == null) input.readBytes() else ByteArray(length).also { buf -> + var read = 0 + while (read < length) { + val n = input.read(buf, read, length - read) + check(n > 0) { "devtools closed after $read of $length bytes" } + read += n + } + } + return body.toString(Charsets.UTF_8) + } + + internal fun parseTarget(port: Int, json: String): Target? { + val list = JSONArray(json) + for (i in 0 until list.length()) { + val t = list.optJSONObject(i) ?: continue + if (!t.optString("title").startsWith("QuickAccess")) continue + val ws = t.optString("webSocketDebuggerUrl") + val path = Regex("^ws://[^/]+(/devtools/page/[A-Za-z0-9-]+)$").find(ws)?.groupValues?.get(1) ?: continue + return Target(port, path) + } + return null + } + + private fun eval(context: Context, expression: String): String? = runCatching { + val answer = AgentGuest.steamEval(context, expression, EVAL_MS) + if (answer.optBoolean("ok")) answer.opt("value")?.takeIf { it != JSONObject.NULL }?.toString() else null + }.getOrNull() +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt b/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt index b309bca43b..207a9921e6 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt @@ -105,14 +105,9 @@ object WinComponents { const val VCREDIST_ARM64 = "vcredist2022_arm64" internal fun builtInArm64Runtime(): Component { - fun value(view: String, name: String, type: String, data: String) = Step("set_register_key", JSONObject() - .put("action", "set_register_key").put("key", "HKLM\\Software\\${view}Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\arm64") - .put("value", name).put("type", type).put("data", data)) - val steps = listOf("", "Wow6432Node\\").flatMap { view -> - listOf(value(view, "Installed", "REG_DWORD", "1"), value(view, "Major", "REG_DWORD", "14"), value(view, "Minor", "REG_DWORD", "44"), - value(view, "Bld", "REG_DWORD", "35211"), value(view, "Rbld", "REG_DWORD", "0"), value(view, "Version", "REG_SZ", "v14.44.35211.00")) - } - return Component(VCREDIST_ARM64, "Microsoft Visual C++ 2015-2022 ARM64 runtime 14.44.35211 (registry entries only)", "Microsoft", "ready", emptyList(), steps) + val install = Step("install_exe", JSONObject().put("action", "install_exe").put("file_name", "VC_redist.arm64.exe") + .put("url", "https://aka.ms/vs/17/release/vc_redist.arm64.exe")) + return Component(VCREDIST_ARM64, "Microsoft Visual C++ 2015-2022 Redistributable (arm64)", "Microsoft", "ready", emptyList(), listOf(install), revision = 2) } private fun parse(body: String): List? { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/CloudSaves.kt b/app/src/main/java/com/droiddeck/launcher/stores/CloudSaves.kt index 5923cd6e44..ef3c2d3482 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/CloudSaves.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/CloudSaves.kt @@ -113,7 +113,7 @@ object CloudSaves { } Store.UBISOFT -> UBISOFT_TEMPLATE Store.EA -> eaRules(context, id) ?: return null - Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.ROCKSTAR -> "" + Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.ROCKSTAR, Store.STEAM -> "" } ?: return null p.edit() .putString("cloud_template_$id", fetched.ifEmpty { TEMPLATE_NONE }) @@ -181,7 +181,7 @@ object CloudSaves { Store.EPIC -> CloudSavePaths.epic(template, pfx, folder, EpicCredentialStore.load(context)?.accountId.orEmpty(), id) Store.EA -> if (sidecar.extra["masterTitleId"].isNullOrEmpty()) null else EaSaveRules.parse(template)?.base()?.let(EaSaveRules::template)?.let { CloudSavePaths.gog(it, pfx, folder) } - Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR -> null + Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR, Store.STEAM -> null } return dir to (if (dir == null) "unresolved" else "ok") } @@ -221,7 +221,7 @@ object CloudSaves { if (rules == null || base == null || token == null || uid.isEmpty() || master.isEmpty()) null else EaCloud(token, uid, EaCloud.keys(master, sidecar?.extra?.get("multiplayerId").orEmpty()), base, rules, saveFolder(context, store, id).first) } - Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.ROCKSTAR -> null + Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.ROCKSTAR, Store.STEAM -> null } private fun signedIn(context: Context, store: Store): Boolean = when (store) { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/LoginFlows.kt b/app/src/main/java/com/droiddeck/launcher/stores/LoginFlows.kt index a1b54088eb..99870f032c 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/LoginFlows.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/LoginFlows.kt @@ -16,7 +16,7 @@ internal object LoginFlows { Store.UBISOFT -> ubisoftFlow(browserUserAgent) Store.EA -> eaFlow(browserUserAgent) Store.ROCKSTAR -> rockstarFlow(browserUserAgent) - Store.ITCH, Store.XBOX, Store.BATTLENET -> null + Store.ITCH, Store.XBOX, Store.BATTLENET, Store.STEAM -> null } @Volatile var epicFlow: () -> StoreLoginActivity.Flow? = { null } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/SteamAchievements.kt b/app/src/main/java/com/droiddeck/launcher/stores/SteamAchievements.kt new file mode 100644 index 0000000000..a1b270a8ae --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/SteamAchievements.kt @@ -0,0 +1,58 @@ +package com.droiddeck.launcher.stores + +import android.content.Context +import com.droiddeck.launcher.agent.AgentGuest +import com.droiddeck.launcher.session.SessionService +import com.droiddeck.launcher.session.SessionState +import org.json.JSONObject + +object SteamAchievements : StoreAchievements("steam", "Steam") { + fun game(appId: Long) = Game(source, appId.toString()) + + override fun request(context: Context, game: Game): Result { + val appId = game.id.toLongOrNull()?.takeIf { it in 1..4_294_967_295L } ?: return Result.Failed(Reason.NO_SERVICE) + if (!SessionState.running || SessionState.mode != SessionService.MODE_STEAM) return Result.Failed(Reason.UNREACHABLE) + val answer = AgentGuest.steamEval(context, expression(appId), EVAL_TIMEOUT_MS) + if (!answer.optBoolean("ok")) return Result.Failed(Reason.UNREACHABLE) + val value = answer.opt("value")?.takeIf { it != JSONObject.NULL }?.toString() ?: return Result.Failed(Reason.UNREACHABLE) + return parse(appId, value) + } + + internal fun expression(appId: Long) = """(async () => { + const r = await SteamClient.Apps.GetMyAchievementsForApp('$appId'); + return typeof r === 'string' ? r : JSON.stringify(r); + })()""" + + internal fun parse(appId: Long, json: String): Result { + val root = runCatching { JSONObject(json) }.getOrNull() ?: return Result.Failed(Reason.UNREACHABLE) + if (root.optInt("result", 1) != 1) return Result.Found(emptyList()) + val items = root.optJSONObject("data")?.optJSONArray("rgAchievements") ?: return Result.Found(emptyList()) + val out = ArrayList(items.length()) + for (i in 0 until items.length()) { + val a = items.optJSONObject(i) ?: continue + val id = a.optString("strID") + if (id.isEmpty()) continue + val unlocked = a.optBoolean("bAchieved") + out += Achievement( + id = id, + name = a.optString("strName").ifEmpty { id }, + description = a.optString("strDescription"), + hidden = a.optBoolean("bHidden"), + unlocked = unlocked, + unlockedAt = if (unlocked) a.optLong("rtUnlocked") else 0, + icon = image(appId, a.optString("strImage")), + iconLocked = null, + ) + } + return Result.Found(out) + } + + private fun image(appId: Long, value: String): String? = when { + value.isEmpty() -> null + value.startsWith("https://") -> value + value.startsWith("http://") -> "https://" + value.removePrefix("http://") + else -> "https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/apps/$appId/${value.substringAfterLast('/')}" + } + + private const val EVAL_TIMEOUT_MS = 8_000L +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/SteamLiveShortcuts.kt b/app/src/main/java/com/droiddeck/launcher/stores/SteamLiveShortcuts.kt index ced9ae8fb2..c4601cb907 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/SteamLiveShortcuts.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/SteamLiveShortcuts.kt @@ -19,25 +19,33 @@ object SteamLiveShortcuts { private const val EVAL_TIMEOUT_MS = 20_000L private const val THAW_WAIT_MS = 15_000L - fun sync(context: Context, games: List, include: (AddedGames.Game) -> Boolean = { it.source != Library.ADDED }) { + fun sync(context: Context, games: List, include: (AddedGames.Game) -> Boolean = { it.source != Library.ADDED }): Boolean { val wanted = games.filter(include) - if (wanted.isEmpty() || !clientRunning()) return + if (wanted.isEmpty()) return true + if (!clientRunning()) return false val list = JSONArray() for (g in wanted) list.put(JSONObject().put("name", g.name).put("exe", g.guestExe).put("dir", g.guestDir).put("appid", g.appId and 0xFFFFFFFFL).put("launch", g.launchOptions)) val js = """ (async () => { const want = ${list}; - let added = 0; + let added = 0, missed = 0; for (const w of want) { if (await ${KNOWN}(w.appid, w.name, w.exe)) continue; - if (await ${ADD}(w.name, w.exe, w.dir, true, ${JSONObject.quote(compatTool(context))}, w.launch)) added++; + if (await ${ADD}(w.name, w.exe, w.dir, true, ${JSONObject.quote(compatTool(context))}, w.launch)) added++; else missed++; } - return added; + return JSON.stringify({ added, missed }); })() """.trimIndent() - val result = evaluate(context, js) ?: return - Log.i(TAG, "live shortcuts: $result added") - if (result != "0") StoresState.logLine("Steam: $result shortcut(s) added to the running client") + return synced(evaluate(context, js)) + } + + internal fun synced(result: String?): Boolean { + val counts = result?.let { runCatching { JSONObject(it) }.getOrNull() } ?: return false + val added = counts.optInt("added") + val missed = counts.optInt("missed") + Log.i(TAG, "live shortcuts: $added added" + if (missed > 0) ", $missed not added" else "") + if (added > 0) StoresState.logLine("Steam: $added shortcut(s) added to the running client") + return missed == 0 } fun ensure(context: Context, name: String, exe: String, dir: String, compat: Boolean, appId: Long? = null): Long? { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/Store.kt b/app/src/main/java/com/droiddeck/launcher/stores/Store.kt index 67b439943d..765ae7a5ce 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/Store.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/Store.kt @@ -10,11 +10,18 @@ enum class Store(val id: String, val label: String, val shortLabel: String) { UBISOFT("ubisoft", "Ubisoft Connect", "Ubisoft"), AMAZON("amazon", "Amazon Games", "Amazon"), BATTLENET("battlenet", "Battle.net", "Battle.net"), - GAMEJOLT("gamejolt", "Game Jolt", "Game Jolt"); + GAMEJOLT("gamejolt", "Game Jolt", "Game Jolt"), + STEAM("steamstore", "Steam", "Steam"); val folder: String get() = if (this == ITCH) "itch" else shortLabel + /** The Library tab its games list under: Steam's are the Steam client's own tab. */ + val librarySource: String get() = if (this == STEAM) com.droiddeck.launcher.frontend.Library.SOURCE_STEAM else id + companion object { fun byId(id: String?): Store? = entries.firstOrNull { it.id == id } + + /** The stores with a tab of their own; Steam's games list in the Library's Steam tab. */ + val tabbed: List get() = entries - STEAM } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt index 5e30fb7a5d..5bf88fb1b0 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt @@ -90,7 +90,7 @@ object StoreAccounts { fun signedInAs(context: Context, store: Store): String? { val json = read(context, store) ?: return if (isUnavailable(store)) store.label else null if (store == Store.XBOX) return json.optString("username").takeIf { it.isNotBlank() } - if (store == Store.BATTLENET) return json.optString("display_name").takeIf { it.isNotBlank() } + if (store == Store.BATTLENET || store == Store.STEAM) return json.optString("display_name").takeIf { it.isNotBlank() } if (json.optString("access_token", "").isEmpty()) return null return json.optString("display_name", "").ifEmpty { json.optString("username", "") }.ifEmpty { store.label } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreAchievements.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreAchievements.kt index 67ae6bae61..d248caf502 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreAchievements.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreAchievements.kt @@ -95,7 +95,7 @@ abstract class StoreAchievements(val source: String, val label: String) { private set fun invalidate() { revision++ } - private val all: List by lazy { listOf(GogAchievements, EpicAchievements) } + private val all: List by lazy { listOf(GogAchievements, EpicAchievements, SteamAchievements) } fun forSource(source: String?): StoreAchievements? = all.firstOrNull { it.source == source } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt index 040969b840..e9e4f9f631 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt @@ -247,7 +247,7 @@ object StoreInstallRoot { fun storeDir(root: File, store: Store): File = File(root, store.folder) fun gameFolders(context: Context): List = roots(context).flatMap { root -> - Store.entries.flatMap { store -> + Store.entries.filter { it != Store.STEAM }.flatMap { store -> storeDir(root, store).listFiles { f -> f.isDirectory }?.sortedBy { it.name.lowercase() } ?: emptyList() } } @@ -267,7 +267,7 @@ object StoreInstallRoot { fun isFinished(folder: File): Boolean = StoreGameSidecar.read(folder)?.isInstalled == true fun unfinished(context: Context): List = roots(context).flatMap { root -> - Store.entries.filter { it != Store.BATTLENET }.flatMap { store -> + Store.entries.filter { it != Store.BATTLENET && it != Store.STEAM }.flatMap { store -> storeDir(root, store).listFiles { f -> f.isDirectory }.orEmpty().mapNotNull { folder -> val sidecar = StoreGameSidecar.read(folder) when { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt index e792b67a94..4aca4ca028 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt @@ -122,10 +122,16 @@ object StoreInstalls { fun discard(context: Context, folder: File, caches: List) { val app = context.applicationContext + inBackground(folder) { discardNow(app, folder, caches) } + } + + fun deleteLater(dir: File) = inBackground(dir) { deleteTree(dir) } + + private fun inBackground(folder: File, work: () -> Unit) { beginDiscard(folder) val worker = Thread({ try { - discardNow(app, folder, caches) + work() } finally { endDiscard(folder) } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt index 8dfa21a725..e76e5279e1 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt @@ -97,7 +97,7 @@ object StoreLaunch { lines += "del \"%~dp0$EA_ENV\"" lines += ":run" lines += "if exist \"$EA_ORIGIN\" start \"\" \"$EA_ORIGIN\"" - lines += run + lines += "$run %*" lines += "taskkill /f /im Origin.exe >nul 2>&1" } else { lines += run diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreSizes.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreSizes.kt index 8a47c06806..af8e09bc57 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreSizes.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreSizes.kt @@ -63,7 +63,7 @@ object StoreSizes { Store.AMAZON -> AmazonPrefs.get(app).edit().putLong("size_${item.id}", it).apply() Store.ITCH, Store.GAMEJOLT -> {} Store.EA -> com.droiddeck.launcher.stores.ea.EaPrefs.get(app).edit().putLong("size_${item.id}", it).apply() - Store.GOG, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR -> {} + Store.GOG, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR, Store.STEAM -> {} } } }, pool).exceptionally { error -> @@ -142,5 +142,6 @@ object StoreSizes { Store.GOG, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR -> 0L Store.ITCH -> com.droiddeck.launcher.stores.itch.ItchLibrary.size(context, item) Store.GAMEJOLT -> com.droiddeck.launcher.stores.gamejolt.GameJoltBuilds.size(context, item) + Store.STEAM -> com.droiddeck.launcher.stores.steam.SteamStore.plannedBytes(context, item) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreTabs.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreTabs.kt index 975626168d..e73d1e6801 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreTabs.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreTabs.kt @@ -3,7 +3,7 @@ package com.droiddeck.launcher.stores data class StoreTab(val store: Store, val shown: Boolean) fun arrangeStoreTabs(order: List, hidden: Set): List { - val known = Store.entries.associateBy { it.id } + val known = Store.tabbed.associateBy { it.id } val listed = order.mapNotNull { known[it] }.distinct() - return (listed + Store.entries.filterNot { it in listed }).map { StoreTab(it, it.id !in hidden) } + return (listed + Store.tabbed.filterNot { it in listed }).map { StoreTab(it, it.id !in hidden) } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt index 8cd6ea13a2..8c0d4198f1 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt @@ -85,6 +85,7 @@ object StoresState { do { seen = refreshRequests.get() runCatching { com.droiddeck.launcher.stores.battlenet.BattleNetClient.syncAccount(app) } + runCatching { com.droiddeck.launcher.stores.steam.SteamStore.syncAccount(app) } val found = Store.entries.mapNotNull { store -> StoreAccounts.displayName(app, store)?.let { store to it } } val onDisk = StoreInstallRoot.gameFolders(app).mapNotNull { folder -> StoreGameSidecar.read(folder)?.takeIf { it.isInstalled || it.state == StoreGameSidecar.STATE_UPDATING }?.let { InstalledStoreGame(it, folder) } @@ -120,6 +121,8 @@ object StoresState { var unfinished by mutableStateOf>(emptyList()) internal set + var steamPicking by mutableStateOf(null) + fun isUnfinished(item: CatalogItem): Boolean = unfinished.any { it.store == item.store && (it.id == item.id || (it.id == null && it.folder.name == StoreInstallRoot.folderName(item.title, item.id))) } @@ -260,6 +263,7 @@ object StoresState { fun requestInstall(context: Context, item: CatalogItem) { askForNotifications(context) + if (item.store == Store.STEAM) { com.droiddeck.launcher.stores.steam.SteamStore.requestInstall(context, item); return } if (item.store == Store.ITCH && item.extra["uploadId"].isNullOrEmpty()) { itchPicking = item; return } if (item.store == Store.GAMEJOLT && item.extra["buildId"].isNullOrEmpty()) { gameJoltPicking = item; return } if (isUnfinished(item)) { install(context, item); return } @@ -278,6 +282,7 @@ object StoresState { fun install(context: Context, item: CatalogItem, root: java.io.File? = null, language: String? = null) { val app = context.applicationContext + if (item.store == Store.STEAM) { com.droiddeck.launcher.stores.steam.SteamStore.restore(app, item); return } val targetRoot = root ?: StoreInstallRoot.defaultTarget(app)?.root ?: StoreInstallRoot.installRoot(app) if (item.store == Store.BATTLENET && !com.droiddeck.launcher.stores.battlenet.BattleNetInstall.headless(item)) { backends[item.store]?.install(app, item, targetRoot) @@ -315,7 +320,7 @@ object StoresState { val key = "${game.sidecar.store.id}:${game.sidecar.id}" uninstalling[key] = 0f background("stores-uninstall", onFailure = { main.post { uninstalling.remove(key); onDone() } }) { - if (!com.droiddeck.launcher.stores.download.DownloadQueue.holdForRemovalWhenFree(key)) { + if (!com.droiddeck.launcher.stores.download.DownloadQueue.stopForRemoval(app, key)) { logLine("kept \"${game.sidecar.title}\": its download or update is still running") main.post { uninstalling.remove(key); onDone() } return@background diff --git a/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt b/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt index 426d3616a9..6ee2f1b16d 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt @@ -7,6 +7,7 @@ import com.droiddeck.launcher.R import com.droiddeck.launcher.frontend.AddedGames import com.droiddeck.launcher.runtime.BattleNet import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.session.GameStorage import com.droiddeck.launcher.stores.CatalogItem import com.droiddeck.launcher.stores.InstalledStoreGame import com.droiddeck.launcher.stores.Store @@ -130,13 +131,13 @@ object BattleNetClient { StoresState.post { opener?.invoke(args) } } - fun library(context: Context, root: File = preferred(context)): List = - AddedGames.guestPath(context, StoreInstallRoot.storeDir(root, Store.BATTLENET))?.let { listOf("--library", it) }.orEmpty() + fun library(context: Context, root: File? = preferred(context)): List = + root?.let { AddedGames.guestPath(context, StoreInstallRoot.storeDir(it, Store.BATTLENET)) }?.let { listOf("--library", it) }.orEmpty() - internal fun preferred(context: Context): File { + internal fun preferred(context: Context): File? { val second = StoreInstallRoot.libraryRoot(context)?.absolutePath return StoreInstallRoot.targets(context).firstOrNull { it.root.absolutePath == second && (it.root.isDirectory || it.root.mkdirs()) }?.root - ?: StoreInstallRoot.internalRoot(context) + ?: StoreInstallRoot.internalRoot(context).takeIf { second == null && !GameStorage.disconnected(context) } } fun installGame(context: Context, uid: String, root: File) { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt b/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt index 4ceb4278bf..8d5d1e6586 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt @@ -9,6 +9,7 @@ import java.util.concurrent.atomic.AtomicBoolean object DownloadQueue { private const val TAG = "StoreDownloads" + private const val REMOVAL_WAIT_MS = 30_000L interface DownloadJob { fun run(handle: JobHandle): String? @@ -120,17 +121,24 @@ object DownloadQueue { fun releaseRemoval(key: String) { synchronized(lock) { removing.remove(key); (lock as Object).notifyAll() } } - fun holdForRemovalWhenFree(key: String): Boolean = synchronized(lock) { - while (true) { - val item = items[key] - if (item?.entry?.isActive == true || item?.job != null) return@synchronized false - if (key !in cleaningUp && key !in removing) break - (lock as Object).wait() + fun stopForRemoval(context: Context, key: String): Boolean { + if (synchronized(lock) { busyLocked(key) }) cancel(context, key) + val deadline = android.os.SystemClock.uptimeMillis() + REMOVAL_WAIT_MS + return synchronized(lock) { + while (true) { + val busy = busyLocked(key) + if (!busy && key !in cleaningUp && key !in removing) break + val left = deadline - android.os.SystemClock.uptimeMillis() + if (busy && left <= 0) return@synchronized false + (lock as Object).wait(if (busy) left else 0L) + } + removing.add(key) + true } - removing.add(key) - true } + private fun busyLocked(key: String): Boolean = items[key].let { it?.entry?.isActive == true || it?.job != null } + private fun beginCleanup(key: String): Boolean = synchronized(lock) { if (key in removing) return@synchronized false cleaningUp.merge(key, 1, Int::plus) @@ -159,6 +167,7 @@ object DownloadQueue { } fun holdPaused(key: String) = synchronized(lock) { heldPaused.add(key) } + fun dropHeld(key: String) = synchronized(lock) { heldPaused.remove(key) } private var running = 0 fun parallel(context: Context): Int = SessionPrefs.gameStoresParallel(context) @@ -411,6 +420,7 @@ object DownloadQueue { } item.job = null publishLocked() + (lock as Object).notifyAll() } when (item.entry.state) { DownloadState.INSTALLED -> { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLaunch.kt b/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLaunch.kt index a9b623a2d6..7869d2d2bb 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLaunch.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLaunch.kt @@ -73,35 +73,72 @@ object EaLaunch { /** Answers the guest's request right before an EA game starts: session, licence and the LSX endpoint. */ fun prepare(context: Context, request: JSONObject): JSONObject { val app = context.applicationContext + request.optJSONObject("steam")?.let { return prepareSteam(app, request, it) } val id = request.optString("id") - val reply = JSONObject().put("ok", false) - val (folder, recorded) = installed(app, id) ?: return reply.put("reason", "not-installed") + val (folder, recorded) = installed(app, id) ?: return JSONObject().put("ok", false).put("reason", "not-installed") val sidecar = backfill(folder, recorded) runCatching { com.droiddeck.launcher.stores.StoreLaunch.refreshLauncher(folder, sidecar) } File(folder, ENV_FILE).delete() - val account = EaAuth.load(app) ?: return reply.put("reason", "signed-out") - val access = EaAuth.accessToken(app) ?: return reply.put("reason", "sign-in-expired") - val contentId = sidecar.extra["contentId"].orEmpty() - val locale = sidecar.extra["locale"].orEmpty().ifEmpty { "en_US" } - val core = EaOoa.coreDir(folder, sidecar.exe) + val known = (sidecar.extra["contentIds"].orEmpty().split(',') + sidecar.extra["multiplayerId"].orEmpty()).map { it.trim() }.filter { it.isNotEmpty() }.toSet() + val game = Started(folder, id, sidecar.extra["contentId"].orEmpty(), known, sidecar.extra["contentIds"].orEmpty().split(','), + sidecar.title, sidecar.installVersion, sidecar.extra["locale"].orEmpty().ifEmpty { "en_US" }, sidecar.exe) + val (reply, env) = start(app, game, request) + if (env != null) { + val tmp = File(folder, "$ENV_FILE.tmp") + tmp.writeText(env.entries.joinToString("\r\n", postfix = "\r\n") { "${it.key}=${it.value}" }) + tmp.renameTo(File(folder, ENV_FILE)) + } + return reply + } + + private val OFFER = Regex("Origin\\.OFR\\.[0-9]+\\.[0-9]+") + private val CONTENT = Regex("[A-Za-z0-9._-]{1,64}") + + /** Steam's copy of an EA game, which Steam would hand to the EA app; the env comes back in the reply. */ + private fun prepareSteam(app: Context, request: JSONObject, steam: JSONObject): JSONObject { + val failed = JSONObject().put("ok", false) + val root = com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(app).canonicalFile + val folder = File(root, steam.optString("folder").removePrefix("/")).canonicalFile + if (!folder.path.startsWith(root.path + File.separator) || !folder.isDirectory) return failed.put("reason", "no-folder") + fun strings(name: String, pattern: Regex) = steam.optJSONArray(name)?.let { a -> (0 until a.length()).map { a.optString(it) } } + .orEmpty().filter { pattern.matches(it) }.distinct() + val offers = strings("offers", OFFER) + val contents = strings("contentIds", CONTENT) + if (offers.isEmpty() || contents.isEmpty()) return failed.put("reason", "no-offer") + val game = Started(folder, offers.first(), contents.first(), contents.toSet(), contents, steam.optString("title").ifEmpty { folder.name }, + steam.optString("version"), steam.optString("locale").ifEmpty { "en_US" }, steam.optString("exe")) + val (reply, env) = start(app, game, request) + if (env != null) reply.put("id", game.offerId).put("env", JSONObject(env.toMap())) + return reply + } + + private class Started( + val folder: File, val offerId: String, val contentId: String, val contentIds: Set, val licenceIds: List, + val title: String, val version: String, val locale: String, val exe: String, + ) + + private fun start(app: Context, game: Started, request: JSONObject): Pair?> { + val reply = JSONObject().put("ok", false) + val id = game.offerId + val account = EaAuth.load(app) ?: return reply.put("reason", "signed-out") to null + val access = EaAuth.accessToken(app) ?: return reply.put("reason", "sign-in-expired") to null + val contentId = game.contentId + val locale = game.locale + val core = EaOoa.coreDir(game.folder, game.exe) val hashVersion = core?.let(EaOoa::activationVersion) ?: 1 val hardware = request.optJSONObject("hardware")?.let(EaOoa.Hardware::fromJson)?.takeIf { it.complete(hashVersion) } val legacy = EaOoa.legacyCore(core) val lifetime = if (legacy) 14400 else 550 val opaque = EaAuth.mint(app, EaAuth.CLIENT_ID, "token", EaAuth.OPAQUE_SCOPES, "OPAQUE", lifetime).orEmpty() - val known = (sidecar.extra["contentIds"].orEmpty().split(',') + sidecar.extra["multiplayerId"].orEmpty()).map { it.trim() }.filter { it.isNotEmpty() }.toSet() - val lsx = EaLsx.start(app, EaLsx.Game(id, contentId, sidecar.title, sidecar.installVersion, locale, hardware, hashVersion, opaque, - System.currentTimeMillis() + (lifetime - 30) * 1000L, known)) + val lsx = EaLsx.start(app, EaLsx.Game(id, contentId, game.title, game.version, locale, hardware, hashVersion, opaque, + System.currentTimeMillis() + (lifetime - 30) * 1000L, game.contentIds)) val env = environment(id, contentId, locale, if (legacy && opaque.isNotEmpty()) opaque else access, access, opaque, EaAuth.load(app) ?: account) - val tmp = File(folder, "$ENV_FILE.tmp") - tmp.writeText(env.entries.joinToString("\r\n", postfix = "\r\n") { "${it.key}=${it.value}" }) - tmp.renameTo(File(folder, ENV_FILE)) val licenses = JSONArray() val notes = ArrayList() if (core != null) { - val ids = (listOf(contentId) + sidecar.extra["contentIds"].orEmpty().split(',')).map { it.trim() }.filter { it.isNotEmpty() }.distinct() + val ids = (listOf(contentId) + game.licenceIds).map { it.trim() }.filter { it.isNotEmpty() }.distinct() if (hardware == null) notes += "no-hardware" else { val hash = EaOoa.machineHash(hardware, hashVersion) for (content in ids) { @@ -125,7 +162,7 @@ object EaLaunch { } val licenseNote = if (core == null) "none-needed" else "v$hashVersion " + notes.joinToString(",") Log.i(TAG, "prepared $id lsx=$lsx legacy=$legacy opaque=${opaque.isNotEmpty()} licence=$licenseNote") - return reply.put("ok", true).put("lsx", lsx).put("license", licenseNote).put("licenses", licenses) + return reply.put("ok", true).put("lsx", lsx).put("license", licenseNote).put("licenses", licenses) to env } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientInstaller.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientInstaller.kt index d620388c82..cf6e484f49 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientInstaller.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientInstaller.kt @@ -5,6 +5,7 @@ import com.droiddeck.launcher.R import com.droiddeck.launcher.runtime.GuestCommand import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.stores.StoreInstallRoot +import com.droiddeck.launcher.stores.StoreInstalls import com.droiddeck.launcher.stores.download.DownloadQueue import com.droiddeck.launcher.stores.download.DownloadStage import com.droiddeck.launcher.stores.formatBytes @@ -215,7 +216,7 @@ internal class EpicClientInstaller(private val app: Context) : DownloadQueue.Dow val before = EpicClient.read(app) val needApp = !(before.version == launcher.version && File(state, "app/${launcher.version}/.droiddeck-ready").isFile) val needRuntime = !(before.runtimeVersion == runtime.version && File(state, "runtime/${runtime.version}/.droiddeck-ready").isFile) - val dir = EpicClient.downloadsDir(app).apply { mkdirs() } + val dir = EpicClient.downloadsDir(app).also { StoreInstalls.awaitDiscard(it) }.apply { mkdirs() } val gles = EpicClientSources.gles() val appPart = if (needApp) Part(listOf(launcher.url), File(dir, "${launcher.version}-${EpicClientSources.LAUNCHER_FILE}"), null, true) else null val desktopParts = if (needApp) EpicClientSources.DESKTOP.map { Part(it.urls, File(dir, it.file), it.sha256, false, it.size) } else emptyList() @@ -265,7 +266,7 @@ internal class EpicClientInstaller(private val app: Context) : DownloadQueue.Dow override fun cancel(deleteFiles: Boolean) { cancelled.set(true) runCatching { connection?.disconnect() } - if (deleteFiles) EpicClient.downloadsDir(app).deleteRecursively() + if (deleteFiles) StoreInstalls.deleteLater(EpicClient.downloadsDir(app)) } private fun length(url: String): Long { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt index 8ad240e651..6f77df7990 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt @@ -1,7 +1,6 @@ package com.droiddeck.launcher.stores.gog import android.content.Context -import android.os.Environment import android.util.Log import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -143,9 +142,9 @@ object GogComet { val pb = if (com.droiddeck.launcher.runtime.NativeGuest.forSession(context)) { val root = LinuxRuntime.rootDir(context) com.droiddeck.launcher.runtime.NativeGuest.processBuilder(context, root, - LinuxRuntime.binds(context, null, null, Environment.getExternalStorageDirectory(), null), guest).redirectErrorStream(true) + LinuxRuntime.binds(context, null, null, LinuxRuntime.sharedStorage(context), null), guest).redirectErrorStream(true) } else { - ProcessBuilder(LinuxRuntime.command(context, null, null, Environment.getExternalStorageDirectory(), guest)).redirectErrorStream(true).also { + ProcessBuilder(LinuxRuntime.command(context, null, null, LinuxRuntime.sharedStorage(context), guest)).redirectErrorStream(true).also { it.environment().apply { remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH") put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamClient.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamClient.kt new file mode 100644 index 0000000000..6574a31380 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamClient.kt @@ -0,0 +1,130 @@ +package com.droiddeck.launcher.stores.steam + +import android.content.Context +import android.os.Environment +import com.droiddeck.launcher.R +import com.droiddeck.launcher.frontend.AddedGames +import com.droiddeck.launcher.frontend.Library +import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.session.GameStorage +import com.droiddeck.launcher.session.SecondaryLibrary +import com.droiddeck.launcher.session.SessionPhase +import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.session.SessionService +import com.droiddeck.launcher.session.SessionState +import com.droiddeck.launcher.session.SteamLibraries +import com.droiddeck.launcher.stores.StoreInstallRoot +import org.json.JSONArray +import org.json.JSONObject +import java.io.File + +/** The active Steam client's folders as the app sees them. Reads storage; call off the main thread. */ +internal object SteamClient { + const val X86_64 = "x86_64" + + class Target( + val library: SteamLibraryFolders.Library, val engineHost: File, val label: String, + val freeBytes: Long, val removable: Boolean, val folder: Boolean, + ) + + fun activeArch(context: Context): String = SessionPrefs.activeSteamClientArch(context) + + private fun guestHome(arch: String) = if (arch == X86_64) "/root/.droiddeck-x64" else "/root" + + fun guestRoot(arch: String) = "${guestHome(arch)}/.local/share/Steam" + + private fun aliases(arch: String) = listOf(guestRoot(arch), "${guestHome(arch)}/.steam/steam", "${guestHome(arch)}/.steam/root") + + /** [guest] names [library]; the main library also answers to the client's other spellings of its root. */ + fun sameLibrary(context: Context, library: SteamLibraryFolders.Library, guest: String): Boolean { + if (library.guest == guest) return true + if (!library.main) return false + val arch = activeArch(context) + val wanted = SteamLibraryFolders.normalize(guest) ?: return false + return (aliases(arch) + guestRoot(arch)).mapNotNull(SteamLibraryFolders::normalize).contains(wanted) + } + + fun root(context: Context, arch: String = activeArch(context)): File = SessionPrefs.steamRoot(context, arch) + + fun registry(context: Context, arch: String = activeArch(context)): File = + File(LinuxRuntime.rootDir(context), guestHome(arch).removePrefix("/") + "/.steam/registry.vdf") + + fun loginUsers(context: Context, arch: String = activeArch(context)): File = File(root(context, arch), "config/loginusers.vdf") + + fun language(context: Context): String = + runCatching { SteamLibraryFolders.language(registry(context).readText()) }.getOrNull() ?: "english" + + fun mounts(context: Context): List { + val out = ArrayList() + GameStorage.effective(context)?.let { card -> SecondaryLibrary.CARD_GUESTS.forEach { out += SteamLibraryFolders.Mount(it, File(card.path)) } } + SteamLibraries.list(context).forEach { out += SteamLibraryFolders.Mount(it.guest, it.host) } + AddedGames.roots(context).forEach { out += SteamLibraryFolders.Mount(it.guest, it.host) } + StoreInstallRoot.externalRoots(context).forEach { (host, guest) -> out += SteamLibraryFolders.Mount(guest, host) } + out += SteamLibraryFolders.Mount("/root/Storage", Environment.getExternalStorageDirectory()) + return out + } + + /** Every library the client lists in libraryfolders.vdf that maps to a folder of the app. */ + fun libraries(context: Context, arch: String = activeArch(context)): List { + val root = root(context, arch) + val text = runCatching { File(root, "steamapps/libraryfolders.vdf").readText() }.getOrNull().orEmpty() + return SteamLibraryFolders.resolve( + SteamLibraryFolders.parse(text), guestRoot(arch), aliases(arch), root, mounts(context), LinuxRuntime.rootDir(context), + ) + } + + private fun canonical(file: File): String = runCatching { file.canonicalPath }.getOrDefault(file.absolutePath) + + /** The card and added libraries are written through the raw card view when Android allows it, as the session binds them. */ + private fun engineView(context: Context): (File) -> File { + val bases = listOfNotNull(GameStorage.effective(context)?.let { File(it.path) }) + SteamLibraries.list(context).map { it.host } + val seen = HashMap() + return { host -> + val path = host.absolutePath + val base = bases.filter { path == it.absolutePath || path.startsWith(it.absolutePath + "/") }.maxByOrNull { it.absolutePath.length } + if (base == null) host else { + val content = seen.getOrPut(base.absolutePath) { SecondaryLibrary.contentPath(base) } + if (content.absolutePath == base.absolutePath) host + else path.removePrefix(base.absolutePath).trimStart('/').let { if (it.isEmpty()) content else File(content, it) } + } + } + } + + class EngineLibraries(val libraries: List>) { + val json: String get() = JSONArray().apply { + for ((library, host) in libraries) put(JSONObject().put("host", host.absolutePath).put("guest", library.guest)) + }.toString() + + fun hostOf(library: SteamLibraryFolders.Library): File = + libraries.firstOrNull { it.first.guest == library.guest }?.second ?: library.host + } + + fun engineLibraries(context: Context, arch: String = activeArch(context)): EngineLibraries { + val view = engineView(context) + return EngineLibraries(libraries(context, arch).filter { it.host.isDirectory }.map { it to view(it.host) }) + } + + fun targets(context: Context): List { + val arch = activeArch(context) + val card = GameStorage.effective(context)?.let { canonical(File(it.path)) } + val known = Library.steamLibraries(context, arch).associate { (host, label) -> + canonical(host) to if (label == "internal") context.getString(R.string.games_internal) else label + } + val engine = engineLibraries(context) + return engine.libraries.mapNotNull { (library, host) -> + if (!library.host.isDirectory || !library.host.canWrite()) return@mapNotNull null + val path = canonical(library.host) + val onCard = card != null && (path == card || path.startsWith("$card/")) + val label = library.label.ifBlank { + if (library.main) context.getString(R.string.stores_target_internal) else known[path] ?: File(library.guest).name + } + Target(library, host, label, StoreInstallRoot.availableBytes(host), removable = onCard, folder = !library.main && !onCard) + } + } + + /** True while a session that can run the Steam client is up or starting. */ + fun clientMayRun(): Boolean { + val up = SessionState.running || (SessionState.phase != SessionPhase.IDLE && SessionState.phase != SessionPhase.FAILED) + return up && SessionState.mode != SessionService.MODE_RUN + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamEngine.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamEngine.kt new file mode 100644 index 0000000000..826d7ab0c5 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamEngine.kt @@ -0,0 +1,102 @@ +package com.droiddeck.launcher.stores.steam + +import android.content.Context +import android.os.SystemClock +import android.util.Log +import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.stores.StoresNative +import org.json.JSONArray +import org.json.JSONObject + +/** Blocking calls into the Rust engine; they reach the network, so never on the main thread. */ +internal object SteamEngine { + private const val TAG = "SteamEngine" + const val MISSING = "engine_missing" + const val MISSING_TEXT = "Steam: the store engine is not available" + + private const val RETRY_MS = 60_000L + /** After Steam refuses sign-ins for coming too often, wait well past its limit. */ + private const val THROTTLED_MS = 30 * 60_000L + + private val lock = Any() + @Volatile private var signedIn = false + /** The saved login the last sign-in attempt read, so a refusal rejects that login and not one saved since. */ + @Volatile var attempted: String? = null + private set + private var failed: JSONObject? = null + private var failedAt = 0L + + fun failure(error: String): JSONObject = JSONObject().put("ok", false).put("error", error) + + private fun call(op: String, block: () -> String): JSONObject { + if (!StoresNative.ensureLoaded()) return failure(MISSING) + val text = try { + block() + } catch (e: UnsatisfiedLinkError) { + Log.w(TAG, "$op: not in this engine build") + return failure(MISSING) + } catch (t: Throwable) { + Log.w(TAG, "$op: ${t.javaClass.simpleName}") + return failure(t.javaClass.simpleName) + } + return runCatching { JSONObject(text) }.getOrElse { failure("$op: unreadable answer") } + } + + fun signIn(context: Context): JSONObject { + synchronized(lock) { + if (signedIn) return JSONObject().put("ok", true) + failed?.takeIf { SystemClock.elapsedRealtime() - failedAt < waitAfter(it) }?.let { return it } + val roots = JSONArray() + .put(SessionPrefs.steamRoot(context, "arm64").absolutePath) + .put(SessionPrefs.steamRoot(context, SteamClient.X86_64).absolutePath) + val registry = SteamClient.registry(context).absolutePath + attempted = SteamStore.fingerprint(context) + val answer = call("signIn") { SteamNative.nativeSignIn(roots.toString(), registry, "") } + signedIn = answer.optBoolean("ok") + failed = if (signedIn) null else answer + failedAt = SystemClock.elapsedRealtime() + if (!signedIn) Log.w(TAG, "sign-in: ${answer.optString("error")}") + return answer + } + } + + private fun waitAfter(failure: JSONObject): Long { + val error = failure.optString("error") + return if ("RateLimitExceeded" in error || "Throttle" in error) THROTTLED_MS else RETRY_MS + } + + fun forget() { + synchronized(lock) { + failed = null + if (!signedIn) return + signedIn = false + try { + SteamNative.nativeSignOut() + } catch (t: Throwable) { + Log.w(TAG, "sign-out: ${t.javaClass.simpleName}") + } + } + } + + private fun signedCall(context: Context, op: String, block: () -> String): JSONObject { + synchronized(lock) { + val signIn = signIn(context) + if (!signIn.optBoolean("ok")) return signIn + val answer = call(op, block) + val error = answer.optString("error").lowercase() + if (!answer.optBoolean("ok") && listOf("logon", "sign", "session", "connect").any { it in error }) signedIn = false + return answer + } + } + + fun library(context: Context): JSONObject = signedCall(context, "library") { SteamNative.nativeLibrary() } + + fun plan(context: Context, appId: Int, language: String): JSONObject = + signedCall(context, "plan") { SteamNative.nativePlan(appId, language) } + + fun uninstall(appId: Int, steamRoot: String, host: String, guest: String, roots: String): JSONObject { + synchronized(lock) { + return call("uninstall") { SteamNative.nativeUninstall(appId, steamRoot, host, guest, roots) } + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamInstallJob.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamInstallJob.kt new file mode 100644 index 0000000000..dac4beb222 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamInstallJob.kt @@ -0,0 +1,144 @@ +package com.droiddeck.launcher.stores.steam + +import android.content.Context +import com.droiddeck.launcher.R +import com.droiddeck.launcher.stores.download.DownloadQueue +import com.droiddeck.launcher.stores.download.DownloadStage +import com.droiddeck.launcher.stores.download.StoreDownloadTier +import org.json.JSONObject +import java.io.File +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicBoolean +import java.util.concurrent.atomic.AtomicReference + +/** Called by the engine on its own threads. */ +interface SteamInstallListener { + fun onProgress(doneBytes: Long, totalBytes: Long, phase: String?) + fun onComplete(ok: Boolean, result: String?) +} + +internal class SteamInstallJob( + private val app: Context, + private val appId: Int, + private val libraryGuest: String, +) : DownloadQueue.DownloadJob { + private val cancelled = AtomicBoolean(false) + private val started = AtomicBoolean(false) + @Volatile private var discard = false + @Volatile private var installDir: String? = null + @Volatile private var createdDir = false + + override fun run(handle: DownloadQueue.JobHandle): String? { + started.set(true) + try { + return install(handle) + } finally { + if (discard) SteamStore.discardPartial(app, appId, libraryGuest, installDir, createdDir) + } + } + + private fun install(handle: DownloadQueue.JobHandle): String? { + handle.stage(DownloadStage.MANIFEST) + if (SteamClient.clientMayRun()) throw IllegalStateException(app.getString(R.string.steam_store_close_steam)) + val engine = SteamClient.engineLibraries(app) + val target = engine.libraries.firstOrNull { SteamClient.sameLibrary(app, it.first, libraryGuest) } + ?: throw IllegalStateException(app.getString(R.string.game_sync_err_steam_library)) + val signIn = SteamEngine.signIn(app) + if (!signIn.optBoolean("ok")) { + SteamStore.signInFailed(app, signIn.optString("error")) + throw IllegalStateException(SteamStore.errorText(app, signIn)) + } + val language = SteamClient.language(app) + val (plan, planned) = SteamStore.plan(app, appId, language) + if (plan == null) throw IllegalStateException(SteamStore.errorText(app, planned)) + installDir = plan.installDir + createdDir = SteamStore.claimFolder(app, appId, libraryGuest, File(target.second, "steamapps/common/${plan.installDir}")) + if (plan.installBytes > 0) handle.diskSize(plan.installBytes) + if (cancelled.get()) return null + + val tier = StoreDownloadTier.current(app) + val journal = File(app.filesDir, "${SteamStore.JOURNAL}/$appId").apply { mkdirs() } + handle.log("steam: $appId tier=${tier.id} window=${tier.networkWindow} process_workers=${tier.processWorkers}") + val done = CountDownLatch(1) + val succeeded = AtomicBoolean(false) + val answer = AtomicReference("") + val listener = object : SteamInstallListener { + private var stage: DownloadStage? = null + private var shown = -1L + + override fun onProgress(doneBytes: Long, totalBytes: Long, phase: String?) { + synchronized(this) { + val now = SteamLibraryFolders.stageOf(phase.orEmpty()) + if (now != stage) { + stage = now + shown = -1L + } + if (doneBytes < shown) return + shown = doneBytes + if (now == DownloadStage.DOWNLOAD) handle.progress(doneBytes, totalBytes) + else { + handle.stage(now) + if (totalBytes > 0) handle.stageProgress(doneBytes, totalBytes, bytes = true) + } + } + } + + override fun onComplete(ok: Boolean, result: String?) { + answer.set(result.orEmpty()) + succeeded.set(ok) + done.countDown() + } + } + val native = try { + SteamNative.nativeStart( + appId, language, SteamClient.root(app).absolutePath, target.second.absolutePath, target.first.guest, engine.json, + journal.absolutePath, "", tier.networkWindow.coerceIn(1, 128), tier.processWorkers, listener, + ) + } catch (e: UnsatisfiedLinkError) { + throw IllegalStateException(SteamEngine.MISSING_TEXT) + } + if (native == 0L && done.count > 0L) throw IllegalStateException(SteamStore.errorText(app, parse(answer.get()))) + if (native != 0L) { + try { + var forwarded = false + while (true) { + val finished = try { + done.await(CANCEL_POLL_MS, TimeUnit.MILLISECONDS) + } catch (e: InterruptedException) { + cancelled.set(true) + false + } + if (finished) break + if (!forwarded && cancelled.get()) { + runCatching { SteamNative.nativeCancel(native) } + forwarded = true + } + } + } finally { + runCatching { SteamNative.nativeRelease(native) } + } + } + val result = parse(answer.get()) + if (succeeded.get() && result.optBoolean("ok", true)) { + SteamStore.forgetJournal(app, appId, libraryGuest, target.first.guest) + return File(target.first.host, "steamapps/common/${plan.installDir}").path + } + if (cancelled.get() || result.optString("error") == "cancelled") return null + throw IllegalStateException(SteamStore.errorText(app, result)) + } + + private fun parse(text: String): JSONObject = + runCatching { JSONObject(text) }.getOrElse { SteamEngine.failure(text.ifBlank { "install failed" }) } + + override fun cancel(deleteFiles: Boolean) { + cancelled.set(true) + if (!deleteFiles) return + discard = true + if (!started.get()) SteamStore.discardPartial(app, appId, libraryGuest, null, SteamStore.createdFolder(app, appId, libraryGuest)) + } + + private companion object { + const val CANCEL_POLL_MS = 250L + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamLibraryFolders.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamLibraryFolders.kt new file mode 100644 index 0000000000..c22f365acc --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamLibraryFolders.kt @@ -0,0 +1,170 @@ +package com.droiddeck.launcher.stores.steam + +import com.droiddeck.launcher.storage.SteamStorage +import com.droiddeck.launcher.stores.download.DownloadStage +import java.io.File + +internal object SteamLibraryFolders { + data class Folder(val path: String, val label: String) + + class Mount(guest: String, val host: File) { + val guest: String = guest.trimEnd('/') + } + + data class Library(val guest: String, val host: File, val label: String, val main: Boolean) + + data class Installed(val appId: Int, val name: String, val installDir: String?, val library: Library, val sizeOnDisk: Long) + + /** Guest folders that exist only as binds of the session; without their bind they are empty mount points in the rootfs. */ + val BIND_ONLY = listOf("/mnt", "/media", "/storage", "/sdcard", "/root/Storage", "/root/ROMs", "/root/Games") + + private val TOKEN = Regex("\"((?:\\\\.|[^\"\\\\])*)\"|[{}]|//[^\n]*") + private val ACF = Regex("appmanifest_\\d+\\.acf") + private val SIZE_ON_DISK = Regex("^\\s*\"SizeOnDisk\"\\s*\"(\\d+)\"", setOf(RegexOption.MULTILINE, RegexOption.IGNORE_CASE)) + + private fun walk(text: String, pair: (blocks: List, key: String, value: String) -> Unit, closed: (blocks: List) -> Unit = {}) { + val blocks = ArrayList() + var key: String? = null + for (m in TOKEN.findAll(text)) { + val token = m.value + when { + token.startsWith("//") -> {} + token == "{" -> { blocks.add(key.orEmpty()); key = null } + token == "}" -> { if (blocks.isNotEmpty()) { closed(blocks); blocks.removeAt(blocks.lastIndex) }; key = null } + key == null -> key = unescape(m.groupValues[1]) + else -> { pair(blocks, key, unescape(m.groupValues[1])); key = null } + } + } + } + + private fun unescape(s: String): String { + if ('\\' !in s) return s + val out = StringBuilder(s.length) + var i = 0 + while (i < s.length) { + if (s[i] == '\\' && i + 1 < s.length) { out.append(s[i + 1]); i += 2 } else { out.append(s[i]); i++ } + } + return out.toString() + } + + private fun inRoot(blocks: List) = blocks.firstOrNull()?.equals("libraryfolders", ignoreCase = true) == true + + fun parse(text: String): List { + val out = ArrayList() + var path: String? = null + var label = "" + walk(text, pair = { blocks, key, value -> + if (!inRoot(blocks)) return@walk + if (blocks.size == 1 && key.isNotEmpty() && key.all(Char::isDigit)) out += Folder(value, "") + if (blocks.size == 2) when (key.lowercase()) { + "path" -> path = value + "label" -> label = value + } + }, closed = { blocks -> + if (blocks.size == 2 && inRoot(blocks)) path?.let { out += Folder(it, label) } + if (blocks.size == 2) { path = null; label = "" } + }) + return out + } + + fun normalize(path: String): String? { + val p = path.trim().replace(Regex("/+"), "/").trimEnd('/') + if (!p.startsWith("/") || p.split('/').any { it == ".." || it == "." }) return null + return p + } + + private fun under(path: String, prefix: String) = path == prefix || path.startsWith("$prefix/") + + fun hostFor(guest: String, mounts: List, rootfs: File): File? { + val path = normalize(guest) ?: return null + mounts.filter { it.guest.isNotEmpty() && under(path, it.guest) }.maxByOrNull { it.guest.length }?.let { m -> + val rest = path.removePrefix(m.guest).trimStart('/') + return if (rest.isEmpty()) m.host else File(m.host, rest) + } + if (BIND_ONLY.any { under(path, it) } || !under(path, "/root")) return null + return File(rootfs, path.removePrefix("/")) + } + + fun resolve(folders: List, mainGuest: String, aliases: Collection, mainHost: File, mounts: List, rootfs: File): List { + val mains = (aliases + mainGuest).mapNotNull(::normalize).toSet() + val listed = if (folders.any { normalize(it.path) in mains }) folders else listOf(Folder(mainGuest, "")) + folders + val out = ArrayList() + // The main library first, so an entry reaching the same folder under another path cannot take its place. + for (f in listed.sortedByDescending { normalize(it.path) in mains }) { + val guest = normalize(f.path) ?: continue + val main = guest in mains + val host = if (main) mainHost else hostFor(guest, mounts, rootfs) ?: continue + if (out.any { it.host.path == host.path || (main && it.main) }) continue + out += Library(guest, host, f.label.trim(), main) + } + return out.sortedByDescending { it.main } + } + + fun installed(libraries: List, read: (File) -> String? = { runCatching { it.readText() }.getOrNull() }): Map { + val out = LinkedHashMap() + for (library in libraries) { + val apps = File(library.host, "steamapps") + val names = apps.list() ?: continue + for (name in names.sorted()) { + if (!ACF.matches(name)) continue + val file = File(apps, name) + val text = read(file) ?: continue + val manifest = SteamStorage.parseManifest(file, text) ?: continue + if (!manifest.installed || SteamStorage.isTool(manifest) || manifest.appId in out) continue + val size = SIZE_ON_DISK.find(text)?.groupValues?.get(1)?.toLongOrNull() ?: 0L + out[manifest.appId] = Installed(manifest.appId, manifest.name, manifest.installDir, library, size) + } + } + return out + } + + data class SavedAccount(val id: String, val name: String) + + fun savedAccount(loginUsers: String): String? = savedLogin(loginUsers)?.name + + /** + * The account the client signs in with by itself, chosen as the engine does: `AutoLoginUser`, else the most recent, else the newest; + * none when that account opted out of Remember me. [SavedAccount.id] is its SteamID64. + */ + fun savedLogin(loginUsers: String, registry: String = ""): SavedAccount? { + val users = LinkedHashMap>() + walk(loginUsers, pair = { blocks, key, value -> + if (blocks.size == 2 && blocks[0].equals("users", ignoreCase = true)) users.getOrPut(blocks[1]) { HashMap() }[key.lowercase()] = value + }) + val accounts = users.entries.filter { it.key.all(Char::isDigit) && !it.value["accountname"].isNullOrBlank() } + val auto = autoLoginUser(registry) + val (id, user) = auto?.let { name -> accounts.firstOrNull { it.value["accountname"].equals(name, ignoreCase = true) } } + ?: accounts.firstOrNull { it.value["mostrecent"] == "1" } + ?: accounts.maxByOrNull { it.value["timestamp"]?.toLongOrNull() ?: 0L } + ?: return null + if (user["rememberpassword"] == "0") return null + val name = user["personaname"]?.takeIf { it.isNotBlank() } ?: user["accountname"]?.takeIf { it.isNotBlank() } ?: return null + return SavedAccount(id, name) + } + + fun autoLoginUser(registry: String): String? { + var found: String? = null + walk(registry, pair = { blocks, key, value -> + if (found == null && key.equals("AutoLoginUser", ignoreCase = true) && blocks.lastOrNull().equals("Steam", ignoreCase = true) && value.isNotBlank()) found = value + }) + return found + } + + fun language(registry: String): String? { + var found: String? = null + walk(registry, pair = { blocks, key, value -> + if (found == null && key.equals("language", ignoreCase = true) && blocks.lastOrNull().equals("Steam", ignoreCase = true) && value.isNotBlank()) found = value + }) + return found + } + + fun stageOf(phase: String): DownloadStage { + val p = phase.lowercase() + return when { + "verif" in p || "validat" in p -> DownloadStage.VERIFY + listOf("install", "regist", "final", "commit", "acf", "apply").any { it in p } -> DownloadStage.INSTALL + listOf("manifest", "plan", "prepar", "check", "scan", "clean", "alloc", "connect", "logon", "login", "sign").any { it in p } -> DownloadStage.MANIFEST + else -> DownloadStage.DOWNLOAD + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamNative.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamNative.kt new file mode 100644 index 0000000000..bce35d4500 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamNative.kt @@ -0,0 +1,12 @@ +package com.droiddeck.launcher.stores.steam + +object SteamNative { + @JvmStatic external fun nativeSignIn(steamRootsJson: String, registryVdfPath: String, caBundlePath: String): String + @JvmStatic external fun nativeSignOut() + @JvmStatic external fun nativeLibrary(): String + @JvmStatic external fun nativePlan(appId: Int, language: String): String + @JvmStatic external fun nativeStart(appId: Int, language: String, steamRoot: String, gameLibraryHost: String, gameLibraryGuest: String, libraryRootsJson: String, journalDir: String, caBundlePath: String, maxWorkers: Int, processWorkers: Int, listener: Any): Long + @JvmStatic external fun nativeCancel(handle: Long) + @JvmStatic external fun nativeRelease(handle: Long) + @JvmStatic external fun nativeUninstall(appId: Int, steamRoot: String, gameLibraryHost: String, gameLibraryGuest: String, libraryRootsJson: String): String +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamStore.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamStore.kt new file mode 100644 index 0000000000..bbcd1f425d --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamStore.kt @@ -0,0 +1,394 @@ +package com.droiddeck.launcher.stores.steam + +import android.content.Context +import android.content.Intent +import android.net.Uri +import android.util.Log +import android.widget.Toast +import androidx.annotation.StringRes +import com.droiddeck.launcher.R +import com.droiddeck.launcher.frontend.Library +import com.droiddeck.launcher.session.SessionService +import com.droiddeck.launcher.storage.SteamStorage +import com.droiddeck.launcher.stores.CatalogItem +import com.droiddeck.launcher.stores.InstalledStoreGame +import com.droiddeck.launcher.stores.Store +import com.droiddeck.launcher.stores.StoreAccounts +import com.droiddeck.launcher.stores.StoreBackend +import com.droiddeck.launcher.stores.StoreInstallRoot +import com.droiddeck.launcher.stores.StoreInstalls +import com.droiddeck.launcher.stores.StoreSizes +import com.droiddeck.launcher.stores.StoresState +import com.droiddeck.launcher.stores.download.DownloadEntry +import com.droiddeck.launcher.stores.download.DownloadQueue +import com.droiddeck.launcher.stores.download.DownloadState +import com.droiddeck.launcher.stores.download.SavedQueue +import com.droiddeck.launcher.stores.formatBytes +import org.json.JSONArray +import org.json.JSONObject +import java.io.File +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.Executors + +/** Games land in the active client's own libraries, registered as the client does, and only while no session can run the client. */ +internal object SteamStore { + private const val TAG = "SteamStore" + private const val PREFS = "steam-store" + internal const val JOURNAL = "steam-store/journal" + private const val CDN = "https://cdn.cloudflare.steamstatic.com/steam/apps/" + private const val LIBRARY = "library" + private const val LIBRARY_LABEL = "libraryLabel" + private val SIGNED_OUT = setOf("no_saved_login", "remember_me_off", "decrypt_failed") + private val REFUSED = Regex("logon_failed: eresult=(-?\\d+).*") + /** InvalidPassword, AccessDenied, AccountNotFound, Revoked, Expired, AccountLogonDenied. */ + private val REFUSALS = setOf(5, 15, 18, 26, 27, 63) + + class Plan(val installDir: String, val downloadBytes: Long, val installBytes: Long, val buildId: String, val linuxBuild: Boolean) { + companion object { + fun of(json: JSONObject): Plan? { + if (!json.optBoolean("ok")) return null + val dir = json.optString("installDir").takeIf { SteamStore.validDir(it) } ?: return null + return Plan(dir, json.optLong("downloadBytes"), json.optLong("installBytes"), json.optString("buildId"), json.optBoolean("linuxBuild")) + } + } + } + + internal const val LINUX_BUILD = "linux_build" + + /** Each plan with the language it was made for. */ + private val plans = ConcurrentHashMap>() + private val work = Executors.newSingleThreadExecutor { r -> Thread(r, "steam-store") } + @Volatile private var rejectedThisRun: String? = null + + fun key(appId: Int): String = "${Store.STEAM.id}:$appId" + + private fun validDir(dir: String) = dir.isNotBlank() && dir != "." && dir != ".." && '/' !in dir && '\\' !in dir + + private fun prefs(context: Context) = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE) + + private fun toast(context: Context, @StringRes text: Int) { + val app = context.applicationContext + StoresState.post { Toast.makeText(app, text, Toast.LENGTH_LONG).show() } + } + + /** Steam refusing the saved login; a connection failure or a throttled logon leaves the account as it is. */ + internal fun isSignInError(error: String) = + error in SIGNED_OUT || REFUSED.matchEntire(error)?.groupValues?.get(1)?.toIntOrNull() in REFUSALS + + internal fun errorText(context: Context, answer: JSONObject): String { + val error = answer.optString("error") + return when { + error == SteamEngine.MISSING -> SteamEngine.MISSING_TEXT + error == LINUX_BUILD -> context.getString(R.string.steam_store_linux_build) + isSignInError(error) -> context.getString(R.string.stores_login_title, Store.STEAM.label) + error.isBlank() -> "Steam: install failed" + else -> error + } + } + + internal fun fingerprint(context: Context): String { + val users = SteamClient.loginUsers(context) + val registry = SteamClient.registry(context) + return "${SteamClient.activeArch(context)}:${users.lastModified()}:${users.length()}:${registry.lastModified()}:${registry.length()}" + } + + private fun savedAccount(context: Context): SteamLibraryFolders.SavedAccount? { + val print = fingerprint(context) + if (print == rejectedThisRun || print == prefs(context).getString("rejected", null)) return null + val registry = runCatching { SteamClient.registry(context).readText() }.getOrDefault("") + return runCatching { SteamLibraryFolders.savedLogin(SteamClient.loginUsers(context).readText(), registry) }.getOrNull() + } + + /** Mirrors the client's saved sign-in into the store account; reads storage. A new name for the same account only relabels it. */ + fun syncAccount(context: Context): Boolean { + val saved = savedAccount(context) + val stored = StoreAccounts.read(context, Store.STEAM) + val storedId = stored?.optString("steam_id").orEmpty() + if (saved != null && saved.id == storedId) { + if (saved.name != stored?.optString("display_name")) { + StoreAccounts.write(context, Store.STEAM, JSONObject().put("display_name", saved.name).put("steam_id", saved.id)) + } + return false + } + if (saved == null && stored == null) return false + if (saved == null) StoreAccounts.clear(context, Store.STEAM) + else StoreAccounts.write(context, Store.STEAM, JSONObject().put("display_name", saved.name).put("steam_id", saved.id)) + plans.clear() + SteamEngine.forget() + StoresState.post { + StoresState.library.remove(Store.STEAM) + StoresState.problems.remove(Store.STEAM) + } + Log.i(TAG, if (saved == null) "no saved Steam sign-in" else "Steam sign-in found") + return true + } + + internal fun signInFailed(context: Context, error: String) { + if (!isSignInError(error)) return + val print = fingerprint(context) + if (SteamEngine.attempted?.let { it != print } == true) return + rejectedThisRun = print + if (error in SIGNED_OUT) prefs(context).edit().putString("rejected", print).apply() + StoreAccounts.clear(context, Store.STEAM) + StoresState.logLine("Steam: the saved sign-in was not accepted ($error)") + StoresState.post { + StoresState.accounts.remove(Store.STEAM) + StoresState.library.remove(Store.STEAM) + } + } + + fun downloading(): Boolean = StoresState.latestDownloads.any { + it.store == Store.STEAM && (it.state == DownloadState.RUNNING || it.state == DownloadState.QUEUED) + } + + /** A Steam store download holds every session that could start the Steam client. */ + fun blocksSession(intent: Intent?): Boolean { + val mode = intent?.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM + return mode != SessionService.MODE_RUN && (downloading() || StoresState.uninstalling.keys.any { it.startsWith("${Store.STEAM.id}:") }) + } + + internal fun syncLibrary(context: Context, force: Boolean) { + val app = context.applicationContext + if (force) plans.clear() + work.execute { + val answer = SteamEngine.library(app) + if (!answer.optBoolean("ok")) { + val error = answer.optString("error") + if (isSignInError(error)) signInFailed(app, error) + else StoresState.post { + StoresState.problems[Store.STEAM] = errorText(app, answer) + StoresState.library[Store.STEAM] = emptyList() + } + return@execute + } + val art = runCatching { Library.steamLibraryArt(app).toMap() }.getOrDefault(emptyMap()) + val items = items(answer.optJSONArray("games"), art) + StoresState.logLine("Steam: library has ${items.size} games") + StoresState.post { + StoresState.problems.remove(Store.STEAM) + StoresState.library[Store.STEAM] = items + } + } + } + + private fun items(games: JSONArray?, art: Map): List { + val out = ArrayList() + for (i in 0 until (games?.length() ?: 0)) { + val game = games?.optJSONObject(i) ?: continue + val id = game.optInt("appId").takeIf { it > 0 } ?: continue + val type = game.optString("type").lowercase() + if (type.isNotEmpty() && type != "game") continue + val name = game.optString("name").takeIf { it.isNotBlank() } ?: continue + out += CatalogItem( + Store.STEAM, id.toString(), name, + imageUrl = "$CDN$id/header.jpg", + tallImageUrl = art[id]?.let { Uri.fromFile(it).toString() } ?: "$CDN$id/library_600x900.jpg", + isFree = game.optBoolean("free"), + storeUrl = "https://store.steampowered.com/app/$id/", + owned = true, + ) + } + return out.distinctBy { it.id }.sortedBy { it.title.lowercase() } + } + + /** Reaches the network; call off the main thread. */ + internal fun plan(context: Context, appId: Int, language: String = SteamClient.language(context)): Pair { + val plan = plans[appId]?.takeIf { it.first == language }?.second ?: run { + val answer = SteamEngine.plan(context, appId, language) + val error = answer.optString("error") + if (isSignInError(error)) signInFailed(context, error) + Plan.of(answer)?.also { plans[appId] = language to it } ?: return null to answer + } + if (plan.linuxBuild && !protonMapped(context, appId)) return null to SteamEngine.failure(LINUX_BUILD) + return plan to JSONObject().put("ok", true) + } + + /** The engine installs the Windows depots; a game with a Linux build gets those from the client only when it is mapped to a Proton. */ + private fun protonMapped(context: Context, appId: Int): Boolean { + val config = runCatching { File(SteamClient.root(context), "config/config.vdf").readText() }.getOrNull() ?: return false + return SteamStorage.compatMappings(config)[appId.toString()]?.contains("proton", ignoreCase = true) == true + } + + internal fun plannedBytes(context: Context, item: CatalogItem): Long = + item.id.toIntOrNull()?.let { plan(context, it).first?.installBytes } ?: 0L + + fun requestInstall(context: Context, item: CatalogItem) { + if (SteamClient.clientMayRun()) { + toast(context, R.string.steam_store_close_steam) + return + } + StoresState.steamPicking = item + } + + fun install(context: Context, item: CatalogItem, target: SteamClient.Target) { + val app = context.applicationContext + val appId = item.id.toIntOrNull() ?: return + if (SteamClient.clientMayRun()) { + toast(app, R.string.steam_store_close_steam) + return + } + val plan = plans[appId]?.second + val needed = plan?.installBytes ?: 0L + val tagged = item.copy(extra = item.extra + mapOf(LIBRARY to target.library.guest, LIBRARY_LABEL to target.label)) + val entry = DownloadEntry( + Store.STEAM, item.id, item.title, cover = item.imageUrl, + bytesTotal = plan?.downloadBytes ?: 0L, location = target.label, + ) + SavedQueue.remember(app, tagged, target.library.host) + if (StoreInstallRoot.insufficientSpace(needed, target.freeBytes)) { + val error = app.getString(R.string.stores_storage_insufficient, formatBytes(needed), formatBytes(target.freeBytes)) + DownloadQueue.recordFailed(app, entry, error) { requestInstall(app, item) } + return + } + DownloadQueue.enqueue(app, entry) { SteamInstallJob(app, appId, target.library.guest) } + } + + internal fun restore(context: Context, item: CatalogItem) { + val app = context.applicationContext + val appId = item.id.toIntOrNull() ?: return + val guest = item.extra[LIBRARY] ?: return + work.execute { + // Either client may have finished the install from where this download was paused. + if (installedByAClient(app, appId)) { + DownloadQueue.dropHeld(key(appId)) + StoresState.logLine("Steam: \"${item.title}\" was finished by Steam; its saved download is dropped") + return@execute + } + StoresState.post { + SavedQueue.remember(app, item, null) + val entry = DownloadEntry(Store.STEAM, item.id, item.title, cover = item.imageUrl, location = item.extra[LIBRARY_LABEL].orEmpty()) + DownloadQueue.enqueue(app, entry) { SteamInstallJob(app, appId, guest) } + } + } + } + + private fun installedByAClient(context: Context, appId: Int): Boolean = listOf("arm64", SteamClient.X86_64).any { arch -> + runCatching { appId in SteamLibraryFolders.installed(SteamClient.libraries(context, arch)) }.getOrDefault(false) + } + + /** Removes a game like the client does; [fallback] deletes it when the engine cannot (no engine, or a library it does not map). */ + fun uninstall(context: Context, appId: Int, manifest: File?, fallback: () -> Boolean, onDone: () -> Unit = {}) { + val app = context.applicationContext + if (SteamClient.clientMayRun()) { + toast(app, R.string.steam_store_close_steam) + return + } + val key = key(appId) + if (key in StoresState.uninstalling) return + StoresState.uninstalling[key] = 0f + Thread({ + if (!DownloadQueue.stopForRemoval(app, key)) { + StoresState.logLine("Steam: kept $appId, its download is still running") + StoresState.post { StoresState.uninstalling.remove(key); onDone() } + return@Thread + } + val answer = try { runCatching { + val apps = manifest?.parentFile?.let(::canonical) + // The game may sit in the other client's library; that client's files are the ones to update. + val active = SteamClient.activeArch(app) + val found = listOf(active, if (active == SteamClient.X86_64) "arm64" else SteamClient.X86_64).firstNotNullOfOrNull { arch -> + val libraries = SteamClient.libraries(app, arch) + val chosen = if (apps == null) libraries else libraries.filter { canonical(File(it.host, "steamapps")) == apps } + SteamLibraryFolders.installed(chosen)[appId]?.let { arch to it } + } + val answer = if (found == null) SteamEngine.failure(SteamEngine.MISSING) else { + val (arch, game) = found + val engine = SteamClient.engineLibraries(app, arch) + SteamEngine.uninstall(appId, SteamClient.root(app, arch).absolutePath, engine.hostOf(game.library).absolutePath, game.library.guest, engine.json) + } + when { + answer.optString("error") != SteamEngine.MISSING -> answer + fallback() -> JSONObject().put("ok", true) + else -> SteamEngine.failure("remove_failed") + } + }.getOrElse { SteamEngine.failure(it.javaClass.simpleName) } } finally { DownloadQueue.releaseRemoval(key) } + val ok = answer.optBoolean("ok") + StoresState.logLine(if (ok) "Steam: uninstalled $appId" else "Steam: uninstall of $appId failed: ${answer.optString("error")}") + StoresState.post { + StoresState.uninstalling.remove(key) + if (ok) StoreSizes.onDisk.remove(key) + else Toast.makeText(app, errorText(app, answer), Toast.LENGTH_LONG).show() + onDone() + } + }, "steam-uninstall").start() + } + + private fun canonical(file: File): String = runCatching { file.canonicalPath }.getOrDefault(file.absolutePath) + + /** The engine keys an app's resume journal by library as `///`. */ + private fun libraryKey(guest: String): String = + "%08x".format(java.util.zip.CRC32().apply { update(guest.trimEnd('/').toByteArray()) }.value) + + private fun createdMarker(context: Context, appId: Int, guest: String) = + File(context.filesDir, "$JOURNAL/$appId/created-${libraryKey(guest)}") + + /** Drops the resume state of one app in one library; other libraries' downloads of the app keep theirs. */ + internal fun forgetJournal(context: Context, appId: Int, guest: String, engineGuest: String? = null) { + val app = File(context.filesDir, "$JOURNAL/$appId") + val spelled = engineGuest ?: runCatching { + SteamClient.engineLibraries(context).libraries.firstOrNull { SteamClient.sameLibrary(context, it.first, guest) }?.first?.guest + }.getOrNull() ?: guest + File(app, "$appId/${libraryKey(spelled)}").deleteRecursively() + createdMarker(context, appId, guest).delete() + File(app, "$appId").delete() + app.delete() + } + + /** Whether this install made the game folder in that library: decided by its first attempt and kept for every resume. */ + internal fun claimFolder(context: Context, appId: Int, guest: String, folder: File): Boolean { + val marker = createdMarker(context, appId, guest) + if (marker.isFile) return true + if (folder.exists()) return false + marker.parentFile?.mkdirs() + return runCatching { marker.writeText(folder.name); true }.getOrDefault(false) + } + + internal fun createdFolder(context: Context, appId: Int, guest: String): Boolean = createdMarker(context, appId, guest).isFile + + /** + * Removes what a cancelled download left; a finished install stays. The game folder goes only when this download made it + * ([createdDir]) and no other installed game uses it. + */ + internal fun discardPartial(context: Context, appId: Int, guest: String, installDir: String?, createdDir: Boolean) { + // An unmounted library keeps its journal and ownership record, so a later cancel can still clean it up. + val library = runCatching { + SteamClient.engineLibraries(context).libraries.firstOrNull { SteamClient.sameLibrary(context, it.first, guest) }?.second + }.getOrNull() ?: return + val apps = File(library, "steamapps") + val acf = File(apps, "appmanifest_$appId.acf") + val manifest = acf.takeIf { it.isFile }?.let { f -> runCatching { SteamStorage.parseManifest(f, f.readText()) }.getOrNull() } + if (manifest?.installed == true) { forgetJournal(context, appId, guest); return } + val claimed = runCatching { createdMarker(context, appId, guest).readText() }.getOrNull()?.ifEmpty { null } + val dir = (installDir ?: claimed ?: manifest?.installDir ?: plans[appId]?.second?.installDir)?.takeIf { validDir(it) } + val shared = dir != null && apps.listFiles { f -> f.name.startsWith("appmanifest_") && f.name != acf.name }.orEmpty().any { f -> + runCatching { SteamStorage.parseManifest(f, f.readText()) }.getOrNull()?.installDir == dir + } + if (dir != null && createdDir && !shared) StoreInstalls.deleteTree(File(apps, "common/$dir")) + StoreInstalls.deleteTree(File(apps, "downloading/$appId")) + File(apps, "downloading").listFiles { f -> f.name.startsWith("state_${appId}_") && f.name.endsWith(".patch") }?.forEach { it.delete() } + if (manifest != null) acf.delete() + forgetJournal(context, appId, guest) + StoresState.logLine("Steam: removed the unfinished download of $appId") + } +} + +internal object SteamBackend : StoreBackend { + override val store: Store = Store.STEAM + + override fun signIn(context: Context) { + StoresState.logLine("Steam: sign in from the Steam client") + } + + override fun signOut(context: Context) = SteamEngine.forget() + + override fun syncLibrary(context: Context, force: Boolean) = SteamStore.syncLibrary(context, force) + + override fun loadShelves(context: Context, force: Boolean) {} + + override fun search(context: Context, query: String): List = + StoresState.library[store].orEmpty().filter { it.title.contains(query, ignoreCase = true) } + + override fun install(context: Context, item: CatalogItem, root: File) = SteamStore.restore(context, item) + + override fun uninstall(context: Context, game: InstalledStoreGame) {} +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt index 32597faeb7..675be0a77b 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt @@ -58,17 +58,30 @@ object XboxBackend : StoreBackend { if (cached != null && !cached.needsRefresh(force)) { XboxGamertag.ensure(app); return@Thread } val response = Xodus.run(app, listOf("library", "--json", "--market", market)) val licenses = XboxCatalog.access(response, account, market, report = { StoresState.logLine("Xbox: $it") }) - val products = XboxCatalog.rawProducts(licenses.keys.toList(), market) val cloud = runCatching { XboxCatalog.cloudCatalog(market) } .onFailure { StoresState.logLine("Xbox: cloud lists unavailable (${it.javaClass.simpleName})") }.getOrNull() - val games = mergeEditions(products.mapNotNull { XboxCatalog.product(it, licenses, cloud) }).sortedBy { it.title.lowercase() } - StoresState.logLine("Xbox: library catalog requested=${licenses.size} returned=${products.size} supported=${games.size} " + - "filtered=${products.size - games.size} backend-skipped=${response.optInt("skippedEntitlements")} " + + // The PC entitlement list leaves out console purchases and free games; the streaming service lists them. + val titles = runCatching { XboxCloudSession.titleList(XboxCloudSession.get(app, account), fresh = true) } + .onFailure { StoresState.logLine("Xbox: cloud titles unavailable (${it.javaClass.simpleName})") }.getOrNull() + // Without the Game Pass lists an entitled title cannot be told apart from a purchase, so none are added. + val added = if (cloud == null) emptyMap() else titles?.entitled.orEmpty().filter { it !in licenses } + .associateWith { if (it in cloud.gamePass) "gamepass" else "owned" } + StoresState.logLine("Xbox: cloud titles=${titles?.ids?.size ?: -1} entitled=${titles?.entitled?.size ?: -1} " + + "added=${added.size} (owned ${added.values.count { it == "owned" }}, gamepass ${added.values.count { it == "gamepass" }})") + val entitlements = licenses + added + val returned = java.util.concurrent.atomic.AtomicInteger() + val supported = XboxCatalog.productBatches(entitlements.keys.toList(), market) { batch -> + returned.addAndGet(batch.size) + batch.mapNotNull { XboxCatalog.product(it, entitlements, cloud) } + } + val games = mergeEditions(supported).sortedBy { it.title.lowercase() } + StoresState.logLine("Xbox: library catalog requested=${entitlements.size} returned=${returned.get()} supported=${supported.size} " + + "shown=${games.size} backend-skipped=${response.optInt("skippedEntitlements")} " + "pc=${games.count { it.xboxPc }} cloud=${games.count { it.xboxCloud }} cloud-only=${games.count { !it.xboxPc }} " + "cloud-lists=${cloud?.gamePass?.size ?: -1}/${cloud?.all?.size ?: -1}") synchronized(this) { if (current != generation || StoreAccounts.signedInAs(app, store) != account) return@Thread - access = licenses + access = entitlements runCatching { XboxLibraryCache.write(app, account, market, games) } .onFailure { StoresState.logLine("Xbox: library cache could not be saved") } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt index cd3982ebdd..7afcaeb321 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt @@ -84,10 +84,42 @@ internal object XboxCatalog { return rawProducts(ids, market).mapNotNull { product(it, access) } } - fun rawProducts(ids: List, market: String = Xodus.market()): List { - return ids.map { it.uppercase() }.filter { productId.matches(it) }.distinct().chunked(25).flatMap { batch -> + fun launchArt(id: String, market: String = Xodus.market()): List = + rawProducts(listOf(id.uppercase()), market).firstOrNull()?.let(::launchArtUrls).orEmpty() + + internal fun launchArtUrls(json: JSONObject): List { + val images = objects(objects(json.optJSONArray("LocalizedProperties")).firstOrNull()?.optJSONArray("Images")) + val order = listOf("SuperHeroArt", "TitledHeroArt", "Screenshot", "Hero") + return images.filter { it.optString("ImagePurpose") in order } + .sortedBy { order.indexOf(it.optString("ImagePurpose")) } + .mapNotNull { image -> + val raw = image.optString("Uri") + val url = if (raw.startsWith("//")) "https:$raw" else raw + runCatching { java.net.URI(url) }.getOrNull()?.takeIf { + it.scheme == "https" && it.host in setOf("store-images.s-microsoft.com", "store-images.microsoft.com") && it.userInfo == null && it.port == -1 + }?.toString() + }.distinct().take(12) + } + + fun rawProducts(ids: List, market: String = Xodus.market()): List = productBatches(ids, market) { it } + + // 25 ids per request, up to 4 requests at a time; each batch is mapped as it arrives (a whole library of raw entries is large). + fun productBatches(ids: List, market: String = Xodus.market(), map: (List) -> List): List { + val batches = ids.map { it.uppercase() }.filter { productId.matches(it) }.distinct().chunked(25) + fun fetchBatch(batch: List): List { val body = get("https://displaycatalog.mp.microsoft.com/v7.0/products?bigIds=${batch.joinToString(",")}&market=$market&languages=en-us,neutral") - objects(body.optJSONArray("Products")).filter { it.optString("ProductId").uppercase() in batch } + return map(objects(body.optJSONArray("Products")).filter { it.optString("ProductId").uppercase() in batch }) + } + if (batches.size <= 1) return batches.flatMap(::fetchBatch) + val pool = java.util.concurrent.Executors.newFixedThreadPool(4) + try { + val tasks = batches.map { batch -> pool.submit(java.util.concurrent.Callable { fetchBatch(batch) }) } + return tasks.flatMap { task -> + try { task.get(60, java.util.concurrent.TimeUnit.SECONDS) } + catch (e: java.util.concurrent.ExecutionException) { throw e.cause ?: e } + } + } finally { + pool.shutdownNow() } } @@ -180,16 +212,28 @@ val CatalogItem.xboxPc: Boolean get() = extra["pc"] != "0" val CatalogItem.xboxCloud: Boolean get() = extra["cloud"] == "1" val CatalogItem.xboxCloudId: String get() = extra["cloudId"]?.takeIf { it.isNotEmpty() } ?: id +// One card per title: a cloud-only edition folds into the PC card (which then streams, and counts as owned when +// the cloud edition is); cloud-only editions with the same title become one card, owned first. internal fun mergeEditions(games: List): List { - fun key(title: String) = title.lowercase().replace(Regex("[^a-z0-9]+"), "") + fun key(title: String): String { + val lower = title.lowercase() + val letters = StringBuilder().apply { lower.codePoints().filter { Character.isLetterOrDigit(it) }.forEach { appendCodePoint(it) } } + return letters.toString().ifEmpty { lower.trim() } + } + val pcKeys = games.filter { it.xboxPc }.map { key(it.title) }.toSet() val cloudOnly = games.filter { !it.xboxPc && it.xboxCloud }.groupBy { key(it.title) } - val folded = HashSet() - val merged = games.map { game -> - if (!game.xboxPc || game.xboxCloud) game - else cloudOnly[key(game.title)]?.firstOrNull()?.let { console -> - folded.add(console.id) - game.copy(extra = game.extra + mapOf("cloud" to "1", "cloudId" to console.id)) - } ?: game + .mapValues { (_, list) -> list.sortedByDescending { it.owned }.first() } + return games.mapNotNull { game -> + val console = cloudOnly[key(game.title)] + when { + !game.xboxPc -> game.takeIf { key(game.title) !in pcKeys && (console == null || console === game) } + console == null -> game + else -> { + val cloudId = if (game.xboxCloud) game.extra["cloudId"].orEmpty() else console.id + val merged = game.copy(extra = game.extra + mapOf("cloud" to "1", "cloudId" to cloudId)) + if (console.owned && !game.owned) merged.copy(owned = true, subscription = false, extra = merged.extra + ("access" to "owned")) + else merged + } + } } - return merged.filter { it.id !in folded } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudPlayerActivity.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudPlayerActivity.kt index 354850932c..cd522ff3b8 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudPlayerActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudPlayerActivity.kt @@ -6,6 +6,7 @@ import android.content.Intent import android.graphics.Color import android.os.Bundle import android.view.Gravity +import android.view.View import android.view.KeyEvent import android.view.WindowManager import android.webkit.JavascriptInterface @@ -47,6 +48,8 @@ class XboxCloudPlayerActivity : ComponentActivity() { private lateinit var root: FrameLayout private var web: WebView? = null private var notice: LinearLayout? = null + private lateinit var art: XboxLaunchArt + private lateinit var artStatus: TextView private val worker = Executors.newSingleThreadExecutor() private val signalling = Executors.newCachedThreadPool() @Volatile private var session: XboxCloudSession.Session? = null @@ -68,15 +71,24 @@ class XboxCloudPlayerActivity : ComponentActivity() { root = FrameLayout(this).apply { setBackgroundColor(Color.BLACK) } setContentView(root) val requested = intent.getStringExtra("product").orEmpty() + art = XboxLaunchArt(this) { diag("cloud player $it") } + root.addView(art.view(intent.getStringExtra("title").orEmpty()) { cancelLaunch() }, FrameLayout.LayoutParams(-1, -1)) + artStatus = TextView(this).apply { + setTextColor(Color.WHITE); textSize = 16f; gravity = Gravity.CENTER; setShadowLayer(10f, 0f, 0f, Color.BLACK); visibility = View.GONE + } + root.addView(artStatus, FrameLayout.LayoutParams(-1, -2, Gravity.BOTTOM).apply { bottomMargin = 120 }) + art.load(requested) showNotice("Signing in to Xbox Cloud Gaming…", withButtons = false) worker.execute { val result = runCatching { val account = StoreAccounts.signedInAs(applicationContext, Store.XBOX) ?: error("Sign in to the Xbox store first.") val cached = XboxLibraryCache.read(applicationContext, account, Xodus.market())?.games?.firstOrNull { it.id == requested } val product = cached?.extra?.get("cloudId")?.takeIf { it.isNotEmpty() } ?: requested - webUrl = XboxCatalog.cloudUrl(requested, cached?.title ?: intent.getStringExtra("title").orEmpty(), product) + val name = cached?.title ?: intent.getStringExtra("title").orEmpty() + webUrl = XboxCatalog.cloudUrl(requested, name, product) val active = XboxCloudSession.get(applicationContext, account) - val title = XboxCloudSession.titles(active)[product] ?: error("This game can't be streamed with this account here.") + val title = XboxCloudSession.titleFor(active, product, name) { diag("cloud player: $it") } + ?: error("This game can't be streamed with this account here.") settings = XboxCloudSettings.load(applicationContext) startedWith = settings session = active.forStream(settings.region, settings.osName); titleId = title @@ -86,6 +98,7 @@ class XboxCloudPlayerActivity : ComponentActivity() { if (closed) return@runOnUiThread result.onSuccess { openPlayer() }.onFailure { diag("cloud player not started: ${it.javaClass.simpleName}: ${it.message?.take(160)}") + hideArt() showNotice(it.message ?: "Xbox Cloud Gaming could not start.", withButtons = true) } } @@ -130,6 +143,12 @@ class XboxCloudPlayerActivity : ComponentActivity() { fun call(id: Int, op: String, arg: String) { signalling.execute { val reply = runCatching { handle(op, arg) }.getOrElse { XboxCloudSession.Reply(0, it.javaClass.simpleName) } + if (closed && op == "start") { + val active = session; val path = sessionPath + if (active != null && path != null) runCatching { XboxCloudSession.request(active, "DELETE", "/$path") } + .onSuccess { diag("cloud player cancelled: session closed ${it.status}") } + return@execute + } if (reply.status !in 200..299) diag("cloud player $op: ${reply.status} ${reply.body.take(300)}") else if (op != "state" && op != "keepalive") diag("cloud player $op: ${reply.status}") runOnUiThread { web?.evaluateJavascript("window.__ddResolve($id, ${reply.status}, ${JSONObject.quote(reply.body)})", null) } @@ -137,12 +156,24 @@ class XboxCloudPlayerActivity : ComponentActivity() { } @JavascriptInterface - fun status(text: String) { android.util.Log.i("XboxCloudPlayer", "status: ${text.take(120)}") } + fun status(text: String) { + android.util.Log.i("XboxCloudPlayer", "status: ${text.take(120)}") + if (art.shown) runOnUiThread { if (art.shown) { artStatus.text = text; artStatus.visibility = if (text.isEmpty()) View.GONE else View.VISIBLE } } + } @JavascriptInterface fun playing() { diag("cloud player streaming") - runOnUiThread { web?.requestFocus() } + runOnUiThread { + web?.requestFocus() + if (art.shown) { web?.evaluateJavascript(FIRST_FRAME_JS, null); root.postDelayed({ hideArt() }, 6000) } + } + } + + @JavascriptInterface + fun firstFrame() { + if (art.shown) diag("cloud player first frame") + hideArt() } @JavascriptInterface @@ -154,6 +185,7 @@ class XboxCloudPlayerActivity : ComponentActivity() { @JavascriptInterface fun failed(stage: String, detail: String) { diag("cloud player failed at ${stage.take(40)}: ${detail.take(300)}") + hideArt() runOnUiThread { if (!closed) showNotice("The stream could not start ($stage).", withButtons = true) } } } @@ -164,6 +196,13 @@ class XboxCloudPlayerActivity : ComponentActivity() { return signals.op(op, arg).also { sessionPath = signals.path } } + private fun hideArt() { + art.hide() + runOnUiThread { artStatus.visibility = View.GONE } + } + + private fun cancelLaunch() { if (!isFinishing) { diag("cloud player launch cancelled"); finish() } } + private fun showNotice(text: String, withButtons: Boolean) { notice?.let { root.removeView(it) } val box = LinearLayout(this).apply { @@ -264,6 +303,10 @@ class XboxCloudPlayerActivity : ComponentActivity() { } return super.dispatchKeyEvent(event) } + if (art.shown && (event.keyCode == KeyEvent.KEYCODE_BUTTON_B || event.keyCode == KeyEvent.KEYCODE_BACK)) { + if (event.action == KeyEvent.ACTION_UP) cancelLaunch() + return true + } if (notice == null && guideKey(event)) return true if (event.keyCode == KeyEvent.KEYCODE_BACK) { if (event.action == KeyEvent.ACTION_UP) { if (notice == null) openMenu() else finish() } @@ -379,6 +422,10 @@ class XboxCloudPlayerActivity : ComponentActivity() { companion object { private const val DOUBLE_PRESS_MS = 350L + // Calls DDCloud.firstFrame() once the page's video has decoded a frame (or after 6 s). + private const val FIRST_FRAME_JS = "(function(){var t=Date.now();(function poll(){var v=document.querySelector('video');" + + "var n=v&&v.getVideoPlaybackQuality?v.getVideoPlaybackQuality().totalVideoFrames:0;" + + "if(n>0||(v&&v.currentTime>0)||Date.now()-t>6000){DDCloud.firstFrame();return;}setTimeout(poll,100);})();})()" fun intent(context: Context, productId: String, title: String): Intent = Intent(context, XboxCloudPlayerActivity::class.java) .putExtra("product", productId.uppercase()).putExtra("title", title) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSession.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSession.kt index 835a55166c..4638e47929 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSession.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSession.kt @@ -35,7 +35,7 @@ internal object XboxCloudSession { json.optString("userToken").takeIf { !json.isNull("userToken") && it.isNotEmpty() }, System.currentTimeMillis() + seconds * 1000).also { cached = it } } - fun clear() { cached = null; titleIds = null } + fun clear() { cached = null; titleList = null; looked = null } fun fromMainProcess(app: Context, account: String, timeoutSeconds: Long = 90): Session? { cached?.takeIf { it.account == account && it.fresh }?.let { return it } @@ -61,21 +61,64 @@ internal object XboxCloudSession { b.getString("baseUri").orEmpty(), regions, b.getString("userToken"), b.getLong("expiresAt")) } - @Volatile private var titleIds: Pair>? = null + class Titles(val ids: Map, val entitled: Set) - fun titles(session: Session): Map { - titleIds?.takeIf { it.first == session.account }?.let { return it.second } + @Volatile private var titleList: Pair? = null + + fun titles(session: Session): Map = titleList(session).ids + + // Entitled = details.hasEntitlement or isFreeInStore, as Greenlight's xcloud.ts by unknownskl (MIT). + fun titleList(session: Session, fresh: Boolean = false): Titles { + if (!fresh) titleList?.takeIf { it.first == session.account }?.let { return it.second } val reply = request(session, "GET", "/v2/titles") check(reply.status == 200) { "Xbox Cloud Gaming answered ${reply.status}" } val results = JSONObject(reply.body).optJSONArray("results") ?: JSONArray() - val map = (0 until results.length()).mapNotNull { index -> - val row = results.optJSONObject(index) ?: return@mapNotNull null - val product = row.optJSONObject("details")?.optString("productId")?.uppercase().orEmpty() + val ids = LinkedHashMap() + val entitled = LinkedHashSet() + for (index in 0 until results.length()) { + val row = results.optJSONObject(index) ?: continue + val details = row.optJSONObject("details") + val product = details?.optString("productId")?.uppercase().orEmpty() val title = row.optString("titleId") - if (product.matches(Regex("[A-Z0-9]{12}")) && title.isNotBlank() && title.length <= 64) product to title else null - }.toMap() - titleIds = session.account to map - return map + if (!product.matches(Regex("[A-Z0-9]{12}")) || title.isBlank() || title.length > 64) continue + ids.putIfAbsent(product, title) + if (details?.optBoolean("hasEntitlement") == true || details?.optBoolean("isFreeInStore") == true) entitled += product + } + return Titles(ids, entitled).also { titleList = session.account to it } + } + + @Volatile private var looked: Pair>? = null + + // Lookup by product id (POST /v2/titles with alternateIds) as Better xCloud's getTitleInfo (MIT). + fun titleFor(session: Session, productId: String, name: String = "", log: (String) -> Unit = {}): String? { + val product = productId.uppercase() + val list = titles(session) + list[product]?.let { return it } + val cache = looked?.takeIf { it.first == session.account }?.second ?: HashMap().also { looked = session.account to it } + cache[product]?.let { return it } + val body = JSONObject().put("alternateIds", JSONArray().put(product)).put("alternateIdType", "productId").toString() + val reply = runCatching { request(session, "POST", "/v2/titles", body) }.getOrNull() + val rows = reply?.takeIf { it.status == 200 }?.let { runCatching { JSONObject(it.body).optJSONArray("results") }.getOrNull() } + val row = rows?.optJSONObject(0) + val title = row?.optString("titleId").orEmpty() + val rowProduct = row?.optJSONObject("details")?.optString("productId")?.uppercase().orEmpty() + log("title lookup $product: http ${reply?.status ?: -1}, results ${rows?.length() ?: -1}, title ${title.ifEmpty { "-" }}, product ${rowProduct.ifEmpty { "-" }}") + if (title.isNotBlank() && title.length <= 64) { cache[product] = title; return title } + val key = nameKey(name) + if (key.length >= 4) { + val byName = list.values.filter { it.uppercase() == key }.distinct() + log("title by name $key: ${byName.joinToString().ifEmpty { "none" }}") + if (byName.size == 1) { cache[product] = byName[0]; return byName[0] } + } + return null + } + + private val EDITION_WORDS = Regex("(STANDARD|DELUXE|PREMIUM|ULTIMATE|GOLD|COMPLETE|DEFINITIVE|ENHANCED|ANNIVERSARY|GAMEOFTHEYEAR|GOTY)?EDITION$|GAMEPREVIEW$|FORWINDOWS(10)?$|XBOXSERIESXS$|XBOXONE$|PC$") + + internal fun nameKey(name: String): String { + var key = name.uppercase().replace(Regex("[^A-Z0-9]"), "") + repeat(3) { key = key.replace(EDITION_WORDS, "") } + return key } class Reply(val status: Int, val body: String) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt index fab04097d3..c86eff693c 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt @@ -137,7 +137,7 @@ internal class XboxInstaller(private val app: Context, private val item: Catalog delete = deleteFiles val process = child if (process == null) { - if (deleteFiles && !item.extra["baseId"].isNullOrBlank()) StoreInstalls.deleteTree(folder) + if (deleteFiles && !item.extra["baseId"].isNullOrBlank()) StoreInstalls.deleteLater(folder) else if (deleteFiles) StoreInstalls.discard(app, folder, emptyList()) return } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLaunchArt.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLaunchArt.kt new file mode 100644 index 0000000000..7e6cee72c7 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLaunchArt.kt @@ -0,0 +1,142 @@ +package com.droiddeck.launcher.stores.xbox + +import android.app.Activity +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.Crossfade +import androidx.compose.animation.core.Animatable +import androidx.compose.animation.core.LinearEasing +import androidx.compose.animation.core.tween +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.foundation.background +import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.onClick +import androidx.compose.ui.semantics.role +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import coil.compose.AsyncImage +import coil.request.ImageRequest +import com.droiddeck.launcher.R +import com.droiddeck.launcher.stores.Store +import com.droiddeck.launcher.stores.StoreAccounts +import com.droiddeck.launcher.ui.DroidDeckTheme +import kotlinx.coroutines.delay + +// The game's art as a slow slideshow while a cloud stream connects, until the first video frame. +// From Even Better Xcloud (BannerCloud) 7ec2a75. +internal class XboxLaunchArt(private val activity: Activity, private val log: (String) -> Unit) { + private val urls = mutableStateListOf() + private var visible by mutableStateOf(true) + @Volatile var shown = true + private set + + fun view(title: String, onCancel: () -> Unit): ComposeView = ComposeView(activity).apply { + setContent { DroidDeckTheme { LaunchArt(urls, title, visible, onCancel) } } + } + + fun load(product: String) { + if (product.isEmpty()) return + val app = activity.applicationContext + Thread({ + runCatching { + val account = StoreAccounts.signedInAs(app, Store.XBOX) ?: return@runCatching + val game = XboxLibraryCache.read(app, account, Xodus.market())?.games?.firstOrNull { it.id == product } + game?.imageUrl?.let { url -> activity.runOnUiThread { if (urls.isEmpty()) urls.add(url) } } + val more = XboxCatalog.launchArt(product) + if (more.isNotEmpty()) activity.runOnUiThread { urls.addAll(more.filter { it !in urls }) } + }.onFailure { log("launch art: ${it.javaClass.simpleName}") } + }, "launch-art").start() + } + + fun hide() { + shown = false + activity.runOnUiThread { visible = false } + } +} + +@Composable +private fun LaunchArt(images: List, title: String, visible: Boolean, onCancel: () -> Unit) { + AnimatedVisibility(visible, enter = fadeIn(tween(400)), exit = fadeOut(tween(700))) { + Box(Modifier.fillMaxSize().background(Color.Black)) { + var index by remember { mutableIntStateOf(0) } + LaunchedEffect(images.size) { + while (true) { + delay(SLIDE_MS) + if (images.size > 1) index = (index + 1) % images.size + } + } + Crossfade(targetState = images.getOrNull(index % images.size.coerceAtLeast(1)), animationSpec = tween(1400), + label = "launch-art") { url -> + if (url != null) Slide(url, index) + } + Box(Modifier.fillMaxSize().background(Brush.verticalGradient( + 0f to Color(0x66000000), 0.45f to Color(0x22000000), 0.78f to Color(0xB3000000), 1f to Color(0xF2000000)))) + Text(title, style = MaterialTheme.typography.headlineSmall, color = Color.White, maxLines = 2, + overflow = TextOverflow.Ellipsis, + modifier = Modifier.align(Alignment.BottomStart).padding(start = 40.dp, end = 220.dp, bottom = 34.dp)) + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp), + modifier = Modifier.align(Alignment.BottomEnd).padding(end = 40.dp, bottom = 30.dp) + .clip(RoundedCornerShape(50)).background(Color(0x99000000)) + .pointerInput(Unit) { detectTapGestures { onCancel() } } + .semantics(mergeDescendants = true) { role = Role.Button; onClick { onCancel(); true } } + .padding(start = 8.dp, end = 18.dp, top = 8.dp, bottom = 8.dp)) { + Box(Modifier.size(28.dp).clip(CircleShape).background(Color(0xFFE5484D)), contentAlignment = Alignment.Center) { + Text("B", color = Color.White, fontWeight = FontWeight.Bold, fontSize = 15.sp) + } + Text(stringResource(R.string.common_cancel), color = Color.White, fontSize = 16.sp, fontWeight = FontWeight.SemiBold) + } + } + } +} + +@Composable +private fun Slide(url: String, index: Int) { + val ctx = LocalContext.current + val progress = remember(url) { Animatable(0f) } + LaunchedEffect(url) { progress.animateTo(1f, tween((SLIDE_MS + 1600).toInt(), easing = LinearEasing)) } + val dir = if (index % 2 == 0) 1f else -1f + AsyncImage( + model = ImageRequest.Builder(ctx).data(url).crossfade(500).build(), + contentDescription = null, contentScale = ContentScale.Crop, + modifier = Modifier.fillMaxSize().graphicsLayer { + val p = progress.value + val s = 1.06f + 0.10f * p + scaleX = s; scaleY = s + translationX = dir * (p - 0.5f) * size.width * 0.04f + }) +} + +private const val SLIDE_MS = 5200L diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxManifest.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxManifest.kt index b33d1d0d77..1f6cb7851d 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxManifest.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxManifest.kt @@ -94,17 +94,16 @@ internal object XboxManifest { } fun executable(folder: File): String { - for (path in read(folder).executables) { + val listed = read(folder).executables + for (path in listed) { require(!path.startsWith('/') && !path.contains(':') && path.split('/').none { it == ".." || it.isEmpty() }) - var file = folder - for (part in path.split('/')) { - val matches = file.listFiles().orEmpty().filter { it.name.equals(part, true) } - require(matches.size == 1) { "Missing or ambiguous Xbox launch path." } - file = matches.single() - } + val file = path.split('/').fold(folder) { dir, part -> + dir?.listFiles().orEmpty().filter { it.name.equals(part, true) }.singleOrNull() + } ?: continue require(file.canonicalPath.startsWith(folder.canonicalPath + File.separator)) if (file.isFile) return forwarded(folder, file) ?: file.relativeTo(folder).invariantSeparatorsPath } + require(listed.isEmpty()) { "Missing or ambiguous Xbox launch path." } error("The Xbox package has no supported PC launch executable.") } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePlayerActivity.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePlayerActivity.kt index 2125bf802a..b4d12ba922 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePlayerActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePlayerActivity.kt @@ -5,6 +5,7 @@ import com.droiddeck.launcher.ui.focusGlide import android.content.Context import android.content.Intent import android.graphics.Color +import android.media.AudioAttributes import android.os.Build import android.os.Bundle import android.os.VibrationEffect @@ -75,6 +76,7 @@ class XboxNativePlayerActivity : ComponentActivity() { @Volatile private var connectedOnce = false @Volatile private var endedInBackground = false private var backgroundEnd: Runnable? = null + private lateinit var art: XboxLaunchArt private var notice: androidx.compose.ui.platform.ComposeView? = null @Volatile private var regionNames = emptyList() @Volatile private var serverName: String? = null @@ -103,7 +105,10 @@ class XboxNativePlayerActivity : ComponentActivity() { root = FrameLayout(this).apply { setBackgroundColor(Color.BLACK) } surfaceView = SurfaceView(this) root.addView(surfaceView, FrameLayout.LayoutParams(-1, -1)) - status = TextView(this).apply { setTextColor(Color.WHITE); textSize = 16f; gravity = Gravity.CENTER } + art = XboxLaunchArt(this) { log(it) } + root.addView(art.view(intent.getStringExtra("title").orEmpty()) { cancelLaunch() }, FrameLayout.LayoutParams(-1, -1)) + art.load(intent.getStringExtra("product").orEmpty()) + status = TextView(this).apply { setTextColor(Color.WHITE); textSize = 16f; gravity = Gravity.CENTER; setShadowLayer(10f, 0f, 0f, Color.BLACK) } root.addView(status, FrameLayout.LayoutParams(-1, -2, Gravity.BOTTOM).apply { bottomMargin = 120 }) overlay = TextView(this).apply { setTextColor(Color.WHITE); textSize = 12f; typeface = android.graphics.Typeface.MONOSPACE @@ -118,6 +123,7 @@ class XboxNativePlayerActivity : ComponentActivity() { val egl = EglBase.create().also { eglBase = it } val nativeVideo = XboxNativeVideo(this, egl) { log(it) }.also { video = it } + nativeVideo.onFirstFrame = { hideArt() } surfaceView.holder.addCallback(object : SurfaceHolder.Callback { override fun surfaceCreated(holder: SurfaceHolder) {} override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) { @@ -137,9 +143,12 @@ class XboxNativePlayerActivity : ComponentActivity() { private fun log(text: String) = com.droiddeck.launcher.stores.StoresState.logLine("Xbox: native player: ${text.take(240)}") private fun show(text: String) = runOnUiThread { status.text = text; status.visibility = if (text.isEmpty()) android.view.View.GONE else android.view.View.VISIBLE } + private fun hideArt() { if (art.shown) { art.hide(); show("") } } + private fun cancelLaunch() { if (!isFinishing) { log("launch cancelled"); finish() } } private fun fail(stage: String, detail: String) { log("failed at $stage: $detail") + art.hide() if (closed) return if (connectedOnce) showNotice("The connection to the cloud console was lost", "The stream stopped reaching this device ($detail). Restart the stream to play again: the game starts over, " + @@ -232,12 +241,14 @@ class XboxNativePlayerActivity : ComponentActivity() { val active = (shared ?: XboxCloudSession.get(applicationContext, account)).forStream(settings.region, settings.osName) regionNames = active.regionList.map { it.name } serverName = active.regionList.firstOrNull { it.baseUri == active.baseUri }?.name - val title = XboxCloudSession.titles(active)[product] ?: error("This game can't be streamed with this account here.") + val title = XboxCloudSession.titleFor(active, product, cached?.title ?: intent.getStringExtra("title").orEmpty()) { log(it) } + ?: error("This game can't be streamed with this account here.") val signals = XboxCloudSignalling(active, title, settings).also { signalling = it } log("$product -> $title, region ${java.net.URI(active.baseUri).host}, frame gen ${settings.frameGen}") show("Starting the game on Xbox Cloud Gaming…") expect("start", signals.start()) + if (closed) { runCatching { signals.stop() }.onSuccess { log("cancelled: session closed ${it?.status}") }; return } var connected = false var waited = 0 while (!closed) { @@ -270,7 +281,15 @@ class XboxNativePlayerActivity : ComponentActivity() { log("latency: instant input ${settings.instantInput}, small buffer ${settings.smallBuffer}, fast decoder ${settings.fastDecoder}, " + "zero-copy ${zeroSurface != null}") val f = PeerConnectionFactory.builder() - .setAudioDeviceModule(JavaAudioDeviceModule.builder(applicationContext).createAudioDeviceModule()) + // WebRTC defaults to voice-call audio (mono, speaker/earpiece only); game audio follows + // the normal output (HDMI, USB, Bluetooth) and keeps the stream's stereo. + .setAudioDeviceModule(JavaAudioDeviceModule.builder(applicationContext) + .setAudioAttributes(AudioAttributes.Builder() + .setUsage(AudioAttributes.USAGE_GAME) + .setContentType(AudioAttributes.CONTENT_TYPE_MOVIE) + .build()) + .setUseStereoOutput(true) + .createAudioDeviceModule()) .setVideoDecoderFactory(org.webrtc.DroidDeckLowLatencyDecoderFactory(egl.eglBaseContext, settings.fastDecoder, zeroSurface) { zeroCopyFrames++ } .also { decoders = it }) .setVideoEncoderFactory(DefaultVideoEncoderFactory(egl.eglBaseContext, true, true)) @@ -365,7 +384,7 @@ class XboxNativePlayerActivity : ComponentActivity() { when (state) { PeerConnection.PeerConnectionState.CONNECTED -> { connectedOnce = true - show("") + if (art.shown) root.postDelayed({ hideArt() }, 6000) else show("") video?.setFpsTarget(settings.fpsTarget) video?.setFrameGeneration(effectiveFrameGen()) } @@ -427,6 +446,10 @@ class XboxNativePlayerActivity : ComponentActivity() { } return super.dispatchKeyEvent(event) } + if (art.shown && (event.keyCode == KeyEvent.KEYCODE_BUTTON_B || event.keyCode == KeyEvent.KEYCODE_BACK)) { + if (event.action == KeyEvent.ACTION_UP) cancelLaunch() + return true + } if (isGuide(event)) { if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) { val pending = pendingNexus diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeVideo.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeVideo.kt index 193f4e58b7..7db236e739 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeVideo.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeVideo.kt @@ -54,6 +54,7 @@ internal class XboxNativeVideo(private val context: Context, eglBase: EglBase, p private var nextDueNs = 0L @Volatile var frames = 0L private set + @Volatile var onFirstFrame: (() -> Unit)? = null fun setSurface(target: Surface?, width: Int, height: Int, displayRefreshHz: Float) = synchronized(lock) { refreshHz = displayRefreshHz @@ -126,7 +127,10 @@ internal class XboxNativeVideo(private val context: Context, eglBase: EglBase, p if (nextDueNs == 0L || now - nextDueNs > interval) nextDueNs = now if (now + 4_000_000L < nextDueNs) true else { nextDueNs += interval; false } } - if (attached && buffer != null && !skip) { WaylandCompositor.nativeStreamFrame(buffer); frames++ } + if (attached && buffer != null && !skip) { + WaylandCompositor.nativeStreamFrame(buffer); frames++ + onFirstFrame?.let { onFirstFrame = null; it() } + } buffer?.close() held.addLast(image) while (held.size > 2) held.removeFirst().close() diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt index 39866fceea..07d47c78cd 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt @@ -1,7 +1,6 @@ package com.droiddeck.launcher.stores.xbox import android.content.Context -import android.os.Environment import com.droiddeck.launcher.core.AddonPack import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent import com.droiddeck.launcher.runtime.LinuxRuntime @@ -82,7 +81,7 @@ internal object Xodus { networkLink.start() val runtime = (runtimeDirectory ?: File(app.filesDir, "xbox-runtime")).apply { mkdirs() } val root = LinuxRuntime.rootDir(app) - val external = Environment.getExternalStorageDirectory() + val external = LinuxRuntime.sharedStorage(app) val extraBinds = StoreInstallRoot.externalBindSpecsForXodus(app) val binds = LinuxRuntime.binds(app, null, null, external, extraBinds) val fastPathPreloaded = runCatching { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AddonBrowser.kt b/app/src/main/java/com/droiddeck/launcher/ui/AddonBrowser.kt index 052241a8b9..fc62ea718d 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AddonBrowser.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AddonBrowser.kt @@ -273,7 +273,7 @@ internal fun AddonBrowserDialog(targets: List, initial: WowAdd var text by remember { mutableStateOf("") } var category by remember { mutableStateOf(null) } var sort by remember { mutableStateOf(WowAddonCatalog.Sort.POPULAR) } - var source by remember { mutableStateOf(AddonSource.WOWI) } + var source by remember(curseForge != null) { mutableStateOf(if (curseForge != null) AddonSource.CURSE else AddonSource.WOWI) } val curse = if (source == AddonSource.CURSE && link != null) curseForge else null LaunchedEffect(link) { link?.refresh() } var notice by remember { mutableStateOf(null) } @@ -425,8 +425,8 @@ internal fun AddonBrowserDialog(targets: List, initial: WowAdd } val sourceChip: @Composable () -> Unit = { if (curseForge != null) BrowseDropdown(sourceName) { first, done -> - MenuItem(stringResource(R.string.addons_source_wowi), source == AddonSource.WOWI, focusRequester = first) { source = AddonSource.WOWI; done() } - MenuItem(stringResource(R.string.addons_source_curse), source == AddonSource.CURSE) { source = AddonSource.CURSE; done() } + MenuItem(stringResource(R.string.addons_source_wowi), curse == null, focusRequester = first) { source = AddonSource.WOWI; done() } + MenuItem(stringResource(R.string.addons_source_curse), curse != null) { source = AddonSource.CURSE; done() } } } val categoryChip: @Composable () -> Unit = { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AgentSetupView.kt b/app/src/main/java/com/droiddeck/launcher/ui/AgentSetupView.kt index 25b01904d8..615d59cb61 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AgentSetupView.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AgentSetupView.kt @@ -46,6 +46,7 @@ import androidx.compose.ui.platform.testTag import com.droiddeck.launcher.agent.AgentSetup.Status import com.droiddeck.launcher.agent.AgentSetup.Step import com.droiddeck.launcher.core.WirelessAdbPairingService +import com.droiddeck.launcher.session.QuestExperimental @Composable internal fun AgentSetupView(modifier: Modifier, firstControl: Modifier = Modifier, onDone: () -> Unit = {}) { @@ -104,11 +105,16 @@ internal fun AgentSetupView(modifier: Modifier, firstControl: Modifier = Modifie var keyOpen by rememberSaveable(harness.id) { mutableStateOf(false) } val (title, hint) = labels(step, harness.name, keyed) val lab = AgentHost.lab?.takeIf { it.prepare && it.running } + val questConnection = step == Step.CONNECTION && status != Status.DONE && QuestExperimental.isSupported() val detail = when { step == Step.PREPARE && lab != null -> stringResource(R.string.agent_prepare_progress, lab.permille / 10, clock(lab.etaSeconds.toLong().coerceAtLeast(0))) keyed && status == Status.DONE && AgentSetup.detail[step] == null -> harness.providers.filter { it.id in AgentSetup.keys }.joinToString(" · ") { it.name }.ifEmpty { stringResource(R.string.agent_step_free_models) } + // The Quest hint holds the one-time commands, so it stays under the status until the step passes. + questConnection -> AgentSetup.detail[step]?.let { "$it\n$hint" } ?: hint + // The Quest hint is setup instructions; once connected, the row says what it is for. + step == Step.CONNECTION && QuestExperimental.isSupported() -> AgentSetup.detail[step] ?: stringResource(R.string.agent_step_connection_hint) else -> AgentSetup.detail[step] ?: hint } // Shown while the sign-in is pending, so it is still there after a trip to the browser for the key. @@ -121,6 +127,7 @@ internal fun AgentSetupView(modifier: Modifier, firstControl: Modifier = Modifie Status.TODO, Status.FAILED -> CheckState.WARN }, title, detail, divider = index < steps.lastIndex && !showKey, + detailLines = if (questConnection) Int.MAX_VALUE else 2, ) { val blocked = (step in setOf(Step.SIGN_IN, Step.GITHUB, Step.BUILD_TOOLS) && AgentSetup.status[Step.INSTALL] != Status.DONE) || (step == Step.PREPARE && AgentSetup.status[Step.BUILD_TOOLS] != Status.DONE) @@ -258,7 +265,9 @@ internal fun agentStorageWarning(item: AgentStorage.Item) = when (item) { @Composable private fun labels(step: Step, harness: String, keyed: Boolean = false): Pair = when (step) { - Step.CONNECTION -> stringResource(R.string.agent_step_connection) to stringResource(R.string.agent_step_connection_hint) + Step.CONNECTION -> stringResource(R.string.agent_step_connection) to + if (QuestExperimental.isSupported()) stringResource(R.string.agent_step_connection_quest_hint, LocalContext.current.packageName) + else stringResource(R.string.agent_step_connection_hint) Step.INSTALL -> stringResource(R.string.agent_step_install, harness) to stringResource(R.string.agent_step_install_hint) Step.SIGN_IN -> stringResource(R.string.agent_step_sign_in, harness) to stringResource(if (keyed) R.string.agent_step_sign_in_key_hint else R.string.agent_step_sign_in_hint) Step.GITHUB -> stringResource(R.string.agent_step_github) to stringResource(R.string.agent_step_github_hint) @@ -267,7 +276,7 @@ private fun labels(step: Step, harness: String, keyed: Boolean = false): Pair R.string.agent_action_pair + Step.CONNECTION -> if (QuestExperimental.isSupported()) R.string.agent_action_allow else R.string.agent_action_pair Step.INSTALL -> R.string.agent_action_install Step.SIGN_IN, Step.GITHUB -> R.string.agent_action_sign_in Step.BUILD_TOOLS -> R.string.agent_action_install @@ -276,6 +285,7 @@ private fun action(step: Step): Int = when (step) { /** The pairing DroidDeck already uses for the phantom process fix; the agent reuses its key. */ private fun pair(context: android.content.Context) { + if (QuestExperimental.isSupported()) return AgentSetup.trustOnDevice(context) if (!WirelessAdbPairingService.notificationsEnabled(context)) { context.startActivity(android.content.Intent(android.provider.Settings.ACTION_APP_NOTIFICATION_SETTINGS) .putExtra(android.provider.Settings.EXTRA_APP_PACKAGE, context.packageName) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomArtPanel.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomArtPanel.kt new file mode 100644 index 0000000000..8d4c3b8bc8 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomArtPanel.kt @@ -0,0 +1,129 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.animation.Crossfade +import androidx.compose.animation.core.LinearEasing +import androidx.compose.animation.core.RepeatMode +import androidx.compose.animation.core.animateFloat +import androidx.compose.animation.core.infiniteRepeatable +import androidx.compose.animation.core.rememberInfiniteTransition +import androidx.compose.animation.core.tween +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxWithConstraints +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.widthIn +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import coil.compose.AsyncImage +import com.droiddeck.launcher.R +import com.droiddeck.launcher.agent.AgentGuest +import com.droiddeck.launcher.frontend.Library +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.withContext + +private const val ART_POLL_MS = 2_000L +private const val RESCAN_MS = 30_000L +private const val DRIFT_MS = 28_000 + +/** The game's art filling the bottom screen with a slow pan and zoom, for the running game or the one selected in Steam. */ +@Composable +internal fun ArtPanel(runningGame: () -> String?) { + val context = LocalContext.current.applicationContext + var game by remember { mutableStateOf(null) } + var playing by remember { mutableStateOf(false) } + FullScreenChrome() + LaunchedEffect(Unit) { + var games = emptyList() + var scanned = 0L + while (isActive) { + val running = runningGame()?.toLongOrNull() + val shown = running ?: withContext(Dispatchers.IO) { runCatching { AgentGuest.selectedSteamAppId(context) }.getOrNull() } + val missing = games.isEmpty() || (shown != null && games.none { it.appId.toLong() == shown }) + if (missing && (scanned == 0L || System.currentTimeMillis() - scanned > RESCAN_MS)) { + withContext(Dispatchers.IO) { runCatching { Library.steamGames(context) }.getOrNull() }?.let { games = it } + scanned = System.currentTimeMillis() + } + // Reloaded every poll so stats that failed to load once still arrive; the crossfade is keyed by app id. + // A running game that cannot be loaded is not stood in for by another game's art. + val loaded = withContext(Dispatchers.IO) { IdleHome.load(context, games, shown) } + ?.takeIf { running == null || (it.appId.toLong() and 0xFFFFFFFFL) == running } + if (loaded != game) game = loaded + playing = running != null && running == game?.appId?.toLong() + delay(ART_POLL_MS) + } + } + Box(Modifier.fillMaxSize().background(Color.Black).testTag("bottom-art")) { + // Keyed by app id so a refreshed game keeps its pan; the fading-out scene keeps its last details. + val seen = remember { HashMap() } + game?.let { seen[it.appId] = it } + Crossfade(game?.appId, label = "art") { id -> + // Read from state here, so refreshed details for the same game recompose this scene. + val shown = game?.takeIf { it.appId == id } ?: seen[id] + if (shown != null) ArtScene(shown, playing) + } + } +} + +@Composable +private fun ArtScene(game: IdleGame, playing: Boolean) { + val drift = rememberInfiniteTransition(label = "drift") + val t by drift.animateFloat(0f, 1f, infiniteRepeatable(tween(DRIFT_MS, easing = LinearEasing), RepeatMode.Reverse), label = "t") + val eased = t * t * (3 - 2 * t) + BoxWithConstraints(Modifier.fillMaxSize()) { + if (game.art != null) AsyncImage( + model = game.art, contentDescription = null, contentScale = ContentScale.Crop, + modifier = Modifier.fillMaxSize().graphicsLayer { + val scale = 1.08f + 0.14f * eased + scaleX = scale + scaleY = scale + translationX = (eased - 0.5f) * size.width * (scale - 1f) + translationY = (0.5f - eased) * size.height * (scale - 1f) * 0.5f + }, + ) + Box( + Modifier.fillMaxSize().background( + Brush.verticalGradient(0.55f to Color.Transparent, 1f to Color.Black.copy(alpha = 0.78f)), + ), + ) + Column(Modifier.align(Alignment.BottomStart).padding(28.dp).fillMaxWidth(0.6f)) { + Text( + stringResource(if (playing) R.string.bottom_art_playing else if (game.highlighted) R.string.bottom_idle_selected + else R.string.bottom_idle_recent).uppercase(), + fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.4.sp, color = Color.White.copy(alpha = 0.7f), + ) + if (game.logo != null) AsyncImage( + model = game.logo, contentDescription = game.name, contentScale = ContentScale.Fit, alignment = Alignment.BottomStart, + modifier = Modifier.padding(top = 10.dp).widthIn(max = 460.dp).height(128.dp), + ) else Text( + game.name, fontSize = 34.sp, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 2, + overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(top = 4.dp), + ) + Text(idleDetails(game), fontSize = 14.sp, color = Color.White.copy(alpha = 0.75f), maxLines = 1, + modifier = Modifier.padding(top = 8.dp)) + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomBrightness.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomBrightness.kt new file mode 100644 index 0000000000..2cc7f31fad --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomBrightness.kt @@ -0,0 +1,84 @@ +package com.droiddeck.launcher.ui + +import android.content.Context +import android.provider.Settings +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.DarkMode +import androidx.compose.material.icons.outlined.LightMode +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.droiddeck.launcher.R +import com.droiddeck.launcher.session.SessionPrefs + +/** The bottom screen's own brightness, in percent. It never goes below [MIN] so the slider cannot leave the screen dark. */ +internal object BottomBrightness { + const val MIN = 5 + const val STEP = 5 + + /** The window brightness to use while the screen is on, or null to follow the system. */ + fun level(context: Context): Float? = SessionPrefs.bottomBrightness(context)?.let { clamp(it) / 100f } + + fun clamp(percent: Int): Int = percent.coerceIn(MIN, 100) + + /** Where the slider starts: the saved level, else the system brightness as a percentage. */ + fun initial(context: Context): Int = clamp(SessionPrefs.bottomBrightness(context) ?: runCatching { + Settings.System.getInt(context.contentResolver, Settings.System.SCREEN_BRIGHTNESS) * 100 / 255 + }.getOrDefault(60)) + + /** Auto-dim never brightens a screen the user set darker, here or in the system's manual brightness. */ + fun dimmed(context: Context, dim: Float): Float = minOf(dim, level(context) ?: system(context) ?: dim) + + private fun system(context: Context): Float? = runCatching { + val resolver = context.contentResolver + if (Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE) != Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL) null + else Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS) / 255f + }.getOrNull() +} + +/** A dropdown under the bottom bar: a brightness slider and the screen-off button. A tap outside closes it. */ +@Composable +internal fun BrightnessDrop(percent: Int, onChange: (Int) -> Unit, onScreenOff: () -> Unit, onDismiss: () -> Unit) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val shape = RoundedCornerShape(16.dp) + Box( + Modifier.fillMaxSize().clickable(remember { MutableInteractionSource() }, indication = null, onClick = onDismiss) + .padding(top = BAR_HEIGHT, start = 12.dp, end = 12.dp), + ) { + Row( + Modifier.fillMaxWidth().testTag("bottom-brightness").clip(shape).background(colors.surface).border(1.dp, pal.line, shape) + .clickable(remember { MutableInteractionSource() }, indication = null) {} + .padding(horizontal = 12.dp, vertical = 6.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(10.dp), + ) { + Icon(Icons.Outlined.LightMode, contentDescription = null, tint = colors.onSurfaceVariant, modifier = Modifier.size(22.dp)) + ValueSlider( + percent, BottomBrightness.MIN..100, BottomBrightness.STEP, true, stringResource(R.string.bottom_brightness), { "$it%" }, + modifier = Modifier.weight(1f), track = 32.dp, onChange = onChange, + ) + BarButton(stringResource(R.string.bottom_screen_off), Modifier.testTag("bottom-brightness-off"), vector = Icons.Filled.DarkMode, + onClick = onScreenOff) + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomChrome.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomChrome.kt new file mode 100644 index 0000000000..2d714863e2 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomChrome.kt @@ -0,0 +1,88 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectVerticalDragGestures +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.ExpandMore +import androidx.compose.material3.Icon +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.dp +import com.droiddeck.launcher.R + +/** Whether the bottom screen's bar is shown. Panels that need the whole screen ask for it hidden; a pull tab brings it back. */ +internal object BottomChrome { + private val requests = mutableIntStateOf(0) + + /** The user's choice, which wins until a panel's request changes; null follows the requests. */ + private val chosen = mutableStateOf(null) + + val barShown: Boolean get() = chosen.value ?: (requests.intValue == 0) + + fun show(shown: Boolean) { + chosen.value = shown + } + + fun reset() { + chosen.value = null + } + + internal fun request(on: Boolean) { + requests.intValue = (requests.intValue + if (on) 1 else -1).coerceAtLeast(0) + chosen.value = null + } +} + +/** Asks for the bar hidden while this is composed, as art, a page being read or a map being viewed do. */ +@Composable +internal fun FullScreenChrome() { + DisposableEffect(Unit) { + BottomChrome.request(true) + onDispose { BottomChrome.request(false) } + } +} + +private const val PULL_PX = 6f + +/** The tab at the top edge that brings the hidden bar back, by a tap or a pull down. */ +@Composable +internal fun PullTab() { + val description = stringResource(R.string.bottom_bar_show) + val shape = RoundedCornerShape(bottomStart = 14.dp, bottomEnd = 14.dp) + Box(Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) { + Box( + contentAlignment = Alignment.Center, + modifier = Modifier.testTag("bottom-pull-tab").size(width = 72.dp, height = 26.dp) + .semantics { contentDescription = description } + .clip(shape).background(Color.Black.copy(alpha = 0.55f)).border(1.dp, Color.White.copy(alpha = 0.14f), shape) + .pointerInput(Unit) { + var pulled = 0f + detectVerticalDragGestures(onDragStart = { pulled = 0f }, onDragEnd = { pulled = 0f }, onDragCancel = { pulled = 0f }) { change, drag -> + pulled = (pulled + drag).coerceAtLeast(0f) + if (pulled > PULL_PX) { change.consume(); pulled = 0f; BottomChrome.show(true) } + } + } + .clickable(role = Role.Button) { BottomChrome.show(true) }, + ) { + Icon(Icons.Outlined.ExpandMore, contentDescription = null, tint = Color.White.copy(alpha = 0.85f), modifier = Modifier.size(22.dp)) + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomDashboard.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomDashboard.kt index 6838a17760..21a685eee9 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BottomDashboard.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomDashboard.kt @@ -68,7 +68,8 @@ internal object SessionBottomTab { } } -internal fun pageForGameStart(ids: List): String? = GAME_PAGE.takeIf { it in ids } +internal fun pageForGameStart(ids: List, remembered: String? = null): String? = + remembered?.takeIf { it in ids } ?: GAME_PAGE.takeIf { it in ids } private const val DEFAULT_PAGE = "telemetry" private const val GAME_PAGE = "telemetry" @@ -81,13 +82,14 @@ internal fun BottomDashboard( onPage: (String) -> Unit, bar: BottomBarModel? = null, gameStarts: Int = 0, + gamePage: () -> String? = { null }, strip: (@Composable (String?) -> Unit)? = null, ) { val colors = MaterialTheme.colorScheme - var current by remember { mutableStateOf(pickBottomPage(remembered, pages.map { it.id })) } + var current by remember { mutableStateOf(gamePage()?.takeIf { id -> pages.any { it.id == id } } ?: pickBottomPage(remembered, pages.map { it.id })) } val startsWhenOpened = remember { gameStarts } LaunchedEffect(gameStarts) { - if (gameStarts != startsWhenOpened) pageForGameStart(pages.map { it.id })?.let { current = it } + if (gameStarts != startsWhenOpened) pageForGameStart(pages.map { it.id }, gamePage())?.let { current = it } } val page = pages.firstOrNull { it.id == current } ?: pages.firstOrNull() Column(Modifier.fillMaxSize().background(colors.background)) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomGuidesPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomGuidesPage.kt new file mode 100644 index 0000000000..832d100e1c --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomGuidesPage.kt @@ -0,0 +1,585 @@ +package com.droiddeck.launcher.ui + +import android.annotation.SuppressLint +import android.graphics.BitmapFactory +import android.net.Uri +import android.view.ViewGroup +import android.webkit.CookieManager +import android.webkit.RenderProcessGoneDetail +import android.webkit.WebResourceRequest +import android.webkit.WebView +import android.webkit.WebViewClient +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.foundation.gestures.detectTransformGestures +import androidx.compose.foundation.horizontalScroll +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.key +import androidx.compose.runtime.mutableFloatStateOf +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.ImageBitmap +import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.compose.ui.viewinterop.AndroidView +import coil.compose.AsyncImage +import com.droiddeck.launcher.R +import com.droiddeck.launcher.stores.SteamAchievements +import androidx.compose.foundation.verticalScroll +import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.session.GameLinks +import com.droiddeck.launcher.session.GuideLibrary +import com.droiddeck.launcher.session.SessionState +import com.droiddeck.launcher.session.SteamGuides +import com.droiddeck.launcher.session.SteamWebLogin +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.async +import kotlinx.coroutines.launch +import kotlinx.coroutines.suspendCancellableCoroutine +import kotlinx.coroutines.withContext +import java.io.File +import kotlin.coroutines.resume + +private sealed class GuideList { + object Loading : GuideList() + object Failed : GuideList() + class Found(val guides: List) : GuideList() +} + +internal enum class GuideSection(val label: Int) { + GUIDES(R.string.bottom_page_guides), + ACHIEVEMENTS(R.string.achievements_title), + WIKI(R.string.bottom_guides_wiki), + MAPS(R.string.bottom_guides_maps), + SAVED(R.string.bottom_guides_saved), +} + +private val TAG_LABELS = listOf( + null to R.string.bottom_guides_tag_all, + "Walkthroughs" to R.string.bottom_guides_tag_walkthroughs, + "Achievements" to R.string.achievements_title, + "Secrets" to R.string.bottom_guides_tag_secrets, + "Maps or Levels" to R.string.bottom_guides_maps, +) + +@Composable +internal fun GuidesPanel(runningGame: () -> String?) { + val context = LocalContext.current + val id = rememberShownGame(runningGame) + if (id == null) { + PanelNote(stringResource(R.string.bottom_guides_no_game)) + return + } + val game = id.toString() + val scope = rememberCoroutineScope() + val host = rememberMenuHost() + val firstGame = remember { id } + var reading by remember(id) { mutableStateOf(if (id == firstGame) SteamGuides.place(context, game)?.url else null) } + var section by remember(id) { mutableStateOf(GuideSection.GUIDES) } + var tag by remember(id) { mutableStateOf(null) } + var list by remember(id) { mutableStateOf(GuideList.Loading) } + var cookieHeader by remember(id) { mutableStateOf(null) } + var name by remember(id) { mutableStateOf(null) } + var openMap by remember(id) { mutableStateOf(null) } + if (reading != null || openMap != null) FullScreenChrome() + var libraryRevision by remember(id) { mutableIntStateOf(0) } + var note by remember(id) { mutableStateOf(null) } + LaunchedEffect(id) { + val cookies = withContext(Dispatchers.IO) { + runCatching { + SteamWebLogin.read(LinuxRuntime.rootDir(context), SessionState.steamClientArch, File(context.cacheDir, "steam-web-login")) + }.getOrDefault(emptyList()) + } + val manager = CookieManager.getInstance() + for (c in cookies) suspendCancellableCoroutine { cont -> manager.setCookie("https://${c.host}", c.header) { cont.resume(Unit) } } + cookieHeader = cookies.filter { steamChatAllows(it.host) }.joinToString("; ") { it.header.substringBefore(';') } + name = withContext(Dispatchers.IO) { IdleHome.overview(context, id)?.name } + } + LaunchedEffect(id, tag, cookieHeader) { + val header = cookieHeader ?: return@LaunchedEffect + list = GuideList.Loading + list = withContext(Dispatchers.IO) { SteamGuides.list(id, header, tag) }?.let { GuideList.Found(it) } ?: GuideList.Failed + } + val pinnedMsg = stringResource(R.string.bottom_guides_pinned) + val pinFailedMsg = stringResource(R.string.bottom_guides_pin_failed) + val savedMsg = stringResource(R.string.bottom_guides_saved_note) + openMap?.let { map -> + MapViewer(map, onBack = { openMap = null; libraryRevision++ }, onDelete = { + GuideLibrary.delete(map) + openMap = null + libraryRevision++ + }) + return + } + reading?.let { open -> + // A new game or page needs a new WebView: its factory runs once and keeps the first page's callbacks. + key(game, open) { + GuideReaderPanel( + url = open, + scroll = SteamGuides.place(context, game)?.takeIf { it.url == open }?.scroll ?: 0f, + note = note, + onBack = { reading = null; note = null }, + onPlace = { url, s -> SteamGuides.savePlace(context, game, url, s) }, + onSave = { view -> + val file = GuideLibrary.savedFile(context, game) + val title = view.title.orEmpty() + val url = view.url.orEmpty() + view.saveWebArchive(file.path, false) { path -> + if (path != null) { + GuideLibrary.recordSaved(file, title, url) + note = savedMsg + libraryRevision++ + } + } + }, + onPin = { image -> + scope.launch { + val cookies = CookieManager.getInstance().getCookie(image) + val file = withContext(Dispatchers.IO) { GuideLibrary.pin(context, game, image, cookies) } + note = if (file != null) pinnedMsg else pinFailedMsg + libraryRevision++ + } + }, + onStopped = { reading = null }, + ) + } + return + } + PanelColumn { + TabStrip(GuideSection.entries.map { stringResource(it.label) }, section.ordinal, { section = GuideSection.entries[it] }, + modifier = Modifier.fillMaxWidth(), compact = true, centered = true) + Column(Modifier.weight(1f).fillMaxWidth().verticalScroll(rememberScrollState())) { + when (section) { + GuideSection.GUIDES -> GuidesSection(host, list, tag, SteamGuides.place(context, game), onTag = { tag = it }, onOpen = { reading = it }) + GuideSection.ACHIEVEMENTS -> AchievementsSection(id) + GuideSection.WIKI -> WikiSection(id, name, onOpen = { reading = it }) + GuideSection.MAPS -> MapsSection(id, game, name, libraryRevision, onOpenMap = { openMap = it }, onOpen = { reading = it }) + GuideSection.SAVED -> SavedSection(game, libraryRevision, onOpen = { reading = Uri.fromFile(it).toString() }, onDelete = { + GuideLibrary.delete(it) + libraryRevision++ + }) + } + } + } +} + +@Composable +private fun GuidesSection( + host: MenuHost, list: GuideList, tag: String?, last: SteamGuides.Place?, onTag: (String?) -> Unit, onOpen: (String) -> Unit, +) { + SettingsGroup(stringResource(R.string.bottom_guides_steam)) { + if (last != null) PanelRow(stringResource(R.string.bottom_guides_continue), onClick = { onOpen(last.url) }, tag = "bottom-guides-continue", + trailing = { SecondaryButton(stringResource(R.string.store_open), compact = true) { onOpen(last.url) } }) + ChoiceRow(host, "guides-tag", stringResource(R.string.bottom_guides_category), null, + TAG_LABELS.map { (value, label) -> value to stringResource(label) }, tag) { onTag(it) } + when (list) { + GuideList.Loading -> PanelRow(stringResource(R.string.achievements_reading)) + GuideList.Failed -> PanelRow(stringResource(R.string.bottom_guides_failed)) + is GuideList.Found -> + if (list.guides.isEmpty()) PanelRow(stringResource(R.string.bottom_guides_empty)) + else for (guide in list.guides) GuideRow(guide) { onOpen(guide.url) } + } + } +} + +@Composable +private fun AchievementsSection(appId: Long) { + val game = remember(appId) { SteamAchievements.game(appId) } + val state = rememberAchievements(game) ?: return + Box(Modifier.padding(top = 8.dp)) { AchievementsTab(SteamAchievements.label, state) } +} + +@Composable +private fun WikiSection(appId: Long, name: String?, onOpen: (String) -> Unit) { + val context = LocalContext.current + var links by remember(appId) { mutableStateOf?>(null) } + var tier by remember(appId) { mutableStateOf(null) } + LaunchedEffect(appId, name) { + val (found, t) = withContext(Dispatchers.IO) { + val pending = async { GameLinks.protonTier(appId) } + GameLinks.links(context, appId, name) to pending.await() + } + tier = t + links = found + } + val open = stringResource(R.string.store_open) + val found = links + if (found == null) { + SettingsGroup(stringResource(R.string.bottom_guides_wiki)) { PanelRow(stringResource(R.string.achievements_reading)) } + return + } + tier?.let { t -> + SettingsGroup(stringResource(R.string.fex_compatibility_label)) { + PanelRow(stringResource(R.string.bottom_guides_protondb), tag = "guides-protondb", onClick = { onOpen("https://www.protondb.com/app/$appId") }, + trailing = { PanelValue(stringResource(tierLabel(t)), tierColor(t)) }) + } + } + SettingsGroup(stringResource(R.string.bottom_guides_wiki)) { + for (link in found.filter { it.kind != GameLinks.Kind.MAPGENIE }) PanelRow(stringResource(linkLabel(link.kind)), Uri.parse(link.url).host.orEmpty().removePrefix("www."), + onClick = { onOpen(link.url) }, + trailing = { SecondaryButton(open, compact = true, modifier = Modifier.testTag("guides-link-${link.kind.name.lowercase()}")) { onOpen(link.url) } }) + } + name?.let { n -> + SettingsGroup(stringResource(R.string.bottom_guides_search)) { + for (s in GameLinks.searches(n, found)) PanelRow(stringResource(searchLabel(s.id)), n, onClick = { onOpen(s.url) }, + trailing = { SecondaryButton(open, compact = true, modifier = Modifier.testTag("guides-search-${s.id}")) { onOpen(s.url) } }) + } + } +} + +@Composable +private fun MapsSection(appId: Long, game: String, name: String?, revision: Int, onOpenMap: (File) -> Unit, onOpen: (String) -> Unit) { + val context = LocalContext.current + var maps by remember(game) { mutableStateOf>(emptyList()) } + LaunchedEffect(game, revision) { maps = withContext(Dispatchers.IO) { GuideLibrary.maps(context, game) } } + SettingsGroup(stringResource(R.string.bottom_guides_maps)) { + if (maps.isEmpty()) PanelRow(stringResource(R.string.bottom_guides_maps_empty), stringResource(R.string.bottom_guides_pin_hint)) + maps.forEachIndexed { i, map -> + PanelRow( + stringResource(R.string.bottom_guides_map_name, i + 1), stringResource(R.string.bottom_guides_markers, map.markers.size), + tag = "guides-map", onClick = { onOpenMap(map.file) }, + leading = { + AsyncImage(model = map.file, contentDescription = null, contentScale = ContentScale.Crop, + modifier = Modifier.size(64.dp, 40.dp).clip(RoundedCornerShape(6.dp))) + }, + ) + } + } + var mapSite by remember(name) { mutableStateOf(null) } + LaunchedEffect(name) { + if (name != null) mapSite = withContext(Dispatchers.IO) { GameLinks.links(context, appId, name) }.firstOrNull { it.kind == GameLinks.Kind.MAPGENIE } + } + mapSite?.let { link -> + val open = stringResource(R.string.store_open) + SettingsGroup(stringResource(R.string.bottom_guides_find_maps)) { + PanelRow(stringResource(R.string.bottom_guides_search_mapgenie), Uri.parse(link.url).run { host.orEmpty() + path.orEmpty() }, + onClick = { onOpen(link.url) }, + trailing = { SecondaryButton(open, compact = true, modifier = Modifier.testTag("guides-maps-mapgenie")) { onOpen(link.url) } }) + } + } +} + +@Composable +private fun SavedSection(game: String, revision: Int, onOpen: (File) -> Unit, onDelete: (File) -> Unit) { + val context = LocalContext.current + var saved by remember(game) { mutableStateOf>(emptyList()) } + LaunchedEffect(game, revision) { saved = withContext(Dispatchers.IO) { GuideLibrary.saved(context, game) } } + val delete = stringResource(R.string.common_delete) + SettingsGroup(stringResource(R.string.bottom_guides_saved)) { + if (saved.isEmpty()) PanelRow(stringResource(R.string.bottom_guides_saved_empty), stringResource(R.string.bottom_guides_saved_hint)) + for (page in saved) PanelRow(page.title, Uri.parse(page.url).host.orEmpty().removePrefix("www."), tag = "guides-saved", + onClick = { onOpen(page.file) }, + trailing = { SecondaryButton(delete, compact = true, modifier = Modifier.testTag("guides-saved-delete")) { onDelete(page.file) } }) + } +} + +@Composable +private fun GuideReaderPanel( + url: String, + scroll: Float, + note: String?, + onBack: () -> Unit, + onPlace: (String, Float) -> Unit, + onSave: (WebView) -> Unit, + onPin: (String) -> Unit, + onStopped: () -> Unit, +) { + val pal = LocalPalette.current + var view by remember { mutableStateOf(null) } + var image by remember(url) { mutableStateOf(null) } + val local = url.startsWith("file:") + PanelColumn { + Row(Modifier.fillMaxWidth().padding(bottom = 4.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { + BackLink(stringResource(R.string.mode_back), compact = true, onClick = onBack) + Text(note ?: stringResource(R.string.bottom_guides_pin_hint), fontSize = 11.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f)) + image?.let { img -> SecondaryButton(stringResource(R.string.bottom_guides_pin), compact = true, modifier = Modifier.testTag("bottom-guides-pin")) { onPin(img); image = null } } + if (!local) SecondaryButton(stringResource(R.string.game_env_save), compact = true, modifier = Modifier.testTag("bottom-guides-save")) { view?.let(onSave) } + } + Box(Modifier.weight(1f).fillMaxWidth().padding(bottom = 6.dp).clip(RoundedCornerShape(14.dp)).border(1.dp, pal.line, RoundedCornerShape(14.dp))) { + GuideReader(url, scroll, onPlace, onStopped, onView = { view = it }, onImage = { image = it }) + } + } +} + +@Composable +internal fun GuideRow(guide: SteamGuides.Guide, onOpen: () -> Unit) { + val pal = LocalPalette.current + PanelRow( + guide.title, + listOfNotNull(guide.author.takeIf { it.isNotEmpty() }, "★".repeat(guide.stars).takeIf { it.isNotEmpty() }).joinToString(" · "), + tag = "guide-${guide.id}", onClick = onOpen, + leading = { + Box(Modifier.size(40.dp).clip(RoundedCornerShape(6.dp)).background(pal.line)) { + if (guide.preview != null) AsyncImage(model = guide.preview, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.fillMaxSize()) + } + }, + ) +} + +internal object ReaderAds { + private val HOSTS = setOf( + "doubleclick.net", "googlesyndication.com", "googleadservices.com", "adservice.google.com", "google-analytics.com", + "googletagservices.com", "googletagmanager.com", "amazon-adsystem.com", "adnxs.com", "criteo.com", "criteo.net", + "taboola.com", "outbrain.com", "pubmatic.com", "rubiconproject.com", "casalemedia.com", "openx.net", "moatads.com", + "scorecardresearch.com", "quantserve.com", "adsafeprotected.com", "3lift.com", "sharethrough.com", "teads.tv", + "yieldmo.com", "media.net", "smartadserver.com", "adform.net", "bidswitch.net", "lijit.com", "sonobi.com", + "indexww.com", "gumgum.com", "nativo.com", "zemanta.com", "primis.tech", "connatix.com", "playwire.com", + "fandomadtags.com", "kargo.com", "33across.com", "onetag-sys.com", "adsrvr.org", "id5-sync.com", "ezoic.net", + "ezojs.com", "mediavine.com", "intergient.com", "nitropay.com", "freestar.io", "pbxai.com", + ) + + fun blocks(host: String?): Boolean { + var h = host?.lowercase() ?: return false + while (true) { + if (h in HOSTS) return true + val dot = h.indexOf('.') + if (dot < 0 || h.indexOf('.', dot + 1) < 0) return false + h = h.substring(dot + 1) + } + } +} + +private const val REDIRECT_GRACE_MS = 10_000L + +internal fun readerAllows(start: String, target: Uri, userInitiated: Boolean): Boolean { + val host = target.host ?: return false + if (target.scheme != "https" && target.scheme != "http") return false + if (steamChatAllows(host) || userInitiated) return true + val home = Uri.parse(start).host?.let(::siteOf) ?: return false + return siteOf(host) == home +} + +private fun siteOf(host: String): String = host.split('.').takeLast(2).joinToString(".") + +@SuppressLint("SetJavaScriptEnabled") +@Composable +private fun GuideReader( + url: String, scroll: Float, onPlace: (String, Float) -> Unit, onStopped: () -> Unit, + onView: (WebView?) -> Unit, onImage: (String) -> Unit, +) { + val context = LocalContext.current + AndroidView(factory = { ctx -> + WebView(ctx).apply { + layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) + isFocusable = false + isFocusableInTouchMode = false + setBackgroundColor(0xFF1B2838.toInt()) + settings.javaScriptEnabled = true + settings.domStorageEnabled = true + settings.allowContentAccess = false + settings.allowFileAccess = url.startsWith("file:") && GuideLibrary.isSaved(context, File(Uri.parse(url).path.orEmpty())) + var restore = scroll + // Opening the page and each tapped link may redirect off the site for a moment; a page's own navigation may not. + var approvedUntil = android.os.SystemClock.uptimeMillis() + REDIRECT_GRACE_MS + webViewClient = object : WebViewClient() { + override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean { + val now = android.os.SystemClock.uptimeMillis() + if (request.hasGesture()) approvedUntil = now + REDIRECT_GRACE_MS + return !readerAllows(url, request.url, request.hasGesture() || (request.isRedirect && now < approvedUntil)) + } + + override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): android.webkit.WebResourceResponse? = + if (ReaderAds.blocks(request.url.host)) android.webkit.WebResourceResponse("text/plain", "utf-8", java.io.ByteArrayInputStream(ByteArray(0))) + else null + + override fun onPageFinished(view: WebView, url: String) { + if (restore > 0f) { + val ratio = restore + restore = 0f + view.postDelayed({ view.scrollTo(0, (view.contentHeight * view.scale * ratio).toInt()) }, 400) + } + } + + override fun onRenderProcessGone(view: WebView, detail: RenderProcessGoneDetail): Boolean { + onStopped() + return true + } + } + setOnLongClickListener { v -> + val hit = (v as WebView).hitTestResult + val src = hit.extra + if ((hit.type == WebView.HitTestResult.IMAGE_TYPE || hit.type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) && + src != null && src.startsWith("http")) { + onImage(src) + true + } else false + } + setOnScrollChangeListener { v, _, y, _, _ -> + val web = v as WebView + val height = web.contentHeight * web.scale + val current = web.url ?: return@setOnScrollChangeListener + if (height > 0) onPlace(current, y / height) + } + onView(this) + loadUrl(url) + } + }, modifier = Modifier.fillMaxSize(), onRelease = { view -> + view.url?.let { current -> onPlace(current, view.scrollY / (view.contentHeight * view.scale).coerceAtLeast(1f)) } + onView(null) + view.destroy() + }) +} + + +@Composable +private fun MapViewer(file: File, onBack: () -> Unit, onDelete: () -> Unit) { + var image by remember(file) { mutableStateOf(null) } + var markers by remember(file) { mutableStateOf(GuideLibrary.markers(file)) } + var scale by remember(file) { mutableFloatStateOf(1f) } + var offset by remember(file) { mutableStateOf(Offset.Zero) } + LaunchedEffect(file) { image = withContext(Dispatchers.IO) { decodeMap(file) } } + val pal = LocalPalette.current + PanelColumn { + Row(Modifier.fillMaxWidth().padding(bottom = 4.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { + BackLink(stringResource(R.string.mode_back), compact = true, onClick = onBack) + Text(stringResource(R.string.bottom_guides_marker_hint), fontSize = 11.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis) + SecondaryButton(stringResource(R.string.common_delete), compact = true, modifier = Modifier.testTag("guides-map-delete"), onClick = onDelete) + } + Box( + Modifier.weight(1f).fillMaxWidth().padding(bottom = 6.dp).clip(RoundedCornerShape(14.dp)).background(Color.Black) + .border(1.dp, pal.line, RoundedCornerShape(14.dp)) + .pointerInput(file) { + detectTransformGestures { _, pan, zoom, _ -> + scale = (scale * zoom).coerceIn(1f, MAX_ZOOM) + offset = if (scale == 1f) Offset.Zero else offset + pan + } + }, + contentAlignment = Alignment.Center, + ) { + val img = image ?: return@Box + Box( + Modifier.aspectRatio(img.width.toFloat() / img.height) + .graphicsLayer(scaleX = scale, scaleY = scale, translationX = offset.x, translationY = offset.y) + .pointerInput(file) { + detectTapGestures( + onDoubleTap = { p -> + if (scale > 1f) { + scale = 1f + offset = Offset.Zero + } else { + scale = DOUBLE_TAP_ZOOM + offset = Offset((size.width / 2f - p.x) * DOUBLE_TAP_ZOOM, (size.height / 2f - p.y) * DOUBLE_TAP_ZOOM) + } + }, + onLongPress = { p -> + markers = markers + (p.x / size.width to p.y / size.height) + GuideLibrary.saveMarkers(file, markers) + }, + onTap = { p -> + val hit = markers.minByOrNull { (x, y) -> MapMarkers.distance(x * size.width, y * size.height, p.x, p.y) } + if (hit != null && MapMarkers.distance(hit.first * size.width, hit.second * size.height, p.x, p.y) < MARKER_HIT_PX * density / scale) { + markers = markers - hit + GuideLibrary.saveMarkers(file, markers) + } + }, + ) + }, + ) { + Image(img, null, Modifier.fillMaxSize(), contentScale = ContentScale.FillBounds) + Canvas(Modifier.fillMaxSize()) { + for ((x, y) in markers) { + val c = Offset(x * size.width, y * size.height) + drawCircle(Color.Black.copy(alpha = 0.6f), radius = 9.dp.toPx() / scale, center = c) + drawCircle(pal.signal, radius = 6.dp.toPx() / scale, center = c) + } + } + } + } + } +} + +internal object MapMarkers { + fun distance(x0: Float, y0: Float, x1: Float, y1: Float): Float = kotlin.math.hypot(x0 - x1, y0 - y1) + + fun sampleSize(width: Int, height: Int, longest: Int): Int { + var sample = 1 + while (maxOf(width, height) / sample > longest) sample *= 2 + return sample + } +} + +private fun decodeMap(file: File): ImageBitmap? = runCatching { + val bounds = BitmapFactory.Options().apply { inJustDecodeBounds = true } + BitmapFactory.decodeFile(file.path, bounds) + val opts = BitmapFactory.Options().apply { inSampleSize = MapMarkers.sampleSize(bounds.outWidth, bounds.outHeight, MAP_LONGEST) } + BitmapFactory.decodeFile(file.path, opts)?.asImageBitmap() +}.getOrNull() + +private const val MAX_ZOOM = 8f +private const val DOUBLE_TAP_ZOOM = 2.5f +private const val MARKER_HIT_PX = 20f +private const val MAP_LONGEST = 4096 +private fun linkLabel(kind: GameLinks.Kind): Int = when (kind) { + GameLinks.Kind.WIKI -> R.string.bottom_guides_link_wiki + GameLinks.Kind.STRATEGYWIKI -> R.string.bottom_guides_link_strategywiki + GameLinks.Kind.PCGAMINGWIKI -> R.string.bottom_guides_link_pcgw + GameLinks.Kind.GAMEFAQS -> R.string.bottom_guides_link_gamefaqs + GameLinks.Kind.IGN -> R.string.bottom_guides_link_ign + GameLinks.Kind.HOWLONGTOBEAT -> R.string.bottom_guides_link_hltb + GameLinks.Kind.MAPGENIE -> R.string.bottom_guides_search_mapgenie +} + +private fun searchLabel(id: String): Int = when (id) { + "youtube" -> R.string.bottom_guides_search_youtube + else -> R.string.bottom_guides_link_gamefaqs +} + +private fun tierLabel(tier: String): Int = when (tier) { + "platinum" -> R.string.bottom_guides_tier_platinum + "gold" -> R.string.bottom_guides_tier_gold + "silver" -> R.string.bottom_guides_tier_silver + "bronze" -> R.string.bottom_guides_tier_bronze + else -> R.string.bottom_guides_tier_borked +} + +private fun tierColor(tier: String): Color = when (tier) { + "platinum" -> Color(0xFFB4C7DC) + "gold" -> Color(0xFFCFB53B) + "silver" -> Color(0xFFA6A6A6) + "bronze" -> Color(0xFFCD7F32) + else -> Color(0xFFFF6B6B) +} + diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomIdleHome.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomIdleHome.kt new file mode 100644 index 0000000000..fa97a401cc --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomIdleHome.kt @@ -0,0 +1,102 @@ +package com.droiddeck.launcher.ui + +import android.content.Context +import android.text.format.DateUtils +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import com.droiddeck.launcher.R +import com.droiddeck.launcher.agent.AgentGuest +import com.droiddeck.launcher.frontend.Library +import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.session.SteamLocalConfig +import java.io.File +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.withContext + +data class IdleGame( + val appId: Int, + val name: String, + val art: File?, + val playtimeMinutes: Long, + val lastPlayed: Long, + val highlighted: Boolean, + val logo: File? = null, +) + +internal object IdleHome { + fun pick(games: List, selected: Long?): Pair? { + games.firstOrNull { selected != null && it.appId.toLong() == selected }?.let { return it to true } + return games.filter { it.lastPlayed > 0 }.maxByOrNull { it.lastPlayed }?.let { it to false } + } + + class Overview(val name: String, val minutes: Long, val lastPlayed: Long) + + fun overviewExpression(appId: Long): String = "(() => { const o = globalThis.appStore?.GetAppOverviewByAppID?.($appId); " + + "return o ? JSON.stringify({name: o.display_name, minutes: o.minutes_playtime_forever, last: o.rt_last_time_played}) : null; })()" + + fun parseOverview(json: String?): Overview? = runCatching { + val o = org.json.JSONObject(json ?: return null) + Overview(o.optString("name").ifEmpty { return null }, o.optLong("minutes"), o.optLong("last")) + }.getOrNull() + + internal fun overview(context: Context, appId: Long): Overview? = runCatching { + val answer = AgentGuest.steamEval(context, overviewExpression(appId), 4_000) + if (!answer.optBoolean("ok")) null else parseOverview(answer.opt("value")?.takeIf { it != org.json.JSONObject.NULL }?.toString()) + }.getOrNull() + + fun load(context: Context, games: List, selected: Long?): IdleGame? { + if (selected != null) overview(context, selected)?.let { o -> + val id = selected.toInt() + val known = games.firstOrNull { it.appId == id } + val cache = File(SessionPrefs.activeSteamRoot(context), "appcache/librarycache") + val art = known?.let { it.hero ?: it.art } ?: runCatching { + Library.steamCacheImage(cache, id, listOf("library_hero.jpg", "library_600x900.jpg", "header.jpg")) + }.getOrNull() + val logo = known?.logo ?: runCatching { Library.steamCacheImage(cache, id, Library.STEAM_LOGOS) }.getOrNull() + return IdleGame(id, o.name, art, o.minutes, o.lastPlayed, highlighted = true, logo = logo) + } + val (game, highlighted) = pick(games, selected) ?: return null + val stats = runCatching { SteamLocalConfig.appStats(SessionPrefs.activeSteamRoot(context), game.appId) }.getOrNull() + return IdleGame( + game.appId, game.name, game.hero ?: game.art, stats?.playtimeMinutes ?: 0L, + maxOf(stats?.lastPlayed ?: 0L, game.lastPlayed), highlighted, game.logo, + ) + } +} + +private const val SELECTION_MS = 2_000L + +@Composable +internal fun rememberShownGame(runningGame: () -> String?): Long? { + val context = LocalContext.current + var appId by remember { mutableStateOf(runningGame()?.toLongOrNull()) } + LaunchedEffect(Unit) { + while (isActive) { + appId = runningGame()?.toLongOrNull() + ?: withContext(Dispatchers.IO) { runCatching { AgentGuest.selectedSteamAppId(context) }.getOrNull() } + delay(SELECTION_MS) + } + } + return appId +} + +@Composable +internal fun idleDetails(game: IdleGame): String { + val hours = game.playtimeMinutes / 60 + val played = when { + game.playtimeMinutes <= 0 -> stringResource(R.string.bottom_idle_never) + hours == 0L -> stringResource(R.string.bottom_idle_minutes, game.playtimeMinutes.toInt()) + else -> stringResource(R.string.bottom_idle_hours, hours.toInt()) + } + if (game.lastPlayed <= 0) return played + val last = DateUtils.getRelativeTimeSpanString(game.lastPlayed * 1000, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS) + return stringResource(R.string.bottom_idle_details, played, last) +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomMirrorPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomMirrorPage.kt new file mode 100644 index 0000000000..95cd939b58 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomMirrorPage.kt @@ -0,0 +1,285 @@ +package com.droiddeck.launcher.ui + +import android.graphics.Bitmap +import android.graphics.RectF +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectDragGestures +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxWithConstraints +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.foundation.layout.widthIn +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.key +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Size +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.FilterQuality +import androidx.compose.ui.graphics.ImageBitmap +import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.graphics.drawscope.Stroke +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.droiddeck.launcher.R +import com.droiddeck.launcher.session.SessionPrefs +import kotlin.coroutines.resume +import kotlin.math.max +import kotlin.math.min +import kotlin.math.roundToInt +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.suspendCancellableCoroutine + +internal enum class MirrorHide(val id: String, val label: Int) { + OFF("off", R.string.bottom_mirror_hide_off), + BLACK("black", R.string.bottom_mirror_hide_black), + DIM("dim", R.string.bottom_mirror_hide_dim); + + fun next(): MirrorHide = entries[(ordinal + 1) % entries.size] + + companion object { + fun from(id: String?): MirrorHide = entries.firstOrNull { it.id == id } ?: OFF + } +} + +internal object MirrorRegion { + const val MIN_SIZE = 0.02f + + fun parse(text: String?): RectF? { + val v = text?.split(',')?.mapNotNull { it.trim().toFloatOrNull() }?.takeIf { it.size == 4 } ?: return null + return normalize(v[0], v[1], v[2], v[3]) + } + + fun format(r: RectF): String = listOf(r.left, r.top, r.right, r.bottom).joinToString(",") { it.toString() } + + fun normalize(x0: Float, y0: Float, x1: Float, y1: Float): RectF? { + val r = RectF(min(x0, x1).coerceIn(0f, 1f), min(y0, y1).coerceIn(0f, 1f), max(x0, x1).coerceIn(0f, 1f), max(y0, y1).coerceIn(0f, 1f)) + return r.takeIf { it.width() >= MIN_SIZE && it.height() >= MIN_SIZE } + } + + fun outputSize(r: RectF, sourceAspect: Float, longest: Int): Pair { + val w = r.width() * sourceAspect + val h = r.height() + return if (w >= h) longest to max(1, (longest * h / w).roundToInt()) else max(1, (longest * w / h).roundToInt()) to longest + } +} + +private const val FRAME_MS = 66L +private const val COMPOSED_SETTLE_MS = 250L +private const val EDIT_LONGEST = 960 +private const val EDIT_TRIES = 3 +private const val EDIT_RETRY_MS = 500L +private const val LIVE_LONGEST = 720 + +@Composable +internal fun MirrorPanel(actions: BottomPageActions) { + val context = LocalContext.current + val copy = actions.copyRegion + if (copy == null) { + MirrorNote(stringResource(R.string.bottom_mirror_no_frame)) + return + } + DisposableEffect(Unit) { + actions.holdComposed(true) + onDispose { actions.holdComposed(false) } + } + val game = actions.gameKey() ?: "steam" + var region by remember(game) { mutableStateOf(MirrorRegion.parse(SessionPrefs.mirrorRegion(context, game))) } + var editing by remember(game) { mutableStateOf(region == null) } + var sharp by remember { mutableStateOf(true) } + val host = rememberMenuHost() + if (editing) { + // A game change must not carry the last game's still or pick into this one's editor. + key(game) { + MirrorEditor(copy, region, actions.sourceAspect(), + onSave = { + region = it + SessionPrefs.setMirrorRegion(context, game, MirrorRegion.format(it)) + editing = false + }, + onCancel = if (region != null) ({ editing = false }) else null) + } + return + } + val r = region ?: return + var hide by remember(game) { mutableStateOf(MirrorHide.from(SessionPrefs.mirrorHide(context, game))) } + DisposableEffect(r, hide) { + actions.maskRegion(r.takeIf { hide != MirrorHide.OFF }, hide == MirrorHide.DIM) + onDispose { actions.maskRegion(null, false) } + } + var frame by remember(r) { mutableStateOf(null) } + var failed by remember(r) { mutableStateOf(false) } + LaunchedEffect(r) { + while (isActive) { + val (w, h) = MirrorRegion.outputSize(r, actions.sourceAspect(), LIVE_LONGEST) + val bitmap = capture(copy, r, w, h) + failed = bitmap == null + if (bitmap != null) frame = bitmap.asImageBitmap() + delay(FRAME_MS) + } + } + val pal = LocalPalette.current + DisposableEffect(Unit) { onDispose { MirrorOptions.open.value = false } } + Box(Modifier.fillMaxSize().background(Color.Black), contentAlignment = Alignment.Center) { + val f = frame + if (f != null) Image(f, null, Modifier.fillMaxSize(), contentScale = ContentScale.Fit, + filterQuality = if (sharp) FilterQuality.None else FilterQuality.Medium) + else if (failed) MirrorNote(stringResource(R.string.bottom_mirror_no_frame)) + if (MirrorOptions.open.value) Box( + Modifier.fillMaxSize().clickable(remember { MutableInteractionSource() }, indication = null) { MirrorOptions.open.value = false }, + contentAlignment = Alignment.TopEnd, + ) { + val shape = RoundedCornerShape(16.dp) + Column( + Modifier.padding(12.dp).widthIn(max = 380.dp).fillMaxWidth().testTag("bottom-mirror-options").clip(shape).background(MaterialTheme.colorScheme.background) + .border(1.dp, pal.line, shape).clickable(remember { MutableInteractionSource() }, indication = null) {} + .padding(horizontal = 10.dp, vertical = 4.dp), + ) { + SettingsGroup(stringResource(R.string.bottom_page_mirror)) { + ActionRow(stringResource(R.string.bottom_mirror_region), null, stringResource(R.string.game_env_edit), + onClick = { MirrorOptions.open.value = false; editing = true }, + modifier = Modifier.testTag("bottom-mirror-edit")) + ChoiceRow(host, "mirror-hide", stringResource(R.string.bottom_mirror_top), null, + MirrorHide.entries.map { it to stringResource(it.label) }, hide) { + hide = it + SessionPrefs.setMirrorHide(context, game, it.id) + } + ChoiceRow(host, "mirror-scaling", stringResource(R.string.bottom_mirror_scaling), null, + listOf(true to stringResource(R.string.bottom_mirror_sharp), false to stringResource(R.string.bottom_mirror_smooth)), sharp) { + sharp = it + } + } + } + } + } +} + +/** Whether the mirror's options card is open, toggled from the bar so the mirror keeps the whole panel. */ +internal object MirrorOptions { + val open = androidx.compose.runtime.mutableStateOf(false) +} + +@Composable +private fun MirrorEditor( + copy: (RectF?, Int, Int, (Bitmap?) -> Unit) -> Unit, + current: RectF?, + sourceAspect: Float, + onSave: (RectF) -> Unit, + onCancel: (() -> Unit)?, +) { + val pal = LocalPalette.current + var still by remember { mutableStateOf(null) } + var failed by remember { mutableStateOf(false) } + var start by remember { mutableStateOf(null) } + var end by remember { mutableStateOf(null) } + var picked by remember { mutableStateOf(current) } + var attempt by remember { mutableIntStateOf(0) } + LaunchedEffect(attempt) { + delay(COMPOSED_SETTLE_MS) + val (w, h) = MirrorRegion.outputSize(RectF(0f, 0f, 1f, 1f), sourceAspect, EDIT_LONGEST) + // The surface can be briefly invalid while the session settles, so a failed still is retried a few times. + var bitmap: Bitmap? = null + for (i in 0 until EDIT_TRIES) { + bitmap = capture(copy, null, w, h) + if (bitmap != null) break + delay(EDIT_RETRY_MS) + } + failed = bitmap == null + still = bitmap?.asImageBitmap() + } + PanelColumn { + Row(Modifier.fillMaxWidth().padding(bottom = 6.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { + onCancel?.let { BackLink(stringResource(R.string.common_cancel), compact = true, onClick = it) } + Text(stringResource(R.string.bottom_mirror_pick), fontSize = 11.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f)) + SecondaryButton(stringResource(R.string.bottom_mirror_save), enabled = picked != null, compact = true, + modifier = Modifier.testTag("bottom-mirror-save")) { picked?.let(onSave) } + } + BoxWithConstraints(Modifier.weight(1f).fillMaxWidth().padding(bottom = 6.dp), contentAlignment = Alignment.Center) { + val image = still + if (image == null) { + if (failed) Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text(stringResource(R.string.bottom_mirror_no_frame), fontSize = 15.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + textAlign = TextAlign.Center, modifier = Modifier.padding(24.dp)) + SecondaryButton(stringResource(R.string.agent_retry), compact = true) { failed = false; attempt++ } + } + return@BoxWithConstraints + } + Box(Modifier.aspectRatio(image.width.toFloat() / image.height).clip(RoundedCornerShape(8.dp))) { + Image(image, null, Modifier.fillMaxSize(), contentScale = ContentScale.FillBounds) + Canvas(Modifier.fillMaxSize().pointerInput(Unit) { + detectDragGestures( + onDragStart = { start = it; end = it }, + onDrag = { change, _ -> end = change.position }, + onDragEnd = { + val a = start + val b = end + if (a != null && b != null) MirrorRegion.normalize(a.x / size.width, a.y / size.height, b.x / size.width, b.y / size.height) + ?.let { picked = it } + start = null + end = null + }, + ) + }) { + val a = start + val b = end + val shown = if (a != null && b != null) RectF(min(a.x, b.x), min(a.y, b.y), max(a.x, b.x), max(a.y, b.y)) + else picked?.let { RectF(it.left * size.width, it.top * size.height, it.right * size.width, it.bottom * size.height) } + if (shown != null) { + val veil = Color.Black.copy(alpha = 0.5f) + drawRect(veil, Offset.Zero, Size(size.width, shown.top)) + drawRect(veil, Offset(0f, shown.bottom), Size(size.width, size.height - shown.bottom)) + drawRect(veil, Offset(0f, shown.top), Size(shown.left, shown.height())) + drawRect(veil, Offset(shown.right, shown.top), Size(size.width - shown.right, shown.height())) + drawRect(pal.signal, Offset(shown.left, shown.top), Size(shown.width(), shown.height()), style = Stroke(3.dp.toPx())) + } + } + } + } + } +} + +@Composable +private fun MirrorNote(text: String) { + Box(Modifier.fillMaxSize()) { + Text(text, fontSize = 15.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, textAlign = TextAlign.Center, + modifier = Modifier.align(Alignment.Center).padding(24.dp)) + } +} + +private suspend fun capture(copy: (RectF?, Int, Int, (Bitmap?) -> Unit) -> Unit, region: RectF?, width: Int, height: Int): Bitmap? = + suspendCancellableCoroutine { cont -> copy(region, width, height) { if (cont.isActive) cont.resume(it) else it?.recycle() } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomPages.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomPages.kt index b51aec8bf1..ff1e64bdb6 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BottomPages.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomPages.kt @@ -27,6 +27,11 @@ class BottomPageActions( val takeScreenshot: ((onDone: (Boolean) -> Unit) -> Unit)? = null, val fps: () -> Float? = { null }, val runningGame: () -> String? = { null }, + val gameKey: () -> String? = runningGame, + val copyRegion: ((android.graphics.RectF?, Int, Int, (android.graphics.Bitmap?) -> Unit) -> Unit)? = null, + val sourceAspect: () -> Float = { 16f / 9f }, + val holdComposed: (Boolean) -> Unit = {}, + val maskRegion: (android.graphics.RectF?, Boolean) -> Unit = { _, _ -> }, ) internal const val BOTTOM_PAGE_TELEMETRY = "telemetry" diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomScreenBar.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomScreenBar.kt index b6509b332d..fe66a06396 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BottomScreenBar.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomScreenBar.kt @@ -25,6 +25,11 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Close import androidx.compose.material.icons.outlined.Dashboard +import androidx.compose.material.icons.outlined.Extension +import androidx.compose.material.icons.outlined.ViewSidebar +import androidx.compose.material.icons.outlined.Wallpaper +import androidx.compose.material.icons.outlined.CropFree +import androidx.compose.material.icons.outlined.MenuBook import androidx.compose.material.icons.outlined.DesktopAccessDisabled import androidx.compose.material.icons.outlined.DesktopWindows import androidx.compose.material.icons.outlined.ExpandLess @@ -236,6 +241,10 @@ internal val SecondScreenMode.icon: ImageVector get() = when (this) { SecondScreenMode.DECK_CONTROLS -> Icons.Outlined.SportsEsports SecondScreenMode.CUSTOM_CONTROLS -> Icons.Outlined.Tune SecondScreenMode.DASHBOARD -> Icons.Outlined.Dashboard + SecondScreenMode.GUIDES -> Icons.Outlined.MenuBook + SecondScreenMode.MIRROR -> Icons.Outlined.CropFree + SecondScreenMode.STEAM_QAM -> Icons.Outlined.ViewSidebar + SecondScreenMode.ART -> Icons.Outlined.Wallpaper SecondScreenMode.DESKTOP -> Icons.Outlined.DesktopWindows } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomSessionPanels.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomSessionPanels.kt new file mode 100644 index 0000000000..10c6eac00b --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomSessionPanels.kt @@ -0,0 +1,95 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.droiddeck.launcher.input.SecondScreenMode + +@Composable +internal fun BottomSessionPanel(mode: SecondScreenMode, actions: BottomPageActions) { + val colors = MaterialTheme.colorScheme + Box(Modifier.fillMaxSize().background(colors.background)) { + CompositionLocalProvider(LocalChipMinWidth provides 96.dp, LocalCompactSettings provides true) { + when (mode) { + SecondScreenMode.GUIDES -> GuidesPanel(actions.runningGame) + SecondScreenMode.MIRROR -> MirrorPanel(actions) + SecondScreenMode.STEAM_QAM -> SteamQamPanel() + SecondScreenMode.ART -> ArtPanel(actions.runningGame) + else -> Unit + } + } + } +} + +@Composable +internal fun PanelColumn(modifier: Modifier = Modifier, content: @Composable ColumnScope.() -> Unit) { + Column(modifier.fillMaxSize().padding(horizontal = 14.dp, vertical = 6.dp), verticalArrangement = Arrangement.spacedBy(2.dp), content = content) +} + +@Composable +internal fun PanelRow( + title: String, + hint: String? = null, + tag: String? = null, + selected: Boolean = false, + leading: (@Composable () -> Unit)? = null, + trailing: (@Composable () -> Unit)? = null, + onClick: (() -> Unit)? = null, +) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + Row( + Modifier.fillMaxWidth() + .background(if (selected) pal.signal.copy(alpha = 0.10f) else Color.Transparent) + .then(if (onClick != null) Modifier.clickable(role = Role.Button, onClick = onClick) else Modifier) + .then(if (tag != null) Modifier.testTag(tag) else Modifier) + .padding(horizontal = 10.dp, vertical = 7.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(10.dp), + ) { + leading?.invoke() + Column(Modifier.weight(1f)) { + Text(title, fontSize = 13.sp, lineHeight = 16.sp, fontWeight = FontWeight.SemiBold, + color = if (selected) pal.signal else colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) + if (!hint.isNullOrEmpty()) Text(hint, fontSize = 11.sp, lineHeight = 14.sp, color = colors.onSurfaceVariant, + maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(top = 2.dp)) + } + trailing?.invoke() + } + Box(Modifier.fillMaxWidth().height(1.dp).background(pal.line)) +} + +@Composable +internal fun PanelValue(text: String, color: Color = MaterialTheme.colorScheme.onBackground) { + Text(text, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = color, maxLines = 1) +} + +@Composable +internal fun PanelNote(text: String, modifier: Modifier = Modifier) { + Box(modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Text(text, fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, textAlign = TextAlign.Center, + modifier = Modifier.padding(24.dp)) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt new file mode 100644 index 0000000000..d2630fa7b7 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt @@ -0,0 +1,302 @@ +package com.droiddeck.launcher.ui + +import android.content.Context +import android.graphics.BitmapFactory +import android.util.Base64 +import androidx.annotation.StringRes +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxWithConstraints +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.AlignHorizontalCenter +import androidx.compose.material.icons.outlined.AlignHorizontalLeft +import androidx.compose.material.icons.outlined.AlignHorizontalRight +import androidx.compose.material.icons.outlined.WidthFull +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshotFlow +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.FilterQuality +import androidx.compose.ui.graphics.ImageBitmap +import androidx.compose.ui.graphics.asAndroidBitmap +import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.input.pointer.PointerEventType +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.IntSize +import com.droiddeck.launcher.R +import com.droiddeck.launcher.session.CdpPage +import com.droiddeck.launcher.session.SessionPhase +import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.session.SessionState +import com.droiddeck.launcher.session.SteamQam +import kotlin.math.min +import kotlin.math.roundToInt +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.NonCancellable +import kotlinx.coroutines.cancelAndJoin +import kotlinx.coroutines.delay +import kotlinx.coroutines.ensureActive +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import kotlinx.coroutines.withTimeoutOrNull +import org.json.JSONArray +import org.json.JSONObject + +internal class QamFrame(val image: ImageBitmap, val cssWidth: Float, val cssHeight: Float, val contentRight: Float) { + val pxPerCss: Float get() = image.width / cssWidth + + /** The menu's own background, sampled inside its right edge, to fill the panel around it. */ + val fill: Color = runCatching { + val x = (contentRight * pxPerCss).roundToInt() - 4 + Color(image.asAndroidBitmap().getPixel(x.coerceIn(0, image.width - 1), image.height / 2)) + }.getOrDefault(Color.Black) +} + +/** How Steam's Quick Access menu sits on the bottom screen. */ +internal enum class QamFit(val id: String, @StringRes val label: Int, val icon: ImageVector, val align: Int) { + FULL("full", R.string.bottom_qam_layout_full, Icons.Outlined.WidthFull, 0), + LEFT("left", R.string.bottom_qam_layout_left, Icons.Outlined.AlignHorizontalLeft, -1), + CENTER("center", R.string.bottom_qam_layout_center, Icons.Outlined.AlignHorizontalCenter, 0), + RIGHT("right", R.string.bottom_qam_layout_right, Icons.Outlined.AlignHorizontalRight, 1); + + val next: QamFit get() = entries[(ordinal + 1) % entries.size] + + companion object { + fun from(id: String?): QamFit = entries.firstOrNull { it.id == id } ?: FULL + + private val state = mutableStateOf(null) + + fun current(context: Context): QamFit = state.value ?: from(SessionPrefs.quickAccessLayout(context)).also { state.value = it } + + fun choose(context: Context, fit: QamFit) { + state.value = fit + SessionPrefs.setQuickAccessLayout(context, fit.id) + } + } +} + +internal object QamLayout { + private const val WIDE_CSS = "div.BasicUI { width: 100% !important; } div[class*=\\\"tab_\\\"] { max-width: none !important; }" + + /** Scale and left edge of the menu in a box; [align] -1, 0 or 1 places a narrower menu left, centred or right. */ + fun fit(boxWidth: Float, boxHeight: Float, contentRight: Float, cssHeight: Float, align: Int = 0): Pair { + val scale = min(boxWidth / contentRight, boxHeight / cssHeight) + return scale to (boxWidth - contentRight * scale) * (align.coerceIn(-1, 1) + 1) / 2f + } + + fun toCss(x: Float, y: Float, scale: Float, left: Float): Pair = (x - left) / scale to y / scale + + /** Makes the menu follow the panel-shaped view (Steam sizes it once, on open) and lifts each tab's 300 px cap, then measures where the content ends. */ + /** [wide] is false while the menu is shown on the top screen, where it keeps Steam's own layout. */ + fun contentScript(wide: Boolean): String = "(() => { let s = document.getElementById('dd-qam-wide'); " + + "if (!s) { s = document.createElement('style'); s.id = 'dd-qam-wide'; document.head.appendChild(s); } " + + "const css = '${if (wide) WIDE_CSS else ""}'; " + + "if (s.textContent !== css) s.textContent = css; if (document.scrollingElement.scrollLeft) document.scrollingElement.scrollLeft = 0; " + + "const w = innerWidth; let right = 0; for (const e of document.body.querySelectorAll('*')) { " + + "const r = e.getBoundingClientRect(); const tab = /(^| )tab_/.test(String(e.className)); " + + "if (r.width > 0 && r.height > 0 && (tab || r.width < w * 0.75) && r.right > right) right = r.right; } " + + "return JSON.stringify([w, innerHeight, devicePixelRatio, right]); })()" +} + +private const val TICK_MS = 1_000L +private const val FAST_TICK_MS = 150L +private const val MAX_RETRY_MS = 4_000L + +/** The last frame shown, so returning to the panel shows the menu at once while the live stream reconnects. */ +private object QamCache { + @Volatile var image: ImageBitmap? = null + @Volatile var shape: FloatArray? = null +} + +@Composable +internal fun SteamQamPanel() { + val context = LocalContext.current.applicationContext + var image by remember { mutableStateOf(QamCache.image) } + var shape by remember { mutableStateOf(QamCache.shape) } + var failed by remember { mutableStateOf(false) } + var slow by remember { mutableStateOf(false) } + LaunchedEffect(Unit) { + delay(2_500) + slow = true + } + val fit = QamFit.current(context) + val holder = remember { arrayOfNulls(1) } + val owner = remember { SteamQam.newOwner() } + val relay = remember { intArrayOf(0) } + val live = remember { java.util.concurrent.atomic.AtomicBoolean(false) } + val aspect = remember { floatArrayOf(0f) } + val measure = Modifier.fillMaxSize().onSizeChanged { if (it.height > 0) aspect[0] = it.width.toFloat() / it.height } + val show = { frame: ImageBitmap -> image = frame; QamCache.image = frame; live.set(true) } + LaunchedEffect(Unit) { + withContext(Dispatchers.IO) { + var misses = 0 + // The lease is renewed on its own, so slow discovery or a retry backoff never lets the held menu lapse. + val renew = launch { + while (isActive) { + if (SessionState.phase == SessionPhase.READY && aspect[0] > 0f) SteamQam.hold(context, aspect[0], owner) + delay(TICK_MS) + } + } + try { + while (isActive) { + // Holding the menu before Steam's first frame keeps gamescope from presenting it. + if (SessionState.phase != SessionPhase.READY) { + delay(FAST_TICK_MS) + continue + } + if (aspect[0] == 0f) { + delay(FAST_TICK_MS) + continue + } + val held = SteamQam.hold(context, aspect[0], owner) + ensureActive() + var reached = held != null + if (held?.open == SteamQam.QUICK_ACCESS) { + var page = holder[0] + if (page == null || page.closed) { + page?.close() + live.set(false) + page = SteamQam.target(context)?.let { t -> + if (relay[0] != 0 && relay[0] != t.port) SteamQam.stopRelay(context, relay[0]) + relay[0] = t.port + runCatching { + CdpPage(t.port, t.path) { method, params -> + if (method == "Page.screencastFrame") { + holder[0]?.send("Page.screencastFrameAck", JSONObject().put("sessionId", params.optInt("sessionId"))) + decodeFrame(params.optString("data"))?.let(show) + } + } + }.onFailure { android.util.Log.w("SteamQam", "devtools connect: $it") }.getOrNull() + } + holder[0] = page + ensureActive() + page?.send("Page.enable") + val started = page?.call("Page.startScreencast", JSONObject().put("format", "jpeg").put("quality", 85) + .put("maxWidth", 1920).put("maxHeight", 1440)) + if (page != null && (started == null || started.has("error") || !started.has("result"))) { + page.close() + page = null + holder[0] = null + } + } + // The screencast sends frames only when the menu repaints, so a still menu needs one screenshot. + if (!live.get()) { + page?.call("Page.captureScreenshot", JSONObject().put("format", "jpeg").put("quality", 85)) + ?.optJSONObject("result")?.optString("data")?.let(::decodeFrame)?.let(show) + } + reached = page != null + val wide = !held.top && QamFit.current(context) == QamFit.FULL + (page?.evaluate(QamLayout.contentScript(wide)) as? String)?.let { text -> + runCatching { + val a = JSONArray(text) + val layout = floatArrayOf(a.getDouble(0).toFloat(), a.getDouble(1).toFloat(), a.getDouble(2).toFloat(), a.getDouble(3).toFloat()) + if (!layout.contentEquals(shape)) { shape = layout; QamCache.shape = layout } + } + } + } + failed = !reached + // With no menu page to reach, retries slow down instead of starting guest processes several times a second. + misses = if (reached) 0 else misses + 1 + val wait = when { + !reached -> minOf(TICK_MS shl minOf(misses - 1, 2), MAX_RETRY_MS) + live.get() -> TICK_MS + else -> FAST_TICK_MS + } + val used = QamFit.current(context) + withTimeoutOrNull(wait) { + snapshotFlow { QamFit.current(context) }.first { it != used } + } + } + } finally { + withContext(NonCancellable) { + renew.cancelAndJoin() + val page = holder[0] + holder[0] = null + runCatching { page?.send("Page.stopScreencast") } + // The page outlives this connection, so the widened layout would otherwise stay on the top screen. + runCatching { page?.evaluate(QamLayout.contentScript(wide = false)) } + page?.close() + SteamQam.release(context, relay[0], owner) + } + } + } + } + val img = image + val l = shape + val f = remember(img, l) { + if (img != null && l != null && l[0] > 0f) QamFrame(img, l[0], l[1], l[3].coerceIn(l[0] * 0.25f, l[0])) else null + } + if (f == null) { + Box(measure) { + if (slow) PanelNote(stringResource(if (failed) R.string.bottom_qam_unavailable else R.string.achievements_reading)) + } + return + } + BoxWithConstraints(measure.background(f.fill)) { + val density = LocalDensity.current + val boxW = with(density) { maxWidth.toPx() } + val boxH = with(density) { maxHeight.toPx() } + val (scale, left) = QamLayout.fit(boxW, boxH, f.contentRight, f.cssHeight, fit.align) + Canvas( + Modifier.fillMaxSize().pointerInput(f.cssWidth, f.contentRight, boxW, boxH, fit) { + var touching = false + var target: CdpPage? = null + try { + awaitPointerEventScope { + while (true) { + val event = awaitPointerEvent() + val change = event.changes.firstOrNull() ?: continue + val (x, y) = QamLayout.toCss(change.position.x, change.position.y, scale, left) + val type = when (event.type) { + PointerEventType.Press -> if (x in 0f..f.contentRight && y in 0f..f.cssHeight) "touchStart" else null + PointerEventType.Move -> "touchMove" + PointerEventType.Release -> "touchEnd" + else -> null + }?.takeIf { it == "touchStart" || touching } ?: continue + if (type == "touchStart") target = holder[0] + touching = type != "touchEnd" + val points = if (type == "touchEnd") JSONArray() + else JSONArray().put(JSONObject().put("x", x.toDouble()).put("y", y.toDouble())) + target?.send("Input.dispatchTouchEvent", JSONObject().put("type", type).put("touchPoints", points)) + if (!touching) target = null + change.consume() + } + } + } finally { + if (touching) target?.send("Input.dispatchTouchEvent", + JSONObject().put("type", "touchCancel").put("touchPoints", JSONArray())) + } + }, + ) { + val px = f.pxPerCss + drawImage( + f.image, + srcOffset = IntOffset.Zero, + srcSize = IntSize((f.contentRight * px).roundToInt().coerceAtMost(f.image.width), f.image.height), + dstOffset = IntOffset(left.roundToInt(), 0), + dstSize = IntSize((f.contentRight * scale).roundToInt(), (f.cssHeight * scale).roundToInt()), + filterQuality = FilterQuality.Medium, + ) + } + } +} + +private fun decodeFrame(data: String): ImageBitmap? = runCatching { + val bytes = Base64.decode(data, Base64.DEFAULT) + BitmapFactory.decodeByteArray(bytes, 0, bytes.size)?.asImageBitmap() +}.getOrNull() diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt b/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt index 446420806c..c916b3f7ad 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt @@ -81,10 +81,13 @@ object BuildWatermark { if (activity is QuestXrActivity) return val decor = activity.window.decorView as? ViewGroup ?: return decor.findViewWithTag(TAG)?.let(decor::removeView) - if (!com.droiddeck.launcher.session.SessionPrefs.buildWatermarkEnabled(activity)) return - val lab = com.droiddeck.launcher.lab.LabOverlay.active?.let { "LAB | ${truncate(it.label)}" } - val build = lineProvider().orEmpty() - val content = (listOfNotNull(lab) + build).ifEmpty { return } + val prefs = com.droiddeck.launcher.session.SessionPrefs + val debugLogs = if (prefs.logsEnabled(activity) && prefs.gameDebugLogsEnabled(activity)) DEBUG_LOGS_LINE else null + val build = if (prefs.buildWatermarkEnabled(activity)) { + listOfNotNull(com.droiddeck.launcher.lab.LabOverlay.active?.let { "LAB | ${truncate(it.label)}" }) + + lineProvider().orEmpty() + } else emptyList() + val content = (build + listOfNotNull(debugLogs)).ifEmpty { return } val margin = (8 * activity.resources.displayMetrics.density).toInt() decor.addView( MarkView(activity, content).apply { tag = TAG }, @@ -96,6 +99,8 @@ object BuildWatermark { ) } + internal const val DEBUG_LOGS_LINE = "GAME DEBUG LOGS ON | slows games" + private const val TAG = "build-watermark" private class MarkView(context: Context, private val lines: List) : View(context) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/DevPreview.kt b/app/src/main/java/com/droiddeck/launcher/ui/DevPreview.kt index 46ea147324..6745afaa01 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/DevPreview.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/DevPreview.kt @@ -57,12 +57,17 @@ import com.droiddeck.launcher.stores.StoresState /** What the Library pretends while a developer previews it. Nothing here is saved: a restart always comes back to [OFF]. */ internal enum class LibraryPreview { OFF, NOTHING_INSTALLED, SIGNED_OUT, SAMPLE } +/** How many games the Steam home pretends are installed. Nothing here is saved. */ +internal enum class SteamHomePreview(val games: Int) { OFF(-1), NONE(0), FEW(3), MANY(12) } + internal enum class DrawerPreview { STEAM, DESKTOP, GAME } /** Developer tools' preview states: screens that are otherwise hard to reach, shown without changing anything real. */ internal object DevPreview { var library by mutableStateOf(LibraryPreview.OFF) var drawer by mutableStateOf(null) + var steamHome by mutableStateOf(SteamHomePreview.OFF) + var openSteam by mutableStateOf(false) /** The UI zoo sheet: where previews are picked, one at a time, only when asked for. */ var zoo by mutableStateOf(false) /** Opt-in: a preview button where its state lives (the Library's toolbar), for switching states without the zoo. */ @@ -87,6 +92,41 @@ internal fun sampleOwned(store: Store): List = internal fun sampleInstalled(owned: Map>): Set = owned.values.flatMap { items -> items.take(SAMPLE_INSTALLED).map { it.key } }.toSet() +/** The Steam home's games while a developer previews it: this many invented titles, no art, nothing installed. */ +internal fun sampleSteamHomeGames(count: Int): List = listOf( + "Portal 2", "Hades", "Celeste", "Stardew Valley", "Hollow Knight", "Balatro", + "Dead Cells", "Terraria", "Vampire Survivors", "Slay the Spire", "Cuphead", "Inscryption", +).take(count).mapIndexed { i, name -> + com.droiddeck.launcher.frontend.Library.SteamGame(1000 + i, name, art = null, library = "steam", lastPlayed = 1_700_000_000_000L - i * 86_400_000L) +} + +/** The pill a previewed Steam home shows, so the fake state is never mistaken for the real one. */ +@Composable +internal fun SteamHomePreviewPill(modifier: Modifier = Modifier) { + val preview = DevPreview.steamHome + if (preview == SteamHomePreview.OFF) return + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val label = stringResource( + when (preview) { + SteamHomePreview.NONE -> R.string.dev_preview_steam_none + SteamHomePreview.FEW -> R.string.dev_preview_steam_few + else -> R.string.dev_preview_steam_many + }, + ) + val end = stringResource(R.string.dev_preview_end) + Row( + verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp), + modifier = modifier.background(colors.surface, CircleShape).border(1.dp, pal.signal, CircleShape) + .clickable(role = Role.Button, onClickLabel = end) { DevPreview.steamHome = SteamHomePreview.OFF } + .padding(start = 14.dp, end = 10.dp, top = 8.dp, bottom = 8.dp).testTag("dev-preview-steam-end"), + ) { + Icon(Icons.Outlined.Visibility, null, tint = pal.signal, modifier = Modifier.size(18.dp)) + Text(stringResource(R.string.dev_preview_banner, label), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) + Icon(Icons.Filled.Close, end, tint = colors.onSurfaceVariant, modifier = Modifier.size(18.dp)) + } +} + /** The pill a previewed Library shows, so the fake state is never mistaken for the real one. */ @Composable internal fun LibraryPreviewPill(modifier: Modifier = Modifier) { @@ -215,6 +255,17 @@ internal fun UiZooSheet() { DrawerPreview.GAME to R.string.session_title_game, )) ActionRow(stringResource(label), null, show, onClick = { close(); DevPreview.drawer = mode }, modifier = Modifier.testTag("zoo-drawer-${mode.name.lowercase()}")) } + SettingsGroup(stringResource(R.string.dev_preview_steam_home)) { + for ((mode, label) in listOf( + SteamHomePreview.NONE to R.string.dev_preview_steam_none, + SteamHomePreview.FEW to R.string.dev_preview_steam_few, + SteamHomePreview.MANY to R.string.dev_preview_steam_many, + )) ActionRow( + stringResource(label), null, show, + onClick = { close(); DevPreview.steamHome = mode; DevPreview.openSteam = true }, + modifier = Modifier.testTag("zoo-steam-${mode.name.lowercase()}"), + ) + } SettingsGroup(stringResource(R.string.dev_preview_library)) { for ((mode, label) in listOf( LibraryPreview.NOTHING_INSTALLED to R.string.dev_preview_library_nothing_installed, diff --git a/app/src/main/java/com/droiddeck/launcher/ui/EmptyLibrary.kt b/app/src/main/java/com/droiddeck/launcher/ui/EmptyLibrary.kt index 192afbece1..b63eada15e 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/EmptyLibrary.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/EmptyLibrary.kt @@ -15,7 +15,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.setValue -import androidx.compose.runtime.withFrameMillis +import androidx.compose.runtime.withFrameNanos import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.CornerRadius import androidx.compose.ui.geometry.Offset @@ -99,7 +99,7 @@ private fun rememberMarkClock(avoid: Rect?): MarkClock { var vx = speed * 0.8f var vy = -speed * 0.6f while (true) { - if (clock.page == Size.Zero) { withFrameMillis { }; continue } + if (clock.page == Size.Zero) { withFrameNanos { }; continue } val f = MarkFrame(clock.page, Offset.Zero) if (clock.at == Offset.Unspecified) clock.at = Offset(clock.page.width * 0.64f, clock.page.height * 0.42f) if (Motion.scale == 0f) { @@ -108,8 +108,13 @@ private fun rememberMarkClock(avoid: Rect?): MarkClock { clock.wall = 0f return@LaunchedEffect } - withFrameMillis { now -> - val dt = if (last < 0) 0f else min(50f, (now - last) / Motion.scale) + withFrameNanos { nanos -> + val scale = Motion.scale + if (scale == 0f) return@withFrameNanos + val settled = clock.intro >= END && clock.ball >= IMPACT + REVEAL_MS && !clock.poked + if (settled && last >= 0 && !IdleFrames.due(nanos)) return@withFrameNanos + val now = nanos / 1_000_000L + val dt = if (last < 0) 0f else min(50f, (now - last).toFloat()) / scale.coerceAtLeast(0.01f) last = now clock.intro += dt clock.wall += dt @@ -117,34 +122,41 @@ private fun rememberMarkClock(avoid: Rect?): MarkClock { val before = clock.ball clock.ball += dt - var x = clock.at.x + vx * dt / 1000f - var y = clock.at.y + vy * dt / 1000f + var x = clock.at.x + var y = clock.at.y val hw = f.ball val hh = f.ball - if (x - hw < 0f) { x = hw; vx = abs(vx) } - if (x + hw > clock.page.width) { x = clock.page.width - hw; vx = -abs(vx) } - if (y - hh < 0f) { y = hh; vy = abs(vy) } - if (y + hh > clock.page.height) { y = clock.page.height - hh; vy = -abs(vy) } - keepOff?.inflate(clearance)?.let { r -> - val nearX = x.coerceIn(r.left, r.right) - val nearY = y.coerceIn(r.top, r.bottom) - val gapX = x - nearX - val gapY = y - nearY - val gap = hypot(gapX, gapY) - if (gap in 0.0001f..f.ball) { - val nx = gapX / gap - val ny = gapY / gap - x = nearX + nx * f.ball - y = nearY + ny * f.ball - val into = vx * nx + vy * ny - if (into < 0f) { vx -= 2f * into * nx; vy -= 2f * into * ny } - } else if (gap <= 0.0001f) { - val outX = if (x < r.center.x) r.left - f.ball - x else r.right + f.ball - x - val outY = if (y < r.center.y) r.top - f.ball - y else r.bottom + f.ball - y - if (abs(outX) < abs(outY)) { x += outX; vx = if (outX < 0) -abs(vx) else abs(vx) } - else { y += outY; vy = if (outY < 0) -abs(vy) else abs(vy) } + var left = dt + do { + val step = min(50f, left) + left -= step + x += vx * step / 1000f + y += vy * step / 1000f + if (x - hw < 0f) { x = hw; vx = abs(vx) } + if (x + hw > clock.page.width) { x = clock.page.width - hw; vx = -abs(vx) } + if (y - hh < 0f) { y = hh; vy = abs(vy) } + if (y + hh > clock.page.height) { y = clock.page.height - hh; vy = -abs(vy) } + keepOff?.inflate(clearance)?.let { r -> + val nearX = x.coerceIn(r.left, r.right) + val nearY = y.coerceIn(r.top, r.bottom) + val gapX = x - nearX + val gapY = y - nearY + val gap = hypot(gapX, gapY) + if (gap in 0.0001f..f.ball) { + val nx = gapX / gap + val ny = gapY / gap + x = nearX + nx * f.ball + y = nearY + ny * f.ball + val into = vx * nx + vy * ny + if (into < 0f) { vx -= 2f * into * nx; vy -= 2f * into * ny } + } else if (gap <= 0.0001f) { + val outX = if (x < r.center.x) r.left - f.ball - x else r.right + f.ball - x + val outY = if (y < r.center.y) r.top - f.ball - y else r.bottom + f.ball - y + if (abs(outX) < abs(outY)) { x += outX; vx = if (outX < 0) -abs(vx) else abs(vx) } + else { y += outY; vy = if (outY < 0) -abs(vy) else abs(vy) } + } } - } + } while (left > 0f) clock.at = Offset(x, y) if (before < IMPACT && clock.ball >= IMPACT) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt index bc55af594e..574ad4c56c 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt @@ -272,7 +272,10 @@ private fun Content( return } if (selected == "steam") { - SteamHome(s, a, modifier) + Box(modifier) { + SteamHome(s, a, Modifier.fillMaxSize()) + SteamHomePreviewPill(Modifier.align(androidx.compose.ui.Alignment.BottomCenter).padding(bottom = 20.dp)) + } return } if (selected == "store") { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt index 2322e93827..d7d2395a3f 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt @@ -96,8 +96,7 @@ import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.layout.onPlaced import com.droiddeck.launcher.core.PhantomProcessLimit - -internal val AttentionAmber = Color(0xFFFFB547) +internal val AttentionAmber: Color @Composable get() = LocalPalette.current.warning @Composable internal fun BottomBar( @@ -308,7 +307,7 @@ private fun RailItem( } if (badge) Box( modifier = Modifier.align(Alignment.TopEnd).padding(top = if (iconOnly) 7.dp else 8.dp, end = if (iconOnly) 9.dp else 18.dp) - .size(8.dp).clip(CircleShape).background(AttentionAmber), + .size(8.dp).clip(CircleShape).background(pal.warning), ) if (count > 0) Text( if (count > 9) "9+" else count.toString(), diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt index 6fdea19e64..fcfc591951 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt @@ -658,6 +658,11 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com LaunchedEffect(SetupTabs.openSection) { if (SetupTabs.openSection != null && (railSelection != "setup" || s.pageKey != null)) showRailPage("setup", true) } + LaunchedEffect(DevPreview.openSteam) { + if (!DevPreview.openSteam) return@LaunchedEffect + DevPreview.openSteam = false + showRailPage("steam", true) + } LaunchedEffect(DevPreview.openLibrary) { if (!DevPreview.openLibrary) return@LaunchedEffect DevPreview.openLibrary = false @@ -842,6 +847,7 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com com.droiddeck.launcher.stores.StoresState.pendingInstall?.let { item -> StoreTheme(item.store) { InstallWhere(item) } } com.droiddeck.launcher.stores.StoresState.itchPicking?.let { item -> StoreTheme(item.store) { ItchBuildPicker(item) { com.droiddeck.launcher.stores.StoresState.itchPicking = null } } } com.droiddeck.launcher.stores.StoresState.gameJoltPicking?.let { item -> StoreTheme(item.store) { GameJoltBuildPicker(item) { com.droiddeck.launcher.stores.StoresState.gameJoltPicking = null } } } + com.droiddeck.launcher.stores.StoresState.steamPicking?.let { item -> StoreTheme(item.store) { SteamInstallWhereDialog(item) { com.droiddeck.launcher.stores.StoresState.steamPicking = null } } } StepsLayer(screenAt) UiZooSheet() SessionDrawerPreview(s.secondScreenDisplays) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt index 543c5f6857..8e3727348b 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt @@ -103,7 +103,7 @@ internal object SetupTabs { } @Composable -internal fun CheckRow(state: CheckState, title: String, detail: String?, divider: Boolean = true, action: (@Composable () -> Unit)? = null) { +internal fun CheckRow(state: CheckState, title: String, detail: String?, divider: Boolean = true, detailLines: Int = 2, action: (@Composable () -> Unit)? = null) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current val tint = when (state) { @@ -135,7 +135,7 @@ internal fun CheckRow(state: CheckState, title: String, detail: String?, divider } Column(modifier = Modifier.weight(1f)) { Text(title, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) - if (detail != null) Text(detail, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis) + if (detail != null) Text(detail, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = detailLines, overflow = TextOverflow.Ellipsis) } if (action != null) action() } @@ -237,12 +237,17 @@ internal fun SetupPanel( onNext = { pick((tab + 1) % tabs.size) }, ), ) { - PageHeader(stringResource(R.string.setup_title)) { + val sectionBar: @Composable (Modifier) -> Unit = { m -> SettingsPillSearch( - Modifier.weight(1f), searching, query, { query = it }, + m, searching, query, { query = it }, onOpen = { searching = true }, onClose = { searching = false; query = "" }, ) { SheetChips(tabs, tab, chipFocus, onPick = pick) } } + val portrait = androidx.compose.ui.platform.LocalConfiguration.current.orientation == android.content.res.Configuration.ORIENTATION_PORTRAIT + if (portrait) { + PageHeader(stringResource(R.string.setup_title)) + Row(Modifier.fillMaxWidth().padding(bottom = 10.dp)) { sectionBar(Modifier.weight(1f)) } + } else PageHeader(stringResource(R.string.setup_title)) { sectionBar(Modifier.weight(1f)) } val listing = searching && query.isNotBlank() val fixed = tab == CONTROLLER_TAB && !listing Column(modifier = Modifier.weight(1f).fillMaxWidth().then(if (fixed) Modifier else Modifier.verticalScroll(rememberScrollState())).padding(bottom = if (fixed) 0.dp else 24.dp)) { @@ -1254,6 +1259,7 @@ private fun CustomColorRows() { Triple("signal", stringResource(R.string.theme_custom_signal), colors.signal), Triple("good", stringResource(R.string.theme_custom_good), colors.good), Triple("error", stringResource(R.string.theme_custom_error), colors.error), + Triple("warning", stringResource(R.string.theme_custom_warning), colors.warning), ) rows.forEach { (key, label, argb) -> diff --git a/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt b/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt index bb4cc867cf..6d64f033b9 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt @@ -56,6 +56,7 @@ import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.SideEffect import androidx.compose.runtime.key +import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.produceState import androidx.compose.runtime.remember @@ -95,6 +96,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import coil.compose.AsyncImage import com.droiddeck.launcher.R +import com.droiddeck.launcher.frontend.AddedGameEdits import com.droiddeck.launcher.frontend.GameRemoval import com.droiddeck.launcher.frontend.Library import com.droiddeck.launcher.runtime.CurseForgeApp @@ -103,6 +105,7 @@ import com.droiddeck.launcher.runtime.WowAddonCatalog import com.droiddeck.launcher.runtime.WowAddons import com.droiddeck.launcher.store.UserAppsState import com.droiddeck.launcher.session.GameSaves +import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.SessionState import com.droiddeck.launcher.stores.CatalogItem import com.droiddeck.launcher.stores.CloudSaves @@ -139,6 +142,7 @@ import androidx.compose.foundation.layout.offset internal class GameRef(val appId: Int?, val store: Store?, val storeId: String?) { fun game(games: List): Library.SteamGame? = when { appId != null -> games.firstOrNull { it.appId == appId } + store == Store.STEAM && storeId != null -> games.firstOrNull { Library.fromSteamClient(it) && it.appId.toString() == storeId } store != null && storeId != null -> games.firstOrNull { it.source == store.id && it.storeId == storeId } else -> null } @@ -182,7 +186,7 @@ internal fun GameDetail( if (nothing) return val source = game?.source ?: store?.id ?: Library.SOURCE_STEAM val title = game?.name ?: item?.title ?: installed?.sidecar?.title ?: id.orEmpty() - val favoriteKey = if (store != null && id != null) "${store.id}:$id" else game?.let { GameRef.key(it) } ?: key + val favoriteKey = if (store == Store.STEAM && id != null) "app:$id" else if (store != null && id != null) "${store.id}:$id" else game?.let { GameRef.key(it) } ?: key val scores = if (source != Library.ADDED) rememberGameScores(title.takeIf { it.isNotBlank() && it != id }) else null val achievements = remember(store, id, item?.accessible, installed) { when { @@ -224,10 +228,22 @@ internal fun GameDetail( val t = tab ?: return@LaunchedEffect if (!inPage) focusWithinFrames({ onStrip }) { tabFocus.getValue(t) } } + var steppedTo by remember(key) { mutableStateOf(null) } + LaunchedEffect(steppedTo, tab) { + val t = steppedTo ?: return@LaunchedEffect + if (t != tab) { + steppedTo = null + return@LaunchedEffect + } + focusSoon { tabFocus.getValue(t) } + steppedTo = null + } fun cycle(step: Int) { if (tabs.size < 2) return val at = tabs.indexOf(tab).coerceAtLeast(0) - picked = tabs[(at + step + tabs.size) % tabs.size] + val next = tabs[(at + step + tabs.size) % tabs.size] + picked = next + if (inPage) steppedTo = next } val art: Any? = game?.hero ?: item?.imageUrl ?: installed?.sidecar?.hero ?: installed?.sidecar?.cover val artModel: Any? = if (art is String) cardArtRequest(art, item?.tallImageUrl) else art @@ -987,6 +1003,25 @@ private fun LaunchTab(game: Library.SteamGame, s: FrontEndState, a: FrontEndActi } val folder = game.gameFiles if (game.library == Library.ADDED && game.source == Library.ADDED && !s.shortcutPicker && folder != null) ShortcutFields(game, folder) + if (game.library == Library.ADDED && Store.byId(game.source) == Store.EA && folder != null) StoreLaunchOptions(folder, a) + } +} + +@Composable +private fun StoreLaunchOptions(folder: File, a: FrontEndActions) { + val app = LocalContext.current.applicationContext + val scope = rememberCoroutineScope() + var saved by remember(folder.path) { mutableStateOf(SessionPrefs.addedGameLaunch(app, folder.path)) } + var editing by remember(folder.path) { mutableStateOf(false) } + Column(Modifier.fillMaxWidth().tabPanel()) { + MenuItem(stringResource(R.string.edit_launch_options), checked = false, detail = saved.ifEmpty { "—" }) { editing = true } + } + if (editing) TextEntryDialog(stringResource(R.string.edit_launch_options), saved, onDismiss = { editing = false }) { value -> + scope.launch { + withContext(Dispatchers.IO) { AddedGameEdits.setLaunchOptions(app, folder.path, value) } + saved = value + a.onAddedGamesChanged(listOf(folder.path)) + } } } @@ -1068,8 +1103,36 @@ private fun AddonsTab(g: Library.SteamGame, targets: List, ses runCatching { CurseForgeApp.byFolder(link.installed(context, target, scanKey)) }.getOrDefault(emptyMap()) } } + val progress = remember(target.addOns) { mutableStateMapOf() } + val curseOf = { item: WowAddons.Installed -> link?.let { l -> managed[item.name.lowercase()]?.let { it to l } } } + val outdated = names.filter { item -> curseOf(item)?.first?.update ?: (updates[item.name] != null) } + val scope = rememberCoroutineScope() if (targets.size > 1) SectionLabel(target.flavor) MenuItem(stringResource(R.string.addons_download), checked = false) { browsing = target } + if (outdated.size > 1 && !SessionState.running) MenuItem( + stringResource(R.string.store_update_all, outdated.size), checked = false, enabled = progress.isEmpty(), + ) { + val plan = outdated.groupBy { item -> curseOf(item)?.first?.id?.let { "curse:$it" } ?: "folder:${item.name}" }.values.map { group -> + Triple(group.map { it.name }, updates[group.first().name], curseOf(group.first())) + } + plan.forEach { (folders) -> folders.forEach { progress[it] = 0 } } + val owned = plan.flatMap { it.first }.toMutableSet() + scope.launch { + try { + plan.forEach { (folders, wowi, curse) -> + val name = folders.first() + val (message, ok) = updateAddon(context, name, wowi.takeIf { curse == null }, target, curse) { pct -> + scope.launch { folders.forEach { progress[it] = pct } } + } + folders.forEach { progress.remove(it) } + owned.removeAll(folders.toSet()) + if (!ok && message != null) android.widget.Toast.makeText(context, message, android.widget.Toast.LENGTH_LONG).show() + } + } finally { + owned.forEach { progress.remove(it) } + } + } + } MenuItem( stringResource(R.string.games_import_addons), checked = false, detail = pluralStringResource(R.plurals.games_addons_count, names.size, names.size), @@ -1078,7 +1141,7 @@ private fun AddonsTab(g: Library.SteamGame, targets: List, ses target.addOns.mkdirs() a.onBrowseFiles(target.addOns) } - names.forEach { item -> key(target.addOns, item.name) { AddonRow(item, updates[item.name], target, a, link?.let { l -> managed[item.name.lowercase()]?.let { it to l } }) } } + names.forEach { item -> key(target.addOns, item.name) { AddonRow(item, updates[item.name], target, a, progress, curseOf(item)) } } } } } @@ -1132,12 +1195,12 @@ private fun CurseForgeEntry(a: FrontEndActions) { } @Composable -internal fun AddonRow(item: WowAddons.Installed, wowiUpdate: WowAddonCatalog.Addon?, target: WowAddons.Target, a: FrontEndActions, curse: Pair? = null) { +internal fun AddonRow(item: WowAddons.Installed, wowiUpdate: WowAddonCatalog.Addon?, target: WowAddons.Target, a: FrontEndActions, progresses: MutableMap, curse: Pair? = null) { val name = item.name val update = wowiUpdate.takeIf { curse == null } val outdated = update != null || curse?.first?.update == true var asking by remember(target.addOns, name) { mutableStateOf(false) } - var progress by remember(target.addOns, name) { mutableStateOf(null) } + val progress = progresses[name] val context = LocalContext.current val scope = rememberCoroutineScope() val delete = stringResource(R.string.common_delete) @@ -1152,31 +1215,39 @@ internal fun AddonRow(item: WowAddons.Installed, wowiUpdate: WowAddonCatalog.Add ) } if (outdated && !SessionState.running) IconAction(Icons.Outlined.Download, stringResource(R.string.common_update), "addon:update:${target.flavor}:$name", enabled = progress == null) { - progress = 0 + progresses[name] = 0 scope.launch { - val message = withContext(Dispatchers.IO) { - if (curse != null) { - val (project, link) = curse - val done = runCatching { link.change(context, target) { CurseForgeApp.update(context, it.inspector, it.guid, project.id) } }.getOrDefault(false) - WowAddons.changed() - if (done) context.getString(R.string.user_apps_updated, name) else context.getString(R.string.stores_dl_failed_reason, name) - } else update?.let { installAddon(context, it, target) { pct -> scope.launch { progress = pct } }.first } + try { + val message = updateAddon(context, name, update, target, curse) { pct -> scope.launch { progresses[name] = pct } }.first + if (message != null) android.widget.Toast.makeText(context, message, android.widget.Toast.LENGTH_LONG).show() + } finally { + progresses.remove(name) } - progress = null - if (message != null) android.widget.Toast.makeText(context, message, android.widget.Toast.LENGTH_LONG).show() } } - if (!SessionState.running) IconAction(Icons.Outlined.Delete, if (curse != null) stringResource(R.string.common_uninstall) else delete, "addon:delete:${target.flavor}:$name", danger = true) { asking = true } + if (!SessionState.running) IconAction(Icons.Outlined.Delete, if (curse != null) stringResource(R.string.common_uninstall) else delete, "addon:delete:${target.flavor}:$name", danger = true, enabled = progress == null) { asking = true } } if (asking) ConfirmDialog( title = if (curse != null) stringResource(R.string.stores_uninstall_title, name) else stringResource(R.string.games_delete_addon_title, name), text = stringResource(R.string.games_delete_addon_body), confirm = if (curse != null) stringResource(R.string.common_uninstall) else delete, - onConfirm = { a.onAddonDelete(target, name) }, + onConfirm = { asking = false; if (progresses[name] == null) a.onAddonDelete(target, name) }, onDismiss = { asking = false }, ) } +private suspend fun updateAddon( + context: android.content.Context, name: String, update: WowAddonCatalog.Addon?, target: WowAddons.Target, + curse: Pair?, onProgress: (Int) -> Unit, +): Pair = withContext(Dispatchers.IO) { + if (curse != null) { + val (project, link) = curse + val done = runCatching { link.change(context, target) { CurseForgeApp.update(context, it.inspector, it.guid, project.id) } }.getOrDefault(false) + WowAddons.changed() + (if (done) context.getString(R.string.user_apps_updated, name) else context.getString(R.string.stores_dl_failed_reason, name)) to done + } else update?.let { installAddon(context, it, target, onProgress).let { (message, version) -> message to (version != null) } } ?: (null to false) +} + @Composable private fun CloudRows(g: Library.SteamGame, onSynced: () -> Unit = {}) { val store = Store.byId(g.source)?.takeIf { it != Store.AMAZON } ?: return diff --git a/app/src/main/java/com/droiddeck/launcher/ui/InputBindingWidgets.kt b/app/src/main/java/com/droiddeck/launcher/ui/InputBindingWidgets.kt index a8eb95b347..23302a090c 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/InputBindingWidgets.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/InputBindingWidgets.kt @@ -33,6 +33,8 @@ internal fun commandLabel(command: InputCommand) = stringResource(when (command) InputCommand.KEYBOARD -> R.string.input_command_keyboard InputCommand.STEAM -> R.string.input_command_steam InputCommand.QUICK_ACCESS -> R.string.input_command_qam + InputCommand.GAME_ZOOM_IN -> R.string.input_command_zoom_in + InputCommand.GAME_ZOOM_OUT -> R.string.input_command_zoom_out }) @Composable diff --git a/app/src/main/java/com/droiddeck/launcher/ui/InputSettingsPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/InputSettingsPage.kt index 2fe1346034..1274945a3b 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/InputSettingsPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/InputSettingsPage.kt @@ -174,14 +174,15 @@ private fun InputSettingsContent(onBack: () -> Unit, onChanged: () -> Unit, embe detail = if (library.usersOfBindings(b.id).size > 1) stringResource(R.string.input_shared_detail, b.name, library.usersOfBindings(b.id).size) else "${profile.name} · ${roleLabel(role)}", onSave = { action -> if (update { l -> + val currentPreset = l.preset(editing.preset) val geometry = if (!editing.click && elementProperties != null && layout != null) l.withLayout(layout.copy(elements = layout.elements.map { if (it.id == elementProperties!!.id) elementProperties!!.copy(name = elementProperties!!.name.trim().ifBlank { it.name }) else it })) else l geometry.withPreset(when { - editing.element != null && editing.click -> b.copy(clicks = b.clicks + (editing.element.id to action)) - editing.element != null -> b.copy(elements = b.elements + (editing.element.id to action)) - editing.key != null -> b.copy(keys = b.keys.filterNot { it.key == editing.key } + PhysicalInputBinding(editing.key, action)) - else -> b.copy(controls = b.controls + (editing.control to action)) + editing.element != null && editing.click -> currentPreset.copy(clicks = currentPreset.clicks + (editing.element.id to action)) + editing.element != null -> currentPreset.copy(elements = currentPreset.elements + (editing.element.id to action)) + editing.key != null -> currentPreset.copy(keys = currentPreset.keys.filterNot { it.key == editing.key } + PhysicalInputBinding(editing.key, action)) + else -> currentPreset.copy(controls = currentPreset.controls + (editing.control to action)) }) }) edit = null }) } else if (!surface) key(page, profileId, role) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/LibraryHidden.kt b/app/src/main/java/com/droiddeck/launcher/ui/LibraryHidden.kt index c50a6c8978..584fee1072 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/LibraryHidden.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/LibraryHidden.kt @@ -15,6 +15,7 @@ import com.droiddeck.launcher.frontend.AddedGames import com.droiddeck.launcher.frontend.Library import com.droiddeck.launcher.frontend.SteamHidden import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.stores.Store internal const val LIBRARY_HIDDEN = "hidden" internal val HIDDEN_DOT = androidx.compose.ui.graphics.Color(0xFF9AA0A6) @@ -46,14 +47,18 @@ internal object LibraryHidden { } } - fun steamId(game: Library.SteamGame?): Long? = game?.takeIf { Library.fromSteamClient(it) }?.appId?.toLong() + /** The Steam client's own id for a game it lists, or for an owned Steam game it has not installed ([key] `steamstore:`). */ + fun steamId(game: Library.SteamGame?, key: String = ""): Long? = + game?.takeIf { Library.fromSteamClient(it) }?.appId?.toLong() + ?: key.takeIf { game == null && it.startsWith("${Store.STEAM.id}:") }?.substringAfter(':')?.toLongOrNull() - fun isHidden(key: String, game: Library.SteamGame?): Boolean = key in keys || steamId(game)?.let { it in steam } == true + fun isHidden(key: String, game: Library.SteamGame?): Boolean = key in keys || steamId(game, key)?.let { it in steam } == true - fun isHidden(entry: LibraryEntry): Boolean = isHidden(entry.favoriteKey, entry.game) + fun isHidden(entry: LibraryEntry): Boolean = + isHidden(entry.favoriteKey, entry.game) || entry.item?.takeIf { it.store == Store.STEAM }?.let { it.key in keys || it.id.toLongOrNull()?.let { id -> id in steam } == true } == true fun set(context: Context, key: String, game: Library.SteamGame?, hidden: Boolean): Boolean { - val id = steamId(game) + val id = steamId(game, key) val root = SessionPrefs.activeSteamRoot(context) val written = id?.let { SteamHidden.write(root, it, hidden) } if (id != null) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/LibraryPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/LibraryPage.kt index e940e7b47f..4a7575d275 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/LibraryPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/LibraryPage.kt @@ -139,7 +139,8 @@ internal class LibraryEntry( val game: Library.SteamGame?, val item: CatalogItem?, val installed: Boolean, ) { val storeKey: String? get() = item?.key ?: game?.storeId?.let { "${game.source}:$it" } - val favoriteKey: String get() = storeKey ?: key + /** A Steam game keeps the key it has once the Steam client lists it, so favoriting it before the install carries over. */ + val favoriteKey: String get() = if (item?.store == Store.STEAM) "app:${item.id}" else storeKey ?: key } internal fun libraryEntries( @@ -149,6 +150,7 @@ internal fun libraryEntries( val out = ArrayList() for (g in games.sortedBy { it.library == Library.XBOX_CLOUD }) { if (g.library == Library.EPIC_LAUNCHER) continue + if (Library.fromSteamClient(g)) claimed.add("${Store.STEAM.id}:${g.appId}") val storeKey = g.storeId?.let { "${g.source}:$it" } val item = storeKey?.let { k -> Store.byId(g.source)?.let { st -> owned[st]?.firstOrNull { it.key == k } } } if (storeKey != null) { @@ -160,7 +162,7 @@ internal fun libraryEntries( } for (store in Store.entries) for (item in owned[store].orEmpty()) { if (!claimed.add(item.key)) continue - out += LibraryEntry(GameRef.key(item), store.id, item.title, null, item, installed = item.key in installedStore) + out += LibraryEntry(GameRef.key(item), store.librarySource, item.title, null, item, installed = item.key in installedStore) } return out.distinctBy { it.key } } @@ -193,6 +195,10 @@ internal fun librarySources( } } +internal fun alwaysLibraryTabs(signedIn: Collection, stores: Boolean, soundMode: Boolean): Set = + (if (soundMode) emptyList() else signedIn.map { it.librarySource }).toSet() + + listOfNotNull(Library.ADDED.takeIf { stores }, Store.BATTLENET.id.takeIf { stores }) + internal object LibraryDisplay { const val DEFAULT_LEVEL = 2 val scales = listOf(0.75f, 0.875f, 1f, 1.2f, 1.45f) @@ -297,7 +303,7 @@ internal object LibraryView { fun showOwned(context: android.content.Context, store: Store) { SessionPrefs.setLibraryShowUninstalled(context, true) ownedRequest++ - source = store.id + source = store.librarySource query = "" focusFirst = true } @@ -372,7 +378,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String, .map { it.store.id }.toSet() val sources = librarySources( all, storeTabs.map { it.store.id }, - listOfNotNull(Store.ITCH.id.takeIf { itchSignedIn && !soundMode }, Store.GAMEJOLT.id.takeIf { gameJoltSignedIn && !soundMode }, Library.ADDED.takeIf { stores }).toSet() + signInChips, + alwaysLibraryTabs(owned.keys, stores, soundMode) + signInChips, favorites, concealed, offStores = if (soundMode) emptySet() else storeTabs.filterNot { it.shown }.map { it.store.id }.toSet(), places = if (soundMode) DEFAULT_LIBRARY_PLACES else StoreTabsState.libraryPlaces, @@ -630,7 +636,8 @@ private fun LibraryGrid( // A search that matches nothing keeps the toolbar, so the search can still be cleared. val customEmpty = !soundMode && source == Library.ADDED && visible.isEmpty() && hiddenUninstalled == 0 && LibraryView.query.isBlank() val splash = !soundMode && (signInStore != null || customEmpty) - val headerItems = (if (splash) 1 else 2) + (if (sizesPending) 1 else 0) + syncing.size + val showHeader = !splash || source == Store.BATTLENET.id + val headerItems = (if (showHeader) 2 else 1) + (if (sizesPending) 1 else 0) + syncing.size val expanded = showUninstalled == true val notInstalled = if (expanded) visible.count { !it.installed } else hiddenUninstalled val toggleAt = when { @@ -764,7 +771,7 @@ private fun LibraryGrid( Box(Modifier.onSizeChanged { chipsH = it.height }) { Rise(0) { if (soundMode) header() else filters() } } } val splashHeight = with(density) { (gridH - chipsH).toDp() - 28.dp }.coerceAtLeast(300.dp) - if (!splash) item(key = if (soundMode) "filters" else "header", span = { GridItemSpan(maxLineSpan) }) { Rise(1) { if (soundMode) filters() else header() } } + if (showHeader) item(key = if (soundMode) "filters" else "header", span = { GridItemSpan(maxLineSpan) }) { Rise(1) { if (soundMode) filters() else header() } } for ((store, line) in syncing) item(key = "sync-${store.id}", span = { GridItemSpan(maxLineSpan) }) { Column(verticalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier.fillMaxWidth()) { Text(store.shortLabel + " · " + line, fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis) @@ -880,6 +887,12 @@ private fun LibraryHeader( clearSearchFocus = searchCleared, inlineWhenStacked = true, lead = soundLead, ) { + if (!soundMode && !s.shortcutPicker && source == Store.BATTLENET.id) { + SecondaryButton( + stringResource(R.string.bnet_open), enabled = !s.busy && DevPreview.library == LibraryPreview.OFF, + compact = true, modifier = Modifier.testTag("library-battlenet-open"), onClick = a.onBattleNet, + ) + } if (soundMode) HeaderIconButton(stringResource(R.string.soundtracks_saved), Icons.Filled.BookmarkBorder, "collections", onClick = onCollections) if (!soundMode && DeveloperTools.on && DevPreview.shortcuts) LibraryPreviewButton() DisplayButton() diff --git a/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt b/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt index f58ee90807..66f6ea110a 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt @@ -100,7 +100,6 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalInputModeManager import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.Role -import androidx.compose.animation.core.animateFloat import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontWeight @@ -649,20 +648,20 @@ internal fun Handle(height: Dp, above: Boolean = false) { val pal = LocalPalette.current val shape = if (above) RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp) else RoundedCornerShape(bottomStart = 12.dp, bottomEnd = 12.dp) val still = Motion.scale == 0f - val bob = androidx.compose.animation.core.rememberInfiniteTransition(label = "handle") - val lift by bob.animateFloat( - 0f, 0f, - androidx.compose.animation.core.infiniteRepeatable( + val lift = remember { Animatable(0f) } + LaunchedEffect(still) { + lift.snapTo(0f) + if (!still) lift.animateTo( + 0f, androidx.compose.animation.core.keyframes { - durationMillis = 2400 + durationMillis = 620 0f at 0 1f at 180 using androidx.compose.animation.core.FastOutSlowInEasing -0.25f at 420 0f at 620 }, - ), - label = "handleBob", - ) + ) + } Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier.height(height).clip(shape).background(colors.surface) @@ -672,7 +671,7 @@ internal fun Handle(height: Dp, above: Boolean = false) { Text(stringResource(R.string.sheet_lip), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant, maxLines = 1) Icon( if (above) Icons.Filled.KeyboardArrowDown else Icons.Filled.KeyboardArrowUp, null, tint = colors.onSurfaceVariant, - modifier = Modifier.size(16.dp).graphicsLayer { translationY = if (still) 0f else (if (above) 3.dp else -3.dp).toPx() * lift }, + modifier = Modifier.size(16.dp).graphicsLayer { translationY = if (still) 0f else (if (above) 3.dp else -3.dp).toPx() * lift.value }, ) } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ManageStores.kt b/app/src/main/java/com/droiddeck/launcher/ui/ManageStores.kt index 2b3a4a5413..add703ce09 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ManageStores.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ManageStores.kt @@ -79,7 +79,7 @@ internal object StoreTabsState { private set fun load(context: android.content.Context) { - SessionPrefs.settleStoresTabOrder(context, Store.entries.map { it.id }) + SessionPrefs.settleStoresTabOrder(context, Store.tabbed.map { it.id }) tabs = arrangeStoreTabs(SessionPrefs.storesTabOrder(context), SessionPrefs.storesTabHidden(context)) libraryPlaces = SessionPrefs.libraryTabPlaces(context) ?: DEFAULT_LIBRARY_PLACES libraryHidden = SessionPrefs.libraryTabsHidden(context) + listOfNotNull(LIBRARY_HIDDEN.takeUnless { SessionPrefs.libraryShowHidden(context) }) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/NavTabs.kt b/app/src/main/java/com/droiddeck/launcher/ui/NavTabs.kt index 19b6ced051..2fa5d01cbd 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/NavTabs.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/NavTabs.kt @@ -27,7 +27,7 @@ internal object DeveloperTools { internal object NavTabs { const val MORE = "more" val ALL = listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent") - val DEFAULT_SHELVED = setOf("soundtracks", "components", "storage", "sync", "decky", "boot-movies", "agent") + val DEFAULT_SHELVED = setOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "agent") val DEFAULT_HIDDEN = setOf("android-apps", "agent") private val SHELVED_WHEN_NEW = setOf("storage", "sync", "decky", "boot-movies", "agent") private val OLD_ORDER = listOf("steam", "games", "soundtracks", "stores", "downloads", "desktop", "agent", "components", "android-apps", "storage", "sync", "setup", "updates") diff --git a/app/src/main/java/com/droiddeck/launcher/ui/RomsDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/RomsDialog.kt index 2504a2eee3..e9e09f7e45 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/RomsDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/RomsDialog.kt @@ -3,6 +3,8 @@ package com.droiddeck.launcher.ui import androidx.compose.foundation.shape.CircleShape import com.droiddeck.launcher.R import androidx.compose.ui.res.stringResource +import androidx.compose.ui.platform.LocalContext +import com.droiddeck.launcher.session.SessionPrefs import androidx.compose.foundation.layout.Column import androidx.compose.ui.Modifier import androidx.compose.foundation.layout.Spacer @@ -22,7 +24,7 @@ fun RomsDialog(path: String?, onChoose: () -> Unit, onClear: () -> Unit, onDismi text = { Column { Text( - stringResource(R.string.roms_text), + stringResource(if (SessionPrefs.mountSharedStorage(LocalContext.current)) R.string.roms_text else R.string.roms_text_unmounted), style = MaterialTheme.typography.bodyMedium, ) Spacer(Modifier.height(10.dp)) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt b/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt index ff0400860c..73df657efe 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt @@ -15,6 +15,10 @@ import android.view.WindowManager import android.widget.FrameLayout import android.widget.LinearLayout import androidx.activity.setViewTreeOnBackPressedDispatcherOwner +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.ExpandLess +import androidx.compose.material.icons.outlined.LightMode +import androidx.compose.material.icons.outlined.Tune import androidx.lifecycle.setViewTreeLifecycleOwner import androidx.lifecycle.setViewTreeViewModelStoreOwner import androidx.savedstate.setViewTreeSavedStateRegistryOwner @@ -43,6 +47,7 @@ class SecondScreenPresentation( private val onMenuTouched: () -> Unit = {}, private val onDeckPanel: (DeckPanel) -> Unit = { SessionPrefs.setDeckPanel(sessionActivity, it) }, private val picker: ((SecondScreenMode) -> ScreenPicker?)? = null, + private val panel: (SecondScreenMode) -> (@androidx.compose.runtime.Composable () -> Unit)? = { null }, ) : Presentation(sessionActivity, display) { private val frame = FrameLayout(context) private var menuView: androidx.compose.ui.platform.ComposeView? = null @@ -67,6 +72,19 @@ class SecondScreenPresentation( var controlsView: InputSurfaceView? = null private set private var created = false + private val brightnessOpen = androidx.compose.runtime.mutableStateOf(false) + private val brightness = androidx.compose.runtime.mutableIntStateOf(BottomBrightness.MIN) + private val brightnessView by lazy { + androidx.compose.ui.platform.ComposeView(context).apply { + setContent { + DroidDeckTheme { + if (!BottomChrome.barShown && currentMode.hasBar) PullTab() + if (brightnessOpen.value) BrightnessDrop(brightness.intValue, ::setBrightness, + onScreenOff = { brightnessOpen.value = false; screenOff() }, onDismiss = { brightnessOpen.value = false }) + } + } + } + } init { setCancelable(false) @@ -80,6 +98,9 @@ class SecondScreenPresentation( window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) frame.addView(root, FrameLayout.LayoutParams(-1, -1)) + frame.addView(brightnessView, FrameLayout.LayoutParams(-1, -1)) + frame.addView(sleepView, FrameLayout.LayoutParams(-1, -1)) + light(BottomScreenLight.ON) setContentView(frame) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { root.setOnApplyWindowInsetsListener { view, insets -> @@ -94,6 +115,7 @@ class SecondScreenPresentation( fun requestKeyboard(forField: Boolean = false) { if (!showsKeyboard || keyboardHost == null) return + wake() if (forField) fieldKeyboard = true keyboardPending = true if (window?.decorView?.hasWindowFocus() == true) showPendingKeyboard() @@ -127,6 +149,8 @@ class SecondScreenPresentation( fun showMode(mode: SecondScreenMode) { if (currentMode == mode && isShowing) return currentMode = mode + brightnessOpen.value = false + BottomChrome.reset() if (created) renderMode() } @@ -136,6 +160,7 @@ class SecondScreenPresentation( fun showChat(onLost: () -> Unit, content: @androidx.compose.runtime.Composable () -> Unit) { if (!showsKeyboard || chatView != null) return + wake() keyboardHost?.takeIf { it.shown }?.hide() keyboardShown.value = false keyboardPending = false @@ -174,6 +199,7 @@ class SecondScreenPresentation( val content = menu ?: return menuShown = on if (on) { + wake() keyboardHost?.takeIf { it.shown }?.hide() keyboardShown.value = false ownComposeViews() @@ -192,6 +218,7 @@ class SecondScreenPresentation( menuView?.let { frame.removeView(it); it.disposeComposition() } menuView = null root.visibility = View.VISIBLE + scheduleDim() } } @@ -223,21 +250,93 @@ class SecondScreenPresentation( } override fun dispatchKeyEvent(event: KeyEvent): Boolean { - val ownKeys = currentMode == SecondScreenMode.TERMINAL || currentMode == SecondScreenMode.DASHBOARD || + val ownKeys = currentMode == SecondScreenMode.TERMINAL || currentMode == SecondScreenMode.DASHBOARD || currentMode.sessionPanel || currentMode == SecondScreenMode.DESKTOP val back = event.keyCode == KeyEvent.KEYCODE_BACK && currentMode == SecondScreenMode.DASHBOARD - val forward = menuShown || !ownKeys || back || PadBridge.isControllerKeyEvent(event) + val pad = PadBridge.isControllerKeyEvent(event) + if (!pad) uiActivity() + val forward = menuShown || !ownKeys || back || pad if (forward && sessionActivity.dispatchKeyEvent(event)) return true return super.dispatchKeyEvent(event) } override fun dispatchTouchEvent(event: MotionEvent): Boolean { + if (event.actionMasked == MotionEvent.ACTION_DOWN && screen == BottomScreenLight.ON) waking = false + if (screen != BottomScreenLight.ON || waking) { + // The touch that wakes the screen is swallowed whole, so its release does not click what is under it. + when (event.actionMasked) { + MotionEvent.ACTION_DOWN -> if (screen != BottomScreenLight.ON) { waking = true; wake() } + MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> waking = false + } + return true + } + scheduleDim() if (menuShown && event.actionMasked == MotionEvent.ACTION_DOWN) onMenuTouched() return super.dispatchTouchEvent(event) } + private val sleepView = View(context).apply { + setBackgroundColor(Color.BLACK) + visibility = View.GONE + } + private var screen = BottomScreenLight.ON + private var waking = false + private val dim = Runnable { if (screen == BottomScreenLight.ON) light(BottomScreenLight.DIM) } + + fun screenOff() { + // A control held by another finger would keep its press, since the screen-off overlay takes the release. + controlsView?.releaseInputs() + light(BottomScreenLight.OFF) + } + + /** Keyboard or mouse use of the bottom screen's own UI counts as activity; an explicit screen off stays off. */ + private fun uiActivity() { + when (screen) { + BottomScreenLight.DIM -> wake() + BottomScreenLight.ON -> scheduleDim() + BottomScreenLight.OFF -> Unit + } + } + + fun wake() { + light(BottomScreenLight.ON) + scheduleDim() + } + + private fun light(state: BottomScreenLight) { + screen = state + sleepView.visibility = if (state == BottomScreenLight.OFF) View.VISIBLE else View.GONE + sleepView.alpha = 1f + val w = window ?: return + w.attributes = w.attributes.apply { + screenBrightness = when (state) { + BottomScreenLight.ON -> BottomBrightness.level(context) ?: state.brightness + BottomScreenLight.DIM -> BottomBrightness.dimmed(context, state.brightness) + BottomScreenLight.OFF -> state.brightness + } + } + } + + private fun toggleBrightness() { + if (!brightnessOpen.value) brightness.intValue = BottomBrightness.initial(context) + brightnessOpen.value = !brightnessOpen.value + } + + private fun setBrightness(percent: Int) { + val value = BottomBrightness.clamp(percent) + brightness.intValue = value + SessionPrefs.setBottomBrightness(context, value) + if (screen == BottomScreenLight.ON) light(BottomScreenLight.ON) + } + + private fun scheduleDim() { + frame.removeCallbacks(dim) + if (!menuShown && BottomScreenLight.autoDims(currentMode) && SessionPrefs.bottomAutoDim(context)) frame.postDelayed(dim, BottomScreenLight.DIM_AFTER_MS) + } + override fun dispatchGenericMotionEvent(event: MotionEvent): Boolean { if (PadBridge.isControllerMotionEvent(event) && sessionActivity.dispatchGenericMotionEvent(event)) return true + if (event.isFromSource(android.view.InputDevice.SOURCE_MOUSE)) uiActivity() return super.dispatchGenericMotionEvent(event) } @@ -266,6 +365,7 @@ class SecondScreenPresentation( } private fun renderMode() { + if (created) wake() dropChat() fieldKeyboard = false keyboardHost?.hide() @@ -282,6 +382,7 @@ class SecondScreenPresentation( val mode = when { requested == SecondScreenMode.DECK_CONTROLS && !SessionState.deckPad -> SecondScreenMode.NONE requested == SecondScreenMode.DASHBOARD && dashboard == null -> SecondScreenMode.NONE + requested.sessionPanel && panel(requested) == null -> SecondScreenMode.NONE requested == SecondScreenMode.DESKTOP && !BottomDesktop.available() -> SecondScreenMode.NONE else -> requested } @@ -300,6 +401,7 @@ class SecondScreenPresentation( attachKeyboard() } SecondScreenMode.DASHBOARD -> renderDashboard() + SecondScreenMode.GUIDES, SecondScreenMode.MIRROR, SecondScreenMode.STEAM_QAM, SecondScreenMode.ART -> renderPanel(mode) SecondScreenMode.DESKTOP -> { root.addView(BottomDesktopPanel(context, onClose, onMenu, (onSteamMenu to onQam).takeIf { SessionState.mode == SessionService.MODE_STEAM }, onSwap, @@ -314,21 +416,47 @@ class SecondScreenPresentation( private fun bar(mode: SecondScreenMode) { val first = barModel(mode) ?: return - root.addView(bottomScreenBarView(context) { barModel(mode) ?: first }, LinearLayout.LayoutParams(-1, -2)) + root.addView(androidx.compose.ui.platform.ComposeView(context).apply { + setContent { + DroidDeckTheme { + androidx.compose.animation.AnimatedVisibility(BottomChrome.barShown, + enter = androidx.compose.animation.expandVertically(), exit = androidx.compose.animation.shrinkVertically()) { + BottomScreenBar(barModel(mode) ?: first) + } + } + } + }, LinearLayout.LayoutParams(-1, -2)) } internal fun barModel(mode: SecondScreenMode): BottomBarModel? { - val swap = listOfNotNull(onSwap?.let { BarExtra(context.getString(R.string.swap_screens), icon = R.drawable.ic_bottom_swap, tag = "bottom-swap", onClick = it) }) + val extras = listOfNotNull(onSwap?.let { BarExtra(context.getString(R.string.swap_screens), icon = R.drawable.ic_bottom_swap, tag = "bottom-swap", onClick = it) }) + + BarExtra(context.getString(R.string.bottom_brightness), vector = Icons.Outlined.LightMode, active = brightnessOpen.value, + tag = "bottom-brightness-toggle", onClick = ::toggleBrightness) + + BarExtra(context.getString(R.string.bottom_bar_hide), vector = Icons.Outlined.ExpandLess, tag = "bottom-bar-hide") { + brightnessOpen.value = false + BottomChrome.show(false) + } fun model(extras: List, tabs: BarTabs? = null) = sessionBarModel(context.getString(mode.label), onClose, onMenu, onSteamMenu, onQam, extras, tabs, picker?.invoke(mode)) return when (mode) { SecondScreenMode.KEYBOARD_TRACKPAD -> model(listOf(BarExtra( context.getString(if (keyboardShown.value) R.string.second_hide_keyboard else R.string.second_show_keyboard), - icon = R.drawable.ic_bottom_keyboard, active = keyboardShown.value, tag = "bottom-keyboard") { showKeyboard() }) + swap) - SecondScreenMode.DECK_CONTROLS -> model(swap, deckPanelTabs(context, deckPanel.value, ::selectDeckPanel)) - SecondScreenMode.DASHBOARD, SecondScreenMode.CUSTOM_CONTROLS -> model(swap) + icon = R.drawable.ic_bottom_keyboard, active = keyboardShown.value, tag = "bottom-keyboard") { showKeyboard() }) + extras) + SecondScreenMode.DECK_CONTROLS -> model(extras, deckPanelTabs(context, deckPanel.value, ::selectDeckPanel)) + SecondScreenMode.STEAM_QAM -> { + val fit = QamFit.current(context) + model(listOf(BarExtra(context.getString(R.string.bottom_qam_layout, context.getString(fit.label)), vector = fit.icon, + tag = "bottom-qam-layout") { QamFit.choose(context, fit.next) }) + extras) + } + SecondScreenMode.MIRROR -> model(listOf(BarExtra(context.getString(R.string.bottom_mirror_options), vector = Icons.Outlined.Tune, + active = MirrorOptions.open.value, tag = "bottom-mirror-options-toggle") { + brightnessOpen.value = false + MirrorOptions.open.value = !MirrorOptions.open.value + }) + extras) + SecondScreenMode.DASHBOARD, SecondScreenMode.CUSTOM_CONTROLS, SecondScreenMode.GUIDES, + SecondScreenMode.ART -> model(extras) SecondScreenMode.TERMINAL -> model(listOf(BarExtra(context.getString(R.string.drawer_keyboard), icon = R.drawable.ic_bottom_keyboard, - tag = "bottom-keyboard") { terminalPanel?.showKeyboard() }) + swap) + tag = "bottom-keyboard") { terminalPanel?.showKeyboard() }) + extras) else -> null } } @@ -348,6 +476,14 @@ class SecondScreenPresentation( root.addView(view, weightParams()) } + private fun renderPanel(mode: SecondScreenMode) { + val content = panel(mode) ?: return + bar(mode) + val view = androidx.compose.ui.platform.ComposeView(context).apply { setContent { PresentationWindows(content) } } + dashboardView = view + root.addView(view, weightParams()) + } + private fun closeDashboard() { dashboardView?.disposeComposition() dashboardView = null @@ -396,3 +532,17 @@ class SecondScreenPresentation( private fun PresentationWindows(content: @androidx.compose.runtime.Composable () -> Unit) { androidx.compose.runtime.CompositionLocalProvider(LocalPresentationWindow provides true) { content() } } + +internal enum class BottomScreenLight(val brightness: Float) { + ON(WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE), + DIM(0.05f), + OFF(WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF); + + companion object { + const val DIM_AFTER_MS = 60_000L + fun autoDims(mode: SecondScreenMode) = mode == SecondScreenMode.DASHBOARD + } +} + +/** Modes drawn with the bottom bar, which the pull tab can bring back. */ +internal val SecondScreenMode.hasBar: Boolean get() = this != SecondScreenMode.NONE && this != SecondScreenMode.MENU && this != SecondScreenMode.DESKTOP diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt index d4b22a2909..ae00595556 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt @@ -258,6 +258,9 @@ class DrawerActions( val upscaleSharpness: Int = 75, val integerScaling: Boolean = false, val onIntegerScaling: (Boolean) -> Unit = {}, + val gameZoomAvailable: Boolean = false, + val gameZoom: Float = 1.0f, + val onGameZoom: (Float) -> Unit = {}, val effects: ScreenEffects = ScreenEffects.OFF, val screenEffectsTarget: String = "auto", val screenEffectsTargets: List> = emptyList(), @@ -315,6 +318,7 @@ class DrawerActions( val onOsc: (String) -> Unit, val onEditSteamTouch: (() -> Unit)? = null, val controller: com.droiddeck.launcher.input.ControllerPrefs.Settings? = null, + val onControllerSize: (Int) -> Unit = {}, val onRumble: (Boolean) -> Unit = {}, val onSuspendPolicy: (String) -> Unit, val onSteamDownloadsInBackground: (Boolean) -> Unit = {}, @@ -664,6 +668,45 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont SessionDrawerPage.HUD -> DroidDeckHudSettings(host, a) { key -> focus.track(page, key) } SessionDrawerPage.DISPLAY -> { SettingsGroup(stringResource(R.string.drawer_page_display)) { + if (a.gameZoomAvailable) SettingsRow( + stringResource(R.string.game_zoom_title), + stringResource(R.string.game_zoom_hint), + ) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(4.dp), + ) { + val zoomOutEnabled = a.gameZoom > 1.0f + val zoomInEnabled = a.gameZoom < 3.0f + val zoomResetEnabled = a.gameZoom > 1.0f + val zoomOut = { a.onGameZoom((a.gameZoom - 0.25f).coerceAtLeast(1.0f)) } + val zoomIn = { a.onGameZoom((a.gameZoom + 0.25f).coerceAtMost(3.0f)) } + val zoomReset = { a.onGameZoom(1.0f) } + + OutlinedButton( + onClick = zoomOut, + enabled = zoomOutEnabled, + modifier = focus.track(page, "game-zoom-out").width(42.dp) + .controllerConfirm(enabled = zoomOutEnabled, onClick = zoomOut), + contentPadding = PaddingValues(horizontal = 4.dp, vertical = 0.dp), + ) { Text("−") } + Text("${(a.gameZoom * 100.0f).toInt()}%", fontSize = 12.sp) + OutlinedButton( + onClick = zoomIn, + enabled = zoomInEnabled, + modifier = focus.track(page, "game-zoom-in").width(42.dp) + .controllerConfirm(enabled = zoomInEnabled, onClick = zoomIn), + contentPadding = PaddingValues(horizontal = 4.dp, vertical = 0.dp), + ) { Text("+") } + OutlinedButton( + onClick = zoomReset, + enabled = zoomResetEnabled, + modifier = focus.track(page, "game-zoom-reset").width(48.dp) + .controllerConfirm(enabled = zoomResetEnabled, onClick = zoomReset), + contentPadding = PaddingValues(horizontal = 2.dp, vertical = 0.dp), + ) { Text("1×") } + } + } val fgOpen = host.open == "fg" val offLabel = stringResource(R.string.frame_gen_off) val fgLabel = FrameGen.label(LocalContext.current, a.frameGen) @@ -749,9 +792,11 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont type, chipModifier = focus.track(page, "pad-type"), onPick = a.onPadType) } a.controller?.let { c -> + SliderRow(stringResource(R.string.ctrl_size), null, c.size, 80..125, step = 5, + format = { "$it%" }, modifier = focus.track(page, "controller-size"), + onChange = a.onControllerSize) ToggleRow(host, "rumble", stringResource(R.string.ctrl_rumble), null, c.rumble, chipModifier = focus.track(page, "rumble"), onChange = a.onRumble) - } } SettingsGroup(stringResource(R.string.input_touchscreen)) { @@ -1430,10 +1475,13 @@ private fun SteamVrRow(a: DrawerActions) { } } -internal fun secondScreenModes(none: Boolean, deckPad: Boolean, dashboard: Boolean, desktop: Boolean): List = +internal fun secondScreenModes(none: Boolean, deckPad: Boolean, dashboard: Boolean, desktop: Boolean, + steam: Boolean = com.droiddeck.launcher.session.SessionState.mode == com.droiddeck.launcher.session.SessionService.MODE_STEAM): List = (if (none) listOf(SecondScreenMode.NONE) else emptyList()) + listOf(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.TERMINAL) + (if (deckPad) listOf(SecondScreenMode.DECK_CONTROLS) else emptyList()) + listOf(SecondScreenMode.CUSTOM_CONTROLS) + (if (dashboard) listOf(SecondScreenMode.DASHBOARD) else emptyList()) + + (if (dashboard && steam) listOf(SecondScreenMode.STEAM_QAM, SecondScreenMode.ART) else emptyList()) + + (if (dashboard) listOf(SecondScreenMode.GUIDES, SecondScreenMode.MIRROR) else emptyList()) + (if (desktop) listOf(SecondScreenMode.DESKTOP) else emptyList()) private val DRAWER_MIN_WIDTH = 300.dp diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt index b95dd6ae1b..a47da769fc 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt @@ -92,6 +92,7 @@ internal object SettingsIndex { s(SettingsSection.CONTROLLER, R.string.setup_tab_controller, "gamepad", "buttons", "mapping", "profile", "remap"), SettingsEntry(SettingsPlace.TAB, R.string.rail_storage, tab = "storage", words = listOf("sd card", "space", "uninstall", "disk")), + SettingsEntry(SettingsPlace.TAB, R.string.storage_shared_mount, tab = "storage", words = listOf("sdcard", "mount", "privacy", "files")), SettingsEntry(SettingsPlace.TAB, R.string.rail_sync, tab = "sync", words = listOf("syncthing", "saves")), SettingsEntry(SettingsPlace.TAB, R.string.rail_decky, tab = "decky", words = listOf("plugins", "plugin store", "homebrew", "loader")), SettingsEntry(SettingsPlace.TAB, R.string.rail_boot_movies, tab = "boot-movies", words = listOf("startup movie", "boot video", "animation", "steamdeckrepo")), diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt index 977fb98c44..e6bda83fa5 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt @@ -170,7 +170,7 @@ internal val LocalRevealChecked = androidx.compose.runtime.compositionLocalOf { internal fun TabStrip( tabs: List, selected: Int, onSelect: (Int) -> Unit, modifier: Modifier = Modifier, focusRequesters: List? = null, - bumpers: Boolean = true, compact: Boolean = false, + bumpers: Boolean = true, compact: Boolean = false, centered: Boolean = false, ) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current @@ -181,8 +181,9 @@ internal fun TabStrip( val tabPadding = if (compact) 10.dp else if (tight) 10.dp else 16.dp Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp), modifier = modifier) { if (bumpers) BumperKey("LB", stringResource(R.string.widgets_prev_tab)) { onSelect((selected + tabs.size - 1) % tabs.size) } - Row( - modifier = Modifier.weight(1f, fill = false).clip(shape).background(colors.surfaceVariant).border(1.dp, pal.line2, shape) + // Centred, the bumpers sit at the edges and the tabs in the middle, as in the bottom bar. + Box(if (centered) Modifier.weight(1f) else Modifier.weight(1f, fill = false), contentAlignment = Alignment.Center) { Row( + modifier = Modifier.clip(shape).background(colors.surfaceVariant).border(1.dp, pal.line2, shape) .horizontalScroll(scroll).selectableGroup().padding(3.dp), ) { tabs.forEachIndexed { i, label -> @@ -208,7 +209,7 @@ internal fun TabStrip( .padding(horizontal = tabPadding, vertical = if (compact) 6.dp else 12.dp), ) } - } + } } if (bumpers) BumperKey("RB", stringResource(R.string.widgets_next_tab)) { onSelect((selected + 1) % tabs.size) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt b/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt index 0551f602fd..6ea5b16cab 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt @@ -82,7 +82,18 @@ import kotlinx.coroutines.withContext private const val WALL_MIN_GAMES = 4 private const val WALL_DISTINCT = 40 -private const val DRIFT_STEP_NS = 15_000_000L +private const val IDLE_FRAME_NS = 30_000_000L + +internal object IdleFrames { + private var shown = 0L + + fun due(nanos: Long): Boolean { + if (nanos == shown) return true + if (nanos - shown < IDLE_FRAME_NS) return false + shown = nanos + return true + } +} @Composable internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier) { @@ -102,7 +113,8 @@ internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier) } val owned = remember(ownedAll, concealed) { ownedAll.filter { it.first.toLong() !in concealed } } val featured = remember(featuredAll, concealed) { featuredAll.filter { it.appId.toLong() !in concealed } } - val games = remember(s.steamGames, LibraryHidden.keys, LibraryHidden.steam) { s.steamGames.filterNot { LibraryHidden.isHidden(hideKey(it), it) }.sortedWith(compareByDescending { it.lastPlayed }.thenBy { it.gameId }) } + val previewing = DevPreview.steamHome + val games = remember(s.steamGames, previewing, LibraryHidden.keys, LibraryHidden.steam) { (if (previewing == SteamHomePreview.OFF) s.steamGames else sampleSteamHomeGames(previewing.games)).filterNot { LibraryHidden.isHidden(hideKey(it), it) }.sortedWith(compareByDescending { it.lastPlayed }.thenBy { it.gameId }) } val narrow = LocalNarrowPane.current var words by remember { mutableStateOf(null) } val mode = com.droiddeck.launcher.session.SessionService.MODE_STEAM @@ -152,12 +164,12 @@ internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier) games.isEmpty() -> EmptyLibrary( avoid = words, wall = if (owned.isEmpty() && featured.isEmpty()) null else { { CapsuleWall(emptyList(), owned = owned, featured = featured) } }, - ) { Box(Modifier.fillMaxSize().graphicsLayer { scaleX = 1.06f; scaleY = 1.06f }) { WallFade() } } + ) { Box(Modifier.fillMaxSize().graphicsLayer { scaleX = 1.06f; scaleY = 1.06f }) { WallFade(bottomWhenTall = true) } } games.size < WALL_MIN_GAMES -> CapsuleFan(games) else -> CapsuleWall(games, owned = owned, featured = featured) } }, - scrim = { if (games.size >= WALL_MIN_GAMES) WallFade() }, + scrim = { if (games.size >= WALL_MIN_GAMES) WallFade(bottomWhenTall = true) }, words = { val onboardingActive by com.droiddeck.launcher.session.Onboarding.active.collectAsState() val onboardingFailed by com.droiddeck.launcher.session.Onboarding.failed.collectAsState() @@ -221,19 +233,35 @@ internal fun Modifier.overhang(by: androidx.compose.ui.unit.Dp = 4.dp): Modifier } @Composable -internal fun WallFade(modifier: Modifier = Modifier.fillMaxSize().overhang()) { +internal fun WallFade(modifier: Modifier = Modifier.fillMaxSize().overhang(), bottomWhenTall: Boolean = false) { val colors = MaterialTheme.colorScheme - Box( - modifier.background( - Brush.horizontalGradient( - 0f to colors.background.copy(alpha = 0.86f), - 0.34f to colors.background.copy(alpha = 0.6f), - 0.68f to colors.background.copy(alpha = 0.14f), - 1f to colors.background.copy(alpha = 0.04f), - ), - ), - ) - Box(modifier.background(Brush.verticalGradient(0.6f to Color.Transparent, 1f to colors.background.copy(alpha = 0.75f)))) + BoxWithConstraints(modifier) { + if (bottomWhenTall && maxHeight > maxWidth) { + // The words sit at the bottom of a tall page, so the art stays clear above them and darkens only behind them. + Box( + Modifier.fillMaxSize().background( + Brush.verticalGradient( + 0f to colors.background.copy(alpha = 0.12f), + 0.5f to colors.background.copy(alpha = 0.18f), + 0.72f to colors.background.copy(alpha = 0.72f), + 1f to colors.background.copy(alpha = 0.94f), + ), + ), + ) + } else { + Box( + Modifier.fillMaxSize().background( + Brush.horizontalGradient( + 0f to colors.background.copy(alpha = 0.86f), + 0.34f to colors.background.copy(alpha = 0.6f), + 0.68f to colors.background.copy(alpha = 0.14f), + 1f to colors.background.copy(alpha = 0.04f), + ), + ), + ) + Box(Modifier.fillMaxSize().background(Brush.verticalGradient(0.6f to Color.Transparent, 1f to colors.background.copy(alpha = 0.75f)))) + } + } } @Composable @@ -281,7 +309,7 @@ internal fun TiltedWall( var shown = 0L while (true) withFrameNanos { now -> if (shown == 0L) shown = now - else if (now - shown >= DRIFT_STEP_NS) { + else if (IdleFrames.due(now)) { drift.floatValue = ((drift.floatValue + (now - shown) / (period.value * 1_000_000.0 * Motion.scale)) % 1.0).toFloat() shown = now } @@ -376,31 +404,45 @@ private fun CapsuleFan(games: List) { transition.animateFloat(0f, 1f, infiniteRepeatable(tween(ms, easing = FastOutSlowInEasing), RepeatMode.Reverse), label = "float") } val still = Motion.scale == 0f - val slots = listOf( + val landscape = listOf( FanSlot(0.54f, 0.14f, 0.62f, -9f), FanSlot(0.70f, 0.24f, 0.56f, 5f), FanSlot(0.40f, 0.30f, 0.50f, -17f), ) + // A tall page sizes the cards from its width, so they fit any aspect; heights are fractions of the width. + val portrait = listOf( + FanSlot(0.27f, 0.11f, 0.70f, -9f), + FanSlot(0.55f, 0.19f, 0.64f, 5f), + FanSlot(0.04f, 0.26f, 0.56f, -17f), + ) BoxWithConstraints( Modifier.fillMaxSize().drawBehind { drawRect( Brush.radialGradient( listOf(pal.signal.copy(alpha = 0.14f), Color.Transparent), - center = Offset(size.width * 0.68f, size.height * 0.45f), radius = size.height * 0.6f, + center = if (size.height > size.width) Offset(size.width * 0.55f, size.height * 0.28f) else Offset(size.width * 0.68f, size.height * 0.45f), + radius = if (size.height > size.width) size.width * 0.9f else size.height * 0.6f, ), ) }, ) { val radius = with(density) { 14.dp.toPx() } + val tall = maxHeight > maxWidth + val slots = if (tall) portrait else landscape for (i in games.indices.reversed()) { val slot = slots[i] - val h = maxHeight * slot.height + val h = if (tall) maxWidth * slot.height else maxHeight * slot.height + val x = if (tall) { + // The lean and the float swing the corners out by about h/2 * sin(angle). + val swing = h * kotlin.math.sin(Math.toRadians(kotlin.math.abs(slot.lean) + 2.0)).toFloat() / 2f + (maxWidth * slot.x).coerceIn(swing, (maxWidth - h * 2f / 3f - swing).coerceAtLeast(swing)) + } else maxWidth * slot.x val v: State = floats[i] val look = WallCapsule(artBrush(hueOf(games[i].name)), games[i].art) val art = look.art?.let { rememberCapsuleArt(it, with(density) { Size((h * 2f / 3f).toPx(), h.toPx()) }, radius) } Spacer( Modifier - .offset(x = maxWidth * slot.x, y = maxHeight * slot.y) + .offset(x = x, y = maxHeight * slot.y) .size(h * 2f / 3f, h) .graphicsLayer { val t = if (still) 0f else v.value diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoragePage.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoragePage.kt index 00b09f2145..caa629aa55 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoragePage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoragePage.kt @@ -168,6 +168,20 @@ internal fun StoragePanel(s: FrontEndState, a: FrontEndActions) { } } +@Composable +private fun SharedStorageGroup() { + val ctx = LocalContext.current + var on by remember { mutableStateOf(SessionPrefs.mountSharedStorage(ctx)) } + SettingsGroup(stringResource(R.string.setup_runtime)) { + SettingsRow(stringResource(R.string.storage_shared_mount), stringResource(R.string.storage_shared_mount_hint)) { + ToggleSwitch(on, label = stringResource(R.string.storage_shared_mount), modifier = Modifier.testTag("setting-shared-storage")) { + SessionPrefs.setMountSharedStorage(ctx, it) + on = it + } + } + } +} + @Composable private fun DefaultStorageGroup() { val ctx = LocalContext.current @@ -347,6 +361,7 @@ private fun OverviewContent(report: StorageSummary, sessionRunning: Boolean, wid Note(stringResource(R.string.storage_session_running)) } DefaultStorageGroup() + SharedStorageGroup() SectionTitle(stringResource(R.string.storage_where), null) val unused = report.unusedTools val tiles = listOf<@Composable (Modifier) -> Unit>( diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoreChips.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoreChips.kt index a822548739..806975b3ee 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoreChips.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoreChips.kt @@ -39,7 +39,7 @@ internal fun sourceColours(source: String): SourceColours = when (source) { Store.UBISOFT.id -> SourceColours(Color(0xFF0B1E44), Color(0xFFA8C6FF), Color(0xFF2E7DFF)) Store.EA.id -> SourceColours(Color(0xFF3A0E12), Color(0xFFFF9A9A), Color(0xFFFF4747)) Store.ROCKSTAR.id -> SourceColours(Color(0xFF3A2A06), Color(0xFFFFD780), Color(0xFFFCAF17)) - Library.SOURCE_STEAM -> SourceColours(Color(0xFF16293D), Color(0xFF7CC4FF), Color(0xFF1A9FFF)) + Library.SOURCE_STEAM, Store.STEAM.id -> SourceColours(Color(0xFF16293D), Color(0xFF7CC4FF), Color(0xFF1A9FFF)) Library.SOURCE_COLLECTION -> SourceColours(Color(0xFF2B1A3D), Color(0xFFD2A8FF), Color(0xFFA25BFF)) FLATHUB -> SourceColours(Color(0xFF0B2E2B), Color(0xFF9FE3DD), FlathubTeal) else -> SourceColours(Color(0xFF1A1D22), Color(0xFF9AA3AF), Color(0xFF9AA3AF)) @@ -47,7 +47,7 @@ internal fun sourceColours(source: String): SourceColours = when (source) { @Composable internal fun sourceLabel(source: String): String = when (source) { - Library.SOURCE_STEAM -> stringResource(R.string.source_steam) + Library.SOURCE_STEAM, Store.STEAM.id -> stringResource(R.string.source_steam) Library.SOURCE_COLLECTION -> stringResource(R.string.soundtracks_collections) Store.GOG.id -> Store.GOG.label Store.EPIC.id -> Store.EPIC.label diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoresInstallDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoresInstallDialog.kt index c5dd008edb..ea7483e531 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoresInstallDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoresInstallDialog.kt @@ -27,6 +27,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.produceState import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment @@ -46,7 +47,10 @@ import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.stores.CatalogItem import com.droiddeck.launcher.stores.StoreInstallRoot import com.droiddeck.launcher.stores.StoreLanguage +import com.droiddeck.launcher.stores.StoreSizes import com.droiddeck.launcher.stores.StoresState +import com.droiddeck.launcher.stores.steam.SteamClient +import com.droiddeck.launcher.stores.steam.SteamStore import com.droiddeck.launcher.stores.formatBytes import com.droiddeck.launcher.stores.gog.GogDownloadManager import kotlinx.coroutines.Dispatchers @@ -133,6 +137,61 @@ internal fun InstallWhereDialog(item: CatalogItem, onDismiss: () -> Unit) { } } +@Composable +internal fun SteamInstallWhereDialog(item: CatalogItem, onDismiss: () -> Unit) { + val ctx = LocalContext.current + val colors = MaterialTheme.colorScheme + val shown = rememberShown(onDismiss) + val close = { shown.targetState = false } + val targets by produceState?>(null, item.key) { + value = withContext(Dispatchers.IO) { runCatching { SteamClient.targets(ctx) }.getOrDefault(emptyList()) } + } + val needed by produceState(StoreSizes.size(item), item.key) { + val bytes = withContext(Dispatchers.IO) { runCatching { SteamStore.plannedBytes(ctx, item) }.getOrDefault(0L) } + if (bytes > 0L) value = bytes + } + val list = targets + val focus = remember(list?.size) { List(list?.size ?: 0) { FocusRequester() } } + LaunchedEffect(focus) { if (focus.isNotEmpty()) focusWithinFrames({ false }) { focus[0] } } + AppDialog(shown, close, "steamInstallWhere", wide = false, maxWidth = 440.dp) { + Rise(0) { + Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) { + Text( + stringResource(R.string.stores_install_title, item.title), fontSize = 15.sp, color = colors.onBackground, + maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f), + ) + Text( + stringResource(R.string.common_cancel), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant, + modifier = Modifier.clip(Shape12).focusGlide().clickable(role = Role.Button, onClick = close).controllerConfirm(onClick = close).padding(horizontal = 10.dp, vertical = 6.dp), + ) + } + } + Rise(1) { + when { + list == null -> androidx.compose.material3.LinearProgressIndicator(Modifier.fillMaxWidth().height(3.dp)) + list.isEmpty() -> Note(stringResource(R.string.game_sync_err_steam_library)) + else -> Column(verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth()) { + list.forEachIndexed { i, t -> + val isLow = StoreInstallRoot.insufficientSpace(needed, t.freeBytes) + val freeText = when { + t.freeBytes < 0L -> stringResource(R.string.stores_target_free_unknown) + isLow -> stringResource(R.string.stores_storage_low, formatBytes(t.freeBytes), formatBytes(needed)) + else -> stringResource(R.string.stores_target_free, formatBytes(t.freeBytes)) + } + TargetRow( + label = t.label, free = freeText, removable = t.removable, folder = t.folder, focus = focus[i], + modifier = Modifier.fillMaxWidth(), warning = isLow, + ) { + SteamStore.install(ctx, item, t) + close() + } + } + } + } + } + } +} + @Composable private fun TargetRow(label: String, free: String, removable: Boolean, folder: Boolean, focus: FocusRequester, modifier: Modifier, warning: Boolean = false, onPick: () -> Unit) { val colors = MaterialTheme.colorScheme diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt index 30caa5fca7..963c2f9c99 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt @@ -1031,6 +1031,7 @@ internal fun storePalette(base: Palette, store: Store?): Palette { Store.UBISOFT -> Color(0xFF2E7DFF) to Color(0xFF1A5BD6) Store.EA -> Color(0xFFFF4747) to Color(0xFFE03030) Store.ROCKSTAR -> Color(0xFFFCAF17) to Color(0xFFD98E00) + Store.STEAM -> Color(0xFF1A9FFF) to Color(0xFF0F6FC0) null -> return base } val on = if (accent.luminance() > 0.18f) Color(0xFF0B0B0D) else Color.White @@ -1323,6 +1324,6 @@ internal fun openUrl(ctx: android.content.Context, url: String) { } internal fun launchStoreGame(store: Store, id: String, s: FrontEndState, a: FrontEndActions) { - val game = s.steamGames.firstOrNull { it.source == store.id && it.storeId == id } + val game = GameRef(null, store, id).game(s.steamGames) if (game != null) a.onSteamGame(game) else a.onStoreGame(store, id) } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt b/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt index 8cf7013d0f..a639615129 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt @@ -38,7 +38,7 @@ class Palette( val background: Color, val surface: Color, val surfaceVariant: Color, val line: Color, val line2: Color, val onBackground: Color, val onSurfaceVariant: Color, val primary: Color, val primary2: Color, val onPrimary: Color, val signal: Color, - val good: Color, val error: Color = Color(0xFFFF8A80), + val good: Color, val error: Color = Color(0xFFFF8A80), val warning: Color = Color(0xFFFFB547), ) data class CustomThemeColors( @@ -54,6 +54,7 @@ data class CustomThemeColors( val signal: Int = 0xFF1A9FFF.toInt(), val good: Int = 0xFF4CD37F.toInt(), val error: Int = 0xFFFF8A80.toInt(), + val warning: Int = 0xFFFFB547.toInt(), ) object Themes { @@ -144,6 +145,7 @@ object Themes { "signal" -> current.copy(signal = color) "good" -> current.copy(good = color) "error" -> current.copy(error = color) + "warning" -> current.copy(warning = color) else -> return } setCustomColors(context, updated) @@ -164,6 +166,7 @@ object Themes { signal = Color(colors.signal), good = Color(colors.good), error = Color(colors.error), + warning = Color(colors.warning), ) fun current(context: Context): Palette { @@ -229,7 +232,9 @@ val Palette.onSignal: Color get() = if (signal.luminance() > 0.18f) Color(0xFF03 @Composable fun DroidDeckTheme(theme: String? = null, appScale: Int = AppUiPrefs.DEFAULT_SCALE, content: @Composable () -> Unit) { - val id = theme ?: SessionPrefs.theme(LocalContext.current) + val context = LocalContext.current + remember(context) { Themes.loadGradient(context) } + val id = theme ?: SessionPrefs.theme(context) if (id == Themes.INNER_GAMER) InnerGamerHue(Themes.rgbSpeed) val p = Themes.byId(id) val scheme = darkColorScheme( diff --git a/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java b/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java index 4e824f6dba..afe0df226f 100644 --- a/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java +++ b/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java @@ -371,6 +371,7 @@ public final class WaylandCompositor { public static native void nativeHdrNoteHeadroomRequest(float ratio); public static native void nativeSetScaleMode(int fullscreenMode, int screenAlignment); + public static native void nativeSetZoom(float zoom); public static native void nativeSetUpscaler(int mode); diff --git a/app/src/main/res/values-ar/input_zoom_strings.xml b/app/src/main/res/values-ar/input_zoom_strings.xml new file mode 100644 index 0000000000..c96953f664 --- /dev/null +++ b/app/src/main/res/values-ar/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + تكبير عرض اللعبة + تصغير عرض اللعبة + \ No newline at end of file diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 922fecc6d6..022f589826 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -1265,6 +1265,11 @@ تحضير تعذّر الوصول إلى تصحيح الأخطاء اللاسلكي؛ زر الاقتران يشغّله اقتران + لا يحتوي Quest على شاشة اقتران. من حاسوب، شغّل مرة واحدة: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS و adb tcpip 5555. ثم اضغط «السماح» واقبل الطلب في النظارة + السماح + اقبل «السماح بتصحيح الأخطاء؟» في النظارة مع تحديد «السماح دائمًا» + تعذّر الاتصال. اقبل طلب تصحيح الأخطاء في النظارة، وإن لم يظهر، شغّل adb tcpip 5555 من حاسوب ثم حاول مجددًا + تعذّر الوصول إلى تصحيح الأخطاء اللاسلكي. اضغط «السماح» لإعداده من جديد تثبيت تسجيل الدخول PR #%1$d @@ -1492,6 +1497,7 @@ %1$d%% استئناف %1$s يظهر باسم /root/ROMs في كل جلسة. مساحة التخزين الداخلية متاحة في /root/Storage. + يظهر باسم /root/ROMs في كل جلسة. لم يتم اختيار مجلد يُطبَّق في الجلسة التالية. بطاقات SD مدعومة. اختيار مجلد @@ -2149,6 +2155,13 @@ العلامة الحمراء هي النقطة التي تُظهر فيها المؤشرات درجة الحرارة باللون الأحمر. الجهاز بالكامل البطارية + صور اللعبة + قيد اللعب + محدد في Steam + آخر ما لُعب + لم يُلعب بعد + %1$d دقيقة لعب + %1$d ساعة لعب إرسال بيانات لوحة العدادات تلقائي يفعّلها لكل لعبة مدرجة هنا، بما في ذلك الألعاب التي يُعثر عليها لاحقًا. تبقى الألعاب التي توقفها متوقفة. @@ -2171,6 +2184,59 @@ الميكروفون متوقف الميكروفون متوقف لهذه اللعبة. للتحدث، فعِّل «الميكروفون» في إعدادات Steam في DroidDeck (الصوت) وابدأ اللعبة من جديد. مستوى الصوت %1$d%% + إخفاء الشريط + إظهار الشريط + سطوع الشاشة السفلية + أطفئ الشاشة السفلية + الأدلة + ابدأ لعبة لترى أدلة Steam الخاصة بها هنا. + متابعة القراءة + لا توجد أدلة Steam لهذه اللعبة بعد. + تعذّر تحميل أدلة Steam. عد عندما تكون متصلًا. + المرآة + اسحب فوق جزء اللعبة الذي تريد عرضه هنا، مثل الخريطة المصغّرة. + احفظ المنطقة + حاد + ناعم + لا يمكن نسخ صورة اللعبة الآن. + الويكي والإصلاحات + الخرائط + المحفوظة + الكل + الشروحات + الأسرار + ثُبّتت الخريطة في خرائط هذه اللعبة. + تعذّر حفظ هذه الصورة. + حُفظت الصفحة للقراءة دون اتصال. + ابحث في الويب + العلامات: %1$d + اعثر على خرائط + استخدم «حفظ» في القارئ للاحتفاظ بصفحة للقراءة دون اتصال. + ثبّت كخريطة + اضغط مطولًا على صورة لتثبيتها كخريطة. + اقرص للتكبير. اضغط مطولًا لإضافة علامة، واضغط على علامة لإزالتها. + ويكي اللعبة + إصلاحات PCGamingWiki + شروحات YouTube + ظاهرة + مخفية + معتمة + أدلة Steam + الفئة + لا توجد خرائط مثبتة بعد + خريطة %1$d + لا توجد صفحات محفوظة بعد + خيارات المرآة + المنطقة + الشاشة العلوية + التحجيم + الوصول السريع + التخطيط: %1$s + العرض الكامل + يسار + وسط + يمين + قائمة الوصول السريع في Steam غير متاحة بعد. إحصاءات داخل اللعبة مؤشرات الشاشة السفلية شريط على كل تبويب @@ -3279,6 +3345,8 @@ موقع التثبيت التخزين الافتراضي تُثبَّت ألعاب المتاجر الجديدة في الموقع المحدد. تبقى الألعاب الحالية في مكانها. تحتفظ مكتبات Steam بإعدادها الخاص. + مساحة تخزين الهاتف في Linux + يربط مساحة التخزين الداخلية لهاتفك في /root/Storage. عند إيقافه، تُربط فقط مجلدات الألعاب التي أضفتها منها. لا تتأثر بطاقات SD. يُطبَّق في الجلسة التالية. السؤال في كل مرة اختر وجهة لكل تثبيت مساحة التخزين الداخلية @@ -4239,6 +4307,12 @@ الإبرازات نجاح خطأ + تحذير عرض HUD أثناء اللعب فقط إخفاء HUD عند عدم اكتشاف إطارات اللعبة. + أغلق Steam أولاً + أوقف تنزيل Steam مؤقتًا أولاً + تثبّت هذه اللعبة إصدار Linux الخاص بها. ثبّتها من Steam. + تكبير اللعبة + اضبط تكبير اللعبة من 100% إلى 300% diff --git a/app/src/main/res/values-b+es+419/input_zoom_strings.xml b/app/src/main/res/values-b+es+419/input_zoom_strings.xml new file mode 100644 index 0000000000..b3a9fa6ce7 --- /dev/null +++ b/app/src/main/res/values-b+es+419/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Aumentar el zoom del juego + Reducir el zoom del juego + \ No newline at end of file diff --git a/app/src/main/res/values-b+es+419/strings.xml b/app/src/main/res/values-b+es+419/strings.xml index dc55741139..33a0f918e1 100644 --- a/app/src/main/res/values-b+es+419/strings.xml +++ b/app/src/main/res/values-b+es+419/strings.xml @@ -1280,6 +1280,11 @@ Preparar No se puede acceder a la depuración inalámbrica; Vincular la activa Vincular + Quest no tiene pantalla de vinculación. Desde una computadora, ejecuta una vez: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS y adb tcpip 5555. Luego toca Permitir y acepta el aviso en el visor + Permitir + Acepta «¿Permitir depuración?» en el visor, con Permitir siempre marcado + No se pudo conectar. Acepta el aviso de depuración en el visor o, si no apareció, ejecuta adb tcpip 5555 desde una computadora y vuelve a intentarlo + No se puede acceder a la depuración inalámbrica. Toca Permitir para configurarla de nuevo Instalar Iniciar sesión PR #%1$d @@ -1538,6 +1543,7 @@ %1$d%% Reanudar %1$s Aparece como /root/ROMs en cada sesión. El almacenamiento interno está en /root/Storage. + Aparece como /root/ROMs en cada sesión. Ninguna carpeta elegida Se aplica en la próxima sesión. Las tarjetas SD funcionan. Elegir carpeta @@ -2144,6 +2150,13 @@ La marca roja indica el punto donde el HUD muestra la temperatura en rojo. todo el dispositivo batería + Arte del juego + Jugando + Seleccionado en Steam + Jugado por última vez + Aún sin jugar + %1$d min jugados + %1$d h jugadas Enviar datos al panel Automático Lo activa en todos los juegos de esta lista, incluidos los que se encuentren más adelante. Los juegos que desactives seguirán desactivados. @@ -2166,6 +2179,59 @@ Micro desactivado El micro está desactivado en este juego. Para hablar, activa Micrófono en los ajustes de Steam de DroidDeck (Audio) y vuelve a iniciar el juego. Volumen %1$d%% + Ocultar barra + Mostrar barra + Brillo de la pantalla inferior + Apagar la pantalla inferior + Guías + Inicia un juego para ver aquí sus guías de Steam. + Seguir leyendo + Este juego aún no tiene guías de Steam. + No se pudieron cargar las guías de Steam. Vuelve a intentarlo cuando tengas conexión. + Espejo + Arrastra sobre la parte del juego que quieras ver aquí, como el minimapa. + Guardar región + Nítido + Suave + Ahora no se puede copiar la imagen del juego. + Wiki y soluciones + Mapas + Guardado + Todo + Guías completas + Secretos + Mapa fijado en los mapas de este juego. + No se pudo guardar esa imagen. + Página guardada para leer sin conexión. + Buscar en la web + Marcadores: %1$d + Buscar mapas + Usa Guardar en el lector para conservar una página sin conexión. + Fijar como mapa + Mantén presionada una imagen para fijarla como mapa. + Pellizca para hacer zoom. Mantén presionado para añadir un marcador y tócalo para quitarlo. + Wiki del juego + Soluciones de PCGamingWiki + Guías en YouTube + Visible + Oculto + Atenuado + Guías de Steam + Categoría + Aún no hay mapas fijados + Mapa %1$d + Aún no hay páginas guardadas + Opciones de espejo + Región + Pantalla superior + Escalado + Acceso rápido + Diseño: %1$s + Ancho completo + Izquierda + Centro + Derecha + El menú de acceso rápido de Steam aún no está disponible. Estadísticas del juego HUD de la pantalla inferior Franja en todas las pestañas @@ -3155,6 +3221,8 @@ Ubicación de instalación Almacenamiento predeterminado Las nuevas instalaciones de las tiendas van a la ubicación seleccionada. Los juegos existentes se quedan donde están. Las bibliotecas de Steam conservan su propio ajuste. + Almacenamiento del teléfono en Linux + Monta el almacenamiento interno de tu teléfono en /root/Storage. Si está desactivado, solo se montan las carpetas de juegos que agregaste desde ahí. No afecta a las tarjetas SD. Se aplica en la próxima sesión. Preguntar siempre Elige un destino para cada instalación Almacenamiento interno @@ -4119,6 +4187,10 @@ Destacados Éxito Error + Advertencia Mostrar el HUD solo durante una partida Ocultar el HUD cuando no se detecten fotogramas del juego. + Cierra Steam primero + Pausa primero la descarga de Steam + Este juego instala su versión para Linux. Instálalo desde Steam. diff --git a/app/src/main/res/values-bg/input_zoom_strings.xml b/app/src/main/res/values-bg/input_zoom_strings.xml new file mode 100644 index 0000000000..22cd636040 --- /dev/null +++ b/app/src/main/res/values-bg/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Увеличаване на мащаба на играта + Намаляване на мащаба на играта + \ No newline at end of file diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 1875c2fedf..8cf8a2002a 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -1249,6 +1249,11 @@ Подготви Безжичното отстраняване на грешки не е достъпно; сдвояването го включва Сдвой + Quest няма екран за сдвояване. От компютър изпълнете веднъж: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS и adb tcpip 5555. След това докоснете „Разреши“ и приемете запитването в шлема + Разреши + Приемете „Разрешаване на отстраняването на грешки?“ в шлема с отметка „Винаги разрешавай“ + Неуспешно свързване. Приемете запитването за отстраняване на грешки в шлема, а ако не се е появило, изпълнете adb tcpip 5555 от компютър и опитайте отново + Безжичното отстраняване на грешки не е достъпно. Докоснете „Разреши“, за да го настроите отново Инсталирай Влез PR #%1$d @@ -1460,6 +1465,7 @@ %1$d%% Продължаване на %1$s Показва се като /root/ROMs във всяка сесия. Вътрешната памет е на /root/Storage. + Показва се като /root/ROMs във всяка сесия. Няма избрана папка Прилага се от следващата сесия. SD картите работят. Избор на папка @@ -2049,6 +2055,13 @@ Червената маркировка е мястото, където HUD показва температурата в червено. цялото устройство батерия + Изображения на играта + Играе се + Избрано в Steam + Последно играна + Още не е играна + %1$d мин игра + %1$d ч игра Изпращане на данни за таблото Автоматично Включва го за всяка игра от списъка тук, включително игри, открити по-късно. Игрите, които изключите, остават изключени. @@ -2071,6 +2084,59 @@ Микрофонът е изключен Микрофонът е изключен за тази игра. За да говорите, включете „Микрофон“ в настройките на Steam в DroidDeck (Звук) и стартирайте играта отново. Сила на звука %1$d%% + Скриване на лентата + Показване на лентата + Яркост на долния екран + Изключи долния екран + Ръководства + Пуснете игра, за да видите тук нейните ръководства в Steam. + Продължи четенето + Все още няма ръководства в Steam за тази игра. + Ръководствата в Steam не се заредиха. Опитайте отново, когато сте онлайн. + Огледало + Плъзнете върху частта от играта, която да се показва тук, например мини картата. + Запази областта + Остро + Гладко + Картината на играта не може да се копира в момента. + Уики и поправки + Карти + Запазени + Всички + Пълни ръководства + Тайни + Картата е закачена към картите на играта. + Изображението не можа да се запази. + Страницата е запазена за офлайн четене. + Търсене в мрежата + Маркери: %1$d + Намиране на карти + Използвайте „Запази“ в четеца, за да имате страницата офлайн. + Закачи като карта + Задръжте върху изображение, за да го закачите като карта. + Щипнете за мащаб. Задръжте, за да добавите маркер; докоснете маркер, за да го премахнете. + Уики на играта + Поправки от PCGamingWiki + Ръководства в YouTube + Видимо + Скрито + Затъмнено + Ръководства в Steam + Категория + Още няма закачени карти + Карта %1$d + Още няма запазени страници + Настройки на огледалото + Област + Горен екран + Мащабиране + Бърз достъп + Оформление: %1$s + Цяла ширина + Вляво + В центъра + Вдясно + Менюто за бърз достъп на Steam още не е налично. Статистика в играта HUD на долния екран Лента на всеки раздел @@ -3159,6 +3225,8 @@ Място за инсталиране Хранилище по подразбиране Новите инсталации от магазини отиват в избраното място. Съществуващите игри остават, където са. Библиотеките на Steam запазват собствената си настройка. + Хранилище на телефона в Linux + Монтира вътрешната памет на телефона ви в /root/Storage. Когато е изключено, се монтират само папките с игри, които сте добавили от нея. SD картите не се засягат. Прилага се от следващата сесия. Питане всеки път Избор на място за всяка инсталация Вътрешна памет @@ -4079,6 +4147,12 @@ Акценти Успех Грешка + Предупреждение Показвай HUD само по време на игра Скривай HUD, когато не се засичат кадри от играта. + Първо затворете Steam + Първо поставете на пауза изтеглянето от Steam + Тази игра инсталира версията си за Linux. Инсталирайте я от Steam. + Мащабиране на играта + Регулирайте увеличението на играта от 100% до 300% diff --git a/app/src/main/res/values-cs/input_zoom_strings.xml b/app/src/main/res/values-cs/input_zoom_strings.xml new file mode 100644 index 0000000000..a5fb0ad850 --- /dev/null +++ b/app/src/main/res/values-cs/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Zvětšit přiblížení hry + Zmenšit přiblížení hry + \ No newline at end of file diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 9e89a11dab..60b90ae035 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -1257,6 +1257,11 @@ Připravit Bezdrátové ladění není dostupné; Spárovat ho zapne Spárovat + Quest nemá obrazovku párování. Z počítače jednou spusťte: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS a adb tcpip 5555. Pak klepněte na Povolit a potvrďte výzvu v headsetu + Povolit + V headsetu potvrďte „Povolit ladění?“ se zaškrtnutým Vždy povolit + Nepodařilo se připojit. Potvrďte výzvu k ladění v headsetu, a pokud se neobjevila, spusťte z počítače adb tcpip 5555 a zkuste to znovu + Bezdrátové ladění není dostupné. Klepnutím na Povolit ho nastavíte znovu Instalovat Přihlásit se PR #%1$d @@ -1476,6 +1481,7 @@ %1$d%% Obnovit %1$s V každé relaci se zobrazí jako /root/ROMs. Vnitřní úložiště je v /root/Storage. + V každé relaci se zobrazí jako /root/ROMs. Nevybrána žádná složka Použije se v další relaci. SD karty fungují. Vybrat složku @@ -2099,6 +2105,13 @@ Červená značka označuje místo, kde HUD zobrazuje teplotu červeně. celé zařízení baterie + Obrázky hry + Hraje se + Vybráno ve Steamu + Naposledy hráno + Zatím nehráno + Odehráno %1$d min + Odehráno %1$d h Odesílat data pro palubní desku Automaticky Zapne to pro každou zde uvedenou hru, včetně her nalezených později. Hry, které vypnete, zůstanou vypnuté. @@ -2121,6 +2134,59 @@ Mikrofon vypnut Mikrofon je pro tuto hru vypnutý. Chcete-li mluvit, zapněte Mikrofon v nastavení Steamu v DroidDecku (Zvuk) a spusťte hru znovu. Hlasitost %1$d%% + Skrýt lištu + Zobrazit lištu + Jas spodní obrazovky + Vypnout spodní obrazovku + Návody + Spusťte hru a uvidíte zde její návody ze Steamu. + Pokračovat ve čtení + Pro tuto hru zatím nejsou žádné návody na Steamu. + Návody ze Steamu se nepodařilo načíst. Zkuste to znovu, až budete online. + Zrcadlo + Táhnutím označte část hry, která se tu má zobrazit, například minimapu. + Uložit oblast + Ostré + Hladké + Obraz hry teď nelze zkopírovat. + Wiki a opravy + Mapy + Uložené + Vše + Návody + Tajemství + Mapa připnuta k mapám této hry. + Obrázek se nepodařilo uložit. + Stránka uložena pro čtení offline. + Hledat na webu + Značky: %1$d + Najít mapy + Tlačítkem Uložit ve čtečce si stránku ponecháte offline. + Připnout jako mapu + Podržením obrázku jej připnete jako mapu. + Přiblížíte roztažením prstů. Podržením přidáte značku, klepnutím ji odeberete. + Wiki hry + Opravy z PCGamingWiki + Návody na YouTube + Zobrazeno + Skryto + Ztlumeno + Návody Steam + Kategorie + Zatím žádné připnuté mapy + Mapa %1$d + Zatím žádné uložené stránky + Možnosti zrcadlení + Oblast + Horní obrazovka + Škálování + Rychlý přístup + Rozložení: %1$s + Plná šířka + Vlevo + Na střed + Vpravo + Nabídka rychlého přístupu Steamu zatím není k dispozici. Statistiky ve hře HUD na spodní obrazovce Lišta na každé kartě @@ -3219,6 +3285,8 @@ Umístění instalace Výchozí úložiště Nové instalace z obchodů půjdou do vybraného umístění. Stávající hry zůstanou, kde jsou. Knihovny Steamu mají vlastní nastavení. + Úložiště telefonu v Linuxu + Připojí vnitřní úložiště telefonu do /root/Storage. Když je vypnuto, připojí se jen složky her, které jste z něj přidali. Karet SD se to netýká. Projeví se v příští relaci. Vždy se zeptat Vybrat cíl u každé instalace Interní úložiště @@ -4159,6 +4227,12 @@ Zvýraznění Úspěch Chyba + Varování Zobrazovat HUD pouze během hry Skrýt HUD, když nejsou detekovány snímky hry. + Nejprve zavřete Steam + Nejprve pozastavte stahování ze Steamu + Tato hra instaluje svou verzi pro Linux. Nainstalujte ji ze Steamu. + Přiblížení hry + Nastavte zvětšení hry od 100 % do 300 % diff --git a/app/src/main/res/values-da/input_zoom_strings.xml b/app/src/main/res/values-da/input_zoom_strings.xml new file mode 100644 index 0000000000..3e09248776 --- /dev/null +++ b/app/src/main/res/values-da/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Forøg spillets zoom + Formindsk spillets zoom + \ No newline at end of file diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index cb76db4888..c316cfc229 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -1249,6 +1249,11 @@ Forbered Trådløs fejlfinding kan ikke nås; Par slår den til Par + Quest har ingen parringsskærm. Kør én gang fra en computer: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS og adb tcpip 5555. Tryk derefter på Tillad, og godkend prompten i headsettet + Tillad + Godkend “Tillad fejlretning?” i headsettet med Tillad altid markeret + Kunne ikke oprette forbindelse. Godkend fejlretningsprompten i headsettet, eller kør adb tcpip 5555 fra en computer og prøv igen, hvis den ikke dukkede op + Trådløs fejlretning kan ikke nås. Tryk på Tillad for at konfigurere den igen Installer Log ind PR #%1$d @@ -1460,6 +1465,7 @@ %1$d%% Genoptag %1$s Vises som /root/ROMs i hver session. Intern lagerplads er på /root/Storage. + Vises som /root/ROMs i hver session. Ingen mappe valgt Gælder fra næste session. SD-kort fungerer. Vælg mappe @@ -2049,6 +2055,13 @@ Det røde mærke angiver, hvor HUD viser temperaturen i rødt. hele enheden batteri + Spilgrafik + Spiller + Valgt i Steam + Senest spillet + Ikke spillet endnu + %1$d min spillet + %1$d t spillet Send instrumentbrætdata Auto Slår det til for alle spil på listen her, også spil, der findes senere. Spil, du slår fra, forbliver slået fra. @@ -2071,6 +2084,59 @@ Mikrofon fra Mikrofonen er slået fra for dette spil. For at tale skal du slå Mikrofon til i DroidDecks Steam-indstillinger (Lyd) og starte spillet igen. Lydstyrke %1$d%% + Skjul bjælke + Vis bjælke + Lysstyrke på nederste skærm + Sluk den nederste skærm + Guides + Start et spil for at se dets Steam-guides her. + Læs videre + Der er endnu ingen Steam-guides til dette spil. + Kunne ikke hente Steam-guides. Prøv igen, når du er online. + Spejl + Træk hen over den del af spillet, der skal vises her, f.eks. minikortet. + Gem område + Skarp + Blød + Spillets billede kan ikke kopieres lige nu. + Wiki og rettelser + Kort + Gemt + Alle + Gennemgange + Hemmeligheder + Kortet er fastgjort til spillets kort. + Billedet kunne ikke gemmes. + Siden er gemt til offline læsning. + Søg på nettet + Markører: %1$d + Find kort + Brug Gem i læseren for at beholde en side offline. + Fastgør som kort + Hold på et billede for at fastgøre det som kort. + Knib for at zoome. Hold for at tilføje en markør, tryk på en for at fjerne den. + Spillets wiki + Rettelser fra PCGamingWiki + Gennemgange på YouTube + Vist + Skjult + Dæmpet + Steam-guides + Kategori + Ingen fastgjorte kort endnu + Kort %1$d + Ingen gemte sider endnu + Spejlindstillinger + Område + Øverste skærm + Skalering + Hurtig adgang + Layout: %1$s + Fuld bredde + Venstre + Midte + Højre + Steams menu til hurtig adgang er ikke tilgængelig endnu. Statistik i spillet HUD på nederste skærm Stribe på alle faner @@ -3159,6 +3225,8 @@ Installationsplacering Standardlager Nye butiksinstallationer går til den valgte placering. Eksisterende spil bliver, hvor de er. Steam-biblioteker har deres egen indstilling. + Telefonens lager i Linux + Monterer telefonens interne lager på /root/Storage. Når det er slået fra, monteres kun de spilmapper, du har tilføjet derfra. SD-kort påvirkes ikke. Træder i kraft ved næste session. Spørg hver gang Vælg en placering for hver installation Internt lager @@ -4079,6 +4147,12 @@ Fremhævninger Succes Fejl + Advarsel Vis kun HUD under spil Skjul HUD, når der ikke registreres spilbilleder. + Luk Steam først + Sæt Steam-downloaden på pause først + Dette spil installerer sin Linux-version. Installer det fra Steam. + Spilzoom + Juster spillets forstørrelse fra 100 % til 300 % diff --git a/app/src/main/res/values-de/input_zoom_strings.xml b/app/src/main/res/values-de/input_zoom_strings.xml new file mode 100644 index 0000000000..1abf75bd99 --- /dev/null +++ b/app/src/main/res/values-de/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Spielzoom vergrößern + Spielzoom verkleinern + \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 37269e423f..de3e9c377d 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -1241,6 +1241,11 @@ Vorbereiten Wireless-Debugging ist nicht erreichbar; Koppeln schaltet es ein Koppeln + Quest hat keinen Kopplungsbildschirm. Führe einmal an einem Computer aus: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS und adb tcpip 5555. Tippe dann auf Zulassen und bestätige die Abfrage im Headset + Zulassen + Bestätige „Debugging zulassen?“ im Headset mit aktiviertem „Immer zulassen“ + Verbindung fehlgeschlagen. Bestätige die Debugging-Abfrage im Headset. Falls keine erschienen ist, führe adb tcpip 5555 an einem Computer aus und versuche es erneut + Kabelloses Debugging ist nicht erreichbar. Tippe auf Zulassen, um es neu einzurichten Installieren Anmelden PR #%1$d @@ -1452,6 +1457,7 @@ %1$d %% %1$s fortsetzen Erscheint in jeder Sitzung als /root/ROMs. Der interne Speicher liegt unter /root/Storage. + Erscheint in jeder Sitzung als /root/ROMs. Kein Ordner ausgewählt Gilt ab der nächsten Sitzung. SD-Karten funktionieren. Ordner auswählen @@ -2041,6 +2047,13 @@ Die rote Markierung kennzeichnet die Stelle, an der das HUD die Temperatur rot anzeigt. ganzes Gerät Akku + Spielgrafik + Wird gespielt + In Steam ausgewählt + Zuletzt gespielt + Noch nicht gespielt + %1$d Min. gespielt + %1$d Std. gespielt Dashboard-Daten senden Automatisch Schaltet es für jedes hier aufgeführte Spiel ein, auch für später gefundene Spiele. Spiele, die du ausschaltest, bleiben aus. @@ -2063,6 +2076,59 @@ Mikro aus Das Mikro ist für dieses Spiel aus. Um zu sprechen, aktiviere „Mikrofon“ in den Steam-Einstellungen von DroidDeck (Audio) und starte das Spiel neu. Lautstärke %1$d%% + Leiste ausblenden + Leiste einblenden + Helligkeit des unteren Bildschirms + Unteren Bildschirm ausschalten + Anleitungen + Starte ein Spiel, um hier seine Steam-Anleitungen zu sehen. + Weiterlesen + Für dieses Spiel gibt es noch keine Steam-Anleitungen. + Steam-Anleitungen konnten nicht geladen werden. Versuche es erneut, sobald du online bist. + Spiegel + Ziehe über den Teil des Spiels, der hier erscheinen soll, etwa die Minikarte. + Bereich speichern + Scharf + Weich + Das Spielbild kann gerade nicht kopiert werden. + Wiki & Fixes + Karten + Gespeichert + Alle + Komplettlösungen + Geheimnisse + Karte zu den Karten dieses Spiels hinzugefügt. + Das Bild konnte nicht gespeichert werden. + Seite für das Offline-Lesen gespeichert. + Im Web suchen + Markierungen: %1$d + Karten finden + Mit „Speichern“ im Reader bleibt eine Seite offline lesbar. + Als Karte anheften + Halte ein Bild gedrückt, um es als Karte anzuheften. + Zum Zoomen auseinanderziehen. Gedrückt halten fügt eine Markierung hinzu, Antippen entfernt sie. + Spiel-Wiki + Fixes von PCGamingWiki + Komplettlösungen auf YouTube + Sichtbar + Verdeckt + Abgedunkelt + Steam-Anleitungen + Kategorie + Noch keine angehefteten Karten + Karte %1$d + Noch keine gespeicherten Seiten + Spiegeloptionen + Bereich + Oberer Bildschirm + Skalierung + Schnellzugriff + Layout: %1$s + Volle Breite + Links + Mitte + Rechts + Das Schnellzugriffsmenü von Steam ist noch nicht verfügbar. Spielstatistiken HUD für den unteren Bildschirm Leiste auf jedem Tab @@ -3159,6 +3225,8 @@ Installationsort Standardspeicher Neue Store-Installationen landen am ausgewählten Ort. Vorhandene Spiele bleiben, wo sie sind. Steam-Bibliotheken behalten ihre eigene Einstellung. + Telefonspeicher in Linux + Bindet den internen Speicher deines Telefons unter /root/Storage ein. Wenn aus, werden nur Spielordner eingebunden, die du daraus hinzugefügt hast. SD-Karten sind nicht betroffen. Gilt ab der nächsten Sitzung. Jedes Mal fragen Für jede Installation ein Ziel wählen Interner Speicher @@ -4079,6 +4147,12 @@ Hervorhebungen Erfolg Fehler + Warnung HUD nur während eines Spiels anzeigen HUD ausblenden, wenn keine Spielframes erkannt werden. + Schließe zuerst Steam + Pausiere zuerst den Steam-Download + Dieses Spiel installiert seine Linux-Version. Installiere es über Steam. + Spielzoom + Spielvergrößerung von 100 % bis 300 % anpassen diff --git a/app/src/main/res/values-el/input_zoom_strings.xml b/app/src/main/res/values-el/input_zoom_strings.xml new file mode 100644 index 0000000000..2600c24f56 --- /dev/null +++ b/app/src/main/res/values-el/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Αύξηση ζουμ παιχνιδιού + Μείωση ζουμ παιχνιδιού + \ No newline at end of file diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index dd2110463c..655da001c1 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -1249,6 +1249,11 @@ Προετοιμασία Η ασύρματη αποσφαλμάτωση δεν είναι προσβάσιμη · η Σύζευξη την ενεργοποιεί Σύζευξη + Το Quest δεν έχει οθόνη σύζευξης. Από έναν υπολογιστή, εκτελέστε μία φορά: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS και adb tcpip 5555. Μετά πατήστε «Να επιτραπεί» και αποδεχτείτε το μήνυμα στο headset + Να επιτραπεί + Αποδεχτείτε το «Να επιτραπεί ο εντοπισμός σφαλμάτων;» στο headset, με επιλεγμένο το «Να επιτρέπεται πάντα» + Δεν ήταν δυνατή η σύνδεση. Αποδεχτείτε το μήνυμα εντοπισμού σφαλμάτων στο headset ή, αν δεν εμφανίστηκε, εκτελέστε adb tcpip 5555 από υπολογιστή και δοκιμάστε ξανά + Ο ασύρματος εντοπισμός σφαλμάτων δεν είναι προσβάσιμος. Πατήστε «Να επιτραπεί» για να τον ρυθμίσετε ξανά Εγκατάσταση Σύνδεση PR #%1$d @@ -1460,6 +1465,7 @@ %1$d%% Συνέχιση %1$s Εμφανίζεται ως /root/ROMs σε κάθε συνεδρία. Ο εσωτερικός χώρος αποθήκευσης βρίσκεται στο /root/Storage. + Εμφανίζεται ως /root/ROMs σε κάθε συνεδρία. Δεν έχει επιλεγεί φάκελος Ισχύει από την επόμενη συνεδρία. Οι κάρτες SD λειτουργούν. Επιλογή φακέλου @@ -2049,6 +2055,13 @@ Η κόκκινη ένδειξη είναι το σημείο όπου το HUD εμφανίζει τη θερμοκρασία με κόκκινο. ολόκληρη η συσκευή μπαταρία + Εικόνες παιχνιδιού + Παίζεται + Επιλεγμένο στο Steam + Παίχτηκε τελευταία + Δεν έχει παιχτεί + %1$d λεπ. παιχνιδιού + %1$d ώρ. παιχνιδιού Αποστολή δεδομένων πίνακα Αυτόματα Το ενεργοποιεί για κάθε παιχνίδι της λίστας, μαζί και όσα βρεθούν αργότερα. Τα παιχνίδια που απενεργοποιείτε παραμένουν ανενεργά. @@ -2071,6 +2084,59 @@ Μικρόφωνο κλειστό Το μικρόφωνο είναι απενεργοποιημένο για αυτό το παιχνίδι. Για να μιλήσετε, ενεργοποιήστε το Μικρόφωνο στις ρυθμίσεις Steam του DroidDeck (Ήχος) και ξεκινήστε ξανά το παιχνίδι. Ένταση %1$d%% + Απόκρυψη γραμμής + Εμφάνιση γραμμής + Φωτεινότητα κάτω οθόνης + Απενεργοποίηση κάτω οθόνης + Οδηγοί + Ξεκινήστε ένα παιχνίδι για να δείτε εδώ τους οδηγούς του στο Steam. + Συνέχεια ανάγνωσης + Δεν υπάρχουν ακόμη οδηγοί Steam για αυτό το παιχνίδι. + Δεν ήταν δυνατή η φόρτωση των οδηγών Steam. Δοκιμάστε ξανά όταν είστε online. + Καθρέφτης + Σύρετε πάνω από το μέρος του παιχνιδιού που θέλετε να εμφανίζεται εδώ, όπως ο μικρός χάρτης. + Αποθήκευση περιοχής + Οξύ + Ομαλό + Η εικόνα του παιχνιδιού δεν μπορεί να αντιγραφεί τώρα. + Wiki και διορθώσεις + Χάρτες + Αποθηκευμένα + Όλα + Οδηγοί ολοκλήρωσης + Μυστικά + Ο χάρτης καρφιτσώθηκε στους χάρτες του παιχνιδιού. + Δεν ήταν δυνατή η αποθήκευση της εικόνας. + Η σελίδα αποθηκεύτηκε για ανάγνωση εκτός σύνδεσης. + Αναζήτηση στο web + Σημάδια: %1$d + Εύρεση χαρτών + Χρησιμοποιήστε την Αποθήκευση στον αναγνώστη για να κρατήσετε μια σελίδα εκτός σύνδεσης. + Καρφίτσωμα ως χάρτη + Πατήστε παρατεταμένα μια εικόνα για να την καρφιτσώσετε ως χάρτη. + Τσιμπήστε για ζουμ. Πατήστε παρατεταμένα για σημάδι, πατήστε ένα για να το αφαιρέσετε. + Wiki του παιχνιδιού + Διορθώσεις από PCGamingWiki + Οδηγοί στο YouTube + Εμφανές + Κρυφό + Σκοτεινό + Οδηγοί Steam + Κατηγορία + Δεν υπάρχουν καρφιτσωμένοι χάρτες + Χάρτης %1$d + Δεν υπάρχουν αποθηκευμένες σελίδες + Επιλογές καθρέφτη + Περιοχή + Πάνω οθόνη + Κλιμάκωση + Γρήγορη πρόσβαση + Διάταξη: %1$s + Πλήρες πλάτος + Αριστερά + Κέντρο + Δεξιά + Το μενού γρήγορης πρόσβασης του Steam δεν είναι ακόμη διαθέσιμο. Στατιστικά παιχνιδιού HUD κάτω οθόνης Λωρίδα σε κάθε καρτέλα @@ -3159,6 +3225,8 @@ Τοποθεσία εγκατάστασης Προεπιλεγμένος αποθηκευτικός χώρος Οι νέες εγκαταστάσεις από καταστήματα πηγαίνουν στην επιλεγμένη τοποθεσία. Τα υπάρχοντα παιχνίδια μένουν όπου είναι. Οι βιβλιοθήκες Steam διατηρούν τη δική τους ρύθμιση. + Αποθηκευτικός χώρος τηλεφώνου στο Linux + Προσαρτά τον εσωτερικό χώρο αποθήκευσης του τηλεφώνου σας στο /root/Storage. Όταν είναι απενεργοποιημένο, προσαρτώνται μόνο οι φάκελοι παιχνιδιών που προσθέσατε από αυτόν. Οι κάρτες SD δεν επηρεάζονται. Ισχύει από την επόμενη συνεδρία. Ερώτηση κάθε φορά Επιλογή προορισμού για κάθε εγκατάσταση Εσωτερικός αποθηκευτικός χώρος @@ -4079,6 +4147,12 @@ Επισημάνσεις Επιτυχία Σφάλμα + Προειδοποίηση Εμφάνιση HUD μόνο κατά τη διάρκεια παιχνιδιού Απόκρυψη HUD όταν δεν ανιχνεύονται καρέ παιχνιδιού. + Κλείστε πρώτα το Steam + Θέστε πρώτα σε παύση τη λήψη του Steam + Αυτό το παιχνίδι εγκαθιστά την έκδοσή του για Linux. Εγκαταστήστε το από το Steam. + Ζουμ παιχνιδιού + Ρυθμίστε τη μεγέθυνση του παιχνιδιού από 100% έως 300% diff --git a/app/src/main/res/values-es/input_zoom_strings.xml b/app/src/main/res/values-es/input_zoom_strings.xml new file mode 100644 index 0000000000..b3a9fa6ce7 --- /dev/null +++ b/app/src/main/res/values-es/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Aumentar el zoom del juego + Reducir el zoom del juego + \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 7c3023606f..6a5d9622da 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -1253,6 +1253,11 @@ Preparar No se puede acceder a la depuración inalámbrica; Emparejar la activa Emparejar + Quest no tiene pantalla de vinculación. Desde un ordenador, ejecuta una vez: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS y adb tcpip 5555. Después toca Permitir y acepta el aviso en el visor + Permitir + Acepta «¿Permitir depuración?» en el visor, con Permitir siempre marcado + No se pudo conectar. Acepta el aviso de depuración en el visor o, si no apareció, ejecuta adb tcpip 5555 desde un ordenador y vuelve a intentarlo + No se puede acceder a la depuración inalámbrica. Toca Permitir para configurarla de nuevo Instalar Iniciar sesión PR #%1$d @@ -1468,6 +1473,7 @@ %1$d%% Reanudar %1$s Aparece como /root/ROMs en cada sesión. El almacenamiento interno está en /root/Storage. + Aparece como /root/ROMs en cada sesión. Ninguna carpeta elegida Se aplica en la próxima sesión. Las tarjetas SD funcionan. Elegir carpeta @@ -2074,6 +2080,13 @@ La marca roja señala el punto en el que el HUD muestra la temperatura en rojo. todo el dispositivo batería + Arte del juego + Jugando + Seleccionado en Steam + Jugado por última vez + Aún sin jugar + %1$d min jugados + %1$d h jugadas Enviar datos al panel Automático Lo activa en todos los juegos de esta lista, incluidos los que se encuentren más adelante. Los juegos que desactives seguirán desactivados. @@ -2096,6 +2109,59 @@ Micro desactivado El micro está desactivado en este juego. Para hablar, activa Micrófono en los ajustes de Steam de DroidDeck (Audio) y vuelve a iniciar el juego. Volumen %1$d%% + Ocultar barra + Mostrar barra + Brillo de la pantalla inferior + Apagar la pantalla inferior + Guías + Inicia un juego para ver aquí sus guías de Steam. + Seguir leyendo + Este juego aún no tiene guías de Steam. + No se han podido cargar las guías de Steam. Vuelve a intentarlo cuando tengas conexión. + Espejo + Arrastra sobre la parte del juego que quieras ver aquí, como el minimapa. + Guardar región + Nítido + Suave + Ahora no se puede copiar la imagen del juego. + Wiki y soluciones + Mapas + Guardado + Todo + Guías completas + Secretos + Mapa fijado en los mapas de este juego. + No se ha podido guardar esa imagen. + Página guardada para leer sin conexión. + Buscar en la web + Marcadores: %1$d + Buscar mapas + Usa Guardar en el lector para conservar una página sin conexión. + Fijar como mapa + Mantén pulsada una imagen para fijarla como mapa. + Pellizca para ampliar. Mantén pulsado para añadir un marcador y tócalo para quitarlo. + Wiki del juego + Soluciones de PCGamingWiki + Guías en YouTube + Visible + Oculto + Atenuado + Guías de Steam + Categoría + Aún no hay mapas fijados + Mapa %1$d + Aún no hay páginas guardadas + Opciones de espejo + Región + Pantalla superior + Escalado + Acceso rápido + Diseño: %1$s + Ancho completo + Izquierda + Centro + Derecha + El menú de acceso rápido de Steam aún no está disponible. Estadísticas del juego HUD de la pantalla inferior Barra en todas las pestañas @@ -3189,6 +3255,8 @@ Ubicación de instalación Almacenamiento predeterminado Las nuevas instalaciones de las tiendas van a la ubicación seleccionada. Los juegos existentes se quedan donde están. Las bibliotecas de Steam conservan su propio ajuste. + Almacenamiento del teléfono en Linux + Monta el almacenamiento interno del teléfono en /root/Storage. Si está desactivado, solo se montan las carpetas de juegos que has añadido desde ahí. No afecta a las tarjetas SD. Se aplica en la próxima sesión. Preguntar siempre Elige un destino para cada instalación Almacenamiento interno @@ -4119,6 +4187,12 @@ Destacados Éxito Error + Advertencia Mostrar el HUD solo durante una partida Ocultar el HUD cuando no se detecten fotogramas del juego. + Cierra Steam primero + Pausa primero la descarga de Steam + Este juego instala su versión para Linux. Instálalo desde Steam. + Zoom del juego + Ajusta la ampliación del juego del 100 % al 300 % diff --git a/app/src/main/res/values-fi/input_zoom_strings.xml b/app/src/main/res/values-fi/input_zoom_strings.xml new file mode 100644 index 0000000000..497213995a --- /dev/null +++ b/app/src/main/res/values-fi/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Suurenna pelin zoomausta + Pienennä pelin zoomausta + \ No newline at end of file diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index b901ff521f..80c90ff817 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -1249,6 +1249,11 @@ Valmistele Langaton virheenkorjaus ei ole tavoitettavissa; Parita ottaa sen käyttöön Parita + Questissa ei ole laiteparinäkymää. Suorita kerran tietokoneelta: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS ja adb tcpip 5555. Napauta sitten Salli ja hyväksy kehote laseissa + Salli + Hyväksy ”Sallitaanko virheenkorjaus?” laseissa, kun Salli aina on valittuna + Yhteyttä ei saatu. Hyväksy virheenkorjauskehote laseissa, tai jos sitä ei näkynyt, suorita adb tcpip 5555 tietokoneelta ja yritä uudelleen + Langatonta virheenkorjausta ei tavoiteta. Määritä se uudelleen napauttamalla Salli Asenna Kirjaudu sisään PR #%1$d @@ -1460,6 +1465,7 @@ %1$d %% Jatka: %1$s Näkyy sessiossa polussa /root/ROMs. Sisäinen tallennustila on /root/Storage. + Näkyy sessiossa polussa /root/ROMs. Kansiota ei valittu Vaikuttaa seuraavaan istuntoon. SD-kortit toimivat. Valitse kansio @@ -2049,6 +2055,13 @@ Punainen merkki on kohta, jossa HUD alkaa näyttää lämpötilan punaisena. koko laite akku + Pelin kuvitus + Pelataan + Valittu Steamissä + Viimeksi pelattu + Ei vielä pelattu + Pelattu %1$d min + Pelattu %1$d h Lähetä kojelaudan tiedot Automaattinen Kytkee sen päälle jokaiselle tässä luetellulle pelille, myös myöhemmin löytyville. Pois kytkemäsi pelit pysyvät pois päältä. @@ -2071,6 +2084,59 @@ Mikrofoni pois Mikrofoni on pois päältä tässä pelissä. Jos haluat puhua, kytke Mikrofoni päälle DroidDeckin Steam-asetuksissa (Ääni) ja käynnistä peli uudelleen. Äänenvoimakkuus %1$d %% + Piilota palkki + Näytä palkki + Alanäytön kirkkaus + Sammuta alanäyttö + Oppaat + Käynnistä peli nähdäksesi sen Steam-oppaat täällä. + Jatka lukemista + Tälle pelille ei ole vielä Steam-oppaita. + Steam-oppaiden lataus epäonnistui. Yritä uudelleen, kun olet verkossa. + Peili + Vedä sen pelin osan yli, joka näytetään täällä, kuten minikartan. + Tallenna alue + Terävä + Pehmeä + Pelikuvaa ei voi kopioida juuri nyt. + Wiki ja korjaukset + Kartat + Tallennetut + Kaikki + Läpipeluut + Salaisuudet + Kartta kiinnitetty pelin karttoihin. + Kuvaa ei voitu tallentaa. + Sivu tallennettu offline-lukua varten. + Hae verkosta + Merkit: %1$d + Etsi karttoja + Tallenna lukijassa, niin sivu toimii myös offline. + Kiinnitä kartaksi + Kiinnitä kuva kartaksi painamalla sitä pitkään. + Zoomaa nipistämällä. Lisää merkki painamalla pitkään, poista napauttamalla. + Pelin wiki + PCGamingWikin korjaukset + Läpipeluut YouTubessa + Näkyvissä + Piilotettu + Himmennetty + Steam-oppaat + Luokka + Ei vielä kiinnitettyjä karttoja + Kartta %1$d + Ei vielä tallennettuja sivuja + Peilauksen asetukset + Alue + Ylänäyttö + Skaalaus + Pikavalikko + Asettelu: %1$s + Koko leveys + Vasen + Keskellä + Oikea + Steamin pikavalikko ei ole vielä käytettävissä. Pelinsisäiset tilastot Alanäytön HUD Palkki kaikilla välilehdillä @@ -3159,6 +3225,8 @@ Asennussijainti Oletustallennustila Uudet kauppa-asennukset menevät valittuun sijaintiin. Nykyiset pelit pysyvät paikoillaan. Steam-kirjastoilla on oma asetuksensa. + Puhelimen tallennustila Linuxissa + Liittää puhelimen sisäisen tallennustilan polkuun /root/Storage. Kun pois päältä, liitetään vain sieltä lisäämäsi pelikansiot. SD-kortit eivät muutu. Tulee voimaan seuraavassa istunnossa. Kysy aina Valitse kohde jokaiselle asennukselle Sisäinen tallennustila @@ -4079,6 +4147,12 @@ Korostukset Onnistuminen Virhe + Varoitus Näytä HUD vain pelin aikana Piilota HUD, kun pelin ruutuja ei havaita. + Sulje Steam ensin + Keskeytä Steam-lataus ensin + Tämä peli asentaa Linux-versionsa. Asenna se Steamista. + Pelin zoomaus + Säädä pelin suurennusta välillä 100–300 % diff --git a/app/src/main/res/values-fr/input_zoom_strings.xml b/app/src/main/res/values-fr/input_zoom_strings.xml new file mode 100644 index 0000000000..be77bcaf05 --- /dev/null +++ b/app/src/main/res/values-fr/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Augmenter le zoom du jeu + Réduire le zoom du jeu + \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 0688318753..db54af05d4 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -1252,6 +1252,11 @@ Préparer Le débogage sans fil n\'est pas accessible ; « Associer » l\'active Associer + Le Quest n\'a pas d\'écran d\'association. Depuis un ordinateur, exécutez une fois : adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS et adb tcpip 5555. Touchez ensuite Autoriser et acceptez la demande dans le casque + Autoriser + Acceptez « Autoriser le débogage ? » dans le casque, avec Toujours autoriser coché + Connexion impossible. Acceptez la demande de débogage dans le casque ou, si elle n\'est pas apparue, exécutez adb tcpip 5555 depuis un ordinateur et réessayez + Le débogage sans fil est injoignable. Touchez Autoriser pour le configurer à nouveau Installer Se connecter PR #%1$d @@ -1467,6 +1472,7 @@ %1$d%% Reprendre %1$s Affiché comme /root/ROMs dans chaque session. Le stockage interne se trouve dans /root/Storage. + Affiché comme /root/ROMs dans chaque session. Aucun dossier sélectionné Prendra effet à la prochaine session. Prend en charge les cartes SD. Choisir un dossier @@ -2073,6 +2079,13 @@ Le repère rouge indique où le HUD affiche la température en rouge. appareil entier batterie + Illustration du jeu + En cours + Sélectionné dans Steam + Joué récemment + Pas encore joué + %1$d min de jeu + %1$d h de jeu Envoyer les données du tableau de bord Automatique L\'active pour chaque jeu listé ici, y compris les jeux trouvés plus tard. Les jeux que vous désactivez restent désactivés. @@ -2095,6 +2108,59 @@ Micro désactivé Le micro est désactivé pour ce jeu. Pour parler, activez Microphone dans les paramètres Steam de DroidDeck (Audio), puis relancez le jeu. Volume %1$d %% + Masquer la barre + Afficher la barre + Luminosité de l’écran inférieur + Éteindre l’écran du bas + Guides + Lancez un jeu pour voir ses guides Steam ici. + Reprendre la lecture + Ce jeu n’a pas encore de guides Steam. + Impossible de charger les guides Steam. Réessayez une fois en ligne. + Miroir + Faites glisser sur la partie du jeu à afficher ici, comme la mini-carte. + Enregistrer la zone + Net + Lissé + L’image du jeu ne peut pas être copiée pour le moment. + Wiki et correctifs + Cartes + Enregistré + Tout + Soluces + Secrets + Carte épinglée aux cartes de ce jeu. + Impossible d’enregistrer cette image. + Page enregistrée pour une lecture hors ligne. + Rechercher sur le web + Repères : %1$d + Trouver des cartes + Utilisez Enregistrer dans le lecteur pour garder une page hors ligne. + Épingler comme carte + Appuyez longuement sur une image pour l’épingler comme carte. + Pincez pour zoomer. Appui long pour ajouter un repère, touchez-en un pour le retirer. + Wiki du jeu + Correctifs PCGamingWiki + Soluces sur YouTube + Visible + Masqué + Assombri + Guides Steam + Catégorie + Aucune carte épinglée + Carte %1$d + Aucune page enregistrée + Options du miroir + Zone + Écran du haut + Mise à l’échelle + Accès rapide + Disposition : %1$s + Pleine largeur + Gauche + Centre + Droite + Le menu d’accès rapide de Steam n’est pas encore disponible. Statistiques en jeu HUD de l\'écran du bas Bande sur tous les onglets @@ -3188,6 +3254,8 @@ Emplacement d\'installation Stockage par défaut Les nouvelles installations depuis les boutiques vont à l\'emplacement sélectionné. Les jeux existants restent où ils sont. Les bibliothèques Steam gardent leur propre réglage. + Stockage du téléphone dans Linux + Monte le stockage interne de votre téléphone dans /root/Storage. Désactivé, seuls les dossiers de jeux que vous y avez ajoutés sont montés. Les cartes SD ne sont pas concernées. S\'applique à la prochaine session. Toujours demander Choisir une destination pour chaque installation Stockage interne @@ -4118,6 +4186,12 @@ Mises en évidence Succès Erreur + Avertissement Afficher le HUD uniquement pendant une partie Masquer le HUD lorsqu’aucune image du jeu n’est détectée. + Fermez d\'abord Steam + Mettez d\'abord en pause le téléchargement Steam + Ce jeu installe sa version Linux. Installez-le depuis Steam. + Zoom du jeu + Réglez le grossissement du jeu de 100 % à 300 % diff --git a/app/src/main/res/values-hi/input_zoom_strings.xml b/app/src/main/res/values-hi/input_zoom_strings.xml new file mode 100644 index 0000000000..c4d12e84e1 --- /dev/null +++ b/app/src/main/res/values-hi/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + गेम ज़ूम बढ़ाएँ + गेम ज़ूम घटाएँ + \ No newline at end of file diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index d0bb555bc9..47b15821d3 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -1249,6 +1249,11 @@ तैयार करें वायरलेस डिबगिंग से कनेक्ट नहीं हो पा रहा; पेयर करने से यह चालू हो जाता है पेयर करें + Quest में पेयरिंग स्क्रीन नहीं है। किसी कंप्यूटर से एक बार चलाएँ: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS और adb tcpip 5555। फिर अनुमति दें पर टैप करें और हेडसेट में संकेत स्वीकार करें + अनुमति दें + हेडसेट में “डीबगिंग की अनुमति दें?” स्वीकार करें, हमेशा अनुमति दें चुना हुआ रखें + कनेक्ट नहीं हो सका। हेडसेट में डीबगिंग संकेत स्वीकार करें, या अगर वह नहीं दिखा, तो कंप्यूटर से adb tcpip 5555 चलाएँ और दोबारा कोशिश करें + वायरलेस डीबगिंग तक नहीं पहुँचा जा सकता। इसे फिर से सेट करने के लिए अनुमति दें पर टैप करें इंस्टॉल करें साइन इन करें PR #%1$d @@ -1460,6 +1465,7 @@ %1$d%% %1$s फिर से शुरू करें हर सेशन में /root/ROMs के रूप में दिखता है। इंटरनल स्टोरेज /root/Storage पर है। + हर सेशन में /root/ROMs के रूप में दिखता है। कोई फ़ोल्डर नहीं चुना गया अगले सेशन से लागू होता है। SD कार्ड काम करते हैं। फ़ोल्डर चुनें @@ -2049,6 +2055,13 @@ लाल निशान वह बिंदु है जहाँ HUD तापमान को लाल रंग में दिखाता है। पूरा डिवाइस बैटरी + गेम आर्ट + खेल रहे हैं + Steam में चुना गया + पिछली बार खेला + अभी तक नहीं खेला + %1$d मिनट खेला + %1$d घंटे खेला डैशबोर्ड डेटा भेजें ऑटोमैटिक यहां दिए हर गेम के लिए इसे चालू करता है, बाद में मिलने वाले गेम भी शामिल हैं। जिन गेम को आप बंद करते हैं, वे बंद ही रहते हैं। @@ -2071,6 +2084,59 @@ माइक बंद इस गेम के लिए माइक बंद है। बात करने के लिए DroidDeck की Steam सेटिंग (ऑडियो) में माइक्रोफ़ोन चालू करें और गेम फिर से शुरू करें। वॉल्यूम %1$d%% + बार छिपाएँ + बार दिखाएँ + नीचे की स्क्रीन की चमक + नीचे की स्क्रीन बंद करें + गाइड + यहाँ Steam गाइड देखने के लिए कोई गेम शुरू करें। + पढ़ना जारी रखें + इस गेम के लिए अभी कोई Steam गाइड नहीं है। + Steam गाइड लोड नहीं हो सके। ऑनलाइन होने पर फिर देखें। + मिरर + गेम का वह हिस्सा चुनने के लिए खींचें जो यहाँ दिखे, जैसे मिनीमैप। + क्षेत्र सहेजें + तेज़ + मुलायम + गेम की तस्वीर अभी कॉपी नहीं हो सकती। + विकी और सुधार + नक्शे + सहेजे गए + सभी + वॉकथ्रू + रहस्य + नक्शा इस गेम के नक्शों में पिन किया गया। + वह छवि सहेजी नहीं जा सकी। + पेज ऑफ़लाइन पढ़ने के लिए सहेजा गया। + वेब पर खोजें + मार्कर: %1$d + नक्शे खोजें + पेज ऑफ़लाइन रखने के लिए रीडर में सहेजें दबाएँ। + नक्शे के रूप में पिन करें + किसी छवि को नक्शे के रूप में पिन करने के लिए देर तक दबाएँ। + ज़ूम के लिए पिंच करें। मार्कर जोड़ने के लिए देर तक दबाएँ, हटाने के लिए उस पर टैप करें। + गेम विकी + PCGamingWiki सुधार + YouTube वॉकथ्रू + दिखाया गया + छिपाया गया + मंद + Steam गाइड + श्रेणी + अभी कोई पिन किया नक्शा नहीं + नक्शा %1$d + अभी कोई सहेजा पेज नहीं + मिरर विकल्प + क्षेत्र + ऊपर की स्क्रीन + स्केलिंग + क्विक एक्सेस + लेआउट: %1$s + पूरी चौड़ाई + बाएँ + बीच में + दाएँ + Steam का क्विक एक्सेस मेनू अभी उपलब्ध नहीं है। इन-गेम आंकड़े निचली स्क्रीन HUD हर टैब पर स्ट्रिप @@ -3159,6 +3225,8 @@ इंस्टॉल की जगह डिफ़ॉल्ट स्टोरेज स्टोर से नए इंस्टॉल चुनी गई जगह पर जाते हैं। मौजूदा गेम जहां हैं वहीं रहते हैं। Steam लाइब्रेरी अपनी सेटिंग रखती हैं। + Linux में फ़ोन स्टोरेज + आपके फ़ोन का इंटरनल स्टोरेज /root/Storage पर माउंट करता है। बंद होने पर केवल वही गेम फ़ोल्डर माउंट होते हैं जो आपने उसमें से जोड़े हैं। SD कार्ड पर असर नहीं पड़ता। अगले सत्र से लागू होता है। हर बार पूछें हर इंस्टॉल के लिए जगह चुनें इंटरनल स्टोरेज @@ -4079,6 +4147,12 @@ हाइलाइट सफलता त्रुटि + चेतावनी HUD केवल गेम के दौरान दिखाएँ गेम के फ़्रेम का पता न चलने पर HUD छिपाएँ। + पहले Steam बंद करें + पहले Steam डाउनलोड रोकें + यह गेम अपना Linux संस्करण इंस्टॉल करता है। इसे Steam से इंस्टॉल करें। + गेम ज़ूम + गेम का ज़ूम 100% से 300% तक समायोजित करें diff --git a/app/src/main/res/values-hu/input_zoom_strings.xml b/app/src/main/res/values-hu/input_zoom_strings.xml new file mode 100644 index 0000000000..743e49fd58 --- /dev/null +++ b/app/src/main/res/values-hu/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Játék nagyítása + Játék kicsinyítése + \ No newline at end of file diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index ec6fcc1046..edc23c97ca 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -1249,6 +1249,11 @@ Előkészítés A vezeték nélküli hibakeresés nem érhető el; a Párosítás bekapcsolja Párosítás + A Quest nem rendelkezik párosítási képernyővel. Egy számítógépről futtasd egyszer: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS és adb tcpip 5555. Ezután koppints az Engedélyezés gombra, és fogadd el a kérdést a headsetben + Engedélyezés + Fogadd el az „Engedélyezed a hibakeresést?” kérdést a headsetben, a Mindig engedélyez bejelölésével + Nem sikerült csatlakozni. Fogadd el a hibakeresési kérdést a headsetben, vagy ha nem jelent meg, futtasd az adb tcpip 5555 parancsot egy számítógépről, és próbáld újra + A vezeték nélküli hibakeresés nem érhető el. Koppints az Engedélyezés gombra az újbóli beállításhoz Telepítés Bejelentkezés PR #%1$d @@ -1460,6 +1465,7 @@ %1$d%% %1$s folytatása Minden munkamenetben /root/ROMs néven jelenik meg. A belső tárhely itt található: /root/Storage. + Minden munkamenetben /root/ROMs néven jelenik meg. Nincs mappa kiválasztva A következő munkamenettől érvényes. SD-kártyák is működnek. Mappa kiválasztása @@ -2049,6 +2055,13 @@ A piros jelölés jelzi, hol jeleníti meg pirosan a HUD a hőmérsékletet. teljes eszköz akkumulátor + Játékgrafika + Játékban + Kiválasztva a Steamben + Legutóbb játszott + Még nem játszott + %1$d perc játék + %1$d óra játék Műszerfal-adatok küldése Automatikus Bekapcsolja az itt felsorolt összes játéknál, a később talált játékokat is beleértve. A kikapcsolt játékok kikapcsolva maradnak. @@ -2071,6 +2084,59 @@ Mikrofon ki A mikrofon ki van kapcsolva ennél a játéknál. A beszédhez kapcsolja be a Mikrofon opciót a DroidDeck Steam-beállításaiban (Hang), majd indítsa újra a játékot. Hangerő %1$d%% + Sáv elrejtése + Sáv megjelenítése + Alsó kijelző fényereje + Alsó képernyő kikapcsolása + Útmutatók + Indíts el egy játékot, hogy itt lásd a Steam-útmutatóit. + Olvasás folytatása + Ehhez a játékhoz még nincs Steam-útmutató. + Nem sikerült betölteni a Steam-útmutatókat. Próbáld újra, ha online vagy. + Tükör + Húzd át a játék azon részét, amelyet itt szeretnél látni, például a minitérképet. + Terület mentése + Éles + Lágy + A játék képe most nem másolható. + Wiki és javítások + Térképek + Mentett + Mind + Végigjátszások + Titkok + A térkép a játék térképei közé került. + A képet nem sikerült menteni. + Az oldal offline olvasásra mentve. + Keresés a weben + Jelölők: %1$d + Térképek keresése + A Mentés gombbal az oldal offline is olvasható marad. + Kitűzés térképként + Tarts lenyomva egy képet, hogy térképként kitűzd. + Csípd a nagyításhoz. Hosszú nyomással jelölőt adsz hozzá, koppintással törlöd. + A játék wikije + PCGamingWiki-javítások + Végigjátszások a YouTube-on + Látható + Rejtett + Sötétített + Steam-útmutatók + Kategória + Még nincs kitűzött térkép + %1$d. térkép + Még nincs mentett oldal + Tükrözés beállításai + Terület + Felső képernyő + Méretezés + Gyorselérés + Elrendezés: %1$s + Teljes szélesség + Balra + Középen + Jobbra + A Steam gyorselérési menüje még nem érhető el. Játékon belüli statisztikák HUD az alsó képernyőn Sáv minden lapon @@ -3159,6 +3225,8 @@ Telepítési hely Alapértelmezett tárhely Az új áruházi telepítések a kiválasztott helyre kerülnek. A meglévő játékok a helyükön maradnak. A Steam-könyvtárak megtartják saját beállításukat. + Telefontárhely a Linuxban + Csatolja a telefon belső tárhelyét a /root/Storage helyre. Kikapcsolva csak az onnan hozzáadott játékmappák lesznek csatolva. Az SD-kártyákat nem érinti. A következő munkamenettől érvényes. Kérdezzen rá minden alkalommal Célhely választása minden telepítésnél Belső tárhely @@ -4079,6 +4147,12 @@ Kiemelések Siker Hiba + Figyelmeztetés HUD megjelenítése csak játék közben HUD elrejtése, ha nem észlelhetők játék képkockái. + Előbb zárd be a Steamet + Előbb szüneteltesd a Steam-letöltést + Ez a játék a Linux-verzióját telepíti. Telepítsd a Steamből. + Játék nagyítása + A játék nagyításának beállítása 100% és 300% között diff --git a/app/src/main/res/values-in/input_zoom_strings.xml b/app/src/main/res/values-in/input_zoom_strings.xml new file mode 100644 index 0000000000..dd4cb60c5f --- /dev/null +++ b/app/src/main/res/values-in/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Perbesar zoom game + Perkecil zoom game + \ No newline at end of file diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 7a71814cde..67f801c7bb 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -1246,6 +1246,11 @@ Siapkan Debug nirkabel tidak dapat dijangkau; Pasangkan menyalakannya Pasangkan + Quest tidak memiliki layar penyambungan. Dari komputer, jalankan sekali: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS dan adb tcpip 5555. Lalu ketuk Izinkan dan terima permintaan di headset + Izinkan + Terima “Izinkan debugging?” di headset, dengan Selalu izinkan dicentang + Tidak dapat terhubung. Terima permintaan debugging di headset, atau jika tidak muncul, jalankan adb tcpip 5555 dari komputer lalu coba lagi + Debugging nirkabel tidak dapat dijangkau. Ketuk Izinkan untuk menyiapkannya lagi Pasang Masuk PR #%1$d @@ -1453,6 +1458,7 @@ %1$d%% Lanjutkan %1$s Muncul sebagai /root/ROMs di setiap sesi. Penyimpanan internal berada di /root/Storage. + Muncul sebagai /root/ROMs di setiap sesi. Belum ada folder yang dipilih Berlaku pada sesi berikutnya. Kartu SD juga bisa. Pilih folder @@ -2025,6 +2031,13 @@ Tanda merah adalah batas saat HUD menampilkan suhu berwarna merah. seluruh perangkat baterai + Gambar game + Sedang dimainkan + Dipilih di Steam + Terakhir dimainkan + Belum dimainkan + %1$d mnt dimainkan + %1$d jam dimainkan Kirim data dasbor Otomatis Mengaktifkannya untuk setiap gim yang tercantum di sini, termasuk gim yang ditemukan nanti. Gim yang Anda matikan tetap mati. @@ -2047,6 +2060,59 @@ Mik mati Mik mati untuk gim ini. Untuk berbicara, aktifkan Mikrofon di setelan Steam DroidDeck (Audio) lalu mulai gim lagi. Volume %1$d%% + Sembunyikan bilah + Tampilkan bilah + Kecerahan layar bawah + Matikan layar bawah + Panduan + Mulai game untuk melihat panduan Steam-nya di sini. + Lanjutkan membaca + Belum ada panduan Steam untuk game ini. + Tidak dapat memuat panduan Steam. Coba lagi saat Anda online. + Cermin + Seret di atas bagian game yang ingin ditampilkan di sini, seperti peta mini. + Simpan area + Tajam + Halus + Gambar game tidak dapat disalin saat ini. + Wiki & perbaikan + Peta + Tersimpan + Semua + Panduan lengkap + Rahasia + Peta disematkan ke peta game ini. + Gambar itu tidak dapat disimpan. + Halaman disimpan untuk dibaca offline. + Cari di web + Penanda: %1$d + Cari peta + Gunakan Simpan di pembaca agar halaman bisa dibaca offline. + Sematkan sebagai peta + Tekan lama gambar untuk menyematkannya sebagai peta. + Cubit untuk memperbesar. Tekan lama untuk menambah penanda, ketuk penanda untuk menghapusnya. + Wiki game + Perbaikan PCGamingWiki + Panduan di YouTube + Tampil + Tersembunyi + Redup + Panduan Steam + Kategori + Belum ada peta yang disematkan + Peta %1$d + Belum ada halaman tersimpan + Opsi cermin + Area + Layar atas + Penskalaan + Akses Cepat + Tata letak: %1$s + Lebar penuh + Kiri + Tengah + Kanan + Menu Akses Cepat Steam belum tersedia. Statistik dalam gim HUD layar bawah Strip di setiap tab @@ -3130,6 +3196,8 @@ Lokasi instalasi Penyimpanan default Instalasi toko baru akan disimpan di lokasi yang dipilih. Game yang sudah ada tetap di lokasinya. Library Steam memakai pengaturannya sendiri. + Penyimpanan ponsel di Linux + Memasang penyimpanan internal ponsel Anda di /root/Storage. Jika nonaktif, hanya folder game yang Anda tambahkan dari sana yang dipasang. Kartu SD tidak terpengaruh. Berlaku pada sesi berikutnya. Tanyakan setiap kali Pilih target untuk setiap instalasi Penyimpanan internal @@ -4049,6 +4117,12 @@ Sorotan Berhasil Kesalahan + Peringatan Tampilkan HUD hanya saat bermain Sembunyikan HUD saat tidak ada frame game yang terdeteksi. + Tutup Steam terlebih dahulu + Jeda unduhan Steam terlebih dahulu + Game ini memasang versi Linux-nya. Pasang dari Steam. + Zoom game + Sesuaikan pembesaran game dari 100% hingga 300% diff --git a/app/src/main/res/values-it/input_zoom_strings.xml b/app/src/main/res/values-it/input_zoom_strings.xml new file mode 100644 index 0000000000..124ed96d1b --- /dev/null +++ b/app/src/main/res/values-it/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Aumenta lo zoom del gioco + Riduci lo zoom del gioco + \ No newline at end of file diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index f5a493b0ec..19021c75bf 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -1244,6 +1244,11 @@ Prepara Il debug wireless non è raggiungibile; Associa lo attiva Associa + Quest non ha una schermata di accoppiamento. Da un computer, esegui una volta: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS e adb tcpip 5555. Poi tocca Consenti e accetta la richiesta nel visore + Consenti + Accetta «Consentire il debug?» nel visore, con Consenti sempre selezionato + Impossibile connettersi. Accetta la richiesta di debug nel visore oppure, se non è comparsa, esegui adb tcpip 5555 da un computer e riprova + Il debug wireless non è raggiungibile. Tocca Consenti per configurarlo di nuovo Installa Accedi PR #%1$d @@ -1459,6 +1464,7 @@ %1$d%% Riprendi %1$s Appare come /root/ROMs in ogni sessione. La memoria interna si trova in /root/Storage. + Appare come /root/ROMs in ogni sessione. Nessuna cartella scelta Si applica dalla prossima sessione. Le schede SD funzionano. Scegli cartella @@ -2065,6 +2071,13 @@ Il segno rosso indica dove l\'HUD mostra la temperatura in rosso. intero dispositivo batteria + Immagini del gioco + In gioco + Selezionato in Steam + Giocato di recente + Non ancora giocato + %1$d min di gioco + %1$d h di gioco Invia dati al cruscotto Automatico Lo attiva per ogni gioco elencato qui, compresi i giochi trovati in seguito. I giochi che disattivi restano disattivati. @@ -2087,6 +2100,59 @@ Microfono disattivato Il microfono è disattivato per questo gioco. Per parlare, attiva Microfono nelle impostazioni Steam di DroidDeck (Audio) e riavvia il gioco. Volume %1$d%% + Nascondi barra + Mostra barra + Luminosità dello schermo inferiore + Spegni lo schermo inferiore + Guide + Avvia un gioco per vederne qui le guide di Steam. + Continua a leggere + Non ci sono ancora guide di Steam per questo gioco. + Impossibile caricare le guide di Steam. Riprova quando sei online. + Specchio + Trascina sulla parte del gioco da mostrare qui, come la minimappa. + Salva area + Nitido + Morbido + Al momento l’immagine del gioco non può essere copiata. + Wiki e correzioni + Mappe + Salvati + Tutte + Procedure complete + Segreti + Mappa fissata tra le mappe di questo gioco. + Impossibile salvare l’immagine. + Pagina salvata per la lettura offline. + Cerca sul web + Segnalini: %1$d + Trova mappe + Usa Salva nel lettore per tenere una pagina offline. + Fissa come mappa + Tieni premuta un’immagine per fissarla come mappa. + Pizzica per lo zoom. Tieni premuto per aggiungere un segnalino, toccalo per rimuoverlo. + Wiki del gioco + Correzioni di PCGamingWiki + Procedure su YouTube + Visibile + Nascosto + Scurito + Guide di Steam + Categoria + Nessuna mappa fissata + Mappa %1$d + Nessuna pagina salvata + Opzioni specchio + Area + Schermo superiore + Scalatura + Accesso rapido + Layout: %1$s + Larghezza piena + Sinistra + Centro + Destra + Il menu di accesso rapido di Steam non è ancora disponibile. Statistiche di gioco HUD dello schermo inferiore Barra su ogni scheda @@ -3188,6 +3254,8 @@ Posizione di installazione Archiviazione predefinita Le nuove installazioni dai negozi vanno nella posizione selezionata. I giochi esistenti restano dove sono. Le librerie di Steam mantengono la propria impostazione. + Memoria del telefono in Linux + Monta la memoria interna del telefono in /root/Storage. Se disattivato, vengono montate solo le cartelle dei giochi che hai aggiunto da lì. Le schede SD non sono interessate. Si applica dalla prossima sessione. Chiedi ogni volta Scegli una destinazione per ogni installazione Memoria interna @@ -4118,6 +4186,12 @@ Evidenziazioni Successo Errore + Avviso Mostra l’HUD solo durante il gioco Nascondi l’HUD quando non vengono rilevati fotogrammi del gioco. + Chiudi prima Steam + Metti prima in pausa il download di Steam + Questo gioco installa la sua versione Linux. Installalo da Steam. + Zoom del gioco + Regola l\'ingrandimento del gioco dal 100% al 300% diff --git a/app/src/main/res/values-ja/input_zoom_strings.xml b/app/src/main/res/values-ja/input_zoom_strings.xml new file mode 100644 index 0000000000..1d82a23541 --- /dev/null +++ b/app/src/main/res/values-ja/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + ゲームのズームを拡大 + ゲームのズームを縮小 + \ No newline at end of file diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 474b14df32..199f44f302 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -1246,6 +1246,11 @@ 準備 ワイヤレスデバッグに接続できません。ペアリングで有効になります ペアリング + Quest にはペア設定画面がありません。パソコンから一度だけ adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS と adb tcpip 5555 を実行し、[許可] をタップしてヘッドセットの確認を承認してください + 許可 + ヘッドセットで「デバッグを許可しますか?」を、[常に許可] にチェックを入れて承認してください + 接続できませんでした。ヘッドセットでデバッグの確認を承認してください。表示されなかった場合は、パソコンから adb tcpip 5555 を実行してもう一度お試しください + ワイヤレス デバッグに接続できません。[許可] をタップして設定し直してください インストール サインイン PR #%1$d @@ -1453,6 +1458,7 @@ %1$d%% %1$sを再開 各セッションで /root/ROMs として表示されます。内部ストレージは /root/Storage にあります。 + 各セッションで /root/ROMs として表示されます。 フォルダが選択されていません 次回のセッションで有効になります。SDカードをサポートしています。 フォルダを選択 @@ -2025,6 +2031,13 @@ 赤いマークは、HUD が温度を赤で表示する位置です。 デバイス全体 バッテリー + ゲームアート + プレイ中 + Steam で選択中 + 最近プレイ + 未プレイ + %1$d 分プレイ + %1$d 時間プレイ ダッシュボード用データを送信 自動 ここに表示されているすべてのゲーム(後から見つかったゲームを含む)でオンにします。オフにしたゲームはオフのままです。 @@ -2047,6 +2060,59 @@ マイク オフ このゲームではマイクがオフです。話すには、DroidDeckのSteam設定(オーディオ)でマイクをオンにして、ゲームを再起動してください。 音量 %1$d%% + バーを隠す + バーを表示 + 下画面の明るさ + 下の画面をオフにする + ガイド + ゲームを起動すると、ここに Steam ガイドが表示されます。 + 続きを読む + このゲームの Steam ガイドはまだありません。 + Steam ガイドを読み込めませんでした。オンラインになってから再度お試しください。 + ミラー + ミニマップなど、ここに表示したいゲーム画面の部分をドラッグで選びます。 + 範囲を保存 + シャープ + なめらか + 現在ゲーム画面をコピーできません。 + Wiki と修正 + マップ + 保存済み + すべて + 攻略 + 秘密 + マップをこのゲームのマップにピン留めしました。 + その画像を保存できませんでした。 + オフラインで読めるようにページを保存しました。 + ウェブを検索 + マーカー: %1$d + マップを探す + リーダーで保存すると、ページをオフラインで読めます。 + マップとしてピン留め + 画像を長押しするとマップとしてピン留めできます。 + ピンチでズーム。長押しでマーカーを追加、タップで削除します。 + ゲームの Wiki + PCGamingWiki の修正 + YouTube の攻略 + 表示 + 非表示 + 暗く + Steam ガイド + カテゴリ + ピン留めしたマップはまだありません + マップ %1$d + 保存したページはまだありません + ミラーの設定 + 範囲 + 上画面 + スケーリング + クイックアクセス + レイアウト: %1$s + 全幅 + 左 + 中央 + 右 + Steam のクイックアクセスメニューはまだ使えません。 ゲーム内統計 下部画面の HUD すべてのタブにストリップを表示 @@ -3130,6 +3196,8 @@ インストール先 デフォルトのストレージ ストアからの新しいインストールは選択した場所に保存されます。既存のゲームはそのままです。Steamライブラリは独自の設定を使用します。 + Linux でのスマホのストレージ + スマホの内部ストレージを /root/Storage にマウントします。オフにすると、そこから追加したゲームフォルダーだけがマウントされます。SD カードには影響しません。次のセッションから適用されます。 毎回確認する インストールごとに保存先を選択します 内部ストレージ @@ -4049,6 +4117,12 @@ 強調表示 成功 エラー + 警告 ゲーム中のみHUDを表示 ゲームのフレームが検出されないときはHUDを非表示にする。 + 先に Steam を閉じてください + 先に Steam のダウンロードを一時停止してください + このゲームは Linux 版をインストールします。Steam からインストールしてください。 + ゲームズーム + ゲームの拡大率を100%から300%の間で調整します diff --git a/app/src/main/res/values-ko/input_zoom_strings.xml b/app/src/main/res/values-ko/input_zoom_strings.xml new file mode 100644 index 0000000000..3011ee320d --- /dev/null +++ b/app/src/main/res/values-ko/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + 게임 확대 + 게임 축소 + \ No newline at end of file diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 629e4c7783..7d139b289b 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -1246,6 +1246,11 @@ 준비 무선 디버깅에 연결할 수 없습니다. 페어링하면 켜집니다 페어링 + Quest에는 페어링 화면이 없습니다. 컴퓨터에서 한 번 실행하세요: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS 및 adb tcpip 5555. 그런 다음 허용을 탭하고 헤드셋에서 요청을 수락하세요 + 허용 + 헤드셋에서 \'디버깅을 허용하시겠습니까?\'를 항상 허용을 선택한 채로 수락하세요 + 연결하지 못했습니다. 헤드셋에서 디버깅 요청을 수락하거나, 요청이 나타나지 않았다면 컴퓨터에서 adb tcpip 5555를 실행한 뒤 다시 시도하세요 + 무선 디버깅에 연결할 수 없습니다. 허용을 탭해 다시 설정하세요 설치 로그인 PR #%1$d @@ -1453,6 +1458,7 @@ %1$d%% %1$s 재개 각 세션에서 /root/ROMs로 표시됩니다. 내부 저장 공간은 /root/Storage에 있습니다. + 각 세션에서 /root/ROMs로 표시됩니다. 선택된 폴더 없음 다음 세션에 적용됩니다. SD 카드를 지원합니다. 폴더 선택 @@ -2025,6 +2031,13 @@ 빨간색 표시는 HUD가 온도를 빨간색으로 표시하는 지점입니다. 기기 전체 배터리 + 게임 아트 + 플레이 중 + Steam에서 선택됨 + 최근 플레이 + 아직 플레이 안 함 + %1$d분 플레이 + %1$d시간 플레이 계기판 데이터 보내기 자동 나중에 발견된 게임을 포함해 여기에 나열된 모든 게임에서 켭니다. 직접 끈 게임은 꺼진 상태로 유지됩니다. @@ -2047,6 +2060,59 @@ 마이크 꺼짐 이 게임에서는 마이크가 꺼져 있습니다. 대화하려면 DroidDeck의 Steam 설정(오디오)에서 마이크를 켜고 게임을 다시 시작하세요. 볼륨 %1$d%% + 막대 숨기기 + 막대 표시 + 아래쪽 화면 밝기 + 아래 화면 끄기 + 가이드 + 게임을 시작하면 여기에 Steam 가이드가 표시됩니다. + 이어서 읽기 + 이 게임에는 아직 Steam 가이드가 없습니다. + Steam 가이드를 불러오지 못했습니다. 온라인 상태에서 다시 확인하세요. + 미러 + 미니맵처럼 여기에 표시할 게임 화면 부분을 드래그하세요. + 영역 저장 + 선명하게 + 부드럽게 + 지금은 게임 화면을 복사할 수 없습니다. + 위키 및 해결법 + 지도 + 저장됨 + 전체 + 공략 + 비밀 + 이 게임의 지도에 고정했습니다. + 이미지를 저장할 수 없습니다. + 오프라인으로 읽도록 페이지를 저장했습니다. + 웹 검색 + 마커: %1$d + 지도 찾기 + 리더에서 저장을 누르면 페이지를 오프라인으로 볼 수 있습니다. + 지도로 고정 + 이미지를 길게 눌러 지도로 고정하세요. + 두 손가락으로 확대하세요. 길게 눌러 마커를 추가하고, 눌러서 삭제합니다. + 게임 위키 + PCGamingWiki 해결법 + YouTube 공략 + 표시 + 숨김 + 어둡게 + Steam 가이드 + 카테고리 + 고정한 지도가 아직 없습니다 + 지도 %1$d + 저장한 페이지가 아직 없습니다 + 미러 옵션 + 영역 + 위 화면 + 스케일링 + 빠른 메뉴 + 레이아웃: %1$s + 전체 너비 + 왼쪽 + 가운데 + 오른쪽 + Steam 빠른 메뉴를 아직 사용할 수 없습니다. 게임 내 통계 하단 화면 HUD 모든 탭에 스트립 표시 @@ -3130,6 +3196,8 @@ 설치 위치 기본 저장소 새 스토어 설치는 선택한 위치에 저장됩니다. 기존 게임은 그대로 유지됩니다. Steam 라이브러리는 자체 설정을 따릅니다. + Linux에서 휴대폰 저장소 + 휴대폰 내부 저장소를 /root/Storage에 마운트합니다. 끄면 그곳에서 추가한 게임 폴더만 마운트됩니다. SD 카드에는 영향이 없습니다. 다음 세션부터 적용됩니다. 매번 묻기 설치할 때마다 위치 선택 내부 저장소 @@ -4049,6 +4117,12 @@ 강조 표시 성공 오류 + 경고 게임 중에만 HUD 표시 게임 프레임이 감지되지 않으면 HUD 숨기기. + 먼저 Steam을 닫으세요 + 먼저 Steam 다운로드를 일시 중지하세요 + 이 게임은 Linux 버전을 설치합니다. Steam에서 설치하세요. + 게임 확대 + 게임 확대율을 100%에서 300%까지 조정합니다 diff --git a/app/src/main/res/values-ms/input_zoom_strings.xml b/app/src/main/res/values-ms/input_zoom_strings.xml new file mode 100644 index 0000000000..b95bb1d04a --- /dev/null +++ b/app/src/main/res/values-ms/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Besarkan zum permainan + Kecilkan zum permainan + \ No newline at end of file diff --git a/app/src/main/res/values-ms/strings.xml b/app/src/main/res/values-ms/strings.xml index 49c45bdb40..73ba644c82 100644 --- a/app/src/main/res/values-ms/strings.xml +++ b/app/src/main/res/values-ms/strings.xml @@ -1246,6 +1246,11 @@ Sediakan Penyahpepijatan wayarles tidak dapat dicapai; Pasangkan menghidupkannya Pasangkan + Quest tiada skrin pasangan. Dari komputer, jalankan sekali: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS dan adb tcpip 5555. Kemudian ketik Benarkan dan terima gesaan dalam set kepala + Benarkan + Terima “Benarkan penyahpepijatan?” dalam set kepala, dengan Sentiasa benarkan ditanda + Tidak dapat bersambung. Terima gesaan penyahpepijatan dalam set kepala, atau jika tiada, jalankan adb tcpip 5555 dari komputer dan cuba lagi + Penyahpepijatan wayarles tidak dapat dicapai. Ketik Benarkan untuk menyediakannya semula Pasang Log masuk PR #%1$d @@ -1453,6 +1458,7 @@ %1$d%% Sambung %1$s Muncul sebagai /root/ROMs dalam setiap sesi. Storan dalaman berada di /root/Storage. + Muncul sebagai /root/ROMs dalam setiap sesi. Tiada folder dipilih Berkuat kuasa pada sesi seterusnya. Kad SD berfungsi. Pilih folder @@ -2025,6 +2031,13 @@ Tanda merah ialah tempat HUD memaparkan suhu dalam warna merah. seluruh peranti bateri + Seni permainan + Sedang dimainkan + Dipilih dalam Steam + Terakhir dimainkan + Belum dimainkan + %1$d min dimainkan + %1$d jam dimainkan Hantar data papan pemuka Automatik Menghidupkannya untuk setiap permainan yang disenaraikan di sini, termasuk permainan yang ditemui kemudian. Permainan yang anda matikan kekal mati. @@ -2047,6 +2060,59 @@ Mikrofon mati Mikrofon dimatikan untuk permainan ini. Untuk bercakap, hidupkan Mikrofon dalam tetapan Steam DroidDeck (Audio) dan mulakan permainan semula. Kelantangan %1$d%% + Sembunyikan bar + Tunjukkan bar + Kecerahan skrin bawah + Matikan skrin bawah + Panduan + Mulakan permainan untuk melihat panduan Steamnya di sini. + Sambung membaca + Belum ada panduan Steam untuk permainan ini. + Tidak dapat memuatkan panduan Steam. Cuba lagi apabila anda dalam talian. + Cermin + Seret ke atas bahagian permainan yang mahu dipaparkan di sini, seperti peta mini. + Simpan kawasan + Tajam + Licin + Gambar permainan tidak dapat disalin sekarang. + Wiki & pembaikan + Peta + Disimpan + Semua + Panduan penuh + Rahsia + Peta disematkan pada peta permainan ini. + Imej itu tidak dapat disimpan. + Halaman disimpan untuk dibaca di luar talian. + Cari di web + Penanda: %1$d + Cari peta + Gunakan Simpan dalam pembaca untuk menyimpan halaman di luar talian. + Sematkan sebagai peta + Tekan lama imej untuk menyematkannya sebagai peta. + Cubit untuk zum. Tekan lama untuk menambah penanda, ketik penanda untuk membuangnya. + Wiki permainan + Pembaikan PCGamingWiki + Panduan YouTube + Ditunjukkan + Disembunyikan + Dimalapkan + Panduan Steam + Kategori + Belum ada peta disematkan + Peta %1$d + Belum ada halaman disimpan + Pilihan cermin + Kawasan + Skrin atas + Penskalaan + Akses Pantas + Susun atur: %1$s + Lebar penuh + Kiri + Tengah + Kanan + Menu Akses Pantas Steam belum tersedia. Statistik dalam permainan HUD skrin bawah Jalur pada setiap tab @@ -3130,6 +3196,8 @@ Lokasi pemasangan Storan lalai Pemasangan kedai baharu pergi ke lokasi yang dipilih. Permainan sedia ada kekal di tempatnya. Pustaka Steam mengekalkan tetapan sendiri. + Storan telefon dalam Linux + Melekapkan storan dalaman telefon anda di /root/Storage. Apabila dimatikan, hanya folder permainan yang anda tambah dari situ dilekapkan. Kad SD tidak terjejas. Berkuat kuasa pada sesi seterusnya. Tanya setiap kali Pilih destinasi bagi setiap pemasangan Storan dalaman @@ -4049,6 +4117,12 @@ Sorotan Berjaya Ralat + Amaran Paparkan HUD hanya semasa bermain Sembunyikan HUD apabila bingkai permainan tidak dikesan. + Tutup Steam dahulu + Jeda muat turun Steam dahulu + Permainan ini memasang versi Linuxnya. Pasang daripada Steam. + Zum permainan + Laraskan pembesaran permainan daripada 100% hingga 300% diff --git a/app/src/main/res/values-nb/input_zoom_strings.xml b/app/src/main/res/values-nb/input_zoom_strings.xml new file mode 100644 index 0000000000..44773d82e5 --- /dev/null +++ b/app/src/main/res/values-nb/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Øk spillzoom + Reduser spillzoom + \ No newline at end of file diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index 39b4ce3cba..96e5da88c7 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -1249,6 +1249,11 @@ Forbered Trådløs feilsøking er ikke tilgjengelig; Par slår den på Par + Quest har ingen sammenkoblingsskjerm. Kjør én gang fra en datamaskin: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS og adb tcpip 5555. Trykk deretter på Tillat og godta spørsmålet i hodesettet + Tillat + Godta «Vil du tillate feilsøking?» i hodesettet med Tillat alltid avkrysset + Kunne ikke koble til. Godta feilsøkingsspørsmålet i hodesettet, eller kjør adb tcpip 5555 fra en datamaskin og prøv igjen hvis det ikke dukket opp + Trådløs feilsøking kan ikke nås. Trykk på Tillat for å sette den opp på nytt Installer Logg inn PR #%1$d @@ -1460,6 +1465,7 @@ %1$d%% Gjenoppta %1$s Vises som /root/ROMs i hver sesjon. Intern lagring er på /root/Storage. + Vises som /root/ROMs i hver sesjon. Ingen mappe valgt Gjelder fra neste sesjon. SD-kort fungerer. Velg mappe @@ -2049,6 +2055,13 @@ Den røde markeringen er der HUD-en viser temperaturen i rødt. hele enheten batteri + Spillgrafikk + Spiller + Valgt i Steam + Sist spilt + Ikke spilt ennå + %1$d min spilt + %1$d t spilt Send dashborddata Automatisk Slår det på for alle spill som er oppført her, også spill som blir funnet senere. Spill du slår av, forblir av. @@ -2071,6 +2084,59 @@ Mikrofon av Mikrofonen er av for dette spillet. For å snakke, slå på Mikrofon i DroidDecks Steam-innstillinger (Lyd) og start spillet på nytt. Volum %1$d%% + Skjul linjen + Vis linjen + Lysstyrke på nedre skjerm + Slå av den nederste skjermen + Guider + Start et spill for å se Steam-guidene her. + Fortsett å lese + Det finnes ingen Steam-guider for dette spillet ennå. + Kunne ikke laste Steam-guider. Prøv igjen når du er på nett. + Speil + Dra over den delen av spillet som skal vises her, for eksempel minikartet. + Lagre område + Skarp + Myk + Spillbildet kan ikke kopieres akkurat nå. + Wiki og fikser + Kart + Lagret + Alle + Gjennomganger + Hemmeligheter + Kartet er festet til kartene for spillet. + Bildet kunne ikke lagres. + Siden er lagret for lesing uten nett. + Søk på nettet + Markører: %1$d + Finn kart + Bruk Lagre i leseren for å beholde en side uten nett. + Fest som kart + Hold på et bilde for å feste det som kart. + Klyp for å zoome. Hold for å legge til en markør, trykk på en for å fjerne den. + Spillets wiki + Fikser fra PCGamingWiki + Gjennomganger på YouTube + Vist + Skjult + Dempet + Steam-guider + Kategori + Ingen festede kart ennå + Kart %1$d + Ingen lagrede sider ennå + Speilvalg + Område + Øvre skjerm + Skalering + Hurtigtilgang + Oppsett: %1$s + Full bredde + Venstre + Midten + Høyre + Steams hurtigtilgangsmeny er ikke tilgjengelig ennå. Statistikk i spillet HUD på bunnskjermen Stripe på hver fane @@ -3159,6 +3225,8 @@ Installasjonsplassering Standard lagring Nye butikkinstallasjoner havner på valgt plassering. Eksisterende spill blir der de er. Steam-biblioteker beholder sin egen innstilling. + Telefonlagring i Linux + Monterer telefonens interne lagring på /root/Storage. Når det er av, monteres bare spillmapper du har lagt til derfra. SD-kort påvirkes ikke. Gjelder fra neste økt. Spør hver gang Velg et mål for hver installasjon Intern lagring @@ -4079,6 +4147,12 @@ Uthevinger Suksess Feil + Advarsel Vis HUD bare mens du spiller Skjul HUD når ingen spillbilder registreres. + Lukk Steam først + Sett Steam-nedlastingen på pause først + Dette spillet installerer Linux-versjonen sin. Installer det fra Steam. + Spillzoom + Juster spillforstørrelsen fra 100 % til 300 % diff --git a/app/src/main/res/values-nl/input_zoom_strings.xml b/app/src/main/res/values-nl/input_zoom_strings.xml new file mode 100644 index 0000000000..813a289b53 --- /dev/null +++ b/app/src/main/res/values-nl/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Gamezoom vergroten + Gamezoom verkleinen + \ No newline at end of file diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 40136f0ea3..0b15dff90d 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -1249,6 +1249,11 @@ Voorbereiden Draadloze foutopsporing is niet bereikbaar; Koppelen schakelt dit in Koppelen + Quest heeft geen koppelscherm. Voer vanaf een computer één keer uit: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS en adb tcpip 5555. Tik daarna op Toestaan en accepteer de melding in de headset + Toestaan + Accepteer ‘Foutopsporing toestaan?’ in de headset, met Altijd toestaan aangevinkt + Verbinden mislukt. Accepteer de foutopsporingsmelding in de headset, of voer adb tcpip 5555 uit vanaf een computer en probeer het opnieuw als er geen verscheen + Draadloze foutopsporing is niet bereikbaar. Tik op Toestaan om het opnieuw in te stellen Installeren Inloggen PR #%1$d @@ -1460,6 +1465,7 @@ %1$d%% %1$s hervatten Verschijnt in elke sessie als /root/ROMs. Interne opslag staat op /root/Storage. + Verschijnt in elke sessie als /root/ROMs. Geen map gekozen Geldt vanaf de volgende sessie. SD-kaarten werken ook. Map kiezen @@ -2049,6 +2055,13 @@ De rode markering is het punt waarop de HUD de temperatuur in het rood weergeeft. hele apparaat accu + Game-afbeelding + Speelt + Geselecteerd in Steam + Laatst gespeeld + Nog niet gespeeld + %1$d min gespeeld + %1$d u gespeeld Dashboardgegevens verzenden Automatisch Zet het aan voor elke game in deze lijst, ook voor games die later worden gevonden. Games die je uitzet, blijven uit. @@ -2071,6 +2084,59 @@ Microfoon uit De microfoon staat uit voor deze game. Zet Microfoon aan in de Steam-instellingen van DroidDeck (Audio) en start de game opnieuw om te praten. Volume %1$d%% + Balk verbergen + Balk tonen + Helderheid van het onderste scherm + Onderste scherm uitzetten + Handleidingen + Start een game om hier de Steam-handleidingen te zien. + Verder lezen + Er zijn nog geen Steam-handleidingen voor deze game. + Kan Steam-handleidingen niet laden. Probeer het opnieuw wanneer je online bent. + Spiegel + Sleep over het deel van de game dat hier moet verschijnen, zoals de minikaart. + Gebied opslaan + Scherp + Vloeiend + Het gamebeeld kan nu niet worden gekopieerd. + Wiki en fixes + Kaarten + Opgeslagen + Alles + Walkthroughs + Geheimen + Kaart vastgezet bij de kaarten van deze game. + Die afbeelding kon niet worden opgeslagen. + Pagina opgeslagen om offline te lezen. + Zoeken op het web + Markeringen: %1$d + Kaarten zoeken + Gebruik Opslaan in de lezer om een pagina offline te bewaren. + Vastzetten als kaart + Houd een afbeelding ingedrukt om die als kaart vast te zetten. + Knijp om te zoomen. Houd ingedrukt om een markering toe te voegen, tik erop om die te verwijderen. + Game-wiki + Fixes van PCGamingWiki + Walkthroughs op YouTube + Zichtbaar + Verborgen + Gedimd + Steam-handleidingen + Categorie + Nog geen vastgezette kaarten + Kaart %1$d + Nog geen opgeslagen pagina\'s + Spiegelopties + Gebied + Bovenste scherm + Schalen + Snelle toegang + Indeling: %1$s + Volledige breedte + Links + Midden + Rechts + Het menu Snelle toegang van Steam is nog niet beschikbaar. In-game statistieken HUD op het onderste scherm Strip op elk tabblad @@ -3159,6 +3225,8 @@ Installatielocatie Standaardopslag Nieuwe winkelinstallaties gaan naar de gekozen locatie. Bestaande games blijven waar ze zijn. Steam-bibliotheken houden hun eigen instelling. + Telefoonopslag in Linux + Koppelt de interne opslag van je telefoon aan /root/Storage. Als dit uit staat, worden alleen gamemappen gekoppeld die je daaruit hebt toegevoegd. SD-kaarten veranderen niet. Geldt vanaf de volgende sessie. Elke keer vragen Kies voor elke installatie een doel Interne opslag @@ -4079,6 +4147,12 @@ Accenten Geslaagd Fout + Waarschuwing HUD alleen tijdens een game weergeven Verberg de HUD wanneer er geen gameframes worden gedetecteerd. + Sluit eerst Steam + Pauzeer eerst de Steam-download + Deze game installeert zijn Linux-versie. Installeer hem via Steam. + Gamezoom + Pas de spelvergroting aan van 100% tot 300% diff --git a/app/src/main/res/values-pl/input_zoom_strings.xml b/app/src/main/res/values-pl/input_zoom_strings.xml new file mode 100644 index 0000000000..00a3bca314 --- /dev/null +++ b/app/src/main/res/values-pl/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Zwiększ powiększenie gry + Zmniejsz powiększenie gry + \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 9ebd06008b..80ca1f1c4b 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -1257,6 +1257,11 @@ Przygotuj Debugowanie bezprzewodowe jest niedostępne; Paruj, aby je włączyć Paruj + Quest nie ma ekranu parowania. Na komputerze uruchom raz: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS oraz adb tcpip 5555. Następnie dotknij Zezwól i zaakceptuj monit w goglach + Zezwól + Zaakceptuj „Zezwolić na debugowanie?” w goglach z zaznaczonym Zawsze zezwalaj + Nie udało się połączyć. Zaakceptuj monit debugowania w goglach, a jeśli się nie pojawił, uruchom adb tcpip 5555 na komputerze i spróbuj ponownie + Debugowanie bezprzewodowe jest nieosiągalne. Dotknij Zezwól, aby skonfigurować je ponownie Zainstaluj Zaloguj się PR #%1$d @@ -1476,6 +1481,7 @@ %1$d%% Wznów %1$s W każdej sesji widoczny jako /root/ROMs. Pamięć wewnętrzna jest w /root/Storage. + W każdej sesji widoczny jako /root/ROMs. Nie wybrano folderu Zadziała od następnej sesji. Karty SD są obsługiwane. Wybierz folder @@ -2099,6 +2105,13 @@ Czerwony znacznik wskazuje temperaturę, od której HUD wyświetla ją na czerwono. całe urządzenie bateria + Grafika gry + W grze + Wybrano w Steam + Ostatnio grane + Jeszcze nie grano + %1$d min gry + %1$d godz. gry Wysyłaj dane do panelu Automatycznie Włącza wysyłanie dla każdej gry z tej listy, także dla gier znalezionych później. Gry, które wyłączysz, pozostaną wyłączone. @@ -2121,6 +2134,59 @@ Mikrofon wył. Mikrofon jest wyłączony dla tej gry. Aby rozmawiać, włącz Mikrofon w ustawieniach Steam w DroidDeck (Dźwięk) i uruchom grę ponownie. Głośność %1$d%% + Ukryj pasek + Pokaż pasek + Jasność dolnego ekranu + Wyłącz dolny ekran + Poradniki + Uruchom grę, aby zobaczyć tu jej poradniki ze Steam. + Czytaj dalej + Ta gra nie ma jeszcze poradników na Steam. + Nie udało się wczytać poradników ze Steam. Spróbuj ponownie, gdy będziesz online. + Lustro + Przeciągnij po fragmencie gry, który ma się tu wyświetlać, np. minimapie. + Zapisz obszar + Ostro + Gładko + Obrazu gry nie można teraz skopiować. + Wiki i poprawki + Mapy + Zapisane + Wszystkie + Solucje + Sekrety + Mapa przypięta do map tej gry. + Nie udało się zapisać obrazu. + Strona zapisana do czytania offline. + Szukaj w sieci + Znaczniki: %1$d + Znajdź mapy + Użyj Zapisz w czytniku, aby zachować stronę offline. + Przypnij jako mapę + Przytrzymaj obraz, aby przypiąć go jako mapę. + Uszczypnij, aby powiększyć. Przytrzymaj, aby dodać znacznik, dotknij go, aby usunąć. + Wiki gry + Poprawki z PCGamingWiki + Solucje na YouTube + Widoczne + Ukryte + Przyciemnione + Poradniki Steam + Kategoria + Brak przypiętych map + Mapa %1$d + Brak zapisanych stron + Opcje lustra + Obszar + Górny ekran + Skalowanie + Szybki dostęp + Układ: %1$s + Pełna szerokość + Do lewej + Na środku + Do prawej + Menu szybkiego dostępu Steam nie jest jeszcze dostępne. Statystyki w grze HUD dolnego ekranu Pasek na każdej karcie @@ -3219,6 +3285,8 @@ Miejsce instalacji Domyślna pamięć Nowe instalacje ze sklepów trafiają do wybranego miejsca. Istniejące gry zostają, gdzie są. Biblioteki Steam mają własne ustawienie. + Pamięć telefonu w Linuksie + Montuje pamięć wewnętrzną telefonu w /root/Storage. Po wyłączeniu montowane są tylko dodane z niej foldery gier. Nie dotyczy kart SD. Działa od następnej sesji. Pytaj za każdym razem Wybieraj miejsce przy każdej instalacji Pamięć wewnętrzna @@ -4159,6 +4227,12 @@ Wyróżnienia Sukces Błąd + Ostrzeżenie Pokazuj HUD tylko podczas gry Ukryj HUD, gdy nie wykryto klatek gry. + Najpierw zamknij Steam + Najpierw wstrzymaj pobieranie ze Steam + Ta gra instaluje swoją wersję dla Linuksa. Zainstaluj ją ze Steama. + Powiększenie gry + Dostosuj powiększenie gry w zakresie od 100% do 300% diff --git a/app/src/main/res/values-pt-rPT/input_zoom_strings.xml b/app/src/main/res/values-pt-rPT/input_zoom_strings.xml new file mode 100644 index 0000000000..c19cb15a1f --- /dev/null +++ b/app/src/main/res/values-pt-rPT/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Aumentar o zoom do jogo + Diminuir o zoom do jogo + \ No newline at end of file diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 57c6b9b645..9121642799 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -1244,6 +1244,11 @@ Preparar A depuração sem fios não está acessível; Emparelhar ativa-a Emparelhar + O Quest não tem ecrã de emparelhamento. Num computador, execute uma vez: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS e adb tcpip 5555. Depois toque em Permitir e aceite o pedido no headset + Permitir + Aceite “Permitir depuração?” no headset, com Permitir sempre assinalado + Não foi possível ligar. Aceite o pedido de depuração no headset ou, se não apareceu, execute adb tcpip 5555 num computador e tente novamente + A depuração sem fios não está acessível. Toque em Permitir para a configurar de novo Instalar Iniciar sessão PR #%1$d @@ -1459,6 +1464,7 @@ %1$d%% Retomar %1$s Aparece como /root/ROMs em cada sessão. O armazenamento interno está em /root/Storage. + Aparece como /root/ROMs em cada sessão. Nenhuma pasta escolhida Aplica-se na próxima sessão. Funciona com cartões SD. Escolher pasta @@ -1812,6 +1818,7 @@ Destaques e indicadores Sucesso Erro + Aviso Esc Ins Del @@ -2079,6 +2086,13 @@ A marca vermelha é o ponto em que o HUD mostra a temperatura a vermelho. todo o dispositivo bateria + Arte do jogo + A jogar + Selecionado no Steam + Jogado por último + Ainda não jogado + %1$d min jogados + %1$d h jogadas Enviar dados para o painel Automático Ativa para todos os jogos aqui listados, incluindo os encontrados mais tarde. Os jogos que desativar permanecem desativados. @@ -2101,6 +2115,59 @@ Microfone desligado O microfone está desligado neste jogo. Para falar, ative Microfone nas definições do Steam do DroidDeck (Áudio) e volte a iniciar o jogo. Volume %1$d%% + Ocultar barra + Mostrar barra + Brilho do ecrã inferior + Desligar o ecrã inferior + Guias + Inicie um jogo para ver aqui os guias Steam dele. + Continuar a ler + Ainda não há guias Steam para este jogo. + Não foi possível carregar os guias Steam. Tente novamente quando estiver online. + Espelho + Arraste sobre a parte do jogo que deve aparecer aqui, como o minimapa. + Guardar região + Nítido + Suave + Não é possível copiar a imagem do jogo agora. + Wiki e correções + Mapas + Guardados + Todos + Guias completos + Segredos + Mapa afixado nos mapas deste jogo. + Não foi possível guardar a imagem. + Página guardada para leitura offline. + Pesquisar na web + Marcadores: %1$d + Encontrar mapas + Use Guardar no leitor para manter uma página offline. + Afixar como mapa + Mantenha premida uma imagem para a afixar como mapa. + Aperte para aplicar zoom. Mantenha premido para adicionar um marcador, toque nele para o remover. + Wiki do jogo + Correções do PCGamingWiki + Guias no YouTube + Visível + Oculto + Escurecido + Guias Steam + Categoria + Ainda não há mapas afixados + Mapa %1$d + Ainda não há páginas guardadas + Opções de espelho + Região + Ecrã superior + Escala + Acesso rápido + Esquema: %1$s + Largura total + Esquerda + Centro + Direita + O menu de acesso rápido do Steam ainda não está disponível. Estatísticas no jogo HUD do ecrã inferior Faixa em todos os separadores @@ -3202,6 +3269,8 @@ Local de instalação Armazenamento predefinido As novas instalações das lojas vão para o local selecionado. Os jogos existentes ficam onde estão. As bibliotecas do Steam mantêm a sua própria definição. + Armazenamento do telemóvel no Linux + Monta o armazenamento interno do telemóvel em /root/Storage. Desativado, só são montadas as pastas de jogos que adicionou a partir dele. Os cartões SD não são afetados. Aplica-se na próxima sessão. Perguntar sempre Escolha um destino para cada instalação Armazenamento interno @@ -4120,4 +4189,9 @@ Suavização de serrilhado Mostrar o HUD apenas durante um jogo Ocultar o HUD quando não forem detetados fotogramas do jogo. + Feche primeiro o Steam + Coloque primeiro em pausa a transferência do Steam + Este jogo instala a sua versão para Linux. Instale-o a partir do Steam. + Zoom do jogo + Ajuste a ampliação do jogo de 100% a 300% diff --git a/app/src/main/res/values-pt/input_strings.xml b/app/src/main/res/values-pt/input_strings.xml index 5847aa3ac4..501f635363 100644 --- a/app/src/main/res/values-pt/input_strings.xml +++ b/app/src/main/res/values-pt/input_strings.xml @@ -22,6 +22,8 @@ Mostrar teclado Abrir o menu do Steam Abrir o acesso rápido do Steam + Aumentar zoom do jogo + Diminuir zoom do jogo Remover controle Adicionar controle Botões específicos do dispositivo diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index c6db0023bb..4ab1890f2a 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -1252,6 +1252,11 @@ Preparar A depuração sem fio não está acessível; Parear a ativa Parear + O Quest não tem tela de pareamento. Em um computador, execute uma vez: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS e adb tcpip 5555. Depois toque em Permitir e aceite o aviso no headset + Permitir + Aceite “Permitir depuração?” no headset, com Sempre permitir marcado + Não foi possível conectar. Aceite o aviso de depuração no headset ou, se ele não apareceu, execute adb tcpip 5555 em um computador e tente novamente + A depuração sem fio não está acessível. Toque em Permitir para configurá-la de novo Instalar Entrar PR #%1$d @@ -1467,6 +1472,7 @@ %1$d%% Retomar %1$s Aparece como /root/ROMs em cada sessão. O armazenamento interno fica em /root/Storage. + Aparece como /root/ROMs em cada sessão. Nenhuma pasta escolhida Vale a partir da próxima sessão. Cartões SD funcionam. Escolher pasta @@ -1820,6 +1826,7 @@ Destaques e indicadores Sucesso Erro + Aviso Esc Ins Del @@ -2087,6 +2094,13 @@ A marca vermelha indica onde o HUD mostra a temperatura em vermelho. dispositivo inteiro bateria + Arte do jogo + Jogando + Selecionado no Steam + Jogado por último + Ainda não jogado + %1$d min jogados + %1$d h jogadas Enviar dados para o painel Automático Ativa para todos os jogos listados aqui, incluindo os encontrados depois. Os jogos que você desativar continuam desativados. @@ -2109,6 +2123,59 @@ Microfone desligado O microfone está desligado neste jogo. Para falar, ative Microfone nas configurações da Steam do DroidDeck (Áudio) e inicie o jogo de novo. Volume %1$d%% + Ocultar barra + Mostrar barra + Brilho da tela inferior + Desligar a tela inferior + Guias + Inicie um jogo para ver os guias Steam dele aqui. + Continuar lendo + Ainda não há guias Steam para este jogo. + Não foi possível carregar os guias Steam. Tente de novo quando estiver online. + Espelho + Arraste sobre a parte do jogo que deve aparecer aqui, como o minimapa. + Salvar região + Nítido + Suave + Não é possível copiar a imagem do jogo agora. + Wiki e correções + Mapas + Salvos + Todos + Detonados + Segredos + Mapa fixado nos mapas deste jogo. + Não foi possível salvar a imagem. + Página salva para leitura offline. + Pesquisar na web + Marcadores: %1$d + Encontrar mapas + Use Salvar no leitor para manter uma página offline. + Fixar como mapa + Toque e segure uma imagem para fixá-la como mapa. + Faça pinça para zoom. Toque e segure para adicionar um marcador, toque nele para remover. + Wiki do jogo + Correções do PCGamingWiki + Detonados no YouTube + Visível + Oculto + Escurecido + Guias Steam + Categoria + Ainda não há mapas fixados + Mapa %1$d + Ainda não há páginas salvas + Opções de espelho + Região + Tela superior + Escala + Acesso rápido + Layout: %1$s + Largura total + Esquerda + Centro + Direita + O menu de acesso rápido do Steam ainda não está disponível. Estatísticas no jogo HUD da tela inferior Faixa em todas as abas @@ -2471,6 +2538,8 @@ Manter proporções Esticar para a tela Escala de imagem + Ajuste a ampliação do jogo de 100% a 300% + Zoom do jogo Filtro de escala Compartilhado entre Steam e Área de trabalho. Aplicado na hora. Compartilhado entre Steam e Área de trabalho. @@ -3210,6 +3279,8 @@ Local de instalação Armazenamento padrão Novas instalações das lojas vão para o local selecionado. Jogos existentes ficam onde estão. As bibliotecas da Steam mantêm a própria configuração. + Armazenamento do celular no Linux + Monta o armazenamento interno do celular em /root/Storage. Desativado, só as pastas de jogos que você adicionou dele são montadas. Cartões SD não são afetados. Vale a partir da próxima sessão. Perguntar sempre Escolha um destino para cada instalação Armazenamento interno @@ -4128,4 +4199,7 @@ Suavização de serrilhado Mostrar o HUD somente durante o jogo Ocultar o HUD quando nenhum quadro do jogo for detectado. + Feche o Steam primeiro + Pause o download do Steam primeiro + Este jogo instala sua versão para Linux. Instale-o pelo Steam. diff --git a/app/src/main/res/values-ro/input_zoom_strings.xml b/app/src/main/res/values-ro/input_zoom_strings.xml new file mode 100644 index 0000000000..275f3563d8 --- /dev/null +++ b/app/src/main/res/values-ro/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Mărește zoomul jocului + Micșorează zoomul jocului + \ No newline at end of file diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 6101dd8761..fe0a3ab63c 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -1253,6 +1253,11 @@ Pregătește Depanarea fără fir nu este accesibilă; „Asociază” o activează Asociază + Quest nu are ecran de asociere. De pe un computer, rulează o dată: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS și adb tcpip 5555. Apoi atinge Permite și acceptă solicitarea în cască + Permite + Acceptă „Permiți remedierea erorilor?” în cască, cu Permite întotdeauna bifat + Conectarea a eșuat. Acceptă solicitarea de remediere a erorilor în cască sau, dacă nu a apărut, rulează adb tcpip 5555 de pe un computer și încearcă din nou + Remedierea wireless a erorilor nu este accesibilă. Atinge Permite pentru a o configura din nou Instalează Conectați-vă PR #%1$d @@ -1468,6 +1473,7 @@ %1$d%% Reluare %1$s Apare ca /root/ROMs în fiecare sesiune. Stocarea internă este la /root/Storage. + Apare ca /root/ROMs în fiecare sesiune. Niciun folder ales Se aplică la sesiunea următoare. Cardurile SD funcționează. Alege folderul @@ -2074,6 +2080,13 @@ Marcajul roșu indică locul în care HUD-ul afișează temperatura în roșu. tot dispozitivul baterie + Imagini din joc + Se joacă + Selectat în Steam + Jucat ultima dată + Nejucat încă + %1$d min jucate + %1$d h jucate Trimite date pentru tabloul de bord Automat Activează trimiterea pentru fiecare joc din listă, inclusiv pentru jocurile găsite mai târziu. Jocurile pe care le dezactivezi rămân dezactivate. @@ -2096,6 +2109,59 @@ Microfon oprit Microfonul este oprit pentru acest joc. Pentru a vorbi, activează Microfon în setările Steam din DroidDeck (Sunet) și pornește din nou jocul. Volum %1$d%% + Ascunde bara + Afișează bara + Luminozitatea ecranului de jos + Oprește ecranul de jos + Ghiduri + Pornește un joc ca să-i vezi aici ghidurile Steam. + Continuă lectura + Încă nu există ghiduri Steam pentru acest joc. + Ghidurile Steam nu s-au putut încărca. Încearcă din nou când ești online. + Oglindă + Trage peste partea din joc care să apară aici, de exemplu minimapa. + Salvează zona + Clar + Neted + Imaginea jocului nu poate fi copiată acum. + Wiki și remedieri + Hărți + Salvate + Toate + Ghiduri complete + Secrete + Harta a fost fixată la hărțile acestui joc. + Imaginea nu a putut fi salvată. + Pagina a fost salvată pentru citire offline. + Caută pe web + Marcaje: %1$d + Găsește hărți + Folosește Salvează în cititor ca să păstrezi o pagină offline. + Fixează ca hartă + Ține apăsat pe o imagine ca s-o fixezi ca hartă. + Ciupește pentru zoom. Ține apăsat ca să adaugi un marcaj, atinge-l ca să-l elimini. + Wiki-ul jocului + Remedieri din PCGamingWiki + Ghiduri pe YouTube + Vizibil + Ascuns + Estompat + Ghiduri Steam + Categorie + Nicio hartă fixată încă + Harta %1$d + Nicio pagină salvată încă + Opțiuni oglindă + Zonă + Ecranul de sus + Scalare + Acces rapid + Aspect: %1$s + Lățime completă + Stânga + Centru + Dreapta + Meniul de acces rapid Steam nu este încă disponibil. Statistici în joc HUD pe ecranul de jos Bandă pe fiecare filă @@ -3189,6 +3255,8 @@ Locație de instalare Stocare implicită Instalările noi din magazine merg în locația selectată. Jocurile existente rămân unde sunt. Bibliotecile Steam își păstrează propria setare. + Stocarea telefonului în Linux + Montează stocarea internă a telefonului în /root/Storage. Când este dezactivat, se montează doar folderele de jocuri pe care le-ați adăugat de acolo. Cardurile SD nu sunt afectate. Se aplică din următoarea sesiune. Întreabă de fiecare dată Alege o destinație pentru fiecare instalare Stocare internă @@ -4119,6 +4187,12 @@ Evidențieri Succes Eroare + Avertisment Afișează HUD-ul doar în timpul jocului Ascunde HUD-ul când nu sunt detectate cadre ale jocului. + Închide mai întâi Steam + Pune mai întâi pe pauză descărcarea Steam + Acest joc își instalează versiunea pentru Linux. Instalează-l din Steam. + Zoom joc + Reglați mărirea jocului între 100% și 300% diff --git a/app/src/main/res/values-ru/input_zoom_strings.xml b/app/src/main/res/values-ru/input_zoom_strings.xml new file mode 100644 index 0000000000..e5c6c303e6 --- /dev/null +++ b/app/src/main/res/values-ru/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Увеличить масштаб игры + Уменьшить масштаб игры + \ No newline at end of file diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 042b6cc500..11939be52a 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -1257,6 +1257,11 @@ Подготовить Беспроводная отладка недоступна; «Сопряжение» включит её Сопряжение + В Quest нет экрана сопряжения. Один раз выполните на компьютере: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS и adb tcpip 5555. Затем нажмите «Разрешить» и подтвердите запрос в шлеме + Разрешить + Подтвердите «Разрешить отладку?» в шлеме, отметив «Всегда разрешать» + Не удалось подключиться. Подтвердите запрос на отладку в шлеме, а если он не появился, выполните adb tcpip 5555 на компьютере и повторите попытку + Беспроводная отладка недоступна. Нажмите «Разрешить», чтобы настроить её заново Установить Войти PR #%1$d @@ -1476,6 +1481,7 @@ %1$d%% Продолжить %1$s Отображается как /root/ROMs в каждой сессии. Внутреннее хранилище находится в /root/Storage. + Отображается как /root/ROMs в каждой сессии. Папка не выбрана Вступит в силу в следующей сессии. Поддерживаются SD-карты. Выбрать папку @@ -2100,6 +2106,13 @@ Красная отметка — температура, с которой HUD показывает значение красным. все устройство батарея + Обложка игры + Идёт игра + Выбрано в Steam + Последняя игра + Ещё не запускалась + Сыграно %1$d мин + Сыграно %1$d ч Передавать данные на дашборд Автоматически Включает передачу для всех игр в этом списке, в том числе найденных позже. Игры, для которых вы ее выключили, остаются выключенными. @@ -2122,6 +2135,59 @@ Микрофон выкл. Микрофон для этой игры выключен. Чтобы говорить, включите «Микрофон» в настройках Steam в DroidDeck (Аудио) и запустите игру снова. Громкость %1$d%% + Скрыть панель + Показать панель + Яркость нижнего экрана + Выключить нижний экран + Руководства + Запустите игру, чтобы увидеть здесь её руководства Steam. + Продолжить чтение + Для этой игры пока нет руководств Steam. + Не удалось загрузить руководства Steam. Попробуйте снова, когда будете в сети. + Зеркало + Проведите по части игры, которую нужно показывать здесь, например по мини-карте. + Сохранить область + Чётко + Сглаженно + Сейчас не удаётся скопировать изображение игры. + Вики и исправления + Карты + Сохранённое + Все + Прохождения + Секреты + Карта закреплена в картах этой игры. + Не удалось сохранить изображение. + Страница сохранена для чтения офлайн. + Поиск в интернете + Метки: %1$d + Найти карты + Нажмите «Сохранить» в читалке, чтобы читать страницу офлайн. + Закрепить как карту + Удерживайте изображение, чтобы закрепить его как карту. + Сведите пальцы для масштаба. Удерживайте, чтобы добавить метку; коснитесь метки, чтобы удалить её. + Вики игры + Исправления PCGamingWiki + Прохождения на YouTube + Видно + Скрыто + Затемнено + Руководства Steam + Категория + Пока нет закреплённых карт + Карта %1$d + Пока нет сохранённых страниц + Параметры зеркала + Область + Верхний экран + Масштабирование + Быстрый доступ + Макет: %1$s + Во всю ширину + Слева + По центру + Справа + Меню быстрого доступа Steam пока недоступно. Игровая статистика HUD нижнего экрана Полоса на всех вкладках @@ -3220,6 +3286,8 @@ Место установки Хранилище по умолчанию Новые установки из магазинов попадают в выбранное место. Установленные игры остаются на месте. У библиотек Steam своя настройка. + Память телефона в Linux + Подключает внутреннюю память телефона в /root/Storage. Если выключено, подключаются только добавленные из неё папки с играми. На SD-карты не влияет. Применяется со следующего сеанса. Спрашивать каждый раз Выбирать место для каждой установки Внутреннее хранилище @@ -4160,6 +4228,12 @@ Выделения Успех Ошибка + Предупреждение Показывать HUD только во время игры Скрывать HUD, когда кадры игры не обнаруживаются. + Сначала закройте Steam + Сначала приостановите загрузку Steam + Эта игра устанавливает свою версию для Linux. Установите её из Steam. + Масштаб игры + Настройте увеличение игры от 100% до 300% diff --git a/app/src/main/res/values-sv/input_zoom_strings.xml b/app/src/main/res/values-sv/input_zoom_strings.xml new file mode 100644 index 0000000000..ddf9701d11 --- /dev/null +++ b/app/src/main/res/values-sv/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Öka spelzoom + Minska spelzoom + \ No newline at end of file diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index ea63d20fb9..66a76edda1 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -1249,6 +1249,11 @@ Förbered Trådlös felsökning kan inte nås; Para slår på den Para + Quest har ingen parkopplingsskärm. Kör en gång från en dator: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS och adb tcpip 5555. Tryck sedan på Tillåt och godkänn frågan i headsetet + Tillåt + Godkänn ”Tillåt felsökning?” i headsetet med Tillåt alltid markerat + Det gick inte att ansluta. Godkänn felsökningsfrågan i headsetet, eller kör adb tcpip 5555 från en dator och försök igen om ingen visades + Trådlös felsökning går inte att nå. Tryck på Tillåt för att konfigurera den igen Installera Logga in PR #%1$d @@ -1460,6 +1465,7 @@ %1$d %% Återuppta %1$s Visas som /root/ROMs i varje session. Det interna lagringsutrymmet finns på /root/Storage. + Visas som /root/ROMs i varje session. Ingen mapp vald Gäller från nästa session. SD-kort fungerar. Välj mapp @@ -2049,6 +2055,13 @@ Det röda märket är där HUD:en visar temperaturen i rött. hela enheten batteri + Spelgrafik + Spelar + Vald i Steam + Senast spelad + Inte spelad än + %1$d min spelat + %1$d tim spelat Skicka data till instrumentpanelen Automatiskt Slår på det för alla spel i listan, även spel som hittas senare. Spel som du stänger av förblir avstängda. @@ -2071,6 +2084,59 @@ Mikrofon av Mikrofonen är avstängd för det här spelet. Slå på Mikrofon i DroidDecks Steam-inställningar (Ljud) och starta spelet igen för att prata. Volym %1$d%% + Dölj fältet + Visa fältet + Ljusstyrka för nedre skärmen + Stäng av den nedre skärmen + Guider + Starta ett spel för att se dess Steam-guider här. + Fortsätt läsa + Det finns inga Steam-guider för det här spelet ännu. + Det gick inte att läsa in Steam-guider. Försök igen när du är online. + Spegel + Dra över den del av spelet som ska visas här, till exempel minikartan. + Spara område + Skarp + Mjuk + Spelbilden kan inte kopieras just nu. + Wiki och fixar + Kartor + Sparat + Alla + Genomgångar + Hemligheter + Kartan har fästs bland spelets kartor. + Bilden kunde inte sparas. + Sidan har sparats för läsning offline. + Sök på webben + Markörer: %1$d + Hitta kartor + Använd Spara i läsaren för att behålla en sida offline. + Fäst som karta + Håll på en bild för att fästa den som karta. + Nyp för att zooma. Håll för att lägga till en markör, tryck på en för att ta bort den. + Spelets wiki + Fixar från PCGamingWiki + Genomgångar på YouTube + Visas + Dold + Dämpad + Steam-guider + Kategori + Inga fästa kartor än + Karta %1$d + Inga sparade sidor än + Spegelalternativ + Område + Övre skärm + Skalning + Snabbåtkomst + Layout: %1$s + Full bredd + Vänster + Mitten + Höger + Steams snabbåtkomstmeny är inte tillgänglig än. Statistik i spelet HUD på nedre skärmen Remsa på varje flik @@ -3159,6 +3225,8 @@ Installationsplats Standardlagring Nya butiksinstallationer hamnar på den valda platsen. Befintliga spel stannar där de är. Steam-bibliotek har sin egen inställning. + Telefonens lagring i Linux + Monterar telefonens interna lagring på /root/Storage. När det är av monteras bara spelmappar du har lagt till därifrån. SD-kort påverkas inte. Gäller från nästa session. Fråga varje gång Välj mål för varje installation Intern lagring @@ -4079,6 +4147,12 @@ Markeringar Lyckades Fel + Varning Visa HUD endast under spel Dölj HUD när inga spelbildrutor upptäcks. + Stäng Steam först + Pausa Steam-nedladdningen först + Det här spelet installerar sin Linux-version. Installera det från Steam. + Spelzoom + Justera spelförstoringen från 100 % till 300 % diff --git a/app/src/main/res/values-th/input_zoom_strings.xml b/app/src/main/res/values-th/input_zoom_strings.xml new file mode 100644 index 0000000000..c22c370488 --- /dev/null +++ b/app/src/main/res/values-th/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + เพิ่มการซูมเกม + ลดการซูมเกม + \ No newline at end of file diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml index 50a282f966..7e2004c609 100644 --- a/app/src/main/res/values-th/strings.xml +++ b/app/src/main/res/values-th/strings.xml @@ -1246,6 +1246,11 @@ เตรียม เชื่อมต่อการดีบักแบบไร้สายไม่ได้; จับคู่จะเปิดใช้งาน จับคู่ + Quest ไม่มีหน้าจอจับคู่ จากคอมพิวเตอร์ ให้รันหนึ่งครั้ง: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS และ adb tcpip 5555 จากนั้นแตะอนุญาตและยอมรับข้อความในเฮดเซ็ต + อนุญาต + ยอมรับ “อนุญาตการแก้ไขข้อบกพร่องไหม” ในเฮดเซ็ต โดยเลือกอนุญาตเสมอ + เชื่อมต่อไม่ได้ ยอมรับข้อความแก้ไขข้อบกพร่องในเฮดเซ็ต หรือหากไม่มีข้อความขึ้น ให้รัน adb tcpip 5555 จากคอมพิวเตอร์แล้วลองอีกครั้ง + เข้าถึงการแก้ไขข้อบกพร่องแบบไร้สายไม่ได้ แตะอนุญาตเพื่อตั้งค่าใหม่ ติดตั้ง ลงชื่อเข้าใช้ PR #%1$d @@ -1453,6 +1458,7 @@ %1$d%% ดำเนินการต่อ %1$s แสดงเป็น /root/ROMs ในแต่ละเซสชัน พื้นที่จัดเก็บภายในอยู่ที่ /root/Storage + แสดงเป็น /root/ROMs ในแต่ละเซสชัน ยังไม่เลือกโฟลเดอร์ มีผลในเซสชันถัดไป ใช้การ์ด SD ได้ เลือกโฟลเดอร์ @@ -2025,6 +2031,13 @@ ขีดสีแดงคือจุดที่ HUD แสดงอุณหภูมิเป็นสีแดง ทั้งเครื่อง แบตเตอรี่ + ภาพเกม + กำลังเล่น + เลือกใน Steam + เล่นล่าสุด + ยังไม่ได้เล่น + เล่นแล้ว %1$d นาที + เล่นแล้ว %1$d ชม. ส่งข้อมูลแดชบอร์ด อัตโนมัติ เปิดใช้สำหรับทุกเกมที่แสดงที่นี่ รวมถึงเกมที่พบในภายหลัง เกมที่คุณปิดไว้จะยังคงปิดอยู่ @@ -2047,6 +2060,59 @@ ไมค์ปิด ไมค์ปิดอยู่สำหรับเกมนี้ หากต้องการพูด ให้เปิดไมโครโฟนในการตั้งค่า Steam ของ DroidDeck (เสียง) แล้วเริ่มเกมอีกครั้ง ระดับเสียง %1$d%% + ซ่อนแถบ + แสดงแถบ + ความสว่างของหน้าจอล่าง + ปิดหน้าจอล่าง + คู่มือ + เริ่มเกมเพื่อดูคู่มือ Steam ของเกมที่นี่ + อ่านต่อ + ยังไม่มีคู่มือ Steam สำหรับเกมนี้ + โหลดคู่มือ Steam ไม่ได้ ลองอีกครั้งเมื่อออนไลน์ + กระจก + ลากครอบส่วนของเกมที่ต้องการแสดงที่นี่ เช่น มินิแมป + บันทึกพื้นที่ + คมชัด + นุ่มนวล + ตอนนี้ไม่สามารถคัดลอกภาพเกมได้ + วิกิและวิธีแก้ + แผนที่ + ที่บันทึกไว้ + ทั้งหมด + บทสรุป + ความลับ + ปักหมุดแผนที่ไว้ในแผนที่ของเกมนี้แล้ว + บันทึกภาพนั้นไม่ได้ + บันทึกหน้าไว้อ่านออฟไลน์แล้ว + ค้นหาบนเว็บ + เครื่องหมาย: %1$d + ค้นหาแผนที่ + ใช้ปุ่มบันทึกในตัวอ่านเพื่อเก็บหน้าไว้อ่านออฟไลน์ + ปักหมุดเป็นแผนที่ + กดค้างที่ภาพเพื่อปักหมุดเป็นแผนที่ + จีบนิ้วเพื่อซูม กดค้างเพื่อเพิ่มเครื่องหมาย แตะเครื่องหมายเพื่อลบ + วิกิของเกม + วิธีแก้จาก PCGamingWiki + บทสรุปบน YouTube + แสดง + ซ่อน + หรี่ + คู่มือ Steam + หมวดหมู่ + ยังไม่มีแผนที่ที่ปักหมุด + แผนที่ %1$d + ยังไม่มีหน้าที่บันทึก + ตัวเลือกการสะท้อน + พื้นที่ + จอบน + การปรับขนาด + เข้าถึงด่วน + เลย์เอาต์: %1$s + เต็มความกว้าง + ซ้าย + กึ่งกลาง + ขวา + เมนูเข้าถึงด่วนของ Steam ยังไม่พร้อมใช้งาน สถิติในเกม HUD หน้าจอล่าง แถบในทุกแท็บ @@ -3130,6 +3196,8 @@ ตำแหน่งติดตั้ง พื้นที่จัดเก็บเริ่มต้น การติดตั้งใหม่จากสโตร์จะไปยังตำแหน่งที่เลือก เกมที่มีอยู่จะอยู่ที่เดิม ไลบรารี Steam ใช้การตั้งค่าของตัวเอง + ที่เก็บข้อมูลโทรศัพท์ใน Linux + เมานต์ที่เก็บข้อมูลภายในของโทรศัพท์ไว้ที่ /root/Storage เมื่อปิด จะเมานต์เฉพาะโฟลเดอร์เกมที่คุณเพิ่มจากที่นั่น ไม่มีผลกับการ์ด SD มีผลในเซสชันถัดไป ถามทุกครั้ง เลือกปลายทางสำหรับการติดตั้งแต่ละครั้ง พื้นที่จัดเก็บภายใน @@ -4049,6 +4117,12 @@ จุดเน้น สำเร็จ ข้อผิดพลาด + คำเตือน แสดง HUD เฉพาะขณะเล่นเกม ซ่อน HUD เมื่อไม่พบเฟรมของเกม + ปิด Steam ก่อน + หยุดการดาวน์โหลด Steam ชั่วคราวก่อน + เกมนี้ติดตั้งเวอร์ชัน Linux ของตัวเอง ให้ติดตั้งจาก Steam + ซูมเกม + ปรับการขยายเกมตั้งแต่ 100% ถึง 300% diff --git a/app/src/main/res/values-tr/input_zoom_strings.xml b/app/src/main/res/values-tr/input_zoom_strings.xml new file mode 100644 index 0000000000..f786107728 --- /dev/null +++ b/app/src/main/res/values-tr/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Oyun yakınlaştırmasını artır + Oyun yakınlaştırmasını azalt + \ No newline at end of file diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 8b3df10ac8..6b7b4ce7b0 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -1241,6 +1241,11 @@ Hazırla Kablosuz hata ayıklamaya ulaşılamıyor; Eşleştir ile açılır Eşleştir + Quest\'te eşleme ekranı yok. Bir bilgisayardan bir kez çalıştırın: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS ve adb tcpip 5555. Ardından İzin ver\'e dokunun ve kulaklıktaki istemi kabul edin + İzin ver + Kulaklıkta “Hata ayıklamaya izin verilsin mi?” istemini Her zaman izin ver işaretliyken kabul edin + Bağlanılamadı. Kulaklıktaki hata ayıklama istemini kabul edin veya istem görünmediyse bir bilgisayardan adb tcpip 5555 çalıştırıp tekrar deneyin + Kablosuz hata ayıklamaya ulaşılamıyor. Yeniden ayarlamak için İzin ver\'e dokunun Yükle Giriş yap PR #%1$d @@ -1452,6 +1457,7 @@ %%%1$d Devam et: %1$s Her oturumda /root/ROMs olarak görünür. Dahili depolama /root/Storage konumundadır. + Her oturumda /root/ROMs olarak görünür. Klasör seçilmedi Sonraki oturumda uygulanır. SD kartlar da çalışır. Klasör seç @@ -2041,6 +2047,13 @@ Kırmızı işaret, sıcaklığın HUD üzerinde kırmızı göründüğü yerdir. tüm cihaz pil + Oyun görseli + Oynanıyor + Steam\'de seçili + Son oynanan + Henüz oynanmadı + %1$d dk oynandı + %1$d sa oynandı Gösterge verilerini gönder Otomatik Sonradan bulunanlar dahil, burada listelenen her oyun için açar. Kapattığınız oyunlar kapalı kalır. @@ -2063,6 +2076,59 @@ Mikrofon kapalı Bu oyun için mikrofon kapalı. Konuşmak için DroidDeck\'in Steam ayarlarında (Ses) Mikrofon\'u açın ve oyunu yeniden başlatın. Ses düzeyi %1$d%% + Çubuğu gizle + Çubuğu göster + Alt ekran parlaklığı + Alt ekranı kapat + Rehberler + Steam rehberlerini burada görmek için bir oyun başlatın. + Okumaya devam et + Bu oyun için henüz Steam rehberi yok. + Steam rehberleri yüklenemedi. Çevrimiçi olduğunuzda tekrar deneyin. + Ayna + Burada gösterilecek oyun bölümünün üzerinden sürükleyin, örneğin mini harita. + Bölgeyi kaydet + Keskin + Yumuşak + Oyun görüntüsü şu anda kopyalanamıyor. + Wiki ve düzeltmeler + Haritalar + Kaydedilenler + Tümü + İzlenecek yollar + Sırlar + Harita bu oyunun haritalarına sabitlendi. + Görsel kaydedilemedi. + Sayfa çevrimdışı okumak için kaydedildi. + Web\'de ara + İşaretler: %1$d + Harita bul + Sayfayı çevrimdışı tutmak için okuyucuda Kaydet\'i kullanın. + Harita olarak sabitle + Bir görseli harita olarak sabitlemek için uzun basın. + Yakınlaştırmak için sıkıştırın. İşaret eklemek için uzun basın, kaldırmak için işarete dokunun. + Oyun wiki\'si + PCGamingWiki düzeltmeleri + YouTube izlenecek yolları + Görünür + Gizli + Karartılmış + Steam rehberleri + Kategori + Henüz sabitlenmiş harita yok + Harita %1$d + Henüz kaydedilmiş sayfa yok + Ayna seçenekleri + Bölge + Üst ekran + Ölçekleme + Hızlı Erişim + Düzen: %1$s + Tam genişlik + Sol + Orta + Sağ + Steam Hızlı Erişim menüsü henüz kullanılamıyor. Oyun içi istatistikler Alt ekrandaki HUD Her sekmede şerit @@ -3159,6 +3225,8 @@ Yükleme konumu Varsayılan depolama Yeni mağaza yüklemeleri seçilen konuma gider. Mevcut oyunlar yerinde kalır. Steam kütüphaneleri kendi ayarlarını korur. + Linux\'ta telefon depolaması + Telefonunuzun dahili depolamasını /root/Storage konumuna bağlar. Kapalıyken yalnızca oradan eklediğiniz oyun klasörleri bağlanır. SD kartlar etkilenmez. Sonraki oturumda uygulanır. Her seferinde sor Her yükleme için bir hedef seçin Dahili depolama @@ -4079,6 +4147,12 @@ Vurgular Başarılı Hata + Uyarı HUD\'yi yalnızca oyun sırasında göster Oyun kareleri algılanmadığında HUD\'yi gizle. + Önce Steam\'i kapatın + Önce Steam indirmesini duraklatın + Bu oyun Linux sürümünü yükler. Steam\'den yükleyin. + Oyun yakınlaştırma + Oyun yakınlaştırmasını %100 ile %300 arasında ayarlayın diff --git a/app/src/main/res/values-uk/input_zoom_strings.xml b/app/src/main/res/values-uk/input_zoom_strings.xml new file mode 100644 index 0000000000..608fb8f973 --- /dev/null +++ b/app/src/main/res/values-uk/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Збільшити масштаб гри + Зменшити масштаб гри + \ No newline at end of file diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index d492865848..6a0d3b607d 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -1257,6 +1257,11 @@ Підготувати Бездротове налагодження недоступне; «Сполучити» увімкне його Сполучити + У Quest немає екрана підключення. Один раз виконайте на комп’ютері: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS і adb tcpip 5555. Потім торкніться «Дозволити» й підтвердьте запит у шоломі + Дозволити + Підтвердьте «Дозволити налагодження?» у шоломі, позначивши «Завжди дозволяти» + Не вдалося підключитися. Підтвердьте запит на налагодження в шоломі, а якщо його не було, виконайте adb tcpip 5555 на комп’ютері й спробуйте ще раз + Бездротове налагодження недоступне. Торкніться «Дозволити», щоб налаштувати його знову Установити Увійти PR #%1$d @@ -1476,6 +1481,7 @@ %1$d%% Продовжити %1$s У кожному сеансі з’являється як /root/ROMs. Внутрішня пам’ять доступна в /root/Storage. + У кожному сеансі з’являється як /root/ROMs. Папку не вибрано Діє з наступного сеансу. SD-карти підтримуються. Вибрати папку @@ -2099,6 +2105,13 @@ Червона позначка — це поріг, після якого HUD показує температуру червоним. весь пристрій акумулятор + Обкладинка гри + Триває гра + Вибрано в Steam + Остання гра + Ще не запускалася + Зіграно %1$d хв + Зіграно %1$d год Надсилати дані для панелі Автоматично Вмикає це для кожної гри в цьому списку, зокрема для знайдених пізніше. Ігри, які ви вимкнете, лишаються вимкненими. @@ -2121,6 +2134,59 @@ Мікрофон вимкнено Для цієї гри мікрофон вимкнено. Щоб говорити, увімкніть «Мікрофон» у налаштуваннях Steam у DroidDeck (Звук) і запустіть гру знову. Гучність %1$d%% + Сховати панель + Показати панель + Яскравість нижнього екрана + Вимкнути нижній екран + Посібники + Запустіть гру, щоб побачити тут її посібники Steam. + Продовжити читання + Для цієї гри ще немає посібників Steam. + Не вдалося завантажити посібники Steam. Спробуйте знову, коли будете онлайн. + Дзеркало + Проведіть по частині гри, яку треба показувати тут, наприклад по мінікарті. + Зберегти область + Чітко + Згладжено + Зараз не вдається скопіювати зображення гри. + Вікі та виправлення + Мапи + Збережене + Усі + Проходження + Секрети + Мапу закріплено в мапах цієї гри. + Не вдалося зберегти зображення. + Сторінку збережено для читання офлайн. + Пошук в інтернеті + Позначки: %1$d + Знайти мапи + Натисніть «Зберегти» в читачі, щоб читати сторінку офлайн. + Закріпити як мапу + Утримуйте зображення, щоб закріпити його як мапу. + Зведіть пальці для масштабу. Утримуйте, щоб додати позначку; торкніться її, щоб видалити. + Вікі гри + Виправлення PCGamingWiki + Проходження на YouTube + Видно + Приховано + Затемнено + Посібники Steam + Категорія + Ще немає закріплених мап + Мапа %1$d + Ще немає збережених сторінок + Параметри дзеркала + Область + Верхній екран + Масштабування + Швидкий доступ + Макет: %1$s + На всю ширину + Ліворуч + По центру + Праворуч + Меню швидкого доступу Steam ще недоступне. Ігрова статистика HUD на нижньому екрані Смуга на кожній вкладці @@ -3219,6 +3285,8 @@ Місце встановлення Сховище за замовчуванням Нові встановлення з магазинів потрапляють у вибране місце. Наявні ігри залишаються на місці. Бібліотеки Steam мають власне налаштування. + Пам\'ять телефона в Linux + Підключає внутрішню пам\'ять телефона в /root/Storage. Якщо вимкнено, підключаються лише додані з неї папки з іграми. На SD-картки не впливає. Застосовується з наступного сеансу. Питати щоразу Вибирати місце для кожного встановлення Внутрішнє сховище @@ -4159,6 +4227,12 @@ Виділення Успіх Помилка + Попередження Показувати HUD лише під час гри Приховувати HUD, коли кадри гри не виявляються. + Спочатку закрийте Steam + Спочатку призупиніть завантаження Steam + Ця гра встановлює свою версію для Linux. Установіть її зі Steam. + Масштаб гри + Налаштуйте збільшення гри від 100% до 300% diff --git a/app/src/main/res/values-vi/input_zoom_strings.xml b/app/src/main/res/values-vi/input_zoom_strings.xml new file mode 100644 index 0000000000..16dbcd0dcf --- /dev/null +++ b/app/src/main/res/values-vi/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + Tăng thu phóng trò chơi + Giảm thu phóng trò chơi + \ No newline at end of file diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index 3a46f7b7f9..9353281a09 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -1246,6 +1246,11 @@ Chuẩn bị Không truy cập được gỡ lỗi không dây; Ghép đôi sẽ bật tính năng này Ghép đôi + Quest không có màn hình ghép nối. Từ máy tính, chạy một lần: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS và adb tcpip 5555. Sau đó nhấn Cho phép và chấp nhận lời nhắc trong kính + Cho phép + Chấp nhận “Cho phép gỡ lỗi?” trong kính, với Luôn cho phép được chọn + Không thể kết nối. Chấp nhận lời nhắc gỡ lỗi trong kính, hoặc nếu không thấy lời nhắc, hãy chạy adb tcpip 5555 từ máy tính rồi thử lại + Không thể kết nối gỡ lỗi không dây. Nhấn Cho phép để thiết lập lại Cài đặt Đăng nhập PR #%1$d @@ -1453,6 +1458,7 @@ %1$d%% Tiếp tục %1$s Hiển thị như /root/ROMs trong mỗi phiên. Bộ nhớ trong ở /root/Storage. + Hiển thị như /root/ROMs trong mỗi phiên. Chưa chọn thư mục Áp dụng từ phiên sau. Thẻ SD hoạt động được. Chọn thư mục @@ -2025,6 +2031,13 @@ Vạch đỏ là vị trí HUD hiển thị nhiệt độ bằng màu đỏ. toàn thiết bị pin + Hình ảnh trò chơi + Đang chơi + Đã chọn trong Steam + Chơi gần đây + Chưa chơi + Đã chơi %1$d phút + Đã chơi %1$d giờ Gửi dữ liệu bảng đồng hồ Tự động Bật cho mọi game trong danh sách này, kể cả game được tìm thấy sau này. Game bạn đã tắt sẽ vẫn tắt. @@ -2047,6 +2060,59 @@ Micro tắt Micro đang tắt cho game này. Để nói chuyện, hãy bật Micro trong thiết lập Steam của DroidDeck (Âm thanh) rồi khởi động lại game. Âm lượng %1$d%% + Ẩn thanh + Hiện thanh + Độ sáng màn hình dưới + Tắt màn hình dưới + Hướng dẫn + Hãy mở một trò chơi để xem hướng dẫn Steam của nó tại đây. + Đọc tiếp + Trò chơi này chưa có hướng dẫn Steam nào. + Không tải được hướng dẫn Steam. Hãy thử lại khi bạn trực tuyến. + Phản chiếu + Kéo qua phần trò chơi muốn hiển thị ở đây, chẳng hạn bản đồ nhỏ. + Lưu vùng + Sắc nét + Mượt + Hiện không thể sao chép hình ảnh trò chơi. + Wiki và cách sửa + Bản đồ + Đã lưu + Tất cả + Hướng dẫn đầy đủ + Bí mật + Đã ghim bản đồ vào bản đồ của trò chơi này. + Không lưu được hình ảnh đó. + Đã lưu trang để đọc ngoại tuyến. + Tìm trên web + Điểm đánh dấu: %1$d + Tìm bản đồ + Dùng Lưu trong trình đọc để giữ trang đọc ngoại tuyến. + Ghim làm bản đồ + Nhấn giữ một hình để ghim làm bản đồ. + Chụm để thu phóng. Nhấn giữ để thêm điểm đánh dấu, chạm vào để xóa. + Wiki trò chơi + Cách sửa từ PCGamingWiki + Hướng dẫn trên YouTube + Hiện + Ẩn + Làm tối + Hướng dẫn Steam + Danh mục + Chưa có bản đồ nào được ghim + Bản đồ %1$d + Chưa có trang nào được lưu + Tùy chọn phản chiếu + Vùng + Màn hình trên + Thu phóng + Truy cập nhanh + Bố cục: %1$s + Toàn chiều rộng + Trái + Giữa + Phải + Menu Truy cập nhanh của Steam chưa sẵn sàng. Thông số trong game HUD màn hình dưới Thanh trên mọi tab @@ -3130,6 +3196,8 @@ Vị trí cài đặt Bộ nhớ mặc định Các bản cài mới từ cửa hàng sẽ vào vị trí đã chọn. Game hiện có vẫn ở nguyên chỗ. Thư viện Steam giữ thiết lập riêng. + Bộ nhớ điện thoại trong Linux + Gắn bộ nhớ trong của điện thoại tại /root/Storage. Khi tắt, chỉ các thư mục trò chơi bạn đã thêm từ đó được gắn. Thẻ SD không bị ảnh hưởng. Áp dụng từ phiên tiếp theo. Luôn hỏi Chọn nơi lưu cho mỗi lần cài Bộ nhớ trong @@ -4049,6 +4117,12 @@ Điểm nhấn Thành công Lỗi + Cảnh báo Chỉ hiển thị HUD khi đang chơi Ẩn HUD khi không phát hiện khung hình trò chơi. + Hãy đóng Steam trước + Hãy tạm dừng tải xuống Steam trước + Trò chơi này cài bản dành cho Linux. Hãy cài từ Steam. + Thu phóng trò chơi + Điều chỉnh độ phóng đại trò chơi từ 100% đến 300% diff --git a/app/src/main/res/values-zh-rCN/input_zoom_strings.xml b/app/src/main/res/values-zh-rCN/input_zoom_strings.xml new file mode 100644 index 0000000000..cda779567a --- /dev/null +++ b/app/src/main/res/values-zh-rCN/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + 放大游戏画面 + 缩小游戏画面 + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index be252ebe48..58bbf19378 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -1329,6 +1329,11 @@ 准备 无线调试无法连接;配对即可开启 配对 + Quest 没有配对界面。请在电脑上运行一次:adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS 和 adb tcpip 5555。然后点按“允许”,并在头显中接受提示 + 允许 + 在头显中接受“允许调试吗?”,并勾选“始终允许” + 无法连接。请在头显中接受调试提示;如果没有出现提示,请在电脑上运行 adb tcpip 5555 后重试 + 无法连接无线调试。点按“允许”重新设置 安装 登录 PR #%1$d @@ -1536,6 +1541,7 @@ %1$d%% 恢复 %1$s 在每个会话中显示为 /root/ROMs。内部存储位于 /root/Storage。 + 在每个会话中显示为 /root/ROMs。 未选择文件夹 将在下次会话生效。支持 SD 卡。 选择文件夹 @@ -2102,6 +2108,13 @@ 红色标记处,HUD 会以红色显示温度。 整机 电池 + 游戏插图 + 正在游玩 + 在 Steam 中选中 + 最近玩过 + 尚未玩过 + 已玩 %1$d 分钟 + 已玩 %1$d 小时 发送仪表盘数据 自动 为此处列出的所有游戏开启,包括之后发现的游戏。你手动关闭的游戏会保持关闭。 @@ -2124,6 +2137,59 @@ 麦克风已关 此游戏的麦克风已关闭。如需语音通话,请在 DroidDeck 的 Steam 设置(音频)中开启麦克风,然后重新启动游戏。 音量 %1$d%% + 隐藏栏 + 显示栏 + 下屏幕亮度 + 关闭下屏 + 指南 + 启动游戏后,这里会显示它的 Steam 指南。 + 继续阅读 + 此游戏还没有 Steam 指南。 + 无法加载 Steam 指南。请在联网后重试。 + 镜像 + 拖动框选要在这里显示的游戏区域,例如小地图。 + 保存区域 + 锐利 + 平滑 + 现在无法复制游戏画面。 + Wiki 与修复 + 地图 + 已保存 + 全部 + 流程攻略 + 秘密 + 已将地图固定到此游戏的地图。 + 无法保存该图片。 + 已保存页面以供离线阅读。 + 网络搜索 + 标记:%1$d + 查找地图 + 在阅读器中点保存,即可离线阅读页面。 + 固定为地图 + 长按图片即可固定为地图。 + 双指缩放。长按添加标记,点按标记可删除。 + 游戏 Wiki + PCGamingWiki 修复 + YouTube 攻略 + 显示 + 隐藏 + 变暗 + Steam 指南 + 分类 + 还没有固定的地图 + 地图 %1$d + 还没有保存的页面 + 镜像选项 + 区域 + 上屏 + 缩放 + 快速访问 + 布局:%1$s + 全宽 + 左侧 + 居中 + 右侧 + Steam 快速访问菜单暂不可用。 游戏内数据 下屏 HUD 所有页签显示横条 @@ -3130,6 +3196,8 @@ 安装位置 默认存储 新的商店安装将保存到所选位置。现有游戏保持原位。Steam 库使用各自的设置。 + 在 Linux 中使用手机存储 + 将手机内部存储挂载到 /root/Storage。关闭后,只会挂载你从中添加的游戏文件夹。不影响 SD 卡。下次会话生效。 每次询问 每次安装时选择目标位置 内部存储 @@ -4049,6 +4117,10 @@ 高亮 成功 错误 + 警告 仅在游戏期间显示 HUD 未检测到游戏帧时隐藏 HUD。 + 请先关闭 Steam + 请先暂停 Steam 下载 + 此游戏会安装其 Linux 版本。请通过 Steam 安装。 diff --git a/app/src/main/res/values-zh-rHK/input_zoom_strings.xml b/app/src/main/res/values-zh-rHK/input_zoom_strings.xml new file mode 100644 index 0000000000..44fe64edb2 --- /dev/null +++ b/app/src/main/res/values-zh-rHK/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + 放大遊戲畫面 + 縮小遊戲畫面 + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 101adaef46..f0a26a39a9 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1245,6 +1245,11 @@ 準備 無線偵錯無法連線;按「配對」即可開啟 配對 + Quest 沒有配對畫面。請在電腦上執行一次:adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS 及 adb tcpip 5555。然後輕按「允許」,並在頭戴裝置中接受提示 + 允許 + 在頭戴裝置中接受「要允許偵錯嗎?」,並剔選「一律允許」 + 無法連接。請在頭戴裝置中接受偵錯提示;如果沒有出現提示,請在電腦上執行 adb tcpip 5555 後再試一次 + 無法連接無線偵錯。輕按「允許」重新設定 安裝 登入 PR #%1$d @@ -1452,6 +1457,7 @@ %1$d%% 繼續 %1$s 在每個會話中顯示為 /root/ROMs。內部儲存空間位於 /root/Storage。 + 在每個會話中顯示為 /root/ROMs。 未選擇資料夾 下次會話生效。支援 SD 卡。 選擇資料夾 @@ -2024,6 +2030,13 @@ 紅色標記是 HUD 將溫度顯示為紅色的界線。 整機 電池 + 遊戲美術 + 遊玩中 + 在 Steam 中選取 + 最近玩過 + 尚未玩過 + 已玩 %1$d 分鐘 + 已玩 %1$d 小時 傳送儀表板資料 自動 為這裡列出的所有遊戲開啟,包括之後找到的遊戲。你關閉的遊戲會維持關閉。 @@ -2046,6 +2059,59 @@ 麥克風已關閉 此遊戲的麥克風已關閉。若要說話,請在 DroidDeck 的 Steam 設定(音訊)中開啟麥克風,然後重新啟動遊戲。 音量 %1$d%% + 隱藏列 + 顯示列 + 下方螢幕亮度 + 關閉下螢幕 + 指南 + 啟動遊戲後,這裡會顯示它的 Steam 指南。 + 繼續閱讀 + 此遊戲暫時沒有 Steam 指南。 + 無法載入 Steam 指南。請在連線後再試。 + 鏡像 + 拖曳框選要在這裡顯示的遊戲區域,例如小地圖。 + 儲存區域 + 銳利 + 平滑 + 目前無法複製遊戲畫面。 + Wiki 與修正 + 地圖 + 已儲存 + 全部 + 流程攻略 + 秘密 + 已將地圖釘選到此遊戲的地圖。 + 無法儲存該圖片。 + 已儲存頁面供離線閱讀。 + 網上搜尋 + 標記:%1$d + 尋找地圖 + 在閱讀器中按儲存,即可離線閱讀頁面。 + 釘選為地圖 + 長按圖片即可釘選為地圖。 + 雙指縮放。長按加入標記,點按標記可刪除。 + 遊戲 Wiki + PCGamingWiki 修正 + YouTube 攻略 + 顯示 + 隱藏 + 變暗 + Steam 指南 + 分類 + 尚未釘選地圖 + 地圖 %1$d + 尚未儲存頁面 + 鏡像選項 + 區域 + 上屏 + 縮放 + 快速存取 + 版面配置:%1$s + 全寬 + 左側 + 置中 + 右側 + Steam 快速存取選單暫時無法使用。 遊戲內數據 下方螢幕 HUD 在所有分頁顯示資訊列 @@ -3127,6 +3193,8 @@ 安裝位置 預設儲存空間 從商店新安裝的遊戲會安裝到所選位置。現有遊戲維持原位。Steam 收藏庫保有自己的設定。 + 在 Linux 中使用手機儲存空間 + 將手機內部儲存空間掛載到 /root/Storage。關閉後,只會掛載你從中加入的遊戲資料夾。不影響 SD 卡。下次工作階段生效。 每次都詢問 每次安裝時選擇目標位置 內部儲存空間 @@ -4049,6 +4117,10 @@ 重點標示 成功 錯誤 + 警告 只在遊戲期間顯示 HUD 未偵測到遊戲畫面時隱藏 HUD。 + 請先關閉 Steam + 請先暫停 Steam 下載 + 此遊戲會安裝其 Linux 版本。請透過 Steam 安裝。 diff --git a/app/src/main/res/values-zh-rTW/input_zoom_strings.xml b/app/src/main/res/values-zh-rTW/input_zoom_strings.xml new file mode 100644 index 0000000000..44fe64edb2 --- /dev/null +++ b/app/src/main/res/values-zh-rTW/input_zoom_strings.xml @@ -0,0 +1,5 @@ + + + 放大遊戲畫面 + 縮小遊戲畫面 + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index f9d96cf955..621d47e5c6 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1245,6 +1245,11 @@ 準備 無線偵錯無法連線;配對即可開啟 配對 + Quest 沒有配對畫面。請在電腦上執行一次:adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS 和 adb tcpip 5555。接著輕觸「允許」,並在頭戴式裝置中接受提示 + 允許 + 在頭戴式裝置中接受「要允許偵錯嗎?」,並勾選「一律允許」 + 無法連線。請在頭戴式裝置中接受偵錯提示;如果沒有出現提示,請在電腦上執行 adb tcpip 5555 後再試一次 + 無法連上無線偵錯。輕觸「允許」重新設定 安裝 登入 PR #%1$d @@ -1452,6 +1457,7 @@ %1$d%% 繼續 %1$s 每個工作階段中顯示為 /root/ROMs。內部儲存空間位於 /root/Storage。 + 每個工作階段中顯示為 /root/ROMs。 未選擇資料夾 下次工作階段生效。支援 SD 卡。 選擇資料夾 @@ -2024,6 +2030,13 @@ 紅色標記是 HUD 將溫度顯示為紅色的位置。 整台裝置 電池 + 遊戲美術 + 遊玩中 + 在 Steam 中選取 + 最近玩過 + 尚未玩過 + 已玩 %1$d 分鐘 + 已玩 %1$d 小時 傳送儀表板資料 自動 為這裡列出的所有遊戲開啟,包括之後找到的遊戲。你關閉的遊戲會維持關閉。 @@ -2046,6 +2059,59 @@ 麥克風已關閉 此遊戲的麥克風已關閉。若要說話,請在 DroidDeck 的 Steam 設定(音訊)中開啟麥克風,然後重新啟動遊戲。 音量 %1$d%% + 隱藏列 + 顯示列 + 下方螢幕亮度 + 關閉下螢幕 + 指南 + 啟動遊戲後,這裡會顯示它的 Steam 指南。 + 繼續閱讀 + 此遊戲尚無 Steam 指南。 + 無法載入 Steam 指南。請在連線後再試。 + 鏡像 + 拖曳框選要在這裡顯示的遊戲區域,例如小地圖。 + 儲存區域 + 銳利 + 平滑 + 目前無法複製遊戲畫面。 + Wiki 與修正 + 地圖 + 已儲存 + 全部 + 流程攻略 + 秘密 + 已將地圖釘選到此遊戲的地圖。 + 無法儲存該圖片。 + 已儲存頁面供離線閱讀。 + 網路搜尋 + 標記:%1$d + 尋找地圖 + 在閱讀器中按儲存,即可離線閱讀頁面。 + 釘選為地圖 + 長按圖片即可釘選為地圖。 + 雙指縮放。長按新增標記,點按標記可刪除。 + 遊戲 Wiki + PCGamingWiki 修正 + YouTube 攻略 + 顯示 + 隱藏 + 變暗 + Steam 指南 + 分類 + 尚未釘選地圖 + 地圖 %1$d + 尚未儲存頁面 + 鏡像選項 + 區域 + 上螢幕 + 縮放 + 快速存取 + 版面配置:%1$s + 全寬 + 左側 + 置中 + 右側 + Steam 快速存取選單暫時無法使用。 遊戲內數據 下螢幕 HUD 在每個分頁顯示資訊列 @@ -3127,6 +3193,8 @@ 安裝位置 預設儲存空間 從商店新安裝的遊戲會安裝到所選位置。現有遊戲維持原位。Steam 收藏庫保有自己的設定。 + 在 Linux 中使用手機儲存空間 + 將手機內部儲存空間掛載到 /root/Storage。關閉後,只會掛載你從中加入的遊戲資料夾。不影響 SD 卡。下次工作階段生效。 每次都詢問 每次安裝時選擇目標位置 內部儲存空間 @@ -4049,6 +4117,10 @@ 醒目標示 成功 錯誤 + 警告 僅在遊戲期間顯示 HUD 未偵測到遊戲畫面時隱藏 HUD。 + 請先關閉 Steam + 請先暫停 Steam 下載 + 此遊戲會安裝其 Linux 版本。請透過 Steam 安裝。 diff --git a/app/src/main/res/values/input_strings.xml b/app/src/main/res/values/input_strings.xml index bc18c561a7..69e35ec0e3 100644 --- a/app/src/main/res/values/input_strings.xml +++ b/app/src/main/res/values/input_strings.xml @@ -21,6 +21,8 @@ Show keyboard Open Steam menu Open Steam quick access + Increase game zoom + Decrease game zoom Remove control Add control Device-specific buttons diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 700d06d37a..29d2b8d03b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -966,7 +966,7 @@ Games and compatibility All bundles Game debug logs - Include Proton, Wine and graphics diagnostics on the next game launch. Can reduce performance and use more storage. + Include Proton, Wine and graphics diagnostics on the next game launch. Turns itself off when that session ends. Can reduce performance and use more storage. Restart this session to save game debug logs Couldn\'t update logging. Check the switch and try again. Debugging tools @@ -1392,6 +1392,11 @@ Prepare Wireless debugging isn\'t reachable; Pair turns it on Pair + Quest has no pairing screen. From a computer, run once: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS and adb tcpip 5555. Then tap Allow and accept the prompt in the headset + Allow + Accept “Allow debugging?” in the headset, with Always allow ticked + Couldn\'t connect. Accept the debugging prompt in the headset, or if none appeared, run adb tcpip 5555 from a computer and try again + Wireless debugging isn\'t reachable. Tap Allow to set it up again Install Sign in Free models @@ -1677,6 +1682,7 @@ %1$d%% Resume %1$s Shows up as /root/ROMs in each session. Internal storage is at /root/Storage. + Shows up as /root/ROMs in each session. No folder chosen Applies next session. SD cards work. Choose folder @@ -2028,6 +2034,7 @@ Highlights Success Error + Warning Esc Ins Del @@ -2319,6 +2326,14 @@ The red mark is where the HUD shows the temperature in red. whole device battery + Game art + Playing + Selected in Steam + Last played + Not played yet + %1$d min played + %1$d h played + %1$s · %2$s Send dashboard data Automatic Turns it on for every game listed here, including games found later. Games you switch off stay off. @@ -2341,6 +2356,70 @@ Mic off Mic is off for this game. To talk, turn on Microphone in DroidDeck\'s Steam settings (Audio) and start the game again. Volume %1$d%% + Hide bar + Show bar + Bottom screen brightness + Turn off the bottom screen + Guides + Start a game to see its Steam guides here. + Continue reading + There are no Steam guides for this game yet. + Could not load Steam guides. Check back once you are online. + Mirror + Drag over the part of the game to show here, such as the minimap. + Save region + Sharp + Smooth + The game picture cannot be copied right now. + Wiki & fixes + Maps + Saved + All + Walkthroughs + Secrets + Map pinned to this game\'s maps. + That image could not be saved. + Page saved for offline reading. + Search the web + Markers: %1$d + Find maps + Use Save in the reader to keep a page for offline reading. + Pin as map + Long-press an image to pin it as a map. + Pinch to zoom. Long-press to add a marker, tap one to remove it. + Game wiki + PCGamingWiki fixes + YouTube walkthroughs + Shown + Hidden + Dimmed + ProtonDB + StrategyWiki + GameFAQs + IGN + HowLongToBeat + Map Genie + Platinum + Gold + Silver + Bronze + Borked + Steam guides + Category + No pinned maps yet + Map %1$d + No saved pages yet + Mirror options + Region + Top screen + Scaling + Quick Access + Layout: %1$s + Full width + Left + Center + Right + Steam\'s Quick Access menu is not available yet. In-game stats Bottom screen HUD Strip on every tab @@ -2722,6 +2801,8 @@ Keep proportions Stretch to display Image scaling + Adjust game magnification from 100% to 300% + Game zoom Integer scaling Uses the largest whole-number scale that fits. May crop screen edges. If the source is larger than the output, fractional scaling fits the full image. Resolution is configured separately. Fit @@ -3488,6 +3569,8 @@ Install location Default storage New store installs go to the selected location. Existing games stay where they are. Steam libraries keep their own setting. + Phone storage in Linux + Mounts your phone\'s internal storage at /root/Storage. When off, only game folders you\'ve added from it are mounted. SD cards are not affected. Applies to the next session. Ask every time Choose a target for each install Internal storage @@ -4298,6 +4381,10 @@ Open Show Previews change nothing real: nothing is installed, removed or signed out, and the menu\'s switches save nothing. A Library preview stays until you end it from its pill or restart. + Steam home + No games installed + 3 games installed + 12 games installed Library Nothing installed Signed out of every store @@ -4390,4 +4477,7 @@ Hide the HUD when no game frames are detected. Getting ready · %1$d%% Finish setup · %1$d%% + Close Steam first + Pause the Steam download first + This game installs its Linux build. Install it from Steam. diff --git a/app/src/main/rust/stores/Cargo.lock b/app/src/main/rust/stores/Cargo.lock index 6a470b3bea..962c867e74 100644 --- a/app/src/main/rust/stores/Cargo.lock +++ b/app/src/main/rust/stores/Cargo.lock @@ -8,6 +8,17 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + [[package]] name = "async-compression" version = "0.4.42" @@ -26,12 +37,24 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + [[package]] name = "bitflags" version = "2.11.1" @@ -47,6 +70,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-padding" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" +dependencies = [ + "generic-array", +] + [[package]] name = "bumpalo" version = "3.20.3" @@ -65,6 +97,15 @@ version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + [[package]] name = "cc" version = "1.2.62" @@ -93,6 +134,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + [[package]] name = "combine" version = "4.6.7" @@ -120,6 +171,12 @@ version = "0.4.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc14f565cf027a105f7a44ccf9e5b424348421a1d8952a8fc9d499d313107789" +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -163,6 +220,23 @@ dependencies = [ "typenum", ] +[[package]] +name = "data-encoding" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "digest" version = "0.10.7" @@ -170,7 +244,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", + "subtle", ] [[package]] @@ -188,20 +264,28 @@ dependencies = [ name = "droiddeckstores" version = "0.1.0" dependencies = [ + "aes", + "cbc", "cc", + "crc32fast", "flate2", "futures-util", + "hmac", "jni", "libc", "lzma-rs", + "rand 0.8.8", "reqwest", + "rsa", "ruzstd", "serde_json", "sha1", "sha2", "tokio", "tokio-rustls", - "webpki-roots", + "tungstenite", + "webpki-roots 1.0.7", + "zeroize", ] [[package]] @@ -317,6 +401,15 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + [[package]] name = "http" version = "1.4.1" @@ -389,7 +482,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", - "webpki-roots", + "webpki-roots 1.0.7", ] [[package]] @@ -528,6 +621,16 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "block-padding", + "generic-array", +] + [[package]] name = "ipnet" version = "2.12.0" @@ -596,12 +699,27 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" +dependencies = [ + "spin", +] + [[package]] name = "libc" version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + [[package]] name = "litemap" version = "0.8.2" @@ -657,12 +775,66 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "num-bigint-dig" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" +dependencies = [ + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.8", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + [[package]] name = "once_cell" version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.2" @@ -675,6 +847,27 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "potential_utf" version = "0.1.5" @@ -731,7 +924,7 @@ dependencies = [ "bytes", "getrandom 0.3.4", "lru-slab", - "rand", + "rand 0.9.4", "ring", "rustc-hash", "rustls", @@ -772,14 +965,35 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + [[package]] name = "rand" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" dependencies = [ - "rand_chacha", - "rand_core", + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", ] [[package]] @@ -789,7 +1003,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", ] [[package]] @@ -836,7 +1059,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots", + "webpki-roots 1.0.7", ] [[package]] @@ -853,6 +1076,26 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rsa" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "rustc-hash" version = "2.1.2" @@ -1007,6 +1250,16 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core 0.6.4", +] + [[package]] name = "simd-adler32" version = "0.3.9" @@ -1035,6 +1288,22 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "spin" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -1255,6 +1524,26 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tungstenite" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4793cb5e56680ecbb1d843515b23b6de9a75eb04b66643e256a396d43be33c13" +dependencies = [ + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand 0.9.4", + "rustls", + "rustls-pki-types", + "sha1", + "thiserror 2.0.18", + "utf-8", + "webpki-roots 0.26.11", +] + [[package]] name = "twox-hash" version = "2.1.5" @@ -1291,6 +1580,12 @@ dependencies = [ "serde", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "utf8_iter" version = "1.0.4" @@ -1412,6 +1707,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.7", +] + [[package]] name = "webpki-roots" version = "1.0.7" diff --git a/app/src/main/rust/stores/Cargo.toml b/app/src/main/rust/stores/Cargo.toml index 97a27659a1..c8caf6f1b3 100644 --- a/app/src/main/rust/stores/Cargo.toml +++ b/app/src/main/rust/stores/Cargo.toml @@ -10,11 +10,17 @@ name = "droiddeckstores" crate-type = ["cdylib"] [dependencies] +aes = "0.8" +cbc = { version = "0.1", features = ["alloc", "block-padding"] } +crc32fast = "1" +hmac = "0.12" jni = "0.21" libc = "0.2" -lzma-rs = { version = "0.3", default-features = false } +lzma-rs = { version = "0.3", default-features = false, features = ["raw_decoder"] } flate2 = { version = "1", default-features = false, features = ["rust_backend"] } +rand = "0.8" reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "gzip"] } +rsa = "0.9" tokio = { version = "1", default-features = false, features = ["rt", "net", "time", "sync", "io-util"] } futures-util = { version = "0.3", default-features = false, features = ["std"] } serde_json = { version = "1", features = ["preserve_order"] } @@ -23,6 +29,8 @@ sha2 = "0.10" tokio-rustls = { version = "0.26", default-features = false, features = ["ring", "tls12"] } webpki-roots = "1" ruzstd = "0.8" +tungstenite = { version = "0.26", default-features = false, features = ["handshake", "rustls-tls-webpki-roots"] } +zeroize = "1" [build-dependencies] cc = "1" diff --git a/app/src/main/rust/stores/JNI.md b/app/src/main/rust/stores/JNI.md index b87390ac8f..80f84aee2c 100644 --- a/app/src/main/rust/stores/JNI.md +++ b/app/src/main/rust/stores/JNI.md @@ -2,19 +2,19 @@ The Kotlin side of the store download engines mirrors this file exactly. Every symbol the library exports is listed here with the class it binds to, the JNI signature, when it is called and on -which thread. The GOG engine and the shared fetch core came from Bannerlator's -`bl-steam-client` crate (method names and signatures match Bannerlator's `BlGogDownload`, only the -package and class names changed). The Epic module (`src/epic/`) and the Amazon module +which thread. The GOG engine, the shared fetch core and the Steam module (`src/steam/`, see its +`NOTICE.md`) are derived from WinNative's `wn-steam-client` crate (GPL-3.0-or-later, +https://github.com/WinNative-Emu/WinNative). The Epic module (`src/epic/`) and the Amazon module (`src/amazon/`) are DroidDeck's own, each written from a functional spec (see `docs/development/epic-cleanroom.md` and `docs/development/amazon-cleanroom.md`); their JNI -surfaces below are new. +surfaces below are new, as is the Steam one. Load it once with `System.loadLibrary("droiddeckstores")`. The library is built by Gradle (`buildRustStores`, see `app/build.gradle`) and is absent from a `-PskipRust=true` build, so every call site must be ready for `UnsatisfiedLinkError` on `loadLibrary` or on the first `external` call and degrade to "store unavailable". -## Conventions that hold for all three engines +## Conventions that hold for all engines - The `external` functions are declared `@JvmStatic` in a Kotlin `object` (a `JClass` arrives as the second JNI argument). Declaring them in a plain `object` without `@JvmStatic` also binds — @@ -290,9 +290,207 @@ absent or that of empty input are created without a request. `.amazon_download_i created when a run starts and removed when it succeeds, which also creates `.amazon_download_complete`; nothing reads either marker. +## `com.droiddeck.launcher.stores.steam.SteamNative` + +Steam store engine (`src/steam/`): signs in with the Linux Steam client's saved login, lists the +account's games, plans and downloads a game straight into the Steam library folder the client +uses, then writes what the client writes on completion, so the client sees the game as installed +and does not update or verify it. Kotlin runs downloads and uninstalls only while the Steam client +is closed. + +```kotlin +package com.droiddeck.launcher.stores.steam + +object SteamNative { + @JvmStatic external fun nativeSignIn(steamRootsJson: String, registryVdfPath: String, caBundlePath: String): String + @JvmStatic external fun nativeSignOut() + @JvmStatic external fun nativeLibrary(): String + @JvmStatic external fun nativePlan(appId: Int, language: String): String + @JvmStatic external fun nativeStart(appId: Int, language: String, steamRoot: String, gameLibraryHost: String, gameLibraryGuest: String, libraryRootsJson: String, journalDir: String, caBundlePath: String, maxWorkers: Int, processWorkers: Int, listener: Any): Long + @JvmStatic external fun nativeCancel(handle: Long) + @JvmStatic external fun nativeRelease(handle: Long) + @JvmStatic external fun nativeUninstall(appId: Int, steamRoot: String, gameLibraryHost: String, gameLibraryGuest: String, libraryRootsJson: String): String +} +``` + +| Method | JNI signature | Symbol suffix | +|---|---|---| +| `nativeSignIn(steamRootsJson, registryVdfPath, caBundlePath): String` | `(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;` | `nativeSignIn` | +| `nativeSignOut()` | `()V` | `nativeSignOut` | +| `nativeLibrary(): String` | `()Ljava/lang/String;` | `nativeLibrary` | +| `nativePlan(appId, language): String` | `(ILjava/lang/String;)Ljava/lang/String;` | `nativePlan` | +| `nativeStart(...)`: Long | `(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IILjava/lang/Object;)J` | `nativeStart` | +| `nativeCancel(handle: Long)` | `(J)V` | `nativeCancel` | +| `nativeRelease(handle: Long)` | `(J)V` | `nativeRelease` | +| `nativeUninstall(appId, steamRoot, gameLibraryHost, gameLibraryGuest, libraryRootsJson): String` | `(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;` | `nativeUninstall` | + +Full symbols are `Java_com_droiddeck_launcher_stores_steam_SteamNative_`. Every `String` +answer is a UTF-8 JSON object with `"ok": true|false`; a failure carries `"error": ""`. `nativeSignIn`, `nativeLibrary`, `nativePlan` and `nativeUninstall` block on the +network or the disk: call them off the main thread. A Rust panic is caught at the boundary and +answers `{"ok":false,"error":"internal_error"}`. + +Paths: "host" paths are Android paths the app can open; "guest" paths are what the Steam client +sees inside proot (what `libraryfolders.vdf` holds). `libraryRootsJson` is a JSON array of +`{"host": "...", "guest": "..."}`, one per library of the active client; it is used to find shared +app folders and `libraryfolders.vdf` entries, and the game library is added to it when missing. + +### `nativeSignIn` + +`steamRootsJson`: JSON array of host paths of Steam roots (arm64 and x86-64 clients), searched in +order. `registryVdfPath`: host path of `~/.steam/registry.vdf` (`""` = none). `caBundlePath`: see +conventions (used for the CM directory request). + +Reads, never writes: `/config/loginusers.vdf` (accounts), `/local.vdf` +(`MachineUserConfigStore/Software/Valve/Steam/ConnectCache`, keys matched case-insensitively; the +entry whose key starts with the 8-hex-digit CRC32 of the lowercased account name), and +`registry.vdf` (`Registry/HKCU/Software/Valve/Steam/AutoLoginUser`). The account is +`AutoLoginUser` when it names a known account, else the one with `MostRecent` `"1"`, else the +newest `Timestamp`. The token is decrypted in memory (key = SHA-256 of the lowercased account +name; AES-256-ECB-wrapped IV, AES-256-CBC + PKCS#7), checked to be a Steam JWT for that +SteamID64, sent once in the CM logon and zeroized. It is never logged, written, renewed or +replaced. + +Answers `{"ok":true,"account":"","steamId":""}` or +`{"ok":false,"error":…}` with `no_saved_login` (no account in any `loginusers.vdf`), +`remember_me_off` (`RememberPassword` `"0"`, or no ConnectCache entry: signed out), +`decrypt_failed` (the entry does not decrypt to this account's token), or `logon_failed: …` +(`logon_failed: eresult= ` when Steam refused the logon, e.g. `eresult=5 +InvalidPassword` for an expired token; otherwise a connection reason). One process-wide session: +a second call while it is logged on answers at once with the same account. After logon the +session sends no persona, friends or presence messages. + +`nativeSignOut()` logs off and drops the session; it never touches the client's files. + +### `nativeLibrary` + +`{"ok":true,"games":[{"appId":291550,"name":"Brawlhalla","installDir":"Brawlhalla","type":"game","free":true}…]}`: +every app the account's licenses grant (package 0, the basic Steam license, is skipped) whose +PICS `common.type` is `game`, sorted by name. `free` = appinfo marks it free to play +(`common.freetogame` or `extended.isfreeapp` `"1"`). Loaded once per session (the first call +fetches PICS for every owned app and can take a while). `not_signed_in` without a session. + +### `nativePlan` + +What `nativeStart` would install for `appId` with `language` (Steam's language names, e.g. +`english`): + +```json +{"ok":true,"appId":291550,"name":"Brawlhalla","installDir":"Brawlhalla","buildId":26465982, + "language":"english","linuxBuild":false,"downloadBytes":…,"installBytes":1594368732, + "depots":[{"depotId":291551,"manifestId":"4224536525702420323","size":1565156559,"dlcAppId":0}], + "shared":[{"depotId":228988,"fromAppId":228980,"manifestId":"6645201662696499616","size":29212173}]} +``` + +Selection (what the client picks for a Windows game run through Proton): `config.oslist` empty or +containing `windows`; `config.osarch` empty or `64` (`32` only when no `64` depot exists); +`config.language` empty or the language (english when the game has no depot for the requested +language but has english ones; the answer's `language` is the one used); no `lowviolence` +depots; for an owned app, only depots one of the account's packages grants (`depotids`), as +the client installs no other; DLC depots (`dlcappid`) only when the DLC is owned; `depotfromapp`/`sharedinstall` +depots are listed under `shared` with the owning app (e.g. 228980 Steamworks Common +Redistributables), whose public manifest they use. Manifest gids are the public branch's, sizes +come from PICS, `buildId` is the public branch's. `installBytes`/`downloadBytes` include the +shared depots (they are not checked against what is already installed here). Errors: +`not_signed_in`, `not_owned`, `appinfo unavailable`, `appinfo unavailable for shared app `, +`no installable Windows depot`, `linux_build` (no Windows depot, and the game has a Linux build). A free app +the account does not own yet is planned without asking for its license. `linuxBuild` is true +when `common.oslist` lists `linux`: the client then installs the Linux build unless the game is +mapped to a Proton, so the caller checks that mapping before installing. + +### `nativeStart` + +Parameters: `appId`, `language`, `steamRoot` (host path of the active client's Steam root; its +`steamapps/` and `config/` hold the two `libraryfolders.vdf` copies, `depotcache/` its cached +manifests), `gameLibraryHost`/`gameLibraryGuest` (the library to install into), `libraryRootsJson`, +`journalDir` (app-private directory for resume journals), `caBundlePath`, `maxWorkers` (request +window ceiling; `0` = 16), `processWorkers` (decrypt/decompress/write threads; `0` = half the +cores, 2 to 6; on SD cards the card writes, not the network, tend to be the limit), `listener`. + +Returns `0` without any callback when the listener is null, `appId <= 0`, the JavaVM or a global +ref cannot be obtained, `steamRoot`/`gameLibraryHost`/`gameLibraryGuest`/`journalDir` is empty, +or the worker thread cannot be spawned. Otherwise the run is on a thread named `steam-dl` +(background priority) and `onComplete` fires exactly once, last. `nativeCancel` is idempotent and +safe until `nativeRelease`; call `nativeRelease` exactly once per non-zero handle, after +`onComplete`. + +| Listener method | JNI signature | When | +|---|---|---| +| `onProgress(doneBytes: Long, totalBytes: Long, phase: String)` | `(JJLjava/lang/String;)V` | `phase` is `preparing` (sign-in check, plan, takeover, keys, manifests; `0`/`0`), `downloading` (the game's depots), `shared` (shared depots) or `registering`. `doneBytes`/`totalBytes` count the depot files (decompressed) of everything this run installs, shared depots included; chunks already correct on disk count as done. At most every 250 ms, plus at every phase change and depot end. | +| `onComplete(ok: Boolean, result: String)` | `(ZLjava/lang/String;)V` | `{"ok":true,"alreadyInstalled":false}` after a download, `{"ok":true,"alreadyInstalled":true}` when the game was already fully installed at the current build (nothing downloaded or written), or `{"ok":false,"error":"…"}`: `cancelled`, `not_signed_in`, `already_running` (a run for the same app is active), `not_owned`, `free_license_refused`, `library_not_in_libraryfolders` (no `libraryfolders.vdf` entry has the guest path), `not_enough_space: need … MiB, have … MiB`, `access_denied: depot `, or a short message for network and disk failures. | + +What a run does, in order: + +1. Plans as `nativePlan`; a free app the account does not own is first added to the account with + `CMsgClientRequestFreeLicense`. +2. Takeover check on `/steamapps/appmanifest_.acf`: absent → fresh + install; `StateFlags` has 4 and none of the update/download/validate bits and `buildid` is the + current build → `alreadyInstalled`; a build on disk at another build (the fully-installed bit + set, even with an update pending) → `update_in_steam`, left to the Steam client; otherwise (a + half-finished client download) `steamapps/downloading/` and `steamapps/temp/` + are deleted and the journal is discarded, while the manifest is kept so registration merges + its settings. +3. Downloads the game's depots in place into `/steamapps/common/`: + no temp files, no space reservation, each file trimmed to its exact size when its last chunk + lands. A chunk used several times is fetched once. Files already on disk are read back chunk by + chunk and only wrong or missing chunks are fetched (resume, update, taking over a client's + partial files). +4. Shared depots go into the library that holds `appmanifest_.acf` (else the Steam + root's own library), folder `steamapps/common/`; a shared depot already + installed at the planned manifest is skipped. +5. Registers: writes `appmanifest_.acf` (keys in the client's order: `appid`, `Universe`, + `name`, `StateFlags` 4, `installdir`, `LastUpdated`, `LastPlayed`, `SizeOnDisk` (the game's + depots), `StagingSize`, `buildid`, `LastOwner` (SteamID64), `DownloadType` 1, `UpdateResult`, + `BytesToDownload`/`BytesDownloaded` (compressed size of every installed depot, shared + included), `BytesToStage`/`BytesStaged` (installed size of the game's depots plus the shared + depots installed in this run), `TargetBuildID`, `AutoUpdateBehavior`, + `AllowOtherDownloadsWhileRunning`, `ScheduledAutoUpdate`, `InstalledDepots` + (`manifest`, `size`, plus `dlcappid` for DLC depots), `InstallScripts` when a game depot has + one, `SharedDepots`, `UserConfig`/`MountedConfig` `language`), merging into an existing file + (unknown keys, `LastPlayed` and the auto-update settings are kept). Updates the shared app's + manifest (`SizeOnDisk`, `InstalledDepots`, `InstallScripts` entry such as + `"228988" "_CommonRedist\\vcredist\\2019\\installscript.vdf"`; created when missing). + Adds `"" "0"` under `apps` of the matching entry in both + `/steamapps/libraryfolders.vdf` and `/config/libraryfolders.vdf` (the + client fills in the size later); nothing else there changes. All files are written through a + temp file + rename. + +Never written: `config.vdf`, `localconfig.vdf`, `registry.vdf` (the client regenerates them) and +`depotcache/` (the client keeps manifests there with decrypted file names, not in the CDN form +this engine caches; it fetches them when it needs them). + +On-disk protocol of the journal: `///depot.config` (JSON: +`buildId`, the finished manifest per depot or an in-progress sentinel) and +`_.manifest` (raw CDN manifests) beside it. `` is the CRC32, as 8 +lowercase hex digits, of `gameLibraryGuest` with trailing `/` removed, so a resume in one library +never trusts depots finished in another. A cancelled or failed run keeps it, and the next `nativeStart` for the same app +resumes (finished depots are skipped, the rest is checked on disk); a journal written for another +build is dropped. It is deleted after a successful registration. Nothing extra is ever left in +the game folder. + +### `nativeUninstall` + +Matches the client's own uninstall: deletes `/steamapps/common/` and +the game's `appmanifest_.acf`, `/depotcache/_.manifest` for +the game's `InstalledDepots` and `/steamapps/shadercache/`; keeps +`steamapps/compatdata/` (the Proton prefix, i.e. saves). For each of the game's +`SharedDepots` that no other installed game in any library lists, deletes that depot's files from +the shared app's folder (empty folders stay, as with the client) and removes its +`InstalledDepots` and `InstallScripts` entries and its size from the shared app's manifest. The +file list comes from the client's `depotcache` copy of that manifest, else from the CDN through +the live session; without either the shared depot is left installed and listed in `keptShared`. +Removes the app from `apps` in both `libraryfolders.vdf` copies. + +Answers `{"ok":true,"removedShared":[228988],"keptShared":[]}`, or `{"ok":false,"error":…}`: +`not_installed` (no app manifest), `bad installdir in app manifest`, `bad arguments`, or a disk +error. + ## Log tags Lines go to logcat under `GogNative` and `EpicNative` (the Amazon module logs only through `onLog`). Bannerlator used `BL_GOG_DL` for the GOG engine; the fetch core's line grammar (`fetch-start`, `fetch-window`, `throughput`, `fetch-end`, `summary`) is unchanged, so its tuning notes still read against a DroidDeck log. + +The Steam module logs under `DroidDeckSteam` and never logs a token; its chunk downloads go +through the fetch core with the label `steam depot=`. diff --git a/app/src/main/rust/stores/src/ea/install.rs b/app/src/main/rust/stores/src/ea/install.rs index fb2cd80ef5..49fd19f1ec 100644 --- a/app/src/main/rust/stores/src/ea/install.rs +++ b/app/src/main/rust/stores/src/ea/install.rs @@ -5,7 +5,6 @@ use std::collections::{HashMap, HashSet}; use std::fs::{self, File, OpenOptions}; use std::io::{Read, Write}; -use std::os::unix::fs::FileExt; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; use std::sync::Mutex; @@ -18,6 +17,7 @@ use super::net; use super::zip::{self, Entry}; use crate::amazon::install::check::{free_bytes, space_problem}; use crate::amazon::install::{Events, ReplaceGate, Stop}; +use crate::grow_write::{holes_supported, is_cancel, GrowFront}; use crate::fetch_core::{distinct_host_count, run_fetch, FetchItem, FetchOptions, FetchSink, SinkError}; pub const LEDGER: &str = ".droiddeck-ea-files"; @@ -37,6 +37,7 @@ struct Split { file: Mutex>, received: Vec, left: AtomicUsize, + front: GrowFront, } #[derive(Clone, Copy)] @@ -483,9 +484,16 @@ impl Placer<'_> { let old = split.received[part].swap(0, Ordering::Relaxed); self.in_flight.fetch_sub(old, Ordering::Relaxed); } - handle - .write_all_at(data, start + offset) - .map_err(|e| SinkError::Fatal(self.fail(format!("Could not write {}: {e}", job.path))))?; + split + .front + .write_all_at(handle, start + offset, data, self.stop) + .map_err(|e| { + if is_cancel(&e) { + SinkError::Retry(format!("{}: cancelled", job.path)) + } else { + SinkError::Fatal(self.fail(format!("Could not write {}: {e}", job.path))) + } + })?; drop(file); split.received[part].fetch_add(data.len() as u64, Ordering::Relaxed); self.in_flight.fetch_add(data.len() as u64, Ordering::Relaxed); @@ -698,6 +706,7 @@ pub fn run(req: &Request, cancel: &AtomicBool, ev: &dyn Events) -> Result> = remote .iter() .enumerate() @@ -711,6 +720,7 @@ pub fn run(req: &Request, cancel: &AtomicBool, ev: &dyn Events) -> Result Result>, hits: Arc) -> String { +#[derive(Default)] +struct Misses { + seen: AtomicUsize, + cancel_at: usize, + cancel: Arc, +} + +fn serve(files: HashMap>, hits: Arc, misses: Arc) -> String { let listener = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = listener.local_addr().unwrap(); let files = Arc::new(files); @@ -30,13 +37,14 @@ fn serve(files: HashMap>, hits: Arc) -> String { let Ok(stream) = stream else { continue }; let files = Arc::clone(&files); let hits = Arc::clone(&hits); - std::thread::spawn(move || answer(stream, &files, &hits)); + let misses = Arc::clone(&misses); + std::thread::spawn(move || answer(stream, &files, &hits, &misses)); } }); format!("http://{addr}") } -fn answer(mut stream: TcpStream, files: &HashMap>, hits: &AtomicUsize) { +fn answer(mut stream: TcpStream, files: &HashMap>, hits: &AtomicUsize, misses: &Misses) { let mut reader = BufReader::new(stream.try_clone().unwrap()); let mut first = String::new(); if reader.read_line(&mut first).is_err() { @@ -54,7 +62,13 @@ fn answer(mut stream: TcpStream, files: &HashMap>, hits: &Atomic hits.fetch_add(1, Ordering::Relaxed); let (status, body) = match files.get(&path) { Some(b) => ("200 OK", b.clone()), - None => ("404 Not Found", Vec::new()), + None => { + if misses.seen.fetch_add(1, Ordering::SeqCst) + 1 == misses.cancel_at { + std::thread::sleep(std::time::Duration::from_millis(300)); + misses.cancel.store(true, Ordering::SeqCst); + } + ("404 Not Found", Vec::new()) + } }; let head = format!("HTTP/1.1 {status}\r\nContent-Length: {}\r\nConnection: close\r\n\r\n", body.len()); let _ = stream.write_all(head.as_bytes()); @@ -106,6 +120,10 @@ fn pattern(seed: u8, len: usize) -> Vec { } fn fixture() -> Fixture { + fixture_missing(false, Arc::new(Misses::default())) +} + +fn fixture_missing(last_chunk: bool, misses: Arc) -> Fixture { let mut c1 = chunk(1, 4096); let mut c2 = chunk(2, 2048); let mut c3 = chunk(3, 1000); @@ -168,10 +186,13 @@ fn fixture() -> Fixture { let mut served = HashMap::new(); served.insert("/Builds/x/test.manifest".to_string(), manifest_bytes); for (info, data) in [(&c1, &d1), (&c2, &d2), (&c3, &d3)] { + if last_chunk && info.guid == c3.guid { + continue; + } served.insert(format!("/Builds/x/{}", parsed.chunk_path(info)), encode(data, true)); } let hits = Arc::new(AtomicUsize::new(0)); - let base = serve(served, Arc::clone(&hits)); + let base = serve(served, Arc::clone(&hits), misses); Fixture { base, hits, @@ -273,6 +294,40 @@ fn a_cancelled_run_reports_cancel() { let _ = fs::remove_dir_all(&game); } +fn kept_c(fx: &Fixture, game: &Path) -> bool { + let c = &fx.expected[1].1; + let partial = game.join(staging::DIR_NAME).join(staging::partial_name("b/c.bin", c.len() as u64, Some(Sha1::digest(c).into()))); + partial.is_file() && staging::list_path(&partial).is_file() +} + +#[test] +fn a_chunk_that_cannot_be_fetched_fails_and_keeps_written_parts() { + let misses = Arc::new(Misses::default()); + let fx = fixture_missing(true, Arc::clone(&misses)); + let game = temp_game("fetch-fail"); + let cancel = AtomicBool::new(false); + let err = run(&request(&fx, &game), &cancel, &Recorder::default()).unwrap_err(); + assert!(matches!(&err, Stop::Failed(m) if m.starts_with("Download failed: ")), "{err:?}"); + assert_eq!(misses.seen.load(Ordering::SeqCst), crate::fetch_core::MAX_ITEM_ATTEMPTS as usize); + assert!(kept_c(&fx, &game)); + let _ = fs::remove_dir_all(&game); +} + +#[test] +fn a_cancel_during_the_last_fetch_attempt_reports_cancel_and_keeps_written_parts() { + let cancel = Arc::new(AtomicBool::new(false)); + let last = crate::fetch_core::MAX_ITEM_ATTEMPTS as usize; + let misses = Arc::new(Misses { seen: AtomicUsize::new(0), cancel_at: last, cancel: Arc::clone(&cancel) }); + let fx = fixture_missing(true, Arc::clone(&misses)); + let game = temp_game("fetch-cancel"); + let events = Recorder::default(); + assert_eq!(run(&request(&fx, &game), &cancel, &events).unwrap_err(), Stop::Cancelled); + assert_eq!(misses.seen.load(Ordering::SeqCst), last); + assert!(events.logs.lock().unwrap().iter().any(|l| l.contains(&format!("failed after {last} attempts")))); + assert!(kept_c(&fx, &game)); + let _ = fs::remove_dir_all(&game); +} + fn place_partial(fx: &Fixture, game: &Path, data: &[u8], list: &str) -> PathBuf { let stage = staging::recover(game).unwrap(); let a = &fx.expected[0].1; diff --git a/app/src/main/rust/stores/src/epic/install/writer.rs b/app/src/main/rust/stores/src/epic/install/writer.rs index 66cab176b3..cf9e4d6172 100644 --- a/app/src/main/rust/stores/src/epic/install/writer.rs +++ b/app/src/main/rust/stores/src/epic/install/writer.rs @@ -8,6 +8,7 @@ use std::time::{Duration, Instant}; use sha1::{Digest, Sha1}; use super::cache; +use crate::grow_write::{holes_supported, is_cancel, GrowFront}; use super::schedule::{PlanPart, Schedule, NONE}; use super::{staging, Events, Stop}; use crate::epic::chunk; @@ -80,6 +81,7 @@ struct Coord { struct Engine<'a> { input: &'a EngineInput<'a>, slots: Vec>, + fronts: Vec, coord: Mutex, wake: Condvar, admitted: AtomicUsize, @@ -95,6 +97,17 @@ struct Engine<'a> { total_bytes: u64, } +enum Halt { + Cancelled, + Failed(String), +} + +impl From for Halt { + fn from(message: String) -> Self { + Halt::Failed(message) + } +} + enum Source<'d> { Memory(&'d [u8]), Cache(PathBuf), @@ -112,6 +125,13 @@ impl<'a> Engine<'a> { message } + fn sink_error(&self, halt: Halt) -> SinkError { + match halt { + Halt::Cancelled => SinkError::Retry("cancelled".into()), + Halt::Failed(message) => SinkError::Fatal(self.fail(message)), + } + } + fn cache_path(&self, producer: usize) -> PathBuf { let p = &self.input.schedule.producers[producer]; let info = &self.input.manifest.chunks[p.chunk as usize]; @@ -158,7 +178,7 @@ impl<'a> Engine<'a> { self.input.schedule.producers[fetch[at] as usize].anchor as usize + 1 } - fn write_use(&self, u: usize, source: &Source<'_>) -> Result<(), String> { + fn write_use(&self, u: usize, source: &Source<'_>) -> Result<(), Halt> { let schedule = &self.input.schedule; let f = schedule.use_file[u] as usize; let j = u - schedule.file_start[f] as usize; @@ -175,16 +195,22 @@ impl<'a> Engine<'a> { let start = part.chunk_offset as usize; let end = start + part.size as usize; if end > data.len() { - return Err(format!("A chunk is too short for {}", file.path)); + return Err(format!("A chunk is too short for {}", file.path).into()); } let piece = &data[start..end]; let handle = self.slots[f].lock().expect("slot lock").file.clone(); let Some(handle) = handle else { - return Err(format!("internal: {} is not open", file.path)); + return Err(format!("internal: {} is not open", file.path).into()); }; - handle - .write_all_at(piece, part.file_offset) - .map_err(|e| format!("Could not assemble or atomically replace {}: {e}", file.path))?; + self.fronts[f] + .write_all_at(&handle, part.file_offset, piece, self.stop) + .map_err(|e| { + if is_cancel(&e) { + Halt::Cancelled + } else { + Halt::Failed(format!("Could not assemble or atomically replace {}: {e}", file.path)) + } + })?; self.written.fetch_add(piece.len() as u64, Ordering::Relaxed); let complete = { @@ -343,14 +369,18 @@ impl<'a> Engine<'a> { } }; let Some(f) = candidate else { continue }; - if let Err(e) = self.admit(f) { - self.fail(e); - return; + match self.admit(f) { + Ok(()) => {} + Err(Halt::Cancelled) => return, + Err(Halt::Failed(e)) => { + self.fail(e); + return; + } } } } - fn admit(&self, f: usize) -> Result<(), String> { + fn admit(&self, f: usize) -> Result<(), Halt> { self.open_stage(f)?; let schedule = &self.input.schedule; let file = &self.input.files[f]; @@ -415,7 +445,7 @@ impl<'a> Engine<'a> { out }; for u in claims { - self.write_use(u, &Source::Memory(&data)).map_err(|e| SinkError::Fatal(self.fail(e)))?; + self.write_use(u, &Source::Memory(&data)).map_err(|h| self.sink_error(h))?; } Ok(0) } @@ -446,8 +476,10 @@ pub fn run(input: &EngineInput<'_>, stop: &AtomicBool, events: &dyn Events) -> R cached[i] = true; } } + let holes = holes_supported(&input.stage_dir); let engine = Engine { input, + fronts: input.files.iter().map(|_| GrowFront::new(holes)).collect(), slots: input .files .iter() @@ -532,7 +564,7 @@ pub fn run(input: &EngineInput<'_>, stop: &AtomicBool, events: &dyn Events) -> R } ready }; - let outcome = std::thread::scope(|scope| { + let (outcome, cancelled) = std::thread::scope(|scope| { let admitter = std::thread::Builder::new() .name("epic-admit".into()) .spawn_scoped(scope, || { @@ -541,7 +573,7 @@ pub fn run(input: &EngineInput<'_>, stop: &AtomicBool, events: &dyn Events) -> R }); if let Err(e) = admitter { engine.fail(format!("could not start the install thread: {e}")); - return None; + return (None, false); } let outcome = if items.is_empty() { None @@ -552,11 +584,9 @@ pub fn run(input: &EngineInput<'_>, stop: &AtomicBool, events: &dyn Events) -> R let mut c = engine.coord.lock().expect("coord lock"); c.fetch_done = true; } - if outcome.as_ref().is_some_and(|o| !o.ok()) { - stop.store(true, Ordering::SeqCst); - } + let cancelled = settle(outcome.as_ref().is_some_and(|o| !o.ok()), stop); engine.wake.notify_all(); - outcome + (outcome, cancelled) }); let failure = engine.failure.lock().expect("failure lock").take().filter(|m| !m.is_empty()); @@ -593,16 +623,35 @@ fetches={} refetches={} peak_cache_mib={} hosts={}", hosts.join(","), )); + ending(failure, complete, fetch_error, cancelled, stop.load(Ordering::SeqCst))?; + Ok(Stats { bytes_written: written, files_written: input.files.len() }) +} + +fn settle(fetch_failed: bool, stop: &AtomicBool) -> bool { + let cancelled = stop.load(Ordering::SeqCst); + if fetch_failed { + stop.store(true, Ordering::SeqCst); + } + cancelled +} + +fn ending( + failure: Option, + complete: bool, + fetch_error: Option, + cancelled: bool, + stopped: bool, +) -> Result<(), Stop> { if let Some(message) = failure { return Err(Stop::Failed(message)); } if complete { - return Ok(Stats { bytes_written: written, files_written: input.files.len() }); + return Ok(()); } - if let Some(message) = fetch_error { + if let Some(message) = fetch_error.filter(|_| !cancelled) { return Err(Stop::Failed(format!("Download failed: {}", tidy_fetch_error(&message)))); } - if stop.load(Ordering::SeqCst) { + if stopped { return Err(Stop::Cancelled); } Err(Stop::Failed("The download ended before every file was written".into())) @@ -704,4 +753,37 @@ mod tests { assert_eq!(fs::read_to_string(staging::list_path(&kept)).unwrap(), "10\n20\n"); let _ = fs::remove_dir_all(&dir); } + + fn end(fetch_error: Option<&str>, stop: &AtomicBool) -> Result<(), Stop> { + let cancelled = settle(fetch_error.is_some(), stop); + ending(None, false, fetch_error.map(str::to_string), cancelled, stop.load(Ordering::SeqCst)) + } + + #[test] + fn a_cancel_during_the_last_fetch_attempt_ends_as_cancelled() { + let stop = AtomicBool::new(true); + assert!(matches!(end(Some("timed out"), &stop), Err(Stop::Cancelled))); + assert!(matches!(end(None, &stop), Err(Stop::Cancelled))); + } + + #[test] + fn a_fetch_failure_without_a_cancel_ends_as_failed() { + let stop = AtomicBool::new(false); + match end(Some("timed out"), &stop) { + Err(Stop::Failed(message)) => assert!(message.starts_with("Download failed: ")), + _ => panic!("a fetch failure must be reported"), + } + assert!(stop.load(Ordering::SeqCst)); + let idle = AtomicBool::new(false); + assert!(matches!(end(None, &idle), Err(Stop::Failed(_)))); + } + + #[test] + fn a_write_failure_or_a_finished_install_wins_over_a_cancel() { + assert!(matches!( + ending(Some("disk full".into()), false, None, true, true), + Err(Stop::Failed(message)) if message == "disk full" + )); + assert!(ending(None, true, Some("late".into()), true, true).is_ok()); + } } diff --git a/app/src/main/rust/stores/src/grow_write.rs b/app/src/main/rust/stores/src/grow_write.rs new file mode 100644 index 0000000000..ba64639a35 --- /dev/null +++ b/app/src/main/rust/stores/src/grow_write.rs @@ -0,0 +1,293 @@ +use std::fs::{self, File, OpenOptions}; +use std::io; +use std::os::unix::fs::{FileExt, MetadataExt, OpenOptionsExt}; +use std::path::Path; +use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::Mutex; + +pub const FILL_STEP: usize = 4 * 1024 * 1024; +pub const DIRECT_GAP: u64 = 4 * 1024 * 1024; +const PROBE_GAP: u64 = 1024 * 1024; +static PROBE_SEQ: AtomicU64 = AtomicU64::new(0); + +const PROBE_PREFIX: &str = ".droiddeck-hole-probe-"; + +pub fn is_cancel(err: &io::Error) -> bool { + err.kind() == io::ErrorKind::Interrupted +} + +pub fn holes_supported(dir: &Path) -> bool { + let probe = dir.join(format!( + "{PROBE_PREFIX}{}-{}", + std::process::id(), + PROBE_SEQ.fetch_add(1, Ordering::Relaxed) + )); + let Ok(file) = OpenOptions::new() + .write(true) + .create_new(true) + .custom_flags(libc::O_NOFOLLOW) + .open(&probe) + else { + return true; + }; + let written = file.write_all_at(&[0u8], PROBE_GAP - 1); + drop(file); + let measured = written.and_then(|_| fs::symlink_metadata(&probe)); + let _ = fs::remove_file(&probe); + measured + .map(|meta| meta.blocks().saturating_mul(512) < PROBE_GAP) + .unwrap_or(true) +} + +pub struct GrowFront { + holes: bool, + size: AtomicU64, + known: AtomicBool, + fill: Mutex<()>, +} + +impl GrowFront { + pub fn new(holes: bool) -> Self { + GrowFront { + holes, + size: AtomicU64::new(0), + known: AtomicBool::new(false), + fill: Mutex::new(()), + } + } + + pub fn reset(&self) { + let _guard = self.fill.lock().unwrap_or_else(|e| e.into_inner()); + self.known.store(false, Ordering::Release); + self.size.store(0, Ordering::Release); + } + + pub fn write_all_at( + &self, + file: &File, + offset: u64, + data: &[u8], + cancel: &AtomicBool, + ) -> io::Result<()> { + let end = offset.saturating_add(data.len() as u64); + if self.holes + || (self.known.load(Ordering::Acquire) && end <= self.size.load(Ordering::Acquire)) + { + return file.write_all_at(data, offset); + } + let _guard = self.fill.lock().unwrap_or_else(|e| e.into_inner()); + let mut size = self.current(file)?; + if offset > size.saturating_add(DIRECT_GAP) { + self.fill_to(file, &mut size, offset - DIRECT_GAP, cancel)?; + } + if let Err(err) = file.write_all_at(data, offset) { + self.known.store(false, Ordering::Release); + return Err(err); + } + self.publish(size.max(end)); + Ok(()) + } + + pub fn extend_to(&self, file: &File, len: u64, cancel: &AtomicBool) -> io::Result<()> { + if self.holes { + return file.set_len(len); + } + let _guard = self.fill.lock().unwrap_or_else(|e| e.into_inner()); + let mut size = self.current(file)?; + if size < len { + self.fill_to(file, &mut size, len, cancel)?; + } + Ok(()) + } + + fn current(&self, file: &File) -> io::Result { + if self.known.load(Ordering::Acquire) { + Ok(self.size.load(Ordering::Acquire)) + } else { + Ok(file.metadata()?.len()) + } + } + + fn fill_to( + &self, + file: &File, + size: &mut u64, + target: u64, + cancel: &AtomicBool, + ) -> io::Result<()> { + let zeros = vec![0u8; FILL_STEP]; + while *size < target { + if cancel.load(Ordering::Relaxed) { + self.publish(*size); + return Err(io::Error::new(io::ErrorKind::Interrupted, "cancelled")); + } + let step = ((target - *size) as usize).min(FILL_STEP); + if let Err(err) = file.write_all_at(&zeros[..step], *size) { + self.known.store(false, Ordering::Release); + return Err(err); + } + *size += step as u64; + self.publish(*size); + } + Ok(()) + } + + fn publish(&self, size: u64) { + self.size.store(size, Ordering::Release); + self.known.store(true, Ordering::Release); + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::Arc; + + fn temp_dir(tag: &str) -> std::path::PathBuf { + let dir = std::env::temp_dir().join(format!( + "grow-write-{tag}-{}-{}", + std::process::id(), + PROBE_SEQ.fetch_add(1, Ordering::Relaxed) + )); + fs::create_dir_all(&dir).unwrap(); + dir + } + + fn open(path: &Path) -> File { + OpenOptions::new() + .create(true) + .read(true) + .write(true) + .truncate(false) + .open(path) + .unwrap() + } + + #[test] + fn far_write_fills_the_gap_in_bounded_steps_and_keeps_data() { + let dir = temp_dir("far"); + let path = dir.join("f.bin"); + let file = open(&path); + let front = GrowFront::new(false); + let cancel = AtomicBool::new(false); + front.write_all_at(&file, 0, b"head", &cancel).unwrap(); + let far = 3 * FILL_STEP as u64 + 123; + front.write_all_at(&file, far, b"tail", &cancel).unwrap(); + front.write_all_at(&file, 100, b"mid", &cancel).unwrap(); + let bytes = fs::read(&path).unwrap(); + assert_eq!(bytes.len() as u64, far + 4); + assert_eq!(&bytes[0..4], b"head"); + assert_eq!(&bytes[100..103], b"mid"); + assert_eq!(&bytes[far as usize..], b"tail"); + assert!(bytes[103..far as usize].iter().all(|b| *b == 0)); + fs::remove_file(&path).unwrap(); + fs::remove_dir(&dir).unwrap(); + } + + #[test] + fn cancel_stops_a_gap_fill_between_steps() { + let dir = temp_dir("cancel"); + let path = dir.join("f.bin"); + let file = open(&path); + let front = GrowFront::new(false); + let cancel = AtomicBool::new(true); + let err = front + .write_all_at(&file, 8 * FILL_STEP as u64, b"x", &cancel) + .unwrap_err(); + assert_eq!(err.kind(), io::ErrorKind::Interrupted); + assert_eq!(fs::metadata(&path).unwrap().len(), 0); + cancel.store(false, Ordering::Relaxed); + front.write_all_at(&file, 10, b"ok", &cancel).unwrap(); + assert_eq!(&fs::read(&path).unwrap()[10..], b"ok"); + fs::remove_file(&path).unwrap(); + fs::remove_dir(&dir).unwrap(); + } + + #[test] + fn concurrent_writers_never_lose_data_to_the_fill() { + let dir = temp_dir("race"); + let path = dir.join("f.bin"); + let file = Arc::new(open(&path)); + let front = Arc::new(GrowFront::new(false)); + let piece = 64 * 1024u64; + let count = 256u64; + let mut order: Vec = (0..count).collect(); + order.reverse(); + let lanes: Vec> = (0..4) + .map(|lane| order.iter().copied().filter(|i| i % 4 == lane).collect()) + .collect(); + let handles: Vec<_> = lanes + .into_iter() + .map(|lane| { + let file = Arc::clone(&file); + let front = Arc::clone(&front); + std::thread::spawn(move || { + let cancel = AtomicBool::new(false); + for i in lane { + let data = vec![(i % 251) as u8 + 1; piece as usize]; + front.write_all_at(&file, i * piece, &data, &cancel).unwrap(); + } + }) + }) + .collect(); + for handle in handles { + handle.join().unwrap(); + } + let bytes = fs::read(&path).unwrap(); + assert_eq!(bytes.len() as u64, piece * count); + for i in 0..count { + let start = (i * piece) as usize; + assert!(bytes[start..start + piece as usize] + .iter() + .all(|b| *b == (i % 251) as u8 + 1)); + } + fs::remove_file(&path).unwrap(); + fs::remove_dir(&dir).unwrap(); + } + + #[test] + fn extend_to_grows_in_steps_and_never_shrinks() { + let dir = temp_dir("extend"); + let path = dir.join("f.bin"); + let file = open(&path); + let front = GrowFront::new(false); + let cancel = AtomicBool::new(false); + front.write_all_at(&file, 0, b"data", &cancel).unwrap(); + let len = 2 * FILL_STEP as u64 + 7; + front.extend_to(&file, len, &cancel).unwrap(); + front.extend_to(&file, 2, &cancel).unwrap(); + let bytes = fs::read(&path).unwrap(); + assert_eq!(bytes.len() as u64, len); + assert_eq!(&bytes[0..4], b"data"); + assert!(bytes[4..].iter().all(|b| *b == 0)); + fs::remove_file(&path).unwrap(); + fs::remove_dir(&dir).unwrap(); + } + + #[test] + fn hole_capable_storage_writes_directly() { + let dir = temp_dir("holes"); + let path = dir.join("f.bin"); + let file = open(&path); + let front = GrowFront::new(true); + let cancel = AtomicBool::new(true); + front + .write_all_at(&file, 8 * FILL_STEP as u64, b"x", &cancel) + .unwrap(); + assert_eq!(fs::metadata(&path).unwrap().len(), 8 * FILL_STEP as u64 + 1); + fs::remove_file(&path).unwrap(); + fs::remove_dir(&dir).unwrap(); + } + + #[test] + fn probe_leaves_nothing_behind() { + let dir = temp_dir("probe"); + let other = dir.join(format!("{PROBE_PREFIX}game-file")); + fs::write(&other, b"kept").unwrap(); + let _ = holes_supported(&dir); + assert_eq!(fs::read_dir(&dir).unwrap().count(), 1); + assert_eq!(fs::read(&other).unwrap(), b"kept"); + fs::remove_file(&other).unwrap(); + fs::remove_dir(&dir).unwrap(); + } +} diff --git a/app/src/main/rust/stores/src/lib.rs b/app/src/main/rust/stores/src/lib.rs index 12a351138f..e0d7554e15 100644 --- a/app/src/main/rust/stores/src/lib.rs +++ b/app/src/main/rust/stores/src/lib.rs @@ -1,4 +1,4 @@ -//! Ported from Bannerlator's bl-steam-client crate (GPL-3.0-or-later), itself derived from WinNative's wn-steam-client. +//! DroidDeck's store download engines. The Steam client and the shared fetch core are derived from WinNative's wn-steam-client (GPL-3.0-or-later, https://github.com/WinNative-Emu/WinNative). #![allow(clippy::missing_safety_doc, clippy::result_large_err)] @@ -9,6 +9,8 @@ pub mod epic; pub mod fetch_core; pub mod fetch_tuning; pub mod gog; +pub mod grow_write; pub mod md5_small; pub mod priority; +pub mod steam; pub mod stores_jni; diff --git a/app/src/main/rust/stores/src/steam/NOTICE.md b/app/src/main/rust/stores/src/steam/NOTICE.md new file mode 100644 index 0000000000..49256ab3e1 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/NOTICE.md @@ -0,0 +1,50 @@ +# Steam store engine: provenance and license notice + +The Steam module of `libdroiddeckstores.so` (`app/src/main/rust/stores/src/steam/`) is a +**derivative work of the `wn-steam-client` crate from the WinNative project**, +, directory +`app/src/main/cpp/wn-steam-client/rust`, taken at upstream commit `a2020b7` (2026-09-01). +The upstream crate is published under **GPL-3.0-or-later**; this derivative is distributed under +the same license as part of DroidDeck. Copyright in the original code remains with the WinNative +authors and contributors, including maxjivi05. + +The shared fetch core (`src/fetch_core.rs`, `src/fetch_tuning.rs`) and `src/md5_small.rs`, which +this module uses, come from the same upstream crate. + +## Modifications made in DroidDeck (GPL-3.0 §5(a) statement of changes) + +Date of modification: 2026-11-07. + +- Ported into the `droiddeckstores` crate as the module `steam`; identifiers, log tag + (`DroidDeckSteam`) and thread name (`steam-dl`) follow DroidDeck naming. +- Kept, with import paths adapted: WebSocket transport (`ws_connection`, `transport`), channel + encryption and handshake (`encrypted_channel`, `handshake_messages`, `crypto`, `key_dictionary`), + CM server discovery (`cm_server`, `cm_server_list`, `steam_directory`), wire formats + (`emsg`, `cmsg_protobuf_header`, `proto_envelope`, `proto_wire`, `wire_format`, `base64`, `vdf`), + `heartbeat`, `job_manager`, `content_manifest`, `depot_chunk`, and the protobuf messages for + logon, licenses, PICS, depot keys, manifest request codes, CDN servers and free licenses. +- `cm_client` reduced to logon with a refresh token, heartbeat, log-off and the download-store + requests; the logon sends `machine_id` `DroidDeck-Steam`; logon and log-off EResults are kept + for error reporting. +- `cm_runtime`: no persona or friends traffic after logon, the C-ABI bridge (`cm_bridge`) is + removed, and outbound messages are cleared from memory once sent. +- Blocking HTTP replaced by a one-shot request helper (`http`); `cdn_client` reduced to `cdn` + (URLs, manifest and HTTP-delivered appinfo fetches); CDN servers are de-duplicated by host, + capped at 10 and filtered by `allowed_app_ids`. +- `depot_writer` rewritten on DroidDeck's shared fetch core: files are written in place without + `fallocate` or zero-fill and trimmed with `set_len`; the number of decode/write workers is a + parameter; a chunk used in several places is fetched once; on resume, chunks on disk are read + back and checked before anything is fetched. +- `depot_config` / `depot_downloader`: the resume journal moved out of the game folder into a + caller-given directory, keyed by app and build; the progress sidecar and clean-pause markers are + dropped. +- New: `signin` (reuse of the Linux Steam client's saved login), `session` (one process-wide CM + session), `library`, `plan` (depot selection), `register` (app manifests, shared depots, + `libraryfolders.vdf`, takeover of half-finished client downloads, uninstall), `kv` (Valve + KeyValues writer), `install` (download orchestration) and a new JNI layer (`jni`). +- `library` records the depots the account's packages grant, and `plan` installs only those + (the client skips the rest, e.g. edition-only depots); `plan` flags apps with a Linux build. +- Not ported: QR and password sign-in, auth sessions, friends, chat and chat images, persona, + lobbies, cloud, user stats, achievements, inventory, published files and workshop, app and + ownership tickets, playing-session control, the Wine bridge, the other stores' downloaders, + the version module and the original JNI layer. diff --git a/app/src/main/rust/stores/src/steam/base64.rs b/app/src/main/rust/stores/src/steam/base64.rs new file mode 100644 index 0000000000..b8854f1ce6 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/base64.rs @@ -0,0 +1,97 @@ +const ALPHABET: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +pub fn encode(bytes: &[u8]) -> String { + if bytes.is_empty() { + return String::new(); + } + + let mut out = String::with_capacity(bytes.len().div_ceil(3) * 4); + let (chunks, remainder) = bytes.as_chunks::<3>(); + for chunk in chunks { + let v = ((chunk[0] as u32) << 16) | ((chunk[1] as u32) << 8) | chunk[2] as u32; + out.push(ALPHABET[((v >> 18) & 0x3f) as usize] as char); + out.push(ALPHABET[((v >> 12) & 0x3f) as usize] as char); + out.push(ALPHABET[((v >> 6) & 0x3f) as usize] as char); + out.push(ALPHABET[(v & 0x3f) as usize] as char); + } + + match remainder { + [a] => { + let v = (*a as u32) << 16; + out.push(ALPHABET[((v >> 18) & 0x3f) as usize] as char); + out.push(ALPHABET[((v >> 12) & 0x3f) as usize] as char); + out.push('='); + out.push('='); + } + [a, b] => { + let v = ((*a as u32) << 16) | ((*b as u32) << 8); + out.push(ALPHABET[((v >> 18) & 0x3f) as usize] as char); + out.push(ALPHABET[((v >> 12) & 0x3f) as usize] as char); + out.push(ALPHABET[((v >> 6) & 0x3f) as usize] as char); + out.push('='); + } + [] => {} + _ => unreachable!(), + } + + out +} + +pub fn decode(s: &str) -> Option> { + let mut out = Vec::with_capacity((s.len() / 4) * 3 + 3); + let mut acc = 0u32; + let mut bits = 0u32; + + for b in s.bytes() { + let v = value_of(b)?; + let Some(v) = v else { + continue; + }; + acc = (acc << 6) | v as u32; + bits += 6; + if bits >= 8 { + bits -= 8; + out.push(((acc >> bits) & 0xff) as u8); + } + } + + Some(out) +} + +fn value_of(b: u8) -> Option> { + match b { + b'A'..=b'Z' => Some(Some(b - b'A')), + b'a'..=b'z' => Some(Some(b - b'a' + 26)), + b'0'..=b'9' => Some(Some(b - b'0' + 52)), + b'+' | b'-' => Some(Some(62)), + b'/' | b'_' => Some(Some(63)), + b'=' | b' ' | b'\t' | b'\n' | b'\r' => Some(None), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn encodes_rfc4648_padding() { + assert_eq!(encode(b""), ""); + assert_eq!(encode(b"f"), "Zg=="); + assert_eq!(encode(b"fo"), "Zm8="); + assert_eq!(encode(b"foo"), "Zm9v"); + assert_eq!(encode(b"foobar"), "Zm9vYmFy"); + } + + #[test] + fn decodes_standard_urlsafe_and_whitespace() { + assert_eq!(decode("Zm9v YmFy"), Some(b"foobar".to_vec())); + assert_eq!(decode("SGVsbG8td29ybGQ_"), Some(b"Hello-world?".to_vec())); + assert_eq!(decode("Zg=="), Some(b"f".to_vec())); + } + + #[test] + fn invalid_character_fails() { + assert_eq!(decode("Zm9v*"), None); + } +} diff --git a/app/src/main/rust/stores/src/steam/cdn.rs b/app/src/main/rust/stores/src/steam/cdn.rs new file mode 100644 index 0000000000..0fd92e0075 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/cdn.rs @@ -0,0 +1,468 @@ +//! SteamPipe CDN: URL formation, manifest + HTTP-delivered appinfo fetches, and the zip/gzip +//! helpers they need. Chunk bodies are fetched by the shared fetch core (`crate::fetch_core`). + +use crate::steam::pb::ccontentserverdirectory::CContentServerDirectoryServerInfo; +use flate2::read::{DeflateDecoder, GzDecoder}; +use std::io::Read; +use std::time::Duration; + +/// Distinct CDN hosts a depot run spreads over. Each chunk carries one URL per host, so this also +/// bounds the per-chunk URL memory. +pub const MAX_CDN_HOSTS: usize = 10; + +pub const MAX_MANIFEST_FETCH_ATTEMPTS: usize = 5; + +/// Largest decompressed manifest accepted; real ones are at most tens of MiB. +pub const MAX_MANIFEST_BYTES: usize = 512 * 1024 * 1024; +/// Largest decompressed HTTP-delivered appinfo accepted. +pub const MAX_APPINFO_BYTES: usize = 64 * 1024 * 1024; + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct CdnManifestResult { + pub raw_manifest: Vec, + pub error: String, + pub http_status: i32, +} + +impl CdnManifestResult { + pub fn ok(&self) -> bool { + self.error.is_empty() && !self.raw_manifest.is_empty() + } +} + +pub fn default_timeout() -> Duration { + Duration::from_secs(30) +} + +pub fn build_manifest_url( + server: &CContentServerDirectoryServerInfo, + depot_id: u32, + manifest_id: u64, + request_code: u64, +) -> Result { + let host = preferred_host(server).ok_or_else(|| "cdn server has no host".to_string())?; + let mut url = format!( + "{}://{}:{}/depot/{}/manifest/{}/5", + if server.use_https() { "https" } else { "http" }, + host, + server.port(), + depot_id, + manifest_id + ); + if request_code != 0 { + url.push('/'); + url.push_str(&request_code.to_string()); + } + Ok(url) +} + +pub fn build_chunk_url( + server: &CContentServerDirectoryServerInfo, + depot_id: u32, + chunk_sha: &[u8], +) -> Result { + if chunk_sha.is_empty() { + return Err("empty chunk sha".to_string()); + } + let host = preferred_host(server).ok_or_else(|| "cdn server has no host".to_string())?; + Ok(format!( + "{}://{}:{}/depot/{}/chunk/{}", + if server.use_https() { "https" } else { "http" }, + host, + server.port(), + depot_id, + hex_encode(chunk_sha) + )) +} + +/// The per-host key the fetch core caps concurrency on (vhost when present, as the URL uses it). +pub fn host_key(server: &CContentServerDirectoryServerInfo) -> String { + preferred_host(server).unwrap_or_default().to_string() +} + +/// Usable servers (not China-only, with a host), de-duplicated by host key, in directory order, +/// at most [`MAX_CDN_HOSTS`]. +pub fn usable_servers( + servers: &[CContentServerDirectoryServerInfo], +) -> Vec { + let mut out: Vec = Vec::new(); + for server in servers { + if server.steam_china_only || server.host.is_empty() { + continue; + } + let key = host_key(server); + if out.iter().any(|s| host_key(s) == key) { + continue; + } + out.push(server.clone()); + if out.len() >= MAX_CDN_HOSTS { + break; + } + } + out +} + +pub fn fetch_manifest( + server: &CContentServerDirectoryServerInfo, + depot_id: u32, + manifest_id: u64, + request_code: u64, + ca_bundle_path: &str, + timeout: Duration, +) -> CdnManifestResult { + let url = match build_manifest_url(server, depot_id, manifest_id, request_code) { + Ok(url) => url, + Err(error) => { + return CdnManifestResult { + error, + ..Default::default() + } + } + }; + match crate::steam::http::get(&url, timeout, ca_bundle_path) { + Ok(response) => validate_manifest_response( + response.status as i32, + response.body, + response.content_length, + ), + Err(error) => CdnManifestResult { + error, + ..Default::default() + }, + } +} + +/// Tries the servers in order (wrapping) with the shared back-off, up to +/// [`MAX_MANIFEST_FETCH_ATTEMPTS`] attempts. +pub fn fetch_manifest_with_retry( + servers: &[CContentServerDirectoryServerInfo], + depot_id: u32, + manifest_id: u64, + request_code: u64, + ca_bundle_path: &str, + cancel: &std::sync::atomic::AtomicBool, +) -> CdnManifestResult { + if servers.is_empty() { + return CdnManifestResult { + error: "no CDN servers available".to_string(), + ..Default::default() + }; + } + let mut last = CdnManifestResult::default(); + for attempt in 0..MAX_MANIFEST_FETCH_ATTEMPTS { + if attempt > 0 { + std::thread::sleep(Duration::from_millis( + crate::fetch_tuning::retry_backoff_millis(attempt as u32), + )); + } + if cancel.load(std::sync::atomic::Ordering::Relaxed) { + return CdnManifestResult { + error: "cancelled".to_string(), + ..Default::default() + }; + } + let server = &servers[attempt % servers.len()]; + last = fetch_manifest( + server, + depot_id, + manifest_id, + request_code, + ca_bundle_path, + default_timeout(), + ); + if last.ok() { + return last; + } + } + last +} + +/// HTTP-delivered PICS appinfo URL (large appinfo the CM did not inline). +pub fn build_appinfo_url(http_host: &str, app_id: u32, sha: &[u8]) -> String { + format!( + "http://{}/appinfo/{}/sha/{}.txt.gz", + http_host, + app_id, + hex_encode(sha) + ) +} + +/// Fetch + gunzip an HTTP-delivered appinfo blob (same VDF as an inline `buffer`). +pub fn fetch_appinfo( + http_host: &str, + app_id: u32, + sha: &[u8], + ca_bundle_path: &str, + timeout: Duration, +) -> Option> { + if http_host.is_empty() || sha.is_empty() { + return None; + } + let url = build_appinfo_url(http_host, app_id, sha); + let response = crate::steam::http::get(&url, timeout, ca_bundle_path).ok()?; + if response.status != 200 || response.body.is_empty() { + return None; + } + maybe_gunzip(response.body, MAX_APPINFO_BYTES) +} + +pub fn validate_manifest_response( + http_status: i32, + body: Vec, + content_length: Option, +) -> CdnManifestResult { + if http_status != 200 { + return CdnManifestResult { + http_status, + error: format!("HTTP status {http_status}"), + ..Default::default() + }; + } + if let Some(expected) = content_length { + if body.len() as u64 != expected { + return CdnManifestResult { + http_status, + error: "manifest body truncated (length mismatch)".to_string(), + ..Default::default() + }; + } + } + let Some(raw_manifest) = unzip_first_entry(&body, MAX_MANIFEST_BYTES) else { + return CdnManifestResult { + http_status, + error: "manifest unzip failed".to_string(), + ..Default::default() + }; + }; + CdnManifestResult { + raw_manifest, + error: String::new(), + http_status, + } +} + +/// The first entry of a zip, refused when it declares or decodes to more than `limit` bytes, or +/// to a size other than the one its header declares. +pub fn unzip_first_entry(zip: &[u8], limit: usize) -> Option> { + if zip.len() < 30 || read_u32(zip, 0)? != 0x0403_4b50 { + return None; + } + let flags = read_u16(zip, 6)?; + let method = read_u16(zip, 8)?; + let comp_size = read_u32(zip, 18)? as usize; + let uncomp_size = read_u32(zip, 22)? as usize; + let name_len = read_u16(zip, 26)? as usize; + let extra_len = read_u16(zip, 28)? as usize; + + if (flags & 0x08) != 0 { + return None; + } + + let data_off = 30usize.checked_add(name_len)?.checked_add(extra_len)?; + if data_off.checked_add(comp_size)? > zip.len() { + return None; + } + if uncomp_size > limit { + return None; + } + let data = &zip[data_off..data_off + comp_size]; + + let out = match method { + 0 => data.to_vec(), + 8 => { + let mut out = Vec::with_capacity(uncomp_size); + DeflateDecoder::new(data) + .take(uncomp_size as u64 + 1) + .read_to_end(&mut out) + .ok()?; + out + } + _ => return None, + }; + (out.len() == uncomp_size).then_some(out) +} + +/// Gunzip; pass through already-inflated bytes (edge caches may decompress). Gzip data that does +/// not decode, or decodes to more than `limit` bytes, is refused. +pub fn maybe_gunzip(body: Vec, limit: usize) -> Option> { + if body.len() < 2 || body[0] != 0x1f || body[1] != 0x8b { + return (body.len() <= limit).then_some(body); + } + let mut out = Vec::new(); + GzDecoder::new(&body[..]) + .take(limit as u64 + 1) + .read_to_end(&mut out) + .ok()?; + (!out.is_empty() && out.len() <= limit).then_some(out) +} + +pub fn hex_encode(bytes: &[u8]) -> String { + crate::gog::to_hex(bytes) +} + +fn preferred_host(server: &CContentServerDirectoryServerInfo) -> Option<&str> { + if !server.vhost.is_empty() { + Some(&server.vhost) + } else if !server.host.is_empty() { + Some(&server.host) + } else { + None + } +} + +fn read_u16(buf: &[u8], off: usize) -> Option { + Some(u16::from_le_bytes(buf.get(off..off + 2)?.try_into().ok()?)) +} + +fn read_u32(buf: &[u8], off: usize) -> Option { + Some(u32::from_le_bytes(buf.get(off..off + 4)?.try_into().ok()?)) +} + +#[cfg(test)] +mod tests { + use super::*; + use flate2::{write::DeflateEncoder, Compression}; + use std::io::Write; + + #[test] + fn extracts_stored_zip_entry() { + let zip = zip_with_entry(0, b"manifest bytes"); + assert_eq!(unzip_first_entry(&zip, 64), Some(b"manifest bytes".to_vec())); + } + + #[test] + fn extracts_deflated_zip_entry() { + let mut encoder = DeflateEncoder::new(Vec::new(), Compression::default()); + encoder.write_all(b"manifest bytes").unwrap(); + let deflated = encoder.finish().unwrap(); + let zip = zip_with_compressed_entry(8, &deflated, b"manifest bytes".len() as u32); + assert_eq!(unzip_first_entry(&zip, 64), Some(b"manifest bytes".to_vec())); + } + + #[test] + fn rejects_data_descriptor_zip_entry() { + let mut zip = zip_with_entry(0, b"x"); + zip[6] = 0x08; + assert_eq!(unzip_first_entry(&zip, 64), None); + } + + #[test] + fn hex_encodes_lowercase() { + assert_eq!(hex_encode(&[0, 1, 0xab, 0xff]), "0001abff"); + } + + #[test] + fn builds_http_appinfo_url() { + assert_eq!( + build_appinfo_url("cache1.steamcontent.com", 601150, &[0xab, 0xcd, 0x01]), + "http://cache1.steamcontent.com/appinfo/601150/sha/abcd01.txt.gz" + ); + } + + #[test] + fn gunzips_gzip_and_passes_through_plain_vdf() { + use flate2::write::GzEncoder; + let mut encoder = GzEncoder::new(Vec::new(), Compression::default()); + encoder.write_all(b"\"appinfo\"{}").unwrap(); + let gz = encoder.finish().unwrap(); + assert_eq!(maybe_gunzip(gz.clone(), 64).unwrap(), b"\"appinfo\"{}"); + assert_eq!(maybe_gunzip(b"\"appinfo\"{}".to_vec(), 64).unwrap(), b"\"appinfo\"{}"); + assert_eq!(maybe_gunzip(gz, 4), None); + assert_eq!(maybe_gunzip(vec![0x1f, 0x8b, 0, 0], 64), None); + } + + #[test] + fn refuses_zip_entries_over_the_limit_or_their_declared_size() { + let mut encoder = DeflateEncoder::new(Vec::new(), Compression::default()); + encoder.write_all(&[7u8; 4096]).unwrap(); + let deflated = encoder.finish().unwrap(); + assert!(unzip_first_entry(&zip_with_compressed_entry(8, &deflated, 4096), 4096).is_some()); + assert_eq!(unzip_first_entry(&zip_with_compressed_entry(8, &deflated, 4096), 4095), None); + assert_eq!(unzip_first_entry(&zip_with_compressed_entry(8, &deflated, 16), 4096), None); + } + + #[test] + fn builds_manifest_and_chunk_urls() { + let server = CContentServerDirectoryServerInfo { + host: "edge.steamcontent.com".into(), + vhost: "cdn.example".into(), + https_support: "mandatory".into(), + ..Default::default() + }; + assert_eq!( + build_manifest_url(&server, 100, 200, 300).unwrap(), + "https://cdn.example:443/depot/100/manifest/200/5/300" + ); + assert_eq!( + build_chunk_url(&server, 100, &[0xab, 0xcd]).unwrap(), + "https://cdn.example:443/depot/100/chunk/abcd" + ); + let plain = CContentServerDirectoryServerInfo { + host: "cache1.example".into(), + ..Default::default() + }; + assert_eq!( + build_manifest_url(&plain, 1, 2, 0).unwrap(), + "http://cache1.example:80/depot/1/manifest/2/5" + ); + } + + #[test] + fn usable_servers_drop_china_empty_and_duplicate_hosts() { + let server = |host: &str, vhost: &str, china: bool| CContentServerDirectoryServerInfo { + host: host.into(), + vhost: vhost.into(), + steam_china_only: china, + ..Default::default() + }; + let list = usable_servers(&[ + server("a", "", false), + server("b", "", true), + server("", "", false), + server("c", "a", false), + server("d", "", false), + ]); + let hosts: Vec<_> = list.iter().map(host_key).collect(); + assert_eq!(hosts, vec!["a", "d"]); + let many: Vec<_> = (0..20) + .map(|i| server(&format!("h{i}"), "", false)) + .collect(); + assert_eq!(usable_servers(&many).len(), MAX_CDN_HOSTS); + } + + #[test] + fn validates_http_status_lengths_and_manifest_zip() { + let zip = zip_with_entry(0, b"manifest bytes"); + let ok = validate_manifest_response(200, zip.clone(), Some(zip.len() as u64)); + assert!(ok.ok()); + assert_eq!(ok.raw_manifest, b"manifest bytes"); + let short = validate_manifest_response(200, zip, Some(999)); + assert_eq!(short.error, "manifest body truncated (length mismatch)"); + assert_eq!( + validate_manifest_response(404, vec![], None).error, + "HTTP status 404" + ); + } + + fn zip_with_entry(method: u16, data: &[u8]) -> Vec { + zip_with_compressed_entry(method, data, data.len() as u32) + } + + fn zip_with_compressed_entry(method: u16, data: &[u8], uncomp_size: u32) -> Vec { + let mut out = Vec::new(); + out.extend_from_slice(&0x0403_4b50u32.to_le_bytes()); + out.extend_from_slice(&20u16.to_le_bytes()); + out.extend_from_slice(&0u16.to_le_bytes()); + out.extend_from_slice(&method.to_le_bytes()); + out.extend_from_slice(&0u16.to_le_bytes()); + out.extend_from_slice(&0u16.to_le_bytes()); + out.extend_from_slice(&0u32.to_le_bytes()); + out.extend_from_slice(&(data.len() as u32).to_le_bytes()); + out.extend_from_slice(&uncomp_size.to_le_bytes()); + out.extend_from_slice(&1u16.to_le_bytes()); + out.extend_from_slice(&0u16.to_le_bytes()); + out.extend_from_slice(b"x"); + out.extend_from_slice(data); + out + } +} diff --git a/app/src/main/rust/stores/src/steam/cm_client.rs b/app/src/main/rust/stores/src/steam/cm_client.rs new file mode 100644 index 0000000000..e49c6f2833 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/cm_client.rs @@ -0,0 +1,873 @@ +//! CM session state and message builders: logon with a refresh token, heartbeat, log-off, and the +//! requests a download store needs (PICS, depot keys, manifest request codes, CDN server list, +//! free licenses). Social, stats, cloud, lobby and ticket messages are not part of this port. + +use crate::steam::cmsg_protobuf_header::{CMsgProtoBufHeader, INVALID_JOB_ID}; +use crate::steam::crypto::generate_session_key; +use crate::steam::emsg::EMsg; +use crate::steam::job_manager::JobResult; +use crate::steam::pb::ccontentserverdirectory::{ + CContentServerDirectoryGetManifestRequestCodeRequest, + CContentServerDirectoryGetServersForSteamPipeRequest, +}; +use crate::steam::pb::cmsg_client_get_depot_decryption_key::CMsgClientGetDepotDecryptionKey; +use crate::steam::pb::cmsg_client_license_list::{CMsgClientLicenseList, License}; +use crate::steam::pb::cmsg_client_pics::{ + CMsgClientPICSAccessTokenRequest, CMsgClientPICSProductInfoRequest, PicsAppInfoReq, + PicsPackageInfoReq, +}; +use crate::steam::pb::cmsg_client_request_free_license::CMsgClientRequestFreeLicense; +use crate::steam::pb::cmsg_clientserver_login::{ + CMsgClientHeartBeat, CMsgClientHello, CMsgClientLogOff, CMsgClientLogon, + CMsgClientLogonResponse, +}; +use crate::steam::proto_envelope::encode_proto_envelope; +use flate2::read::{GzDecoder, ZlibDecoder}; +use std::io::Read; +use std::sync::atomic::{AtomicI32, AtomicU32, AtomicU64, AtomicU8, Ordering}; +use std::sync::Mutex; + +/// Sent as `machine_id` in the logon. +pub const MACHINE_ID: &[u8] = b"DroidDeck-Steam"; +const LOGON_PROTOCOL_VERSION: u32 = 65580; +const LOGON_CLIENT_OS_TYPE: u32 = 16; + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[repr(u8)] +pub enum ClientState { + Disconnected, + Connecting, + Connected, + LoggedOn, +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum InboundAction { + DeliverJob(JobResult), + Multi, + PicsProductInfo, + LogonOk, + LoggedOff, + LicenseList(usize), + ClientMessage, + Ignored, + ParseFailed(&'static str), +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct CMsgMultiBody { + pub size_unzipped: u32, + pub message_body: Vec, +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct OutboundProtoMessage { + pub emsg: EMsg, + pub routing_appid: u32, + pub body: Vec, + pub wire: Vec, +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct OutboundServiceCall { + pub method_name: String, + pub authed: bool, + pub job_id: u64, + pub request_body: Vec, + pub wire: Vec, +} + +pub struct CMClientCore { + state: AtomicU8, + steam_id: AtomicU64, + session_id: AtomicI32, + cell_id: AtomicU32, + /// EResult of the last logon response or log-off (0 = none yet). + last_logon_eresult: AtomicI32, + license_list: Mutex>>, + outbound_wires: Mutex>>, +} + +impl Default for CMClientCore { + fn default() -> Self { + Self { + state: AtomicU8::new(ClientState::Disconnected as u8), + steam_id: AtomicU64::new(0), + session_id: AtomicI32::new(0), + cell_id: AtomicU32::new(0), + last_logon_eresult: AtomicI32::new(0), + license_list: Mutex::new(None), + outbound_wires: Mutex::new(Vec::new()), + } + } +} + +impl CMClientCore { + pub fn state(&self) -> ClientState { + match self.state.load(Ordering::Relaxed) { + 1 => ClientState::Connecting, + 2 => ClientState::Connected, + 3 => ClientState::LoggedOn, + _ => ClientState::Disconnected, + } + } + + pub fn set_state(&self, state: ClientState) { + self.state.store(state as u8, Ordering::Relaxed); + } + + pub fn reset_session_identity(&self) { + self.steam_id.store(0, Ordering::Relaxed); + self.session_id.store(0, Ordering::Relaxed); + // Unsent wires can hold the logon token. + let mut queue = self.outbound_wires.lock().expect("outbound queue poisoned"); + for wire in queue.iter_mut() { + zeroize::Zeroize::zeroize(wire); + } + queue.clear(); + } + + pub fn steam_id(&self) -> u64 { + self.steam_id.load(Ordering::Relaxed) + } + + pub fn session_id(&self) -> i32 { + self.session_id.load(Ordering::Relaxed) + } + + pub fn cell_id(&self) -> u32 { + self.cell_id.load(Ordering::Relaxed) + } + + pub fn last_logon_eresult(&self) -> i32 { + self.last_logon_eresult.load(Ordering::Acquire) + } + + pub fn clear_last_logon_eresult(&self) { + self.last_logon_eresult.store(0, Ordering::Relaxed); + } + + /// The license list Steam pushed after logon; `None` until it arrived. + pub fn license_list(&self) -> Option> { + self.license_list + .lock() + .expect("license list poisoned") + .clone() + } + + pub fn enqueue_proto_message(&self, message: Option) -> bool { + let Some(message) = message else { + return false; + }; + self.enqueue_wire(message.wire) + } + + pub fn enqueue_wire(&self, wire: Vec) -> bool { + if wire.is_empty() { + return false; + } + self.outbound_wires + .lock() + .expect("outbound queue poisoned") + .push(wire); + true + } + + pub fn restore_outbound_wires_front(&self, mut wires: Vec>) { + if wires.is_empty() { + return; + } + let mut queue = self.outbound_wires.lock().expect("outbound queue poisoned"); + if queue.is_empty() { + *queue = wires; + return; + } + let mut restored = Vec::with_capacity(wires.len() + queue.len()); + restored.append(&mut wires); + restored.append(&mut queue); + *queue = restored; + } + + pub fn take_outbound_wires(&self) -> Vec> { + std::mem::take(&mut *self.outbound_wires.lock().expect("outbound queue poisoned")) + } + + pub fn build_proto_message(&self, emsg: EMsg, body: &[u8], routing_appid: u32) -> Vec { + let mut header = CMsgProtoBufHeader { + steamid: self.steam_id(), + client_sessionid: self.session_id(), + routing_appid, + ..Default::default() + }; + if emsg == EMsg::CLIENT_LOGON && header.steamid == 0 { + header.steamid = 0x0110_0001_0000_0000; + } + encode_proto_envelope(emsg, &header, body) + } + + pub fn build_client_hello(&self) -> OutboundProtoMessage { + let body = CMsgClientHello::default().serialize(); + let wire = self.build_proto_message(EMsg::CLIENT_HELLO, &body, 0); + OutboundProtoMessage { + emsg: EMsg::CLIENT_HELLO, + routing_appid: 0, + body, + wire, + } + } + + pub fn build_heartbeat(&self) -> OutboundProtoMessage { + let body = CMsgClientHeartBeat::default().serialize(); + let wire = self.build_proto_message(EMsg::CLIENT_HEART_BEAT, &body, 0); + OutboundProtoMessage { + emsg: EMsg::CLIENT_HEART_BEAT, + routing_appid: 0, + body, + wire, + } + } + + pub fn build_logoff(&self) -> Option { + if self.state() != ClientState::LoggedOn { + return None; + } + self.build_outbound_proto_message(EMsg::CLIENT_LOG_OFF, CMsgClientLogOff.serialize(), 0) + } + + /// `ClientLogon` carrying the saved refresh token as `access_token`. The returned wire holds + /// the token; drop it as soon as it is queued. + pub fn build_logon_with_refresh_token( + &self, + refresh_token: &str, + account_name: &str, + client_supplied_steam_id: u64, + ) -> Option { + if self.state() != ClientState::Connected || refresh_token.is_empty() { + return None; + } + let mut msg = CMsgClientLogon { + access_token: refresh_token.to_string(), + account_name: account_name.to_string(), + client_supplied_steam_id, + machine_id: MACHINE_ID.to_vec(), + protocol_version: LOGON_PROTOCOL_VERSION, + client_os_type: LOGON_CLIENT_OS_TYPE, + supports_rate_limit_response: true, + ..Default::default() + }; + if let Some(key) = generate_session_key() { + let mut client_instance_id = 0u64; + for (idx, byte) in key.bytes.iter().take(8).enumerate() { + client_instance_id |= (*byte as u64) << (idx * 8); + } + msg.client_instance_id = client_instance_id.max(1); + let mut login_id = 0u32; + for (idx, byte) in key.bytes.iter().skip(8).take(4).enumerate() { + login_id |= (*byte as u32) << (idx * 8); + } + msg.obfuscated_private_ip = login_id.max(1); + } + let body = msg.serialize(); + zeroize::Zeroize::zeroize(&mut msg.access_token); + let wire = self.build_proto_message(EMsg::CLIENT_LOGON, &body, 0); + let mut body = body; + zeroize::Zeroize::zeroize(&mut body); + Some(OutboundProtoMessage { + emsg: EMsg::CLIENT_LOGON, + routing_appid: 0, + body: Vec::new(), + wire, + }) + } + + pub fn build_service_method_call( + &self, + method_name: &str, + authed: bool, + job_id: u64, + request_body: &[u8], + ) -> Vec { + let header = CMsgProtoBufHeader { + steamid: self.steam_id(), + client_sessionid: self.session_id(), + jobid_source: job_id, + jobid_target: INVALID_JOB_ID, + target_job_name: method_name.to_string(), + ..Default::default() + }; + let emsg = if authed { + EMsg::SERVICE_METHOD_CALL_FROM_CLIENT + } else { + EMsg::SERVICE_METHOD_CALL_FROM_CLIENT_NON_AUTHED + }; + encode_proto_envelope(emsg, &header, request_body) + } + + pub fn build_outbound_proto_message( + &self, + emsg: EMsg, + body: Vec, + routing_appid: u32, + ) -> Option { + if self.state() != ClientState::LoggedOn { + return None; + } + let wire = self.build_proto_message(emsg, &body, routing_appid); + Some(OutboundProtoMessage { + emsg, + routing_appid, + body, + wire, + }) + } + + pub fn build_job_proto_message( + &self, + emsg: EMsg, + job_id: u64, + body: Vec, + routing_appid: u32, + ) -> Option { + if self.state() != ClientState::LoggedOn { + return None; + } + let header = CMsgProtoBufHeader { + steamid: self.steam_id(), + client_sessionid: self.session_id(), + routing_appid, + jobid_source: job_id, + jobid_target: INVALID_JOB_ID, + ..Default::default() + }; + let wire = encode_proto_envelope(emsg, &header, &body); + Some(OutboundProtoMessage { + emsg, + routing_appid, + body, + wire, + }) + } + + pub fn build_authed_service_call( + &self, + method_name: &str, + job_id: u64, + request_body: Vec, + ) -> Option { + if self.state() != ClientState::LoggedOn { + return None; + } + let wire = self.build_service_method_call(method_name, true, job_id, &request_body); + Some(OutboundServiceCall { + method_name: method_name.to_string(), + authed: true, + job_id, + request_body, + wire, + }) + } + + pub fn build_get_depot_decryption_key( + &self, + depot_id: u32, + app_id: u32, + job_id: u64, + ) -> Option { + if depot_id == 0 || app_id == 0 { + return None; + } + self.build_job_proto_message( + EMsg::CLIENT_GET_DEPOT_DECRYPTION_KEY, + job_id, + CMsgClientGetDepotDecryptionKey { depot_id, app_id }.serialize(), + 0, + ) + } + + pub fn build_manifest_request_code_call( + &self, + app_id: u32, + depot_id: u32, + manifest_id: u64, + branch: &str, + job_id: u64, + ) -> Option { + if app_id == 0 || depot_id == 0 || manifest_id == 0 { + return None; + } + let lower = branch.to_ascii_lowercase(); + let app_branch = if lower.is_empty() || lower == "public" { + String::new() + } else { + branch.to_string() + }; + self.build_authed_service_call( + "ContentServerDirectory.GetManifestRequestCode#1", + job_id, + CContentServerDirectoryGetManifestRequestCodeRequest { + app_id, + depot_id, + manifest_id, + app_branch, + branch_password_hash: String::new(), + } + .serialize(), + ) + } + + pub fn build_get_cdn_servers_call( + &self, + cell_id: u32, + job_id: u64, + ) -> Option { + self.build_authed_service_call( + "ContentServerDirectory.GetServersForSteamPipe#1", + job_id, + CContentServerDirectoryGetServersForSteamPipeRequest { + cell_id, + ..Default::default() + } + .serialize(), + ) + } + + pub fn build_pics_access_tokens( + &self, + packageids: Vec, + appids: Vec, + job_id: u64, + ) -> Option { + self.build_job_proto_message( + EMsg::CLIENT_PICS_ACCESS_TOKEN_REQUEST, + job_id, + CMsgClientPICSAccessTokenRequest { packageids, appids }.serialize(), + 0, + ) + } + + pub fn build_pics_product_info( + &self, + packages: Vec, + apps: Vec, + meta_data_only: bool, + job_id: u64, + ) -> Option { + self.build_job_proto_message( + EMsg::CLIENT_PICS_PRODUCT_INFO_REQUEST, + job_id, + CMsgClientPICSProductInfoRequest { + packages, + apps, + meta_data_only, + single_response: false, + ..Default::default() + } + .serialize(), + 0, + ) + } + + /// Succeeds only for apps Steam gives away; a paid unowned app comes back with a non-OK + /// EResult in the response body. + pub fn build_request_free_license( + &self, + app_ids: &[u32], + job_id: u64, + ) -> Option { + if app_ids.is_empty() { + return None; + } + self.build_job_proto_message( + EMsg::CLIENT_REQUEST_FREE_LICENSE, + job_id, + CMsgClientRequestFreeLicense { + appids: app_ids.to_vec(), + } + .serialize(), + 0, + ) + } + + pub fn route_inbound( + &self, + emsg: EMsg, + header: &CMsgProtoBufHeader, + body: &[u8], + ) -> InboundAction { + match emsg { + EMsg::SERVICE_METHOD_RESPONSE + | EMsg::CLIENT_PICS_ACCESS_TOKEN_RESPONSE + | EMsg::CLIENT_GET_DEPOT_DECRYPTION_KEY_RESPONSE + // 5573 carries its own EResult in the body; the job only reports transport health. + | EMsg::CLIENT_REQUEST_FREE_LICENSE_RESPONSE => { + if header.jobid_target == INVALID_JOB_ID { + InboundAction::Ignored + } else { + let eresult = if header.eresult == -1 { + 1 + } else { + header.eresult + }; + InboundAction::DeliverJob(JobResult { + eresult, + error_message: header.error_message.clone(), + body: body.to_vec(), + synthetic_failure: false, + }) + } + } + EMsg::CLIENT_PICS_PRODUCT_INFO_RESPONSE => InboundAction::PicsProductInfo, + EMsg::MULTI => InboundAction::Multi, + EMsg::CLIENT_LOGON_RESPONSE => { + let Some(resp) = CMsgClientLogonResponse::deserialize(body) else { + return InboundAction::ParseFailed("ClientLogonResponse"); + }; + // The eresult is published last (Release) so a waiter that sees it also sees the + // state and ids that go with it. + let action = if resp.eresult == 1 { + self.state + .store(ClientState::LoggedOn as u8, Ordering::Relaxed); + self.steam_id + .store(resp.client_supplied_steamid, Ordering::Relaxed); + self.session_id + .store(header.client_sessionid, Ordering::Relaxed); + self.cell_id.store(resp.cell_id, Ordering::Relaxed); + InboundAction::LogonOk + } else { + InboundAction::LoggedOff + }; + self.last_logon_eresult + .store(resp.eresult, Ordering::Release); + action + } + EMsg::CLIENT_LOGGED_OFF | EMsg::CLIENT_SERVER_UNAVAILABLE => { + if self.state() == ClientState::LoggedOn { + self.state + .store(ClientState::Connected as u8, Ordering::Relaxed); + } + if emsg == EMsg::CLIENT_LOGGED_OFF { + let eresult = crate::steam::pb::cmsg_clientserver_login::CMsgClientLoggedOff::deserialize(body) + .map(|m| m.eresult) + .unwrap_or(2); + self.last_logon_eresult.store(eresult, Ordering::Relaxed); + } + self.steam_id.store(0, Ordering::Relaxed); + self.session_id.store(0, Ordering::Relaxed); + InboundAction::LoggedOff + } + EMsg::CLIENT_LICENSE_LIST => { + let Some(msg) = CMsgClientLicenseList::deserialize(body) else { + return InboundAction::ParseFailed("ClientLicenseList"); + }; + let count = msg.licenses.len(); + // A refused list keeps the last good snapshot (or none, so the load reports it). + if msg.eresult != 1 && msg.licenses.is_empty() { + return InboundAction::ParseFailed("ClientLicenseList refused"); + } + *self.license_list.lock().expect("license list poisoned") = Some(msg.licenses); + InboundAction::LicenseList(count) + } + _ => InboundAction::ClientMessage, + } + } +} + +pub fn parse_cmsg_multi(body: &[u8]) -> Option { + let mut reader = crate::steam::proto_wire::Reader::new(body); + let mut multi = CMsgMultiBody::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(multi); + }; + match tag.field_number { + 1 => multi.size_unzipped = reader.u32()?, + 2 => multi.message_body = reader.bytes()?.to_vec(), + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(multi) +} + +pub fn decode_multi_records(body: &[u8]) -> Option>> { + let multi = parse_cmsg_multi(body)?; + let records = if multi.size_unzipped > 0 { + gunzip_or_zlib(&multi.message_body, multi.size_unzipped as usize)? + } else { + multi.message_body + }; + + let mut out = Vec::new(); + let mut offset = 0usize; + while offset + 4 <= records.len() { + let inner_len = crate::steam::wire_format::read_u32_le(&records[offset..]) as usize; + offset += 4; + if inner_len == 0 || offset + inner_len > records.len() { + return None; + } + out.push(records[offset..offset + inner_len].to_vec()); + offset += inner_len; + } + (offset == records.len()).then_some(out) +} + +/// Largest MULTI batch accepted once decompressed. +const MAX_MULTI_UNZIPPED: usize = 64 << 20; + +fn gunzip_or_zlib(compressed: &[u8], expected_size: usize) -> Option> { + if expected_size == 0 || expected_size > MAX_MULTI_UNZIPPED { + return None; + } + let limit = expected_size as u64 + 1; + let mut out = Vec::with_capacity(expected_size); + if GzDecoder::new(compressed).take(limit).read_to_end(&mut out).is_ok() && out.len() == expected_size { + return Some(out); + } + out.clear(); + if ZlibDecoder::new(compressed).take(limit).read_to_end(&mut out).is_ok() && out.len() == expected_size { + return Some(out); + } + None +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::steam::proto_envelope::decode_proto_envelope; + use crate::steam::proto_wire::{WireType, Writer}; + use flate2::write::GzEncoder; + use flate2::Compression; + use std::io::Write; + + #[test] + fn service_method_call_sets_authed_and_non_authed_emsgs() { + let core = CMClientCore::default(); + core.steam_id.store(123, Ordering::Relaxed); + core.session_id.store(7, Ordering::Relaxed); + let authed = decode_proto_envelope(&core.build_service_method_call( + "ContentServerDirectory.GetServersForSteamPipe#1", + true, + 55, + b"req", + )) + .unwrap(); + assert_eq!(authed.emsg, EMsg::SERVICE_METHOD_CALL_FROM_CLIENT); + assert_eq!(authed.header.steamid, 123); + assert_eq!(authed.header.client_sessionid, 7); + assert_eq!(authed.header.jobid_source, 55); + assert_eq!(authed.body, b"req"); + let non = decode_proto_envelope(&core.build_service_method_call("X.Y#1", false, 56, b"")) + .unwrap(); + assert_eq!(non.emsg, EMsg::SERVICE_METHOD_CALL_FROM_CLIENT_NON_AUTHED); + } + + #[test] + fn cmsg_multi_decodes_plain_and_gzip_records() { + let first = encode_proto_envelope(EMsg::CLIENT_HELLO, &CMsgProtoBufHeader::default(), b"a"); + let second = encode_proto_envelope( + EMsg::CLIENT_LICENSE_LIST, + &CMsgProtoBufHeader::default(), + b"b", + ); + let mut records = Vec::new(); + records.extend_from_slice(&(first.len() as u32).to_le_bytes()); + records.extend_from_slice(&first); + records.extend_from_slice(&(second.len() as u32).to_le_bytes()); + records.extend_from_slice(&second); + + let mut body = Vec::new(); + Writer::new(&mut body).bytes_field(2, &records); + assert_eq!( + decode_multi_records(&body).unwrap(), + vec![first.clone(), second.clone()] + ); + + let mut encoder = GzEncoder::new(Vec::new(), Compression::default()); + encoder.write_all(&records).unwrap(); + let zipped = encoder.finish().unwrap(); + let mut zipped_body = Vec::new(); + { + let mut writer = Writer::new(&mut zipped_body); + writer.uint32_field(1, records.len() as u32); + writer.bytes_field(2, &zipped); + } + assert_eq!( + decode_multi_records(&zipped_body).unwrap(), + vec![first, second] + ); + } + + #[test] + fn logon_needs_connected_state_and_carries_token_and_machine_id() { + let core = CMClientCore::default(); + assert!(core + .build_logon_with_refresh_token("refresh", "ada", 0) + .is_none()); + core.set_state(ClientState::Connected); + let logon = core + .build_logon_with_refresh_token("refresh", "ada", 123) + .unwrap(); + assert_eq!(logon.emsg, EMsg::CLIENT_LOGON); + let decoded = decode_proto_envelope(&logon.wire).unwrap(); + assert_eq!(decoded.header.steamid, 0x0110_0001_0000_0000); + assert!(decoded.body.windows(7).any(|w| w == b"refresh")); + assert!(decoded + .body + .windows(MACHINE_ID.len()) + .any(|w| w == MACHINE_ID)); + assert!(logon.body.is_empty()); + assert!(core.build_logon_with_refresh_token("", "ada", 1).is_none()); + + assert!(core.build_logoff().is_none()); + core.set_state(ClientState::LoggedOn); + assert_eq!(core.build_logoff().unwrap().emsg, EMsg::CLIENT_LOG_OFF); + } + + #[test] + fn logon_response_updates_session_identity_and_eresult() { + let core = CMClientCore::default(); + let mut body = Vec::new(); + { + let mut w = Writer::new(&mut body); + w.int32_field(1, 1); + w.tag(20, WireType::Fixed64); + w.raw_bytes(&765u64.to_le_bytes()); + } + let header = CMsgProtoBufHeader { + client_sessionid: 42, + ..Default::default() + }; + assert_eq!( + core.route_inbound(EMsg::CLIENT_LOGON_RESPONSE, &header, &body), + InboundAction::LogonOk + ); + assert_eq!(core.state(), ClientState::LoggedOn); + assert_eq!(core.steam_id(), 765); + assert_eq!(core.session_id(), 42); + assert_eq!(core.last_logon_eresult(), 1); + + assert_eq!( + core.route_inbound(EMsg::CLIENT_LOGGED_OFF, &CMsgProtoBufHeader::default(), &[]), + InboundAction::LoggedOff + ); + assert_eq!(core.state(), ClientState::Connected); + assert_eq!(core.steam_id(), 0); + + let mut refused = Vec::new(); + Writer::new(&mut refused).int32_field(1, 5); + let fresh = CMClientCore::default(); + assert_eq!( + fresh.route_inbound(EMsg::CLIENT_LOGON_RESPONSE, &header, &refused), + InboundAction::LoggedOff + ); + assert_eq!(fresh.last_logon_eresult(), 5); + assert_eq!(fresh.state(), ClientState::Disconnected); + } + + #[test] + fn license_list_push_is_stored() { + let core = CMClientCore::default(); + assert!(core.license_list().is_none()); + let mut refused = Vec::new(); + Writer::new(&mut refused).int32_field(1, 2); + assert!(matches!( + core.route_inbound(EMsg::CLIENT_LICENSE_LIST, &CMsgProtoBufHeader::default(), &refused), + InboundAction::ParseFailed(_) + )); + assert!(core.license_list().is_none()); + let mut ok = Vec::new(); + Writer::new(&mut ok).int32_field(1, 1); + assert_eq!( + core.route_inbound(EMsg::CLIENT_LICENSE_LIST, &CMsgProtoBufHeader::default(), &ok), + InboundAction::LicenseList(0) + ); + assert_eq!(core.license_list(), Some(Vec::new())); + } + + #[test] + fn downloader_builders_use_the_expected_messages() { + let core = logged_on_core(); + let depot_key = core.build_get_depot_decryption_key(11, 22, 33).unwrap(); + let decoded = decode_proto_envelope(&depot_key.wire).unwrap(); + assert_eq!(decoded.emsg, EMsg::CLIENT_GET_DEPOT_DECRYPTION_KEY); + assert_eq!(decoded.header.jobid_source, 33); + + let public = core + .build_manifest_request_code_call(480, 100, 555, "public", 44) + .unwrap(); + assert_eq!( + public.method_name, + "ContentServerDirectory.GetManifestRequestCode#1" + ); + assert!(!public.request_body.windows(6).any(|w| w == b"public")); + let beta = core + .build_manifest_request_code_call(480, 100, 555, "Beta", 45) + .unwrap(); + assert!(beta.request_body.windows(4).any(|w| w == b"Beta")); + + let servers = core.build_get_cdn_servers_call(7, 46).unwrap(); + assert_eq!( + servers.method_name, + "ContentServerDirectory.GetServersForSteamPipe#1" + ); + + let product = core + .build_pics_product_info( + vec![PicsPackageInfoReq { + packageid: 100, + access_token: 7, + }], + vec![PicsAppInfoReq { + appid: 480, + access_token: 8, + only_public_obsolete: false, + }], + true, + 3, + ) + .unwrap(); + assert_eq!(product.emsg, EMsg::CLIENT_PICS_PRODUCT_INFO_REQUEST); + assert!(product.body.windows(2).any(|w| w == [0x18, 1])); + + let free = core.build_request_free_license(&[440], 50).unwrap(); + assert_eq!(free.emsg, EMsg::CLIENT_REQUEST_FREE_LICENSE); + assert_eq!(free.body, [0x10, 0xb8, 0x03]); + assert!(core.build_request_free_license(&[], 51).is_none()); + } + + #[test] + fn job_responses_are_delivered_and_builders_need_logon() { + let core = logged_on_core(); + let header = CMsgProtoBufHeader { + jobid_target: 50, + ..Default::default() + }; + assert!(matches!( + core.route_inbound(EMsg::CLIENT_REQUEST_FREE_LICENSE_RESPONSE, &header, &[]), + InboundAction::DeliverJob(_) + )); + assert_eq!( + core.route_inbound( + EMsg::SERVICE_METHOD_RESPONSE, + &CMsgProtoBufHeader::default(), + &[] + ), + InboundAction::Ignored + ); + let offline = CMClientCore::default(); + assert!(offline.build_get_depot_decryption_key(1, 2, 3).is_none()); + assert!(offline.build_get_cdn_servers_call(0, 1).is_none()); + } + + fn logged_on_core() -> CMClientCore { + let core = CMClientCore::default(); + core.state + .store(ClientState::LoggedOn as u8, Ordering::Relaxed); + core.steam_id.store(7656119, Ordering::Relaxed); + core.session_id.store(42, Ordering::Relaxed); + core + } +} diff --git a/app/src/main/rust/stores/src/steam/cm_runtime.rs b/app/src/main/rust/stores/src/steam/cm_runtime.rs new file mode 100644 index 0000000000..cfe8663f72 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/cm_runtime.rs @@ -0,0 +1,594 @@ +use crate::steam::cm_client::{decode_multi_records, CMClientCore, ClientState, InboundAction}; +use crate::steam::cmsg_protobuf_header::{CMsgProtoBufHeader, INVALID_JOB_ID}; +use crate::steam::emsg::{has_proto_flag, strip_proto_flag, EMsg}; +use crate::steam::encrypted_channel::{ChannelDisconnectReason, ChannelState, EncryptedChannel}; +use crate::steam::heartbeat::Heartbeat; +use crate::steam::job_manager::{JobManager, JobResult}; +use crate::steam::pb::cmsg_client_pics::CMsgClientPICSProductInfoResponse; +use crate::steam::pb::cmsg_clientserver_login::CMsgClientLogonResponse; +use crate::steam::proto_envelope::decode_proto_envelope; +use crate::steam::transport::Transport; +use crate::steam::wire_format::read_u32_le; +use std::collections::HashMap; +use std::panic::{self, AssertUnwindSafe}; +use std::sync::{Arc, Mutex}; +use std::time::Duration; +use zeroize::Zeroize; + +type StateCallback = Box; +type ClientMessageCallback = Box; + +/// MULTI batches nest at most this deep (Steam sends one level). +const MAX_MULTI_DEPTH: u32 = 2; + +pub struct CMClientRuntime { + flush: Mutex<()>, + core: Arc, + channel: EncryptedChannel, + jobs: JobManager, + heartbeat: Mutex, + pics_product_info: Mutex>, + on_state: Mutex>, + on_client_message: Mutex>, +} + +impl CMClientRuntime { + pub fn new(core: Arc, transport: Box) -> Arc { + let runtime = Arc::new(Self { + flush: Mutex::new(()), + core, + channel: EncryptedChannel::new(transport), + jobs: JobManager::default(), + heartbeat: Mutex::new(Heartbeat::default()), + pics_product_info: Mutex::new(HashMap::new()), + on_state: Mutex::new(None), + on_client_message: Mutex::new(None), + }); + + let weak = Arc::downgrade(&runtime); + runtime.channel.set_on_connected(move || { + if let Some(runtime) = weak.upgrade() { + runtime.on_channel_connected(); + } + }); + + let weak = Arc::downgrade(&runtime); + runtime.channel.set_on_disconnected(move |reason, detail| { + if let Some(runtime) = weak.upgrade() { + runtime.on_channel_disconnected(reason, detail); + } + }); + + let weak = Arc::downgrade(&runtime); + runtime.channel.set_on_message(move |bytes| { + if let Some(runtime) = weak.upgrade() { + runtime.handle_channel_message(bytes); + } + }); + + runtime + } + + pub fn core(&self) -> &Arc { + &self.core + } + + pub fn connect(&self, url: &str) -> bool { + self.core.set_state(ClientState::Connecting); + self.notify_state(ClientState::Connecting); + if self.channel.connect(url) { + true + } else { + self.core.set_state(ClientState::Disconnected); + self.notify_state(ClientState::Disconnected); + false + } + } + + pub fn disconnect(&self) { + self.heartbeat.lock().expect("heartbeat poisoned").stop(); + self.channel.disconnect(); + self.jobs.fail_all("CMClient disconnected"); + self.core.reset_session_identity(); + self.core.set_state(ClientState::Disconnected); + self.notify_state(ClientState::Disconnected); + } + + pub fn set_ca_bundle_path(&self, path: &str) { + self.channel.set_ca_bundle_path(path); + } + + pub fn set_on_state(&self, callback: F) + where + F: Fn(ClientState) + Send + Sync + 'static, + { + *self.on_state.lock().expect("runtime callback poisoned") = Some(Box::new(callback)); + } + + pub fn set_on_client_message(&self, callback: F) + where + F: Fn(EMsg, &CMsgProtoBufHeader, &[u8]) + Send + Sync + 'static, + { + *self + .on_client_message + .lock() + .expect("runtime callback poisoned") = Some(Box::new(callback)); + } + + pub fn next_job_id(&self) -> u64 { + self.jobs.next_job_id() + } + + pub fn track_job(&self, job_id: u64, callback: F, timeout: Option) + where + F: FnOnce(JobResult) + Send + 'static, + { + self.jobs.track(job_id, callback, timeout); + } + + pub fn flush_outbound(&self) -> usize { + if self.channel.state() != ChannelState::Encrypted { + return 0; + } + // One flush at a time, so two flushers cannot send queued wires out of order. + let _flushing = self.flush.lock().expect("flush poisoned"); + let mut wires = self.core.take_outbound_wires(); + let mut sent = 0usize; + for idx in 0..wires.len() { + if self.channel.send(&wires[idx]) { + // Outbound wires can hold the logon token; clear each one once it is sent. + wires[idx].zeroize(); + sent += 1; + continue; + } + self.core.restore_outbound_wires_front(wires.split_off(idx)); + break; + } + sent + } + + pub fn handle_channel_message(self: &Arc, bytes: &[u8]) -> InboundAction { + self.handle_message_at(bytes, 0) + } + + fn handle_message_at(self: &Arc, bytes: &[u8], depth: u32) -> InboundAction { + let Some(envelope) = decode_proto_envelope(bytes) else { + return self.handle_non_proto_message(bytes); + }; + self.process_envelope(envelope.emsg, &envelope.header, &envelope.body, depth) + } + + fn process_envelope( + self: &Arc, + emsg: EMsg, + header: &CMsgProtoBufHeader, + body: &[u8], + depth: u32, + ) -> InboundAction { + let action = self.core.route_inbound(emsg, header, body); + match &action { + InboundAction::Multi => { + if depth >= MAX_MULTI_DEPTH { + return InboundAction::ParseFailed("MULTI nested too deep"); + } + if let Some(records) = decode_multi_records(body) { + for record in records { + self.handle_message_at(&record, depth + 1); + } + } + } + InboundAction::DeliverJob(result) => { + self.jobs.deliver( + header.jobid_target, + result.eresult, + result.error_message.clone(), + &result.body, + ); + } + InboundAction::LogonOk => { + // No persona or friends traffic: this session exists only to download. + self.start_heartbeat_from_logon(body); + self.notify_state(ClientState::LoggedOn); + self.notify_client_message(emsg, header, body); + } + InboundAction::LoggedOff => { + self.heartbeat.lock().expect("heartbeat poisoned").stop(); + self.notify_state(self.core.state()); + self.notify_client_message(emsg, header, body); + } + InboundAction::Ignored | InboundAction::ParseFailed(_) => {} + InboundAction::PicsProductInfo => self.handle_pics_product_info(header, body), + InboundAction::LicenseList(_) | InboundAction::ClientMessage => { + self.notify_client_message(emsg, header, body); + } + } + action + } + + fn on_channel_connected(self: &Arc) { + // Always send ClientHello first; pre-existing queued wires (e.g. a + // logon enqueued before the channel finished negotiating) must come + // after the Hello or Steam rejects the conversation as malformed. + // If a Hello was already prequeued, do not duplicate it. + let queued = self.core.take_outbound_wires(); + let head_is_hello = queued + .first() + .and_then(|wire| decode_proto_envelope(wire)) + .is_some_and(|env| env.emsg == EMsg::CLIENT_HELLO); + let combined = if head_is_hello { + queued + } else { + let hello = self.core.build_client_hello().wire; + let mut combined = Vec::with_capacity(queued.len() + 1); + combined.push(hello); + combined.extend(queued); + combined + }; + self.core.restore_outbound_wires_front(combined); + // Connected is published only once Hello heads the queue, so a logon queued by a waiter + // that wakes on it cannot get ahead of the Hello. + self.core.set_state(ClientState::Connected); + self.notify_state(ClientState::Connected); + self.flush_outbound(); + } + + fn on_channel_disconnected(self: &Arc, _reason: ChannelDisconnectReason, detail: &str) { + self.heartbeat.lock().expect("heartbeat poisoned").stop(); + self.jobs + .fail_all(&format!("channel disconnected: {detail}")); + self.pics_product_info + .lock() + .expect("pics product info poisoned") + .clear(); + self.core.reset_session_identity(); + self.core.set_state(ClientState::Disconnected); + self.notify_state(ClientState::Disconnected); + } + + fn handle_pics_product_info(&self, header: &CMsgProtoBufHeader, body: &[u8]) { + if header.jobid_target == INVALID_JOB_ID { + return; + } + let mut pending = self + .pics_product_info + .lock() + .expect("pics product info poisoned"); + // Fragments of jobs that timed out or failed are dropped, and a late one starts nothing. + pending.retain(|job, _| self.jobs.is_tracked(*job)); + let Some(response) = CMsgClientPICSProductInfoResponse::deserialize(body) else { + pending.remove(&header.jobid_target); + drop(pending); + // 0 (Invalid) is a failure to every caller; -1 would be delivered as success. + self.jobs.deliver( + header.jobid_target, + 0, + "PICS product-info parse failed".to_string(), + &[], + ); + return; + }; + if !self.jobs.is_tracked(header.jobid_target) { + return; + } + if response.response_pending { + let acc = pending.entry(header.jobid_target).or_default(); + merge_pics_product_info(acc, response); + return; + } + let mut merged = pending.remove(&header.jobid_target).unwrap_or_default(); + merge_pics_product_info(&mut merged, response); + let body = merged.serialize(); + self.jobs + .deliver(header.jobid_target, 1, String::new(), &body); + } + + fn start_heartbeat_from_logon(self: &Arc, body: &[u8]) { + let Some(resp) = CMsgClientLogonResponse::deserialize(body) else { + return; + }; + if resp.heartbeat_seconds <= 0 { + return; + } + let weak = Arc::downgrade(self); + let interval = Duration::from_secs(resp.heartbeat_seconds as u64); + self.heartbeat + .lock() + .expect("heartbeat poisoned") + .start(interval, move || { + if let Some(runtime) = weak.upgrade() { + runtime + .core + .enqueue_wire(runtime.core.build_heartbeat().wire); + runtime.flush_outbound(); + } + }); + } + + fn handle_non_proto_message(&self, bytes: &[u8]) -> InboundAction { + if bytes.len() >= 4 { + let raw = read_u32_le(bytes); + if !has_proto_flag(raw) { + let legacy = strip_proto_flag(raw); + if legacy == EMsg::CHANNEL_ENCRYPT_REQUEST + || legacy == EMsg::CHANNEL_ENCRYPT_RESPONSE + || legacy == EMsg::CHANNEL_ENCRYPT_RESULT + { + return InboundAction::Ignored; + } + } + } + InboundAction::ParseFailed("ProtoEnvelope") + } + + fn notify_state(&self, state: ClientState) { + if let Some(callback) = self + .on_state + .lock() + .expect("runtime callback poisoned") + .as_ref() + { + let _ = panic::catch_unwind(AssertUnwindSafe(|| callback(state))); + } + } + + fn notify_client_message(&self, emsg: EMsg, header: &CMsgProtoBufHeader, body: &[u8]) { + if let Some(callback) = self + .on_client_message + .lock() + .expect("runtime callback poisoned") + .as_ref() + { + let _ = panic::catch_unwind(AssertUnwindSafe(|| callback(emsg, header, body))); + } + } +} + +fn merge_pics_product_info( + acc: &mut CMsgClientPICSProductInfoResponse, + mut next: CMsgClientPICSProductInfoResponse, +) { + acc.apps.append(&mut next.apps); + acc.packages.append(&mut next.packages); + acc.unknown_appids.append(&mut next.unknown_appids); + acc.unknown_packageids.append(&mut next.unknown_packageids); + if next.http_min_size > 0 { + acc.http_min_size = next.http_min_size; + } + if !next.http_host.is_empty() { + acc.http_host = next.http_host; + } + acc.meta_data_only = next.meta_data_only; + acc.response_pending = false; +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::steam::proto_envelope::encode_proto_envelope; + use crate::steam::proto_wire::Writer as ProtoWriter; + use crate::steam::transport::{ConnectedCallback, DisconnectedCallback, MessageCallback}; + use crate::steam::transport::{TransportDisconnectReason, TransportState}; + use crate::steam::wire_format::Writer as WireWriter; + use std::sync::mpsc; + + #[test] + fn connected_channel_sends_client_hello_and_reports_state() { + let shared = Arc::new(MockTransportState::default()); + let runtime = runtime_with_shared_transport(Arc::clone(&shared)); + let states = Arc::new(Mutex::new(Vec::new())); + let states_cb = Arc::clone(&states); + runtime.set_on_state(move |state| states_cb.lock().unwrap().push(state)); + + assert!(runtime.connect("wss://cm.example.com:443/cmsocket/")); + shared.fire_connected(); + + assert_eq!( + states.lock().unwrap().as_slice(), + &[ClientState::Connecting, ClientState::Connected] + ); + let sent = shared.take_sent(); + assert_eq!( + decode_proto_envelope(&sent[0]).unwrap().emsg, + EMsg::CLIENT_HELLO + ); + } + + #[test] + fn connected_channel_flushes_prequeued_hello_without_duplicate() { + let shared = Arc::new(MockTransportState::default()); + let runtime = runtime_with_shared_transport(Arc::clone(&shared)); + runtime + .core + .enqueue_wire(runtime.core.build_client_hello().wire); + + assert!(runtime.connect("wss://cm.example.com:443/cmsocket/")); + shared.fire_connected(); + + let sent = shared.take_sent(); + assert_eq!(sent.len(), 1); + assert_eq!( + decode_proto_envelope(&sent[0]).unwrap().emsg, + EMsg::CLIENT_HELLO + ); + } + + #[test] + fn flush_outbound_preserves_core_queue_order() { + let shared = Arc::new(MockTransportState::default()); + let runtime = runtime_with_shared_transport(Arc::clone(&shared)); + assert!(runtime.connect("wss://cm.example.com:443/cmsocket/")); + shared.fire_connected(); + shared.take_sent(); + + runtime.core.enqueue_wire(vec![1, 2, 3]); + runtime.core.enqueue_wire(vec![4, 5, 6]); + assert_eq!(runtime.flush_outbound(), 2); + assert_eq!(shared.take_sent(), vec![vec![1, 2, 3], vec![4, 5, 6]]); + } + + #[test] + fn inbound_job_response_is_delivered() { + let shared = Arc::new(MockTransportState::default()); + let runtime = runtime_with_shared_transport(shared); + let job_id = runtime.next_job_id(); + let (tx, rx) = mpsc::channel(); + runtime.track_job(job_id, move |result| tx.send(result).unwrap(), None); + + let header = CMsgProtoBufHeader { + jobid_target: job_id, + eresult: 1, + ..Default::default() + }; + let wire = encode_proto_envelope(EMsg::SERVICE_METHOD_RESPONSE, &header, b"reply"); + assert_eq!( + runtime.handle_channel_message(&wire), + InboundAction::DeliverJob(JobResult { + eresult: 1, + error_message: String::new(), + body: b"reply".to_vec(), + synthetic_failure: false, + }) + ); + assert_eq!(rx.recv().unwrap().body, b"reply"); + } + + #[test] + fn multi_records_are_redispatched() { + let shared = Arc::new(MockTransportState::default()); + let runtime = runtime_with_shared_transport(shared); + let (tx, rx) = mpsc::channel(); + runtime.set_on_client_message(move |emsg, _, body| { + tx.send((emsg, body.to_vec())).unwrap(); + }); + + let inner = encode_proto_envelope( + EMsg::CLIENT_SESSION_TOKEN, + &CMsgProtoBufHeader::default(), + &account_info_body("Ada"), + ); + let mut records = Vec::new(); + WireWriter::new(&mut records).u32(inner.len() as u32); + records.extend_from_slice(&inner); + let mut multi_body = Vec::new(); + ProtoWriter::new(&mut multi_body).bytes_field(2, &records); + let multi = encode_proto_envelope(EMsg::MULTI, &CMsgProtoBufHeader::default(), &multi_body); + + assert_eq!(runtime.handle_channel_message(&multi), InboundAction::Multi); + assert_eq!( + rx.recv().unwrap(), + (EMsg::CLIENT_SESSION_TOKEN, account_info_body("Ada")) + ); + } + + #[test] + fn legacy_channel_encrypt_frames_are_ignored() { + let shared = Arc::new(MockTransportState::default()); + let runtime = runtime_with_shared_transport(shared); + let mut legacy = Vec::new(); + WireWriter::new(&mut legacy).u32(EMsg::CHANNEL_ENCRYPT_REQUEST.0); + assert_eq!( + runtime.handle_channel_message(&legacy), + InboundAction::Ignored + ); + } + + fn runtime_with_shared_transport(shared: Arc) -> Arc { + CMClientRuntime::new( + Arc::new(CMClientCore::default()), + Box::new(MockTransport { shared }), + ) + } + + fn account_info_body(name: &str) -> Vec { + let mut body = Vec::new(); + ProtoWriter::new(&mut body).string_field(1, name); + body + } + + struct MockTransportState { + state: Mutex, + connected: Mutex>, + disconnected: Mutex>, + message: Mutex>, + sent: Mutex>>, + } + + impl Default for MockTransportState { + fn default() -> Self { + Self { + state: Mutex::new(TransportState::Disconnected), + connected: Mutex::new(None), + disconnected: Mutex::new(None), + message: Mutex::new(None), + sent: Mutex::new(Vec::new()), + } + } + } + + impl MockTransportState { + fn fire_connected(&self) { + *self.state.lock().unwrap() = TransportState::Connected; + if let Some(callback) = self.connected.lock().unwrap().as_ref() { + callback(); + } + } + + #[allow(dead_code)] + fn fire_disconnected(&self, reason: TransportDisconnectReason, detail: &str) { + *self.state.lock().unwrap() = TransportState::Disconnected; + if let Some(callback) = self.disconnected.lock().unwrap().as_ref() { + callback(reason, detail); + } + } + + #[allow(dead_code)] + fn fire_message(&self, bytes: &[u8]) { + if let Some(callback) = self.message.lock().unwrap().as_ref() { + callback(bytes); + } + } + + fn take_sent(&self) -> Vec> { + std::mem::take(&mut *self.sent.lock().unwrap()) + } + } + + struct MockTransport { + shared: Arc, + } + + impl Transport for MockTransport { + fn connect(&mut self, _url: &str) -> bool { + *self.shared.state.lock().unwrap() = TransportState::Connecting; + true + } + + fn send(&mut self, data: &[u8]) -> bool { + if self.state() != TransportState::Connected { + return false; + } + self.shared.sent.lock().unwrap().push(data.to_vec()); + true + } + + fn disconnect(&mut self) { + *self.shared.state.lock().unwrap() = TransportState::Disconnected; + } + + fn state(&self) -> TransportState { + *self.shared.state.lock().unwrap() + } + + fn set_on_message(&mut self, cb: MessageCallback) { + *self.shared.message.lock().unwrap() = Some(cb); + } + + fn set_on_connected(&mut self, cb: ConnectedCallback) { + *self.shared.connected.lock().unwrap() = Some(cb); + } + + fn set_on_disconnected(&mut self, cb: DisconnectedCallback) { + *self.shared.disconnected.lock().unwrap() = Some(cb); + } + } +} diff --git a/app/src/main/rust/stores/src/steam/cm_server.rs b/app/src/main/rust/stores/src/steam/cm_server.rs new file mode 100644 index 0000000000..1449a5a988 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/cm_server.rs @@ -0,0 +1,93 @@ +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +#[repr(u8)] +pub enum CmTransport { + #[default] + Unknown = 0, + WebSocket = 1, + Tcp = 2, +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct CmServer { + pub endpoint: String, + pub host: String, + pub port: u16, + pub transport: CmTransport, + pub realm: String, + pub datacenter: String, + pub load: i32, + pub weighted_load: f32, +} + +impl CmServer { + pub fn websocket_url(&self) -> String { + if self.transport != CmTransport::WebSocket || self.host.is_empty() || self.port == 0 { + return String::new(); + } + if self.host.contains(':') && !self.host.starts_with('[') { + format!("wss://[{}]:{}/cmsocket/", self.host, self.port) + } else { + format!("wss://{}:{}/cmsocket/", self.host, self.port) + } + } +} + +pub fn parse_endpoint(endpoint: &str) -> Option<(String, u16)> { + let colon = endpoint.rfind(':')?; + if colon == 0 || colon + 1 == endpoint.len() { + return None; + } + let mut host = &endpoint[..colon]; + if host.len() >= 2 && host.starts_with('[') && host.ends_with(']') { + host = &host[1..host.len() - 1]; + } + let port_text = &endpoint[colon + 1..]; + if !port_text.bytes().all(|b| b.is_ascii_digit()) { + return None; + } + let port = port_text.parse::().ok()?; + if port == 0 || port > u16::MAX as u32 { + return None; + } + Some((host.to_string(), port as u16)) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_host_port_and_ipv6_brackets() { + assert_eq!( + parse_endpoint("cm.example.com:443"), + Some(("cm.example.com".to_string(), 443)) + ); + assert_eq!( + parse_endpoint("[2001:db8::1]:27017"), + Some(("2001:db8::1".to_string(), 27017)) + ); + assert_eq!(parse_endpoint("missing-port"), None); + assert_eq!(parse_endpoint("host:0"), None); + assert_eq!(parse_endpoint("host:+443"), None); + assert_eq!(parse_endpoint("host:70000"), None); + } + + #[test] + fn websocket_url_requires_websocket_transport() { + let server = CmServer { + host: "cm.example.com".to_string(), + port: 443, + transport: CmTransport::WebSocket, + ..Default::default() + }; + assert_eq!(server.websocket_url(), "wss://cm.example.com:443/cmsocket/"); + let (host, port) = parse_endpoint("[2001:db8::1]:27017").unwrap(); + let v6 = CmServer { + host, + port, + transport: CmTransport::WebSocket, + ..Default::default() + }; + assert_eq!(v6.websocket_url(), "wss://[2001:db8::1]:27017/cmsocket/"); + } +} diff --git a/app/src/main/rust/stores/src/steam/cm_server_list.rs b/app/src/main/rust/stores/src/steam/cm_server_list.rs new file mode 100644 index 0000000000..069b036186 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/cm_server_list.rs @@ -0,0 +1,205 @@ +use crate::steam::cm_server::{CmServer, CmTransport}; +use std::sync::Mutex; +use std::time::{Duration, Instant}; + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum ServerQuality { + Good, + Bad, +} + +pub const DEFAULT_BAD_MEMORY: Duration = Duration::from_secs(5 * 60); + +pub struct CmServerList { + inner: Mutex, + bad_memory: Duration, +} + +#[derive(Default)] +struct Inner { + entries: Vec, + next_index: usize, +} + +struct Entry { + server: CmServer, + quality: ServerQuality, + marked_bad_at: Option, +} + +impl Default for CmServerList { + fn default() -> Self { + Self::new(DEFAULT_BAD_MEMORY) + } +} + +impl CmServerList { + pub fn new(bad_memory: Duration) -> Self { + Self { + inner: Mutex::new(Inner::default()), + bad_memory, + } + } + + pub fn replace_all(&self, servers: &[CmServer]) { + let mut inner = self.inner.lock().unwrap(); + inner.entries = servers + .iter() + .cloned() + .map(|server| Entry { + server, + quality: ServerQuality::Good, + marked_bad_at: None, + }) + .collect(); + inner.next_index = 0; + } + + pub fn add(&self, server: CmServer) { + self.inner.lock().unwrap().entries.push(Entry { + server, + quality: ServerQuality::Good, + marked_bad_at: None, + }); + } + + pub fn size(&self) -> usize { + self.inner.lock().unwrap().entries.len() + } + + pub fn next_good(&self) -> Option { + let mut inner = self.inner.lock().unwrap(); + if inner.entries.is_empty() { + return None; + } + promote_expired(&mut inner.entries, self.bad_memory); + let n = inner.entries.len(); + for i in 0..n { + let idx = (inner.next_index + i) % n; + if inner.entries[idx].quality == ServerQuality::Good { + inner.next_index = (idx + 1) % n; + return Some(inner.entries[idx].server.clone()); + } + } + None + } + + pub fn mark_bad(&self, endpoint: &str) { + let mut inner = self.inner.lock().unwrap(); + if let Some(entry) = inner + .entries + .iter_mut() + .find(|e| e.server.endpoint == endpoint) + { + entry.quality = ServerQuality::Bad; + entry.marked_bad_at = Some(Instant::now()); + } + } + + pub fn mark_good(&self, endpoint: &str) { + let mut inner = self.inner.lock().unwrap(); + if let Some(entry) = inner + .entries + .iter_mut() + .find(|e| e.server.endpoint == endpoint) + { + entry.quality = ServerQuality::Good; + entry.marked_bad_at = None; + } + } + + pub fn reset_quality(&self) { + let mut inner = self.inner.lock().unwrap(); + for entry in &mut inner.entries { + entry.quality = ServerQuality::Good; + entry.marked_bad_at = None; + } + } +} + +fn promote_expired(entries: &mut [Entry], bad_memory: Duration) { + let now = Instant::now(); + for entry in entries { + if entry.quality == ServerQuality::Bad + && entry + .marked_bad_at + .is_some_and(|t| now.duration_since(t) >= bad_memory) + { + entry.quality = ServerQuality::Good; + entry.marked_bad_at = None; + } + } +} + +pub fn hardcoded_fallback_servers() -> Vec { + const FALLBACK: &[(&str, &str)] = &[ + ("ext1-sea1.steamserver.net", "sea1"), + ("ext2-sea1.steamserver.net", "sea1"), + ("ext1-iad1.steamserver.net", "iad1"), + ("ext2-iad1.steamserver.net", "iad1"), + ("ext1-fra1.steamserver.net", "fra1"), + ("ext2-fra1.steamserver.net", "fra1"), + ("ext1-lax1.steamserver.net", "lax1"), + ("ext1-sgp1.steamserver.net", "sgp1"), + ]; + FALLBACK + .iter() + .map(|(host, dc)| CmServer { + endpoint: format!("{host}:443"), + host: (*host).to_string(), + port: 443, + transport: CmTransport::WebSocket, + realm: "steamglobal".to_string(), + datacenter: (*dc).to_string(), + load: 0, + weighted_load: 0.0, + }) + .collect() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn next_good_round_robins_and_skips_bad() { + let list = CmServerList::default(); + let a = server("a:443"); + let b = server("b:443"); + list.replace_all(&[a.clone(), b.clone()]); + assert_eq!(list.next_good().unwrap().endpoint, a.endpoint); + list.mark_bad(&b.endpoint); + assert_eq!(list.next_good().unwrap().endpoint, a.endpoint); + list.mark_good(&b.endpoint); + assert_eq!(list.next_good().unwrap().endpoint, b.endpoint); + } + + #[test] + fn bad_servers_promote_after_memory_interval() { + let list = CmServerList::new(Duration::ZERO); + let a = server("a:443"); + list.replace_all(std::slice::from_ref(&a)); + list.mark_bad(&a.endpoint); + assert_eq!(list.next_good().unwrap().endpoint, a.endpoint); + } + + #[test] + fn fallback_servers_are_websocket_urls() { + let servers = hardcoded_fallback_servers(); + assert!(!servers.is_empty()); + assert!(servers + .iter() + .all(|s| s.websocket_url().starts_with("wss://"))); + } + + fn server(endpoint: &str) -> CmServer { + let (host, port) = crate::steam::cm_server::parse_endpoint(endpoint).unwrap(); + CmServer { + endpoint: endpoint.to_string(), + host, + port, + transport: CmTransport::WebSocket, + ..Default::default() + } + } +} diff --git a/app/src/main/rust/stores/src/steam/cmsg_protobuf_header.rs b/app/src/main/rust/stores/src/steam/cmsg_protobuf_header.rs new file mode 100644 index 0000000000..23dd670ce8 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/cmsg_protobuf_header.rs @@ -0,0 +1,168 @@ +use crate::steam::proto_wire::{Reader, WireType, Writer}; + +pub const INVALID_JOB_ID: u64 = u64::MAX; + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct CMsgProtoBufHeader { + pub steamid: u64, + pub client_sessionid: i32, + pub routing_appid: u32, + pub jobid_source: u64, + pub jobid_target: u64, + pub target_job_name: String, + pub eresult: i32, + pub error_message: String, + pub realm: u32, + pub messageid: u64, + pub token_id: u64, +} + +impl Default for CMsgProtoBufHeader { + fn default() -> Self { + Self { + steamid: 0, + client_sessionid: 0, + routing_appid: 0, + jobid_source: INVALID_JOB_ID, + jobid_target: INVALID_JOB_ID, + target_job_name: String::new(), + eresult: -1, + error_message: String::new(), + realm: 0, + messageid: 0, + token_id: 0, + } + } +} + +impl CMsgProtoBufHeader { + pub fn serialize(&self, out: &mut Vec) { + let mut writer = Writer::new(out); + + if self.steamid != 0 { + writer.tag(1, WireType::Fixed64); + writer.fixed64_field_force_body(self.steamid); + } + writer.int32_field(2, self.client_sessionid); + writer.uint32_field(3, self.routing_appid); + if self.jobid_source != INVALID_JOB_ID { + writer.tag(10, WireType::Fixed64); + writer.fixed64_field_force_body(self.jobid_source); + } + if self.jobid_target != INVALID_JOB_ID { + writer.tag(11, WireType::Fixed64); + writer.fixed64_field_force_body(self.jobid_target); + } + writer.string_field(12, &self.target_job_name); + if self.eresult >= 0 { + writer.tag(13, WireType::Varint); + writer.varint(self.eresult as i64 as u64); + } + writer.string_field(14, &self.error_message); + writer.uint64_field(18, self.messageid); + writer.uint32_field(32, self.realm); + writer.uint64_field(36, self.token_id); + } + + pub fn deserialize(bytes: &[u8]) -> Option { + let mut reader = Reader::new(bytes); + let mut header = Self::default(); + + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(header); + }; + match tag.field_number { + 1 => { + if tag.wire_type != WireType::Fixed64 { + return None; + } + header.steamid = reader.fixed64()?; + } + 2 => header.client_sessionid = reader.i32()?, + 3 => header.routing_appid = reader.u32()?, + 10 => { + if tag.wire_type != WireType::Fixed64 { + return None; + } + header.jobid_source = reader.fixed64()?; + } + 11 => { + if tag.wire_type != WireType::Fixed64 { + return None; + } + header.jobid_target = reader.fixed64()?; + } + 12 => header.target_job_name = reader.string()?, + 13 => header.eresult = reader.i32()?, + 14 => header.error_message = reader.string()?, + 18 => header.messageid = reader.u64()?, + 32 => header.realm = reader.u32()?, + 36 => header.token_id = reader.u64()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + + Some(header) + } +} + +trait WriterFixedBodies { + fn fixed64_field_force_body(&mut self, v: u64); +} + +impl WriterFixedBodies for Writer<'_> { + fn fixed64_field_force_body(&mut self, v: u64) { + self.raw_bytes(&v.to_le_bytes()); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn serializes_only_set_job_ids() { + let h = CMsgProtoBufHeader { + steamid: 0x1122_3344_5566_7788, + client_sessionid: 17, + routing_appid: 480, + target_job_name: "Authentication.BeginAuthSessionViaCredentials#1".to_string(), + ..Default::default() + }; + let mut bytes = Vec::new(); + h.serialize(&mut bytes); + let parsed = CMsgProtoBufHeader::deserialize(&bytes).unwrap(); + assert_eq!(parsed, h); + assert!(!bytes + .windows(2) + .any(|w| w == [0x51, 0xff] || w == [0x59, 0xff])); + } + + #[test] + fn reads_steam_field_numbers() { + // steammessages_base.proto: eresult = 13, error_message = 14, messageid = 18, realm = 32, token_id = 36. + let bytes = [ + 0x68, 0x05, 0x72, 0x02, b'n', b'o', 0x90, 0x01, 0x07, 0x80, 0x02, 0x01, 0xa0, 0x02, 0x09, + ]; + let h = CMsgProtoBufHeader::deserialize(&bytes).unwrap(); + assert_eq!(h.eresult, 5); + assert_eq!(h.error_message, "no"); + assert_eq!(h.messageid, 7); + assert_eq!(h.realm, 1); + assert_eq!(h.token_id, 9); + let mut out = Vec::new(); + h.serialize(&mut out); + assert_eq!(out, bytes); + } + + #[test] + fn rejects_wrong_fixed_wire_type() { + let bytes = [0x08, 0x01]; + assert_eq!(CMsgProtoBufHeader::deserialize(&bytes), None); + } +} diff --git a/app/src/main/rust/stores/src/steam/content_manifest.rs b/app/src/main/rust/stores/src/steam/content_manifest.rs new file mode 100644 index 0000000000..450b151e7e --- /dev/null +++ b/app/src/main/rust/stores/src/steam/content_manifest.rs @@ -0,0 +1,353 @@ +use crate::steam::base64; +use crate::steam::crypto::{ + aes256_cbc_decrypt, aes256_ecb_decrypt_block, AesBlock, SessionKey, AES_BLOCK_BYTES, + SESSION_KEY_LENGTH, +}; +use crate::steam::proto_wire::{Reader, WireType}; + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct ChunkData { + pub sha: Vec, + pub crc: u32, + pub offset: u64, + pub cb_original: u32, + pub cb_compressed: u32, +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct FileMapping { + pub filename: String, + pub size: u64, + pub flags: u32, + pub sha_filename: Vec, + pub sha_content: Vec, + pub chunks: Vec, + pub linktarget: String, +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct Metadata { + pub depot_id: u32, + pub gid_manifest: u64, + pub creation_time: u32, + pub filenames_encrypted: bool, + pub cb_disk_original: u64, + pub cb_disk_compressed: u64, + pub unique_chunks: u32, + pub crc_encrypted: u32, + pub crc_clear: u32, +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct ContentManifest { + pub metadata: Metadata, + pub files: Vec, + pub signature: Vec, +} + +pub const PAYLOAD_MAGIC: u32 = 0x71f6_17d0; +pub const METADATA_MAGIC: u32 = 0x1f48_12be; +pub const SIGNATURE_MAGIC: u32 = 0x1b81_b817; +pub const END_OF_MANIFEST_MAGIC: u32 = 0x32c4_15ab; + +impl ContentManifest { + pub fn parse(raw: &[u8]) -> Option { + let mut manifest = Self::default(); + let mut have_payload = false; + let mut have_metadata = false; + let mut pos = 0usize; + + loop { + let magic = read_u32_le(raw, &mut pos)?; + if magic == END_OF_MANIFEST_MAGIC { + break; + } + let len = read_u32_le(raw, &mut pos)? as usize; + if pos + len > raw.len() { + return None; + } + let section = &raw[pos..pos + len]; + pos += len; + + match magic { + PAYLOAD_MAGIC => { + parse_payload(section, &mut manifest.files)?; + have_payload = true; + } + METADATA_MAGIC => { + manifest.metadata = parse_metadata(section)?; + have_metadata = true; + } + SIGNATURE_MAGIC => { + manifest.signature = parse_signature(section)?; + } + _ => return None, + } + } + + (have_payload && have_metadata).then_some(manifest) + } + + pub fn decrypt_filenames(&mut self, depot_key: &[u8]) -> bool { + if self.metadata.filenames_encrypted { + if depot_key.len() != SESSION_KEY_LENGTH { + return false; + } + let mut key = [0u8; SESSION_KEY_LENGTH]; + key.copy_from_slice(depot_key); + + for file in &mut self.files { + let Some(clear) = decrypt_name(&key, &file.filename) else { + return false; + }; + file.filename = clear; + if !file.linktarget.is_empty() { + let Some(clear) = decrypt_name(&key, &file.linktarget) else { + return false; + }; + file.linktarget = clear; + } + } + self.metadata.filenames_encrypted = false; + } + + for file in &mut self.files { + file.filename = file.filename.replace('\\', "/"); + file.linktarget = file.linktarget.replace('\\', "/"); + } + + self.files.sort_by(|a, b| { + a.filename + .bytes() + .map(|c| c.to_ascii_lowercase()) + .cmp(b.filename.bytes().map(|c| c.to_ascii_lowercase())) + }); + true + } +} + +fn decrypt_name(key: &SessionKey, enc: &str) -> Option { + let blob = base64::decode(enc)?; + if blob.len() < AES_BLOCK_BYTES * 2 { + return None; + } + let mut wrapped = [0u8; AES_BLOCK_BYTES]; + wrapped.copy_from_slice(&blob[..AES_BLOCK_BYTES]); + let iv: AesBlock = aes256_ecb_decrypt_block(key, &wrapped)?; + let plain = aes256_cbc_decrypt(key, &iv, &blob[AES_BLOCK_BYTES..])?; + let mut out = String::from_utf8_lossy(&plain).into_owned(); + if out.ends_with('\0') { + out.pop(); + } + Some(out) +} + +fn read_u32_le(buf: &[u8], pos: &mut usize) -> Option { + if *pos + 4 > buf.len() { + return None; + } + let v = u32::from_le_bytes(buf[*pos..*pos + 4].try_into().ok()?); + *pos += 4; + Some(v) +} + +fn parse_chunk(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut chunk = ChunkData::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(chunk); + }; + match tag.field_number { + 1 => chunk.sha = reader.bytes()?.to_vec(), + 2 => { + if tag.wire_type != WireType::Fixed32 { + return None; + } + chunk.crc = reader.fixed32()?; + } + 3 => chunk.offset = reader.u64()?, + 4 => chunk.cb_original = reader.u32()?, + 5 => chunk.cb_compressed = reader.u32()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(chunk) +} + +fn parse_file_mapping(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut file = FileMapping::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(file); + }; + match tag.field_number { + 1 => file.filename = reader.string()?, + 2 => file.size = reader.u64()?, + 3 => file.flags = reader.u32()?, + 4 => file.sha_filename = reader.bytes()?.to_vec(), + 5 => file.sha_content = reader.bytes()?.to_vec(), + 6 => file.chunks.push(parse_chunk(reader.bytes()?)?), + 7 => file.linktarget = reader.string()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(file) +} + +fn parse_payload(body: &[u8], out: &mut Vec) -> Option<()> { + let mut reader = Reader::new(body); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(()); + }; + if tag.field_number == 1 { + out.push(parse_file_mapping(reader.bytes()?)?); + } else if !reader.skip(tag.wire_type) { + return None; + } + } + Some(()) +} + +fn parse_metadata(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut metadata = Metadata::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(metadata); + }; + match tag.field_number { + 1 => metadata.depot_id = reader.u32()?, + 2 => metadata.gid_manifest = reader.u64()?, + 3 => metadata.creation_time = reader.u32()?, + 4 => metadata.filenames_encrypted = reader.boolean()?, + 5 => metadata.cb_disk_original = reader.u64()?, + 6 => metadata.cb_disk_compressed = reader.u64()?, + 7 => metadata.unique_chunks = reader.u32()?, + 8 => metadata.crc_encrypted = reader.u32()?, + 9 => metadata.crc_clear = reader.u32()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(metadata) +} + +fn parse_signature(body: &[u8]) -> Option> { + let mut reader = Reader::new(body); + let mut signature = Vec::new(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(signature); + }; + if tag.field_number == 1 { + signature = reader.bytes()?.to_vec(); + } else if !reader.skip(tag.wire_type) { + return None; + } + } + Some(signature) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::steam::crypto::{aes256_cbc_encrypt, aes256_ecb_encrypt_block}; + use crate::steam::proto_wire::Writer; + + #[test] + fn parses_manifest_sections() { + let mut chunk_body = Vec::new(); + { + let mut w = Writer::new(&mut chunk_body); + w.bytes_field(1, &[1; 20]); + w.tag(2, WireType::Fixed32); + w.raw_bytes(&0x1234_5678u32.to_le_bytes()); + w.uint64_field(3, 99); + w.uint32_field(4, 11); + w.uint32_field(5, 22); + } + + let mut file_body = Vec::new(); + { + let mut w = Writer::new(&mut file_body); + w.string_field(1, "bin\\game.exe"); + w.uint64_field(2, 11); + w.uint32_field(3, 1); + w.submessage_field(6, &chunk_body); + } + + let mut payload = Vec::new(); + Writer::new(&mut payload).submessage_field(1, &file_body); + + let mut metadata = Vec::new(); + { + let mut w = Writer::new(&mut metadata); + w.uint32_field(1, 123); + w.uint64_field(2, 456); + w.uint32_field(3, 789); + w.bool_field_force(4, false); + } + + let mut raw = Vec::new(); + push_section(&mut raw, PAYLOAD_MAGIC, &payload); + push_section(&mut raw, METADATA_MAGIC, &metadata); + raw.extend_from_slice(&END_OF_MANIFEST_MAGIC.to_le_bytes()); + + let mut manifest = ContentManifest::parse(&raw).unwrap(); + assert_eq!(manifest.metadata.depot_id, 123); + assert_eq!(manifest.files[0].filename, "bin\\game.exe"); + assert!(manifest.decrypt_filenames(&[])); + assert_eq!(manifest.files[0].filename, "bin/game.exe"); + assert_eq!(manifest.files[0].chunks[0].crc, 0x1234_5678); + } + + #[test] + fn decrypts_encrypted_filenames() { + let key = [9u8; SESSION_KEY_LENGTH]; + let name = encrypt_name(&key, "dir\\file.txt\0"); + let mut manifest = ContentManifest { + metadata: Metadata { + filenames_encrypted: true, + ..Default::default() + }, + files: vec![FileMapping { + filename: name, + ..Default::default() + }], + signature: Vec::new(), + }; + + assert!(manifest.decrypt_filenames(&key)); + assert_eq!(manifest.files[0].filename, "dir/file.txt"); + assert!(!manifest.metadata.filenames_encrypted); + } + + fn push_section(out: &mut Vec, magic: u32, body: &[u8]) { + out.extend_from_slice(&magic.to_le_bytes()); + out.extend_from_slice(&(body.len() as u32).to_le_bytes()); + out.extend_from_slice(body); + } + + fn encrypt_name(key: &SessionKey, name: &str) -> String { + let iv = [5u8; AES_BLOCK_BYTES]; + let wrapped = aes256_ecb_encrypt_block(key, &iv).unwrap(); + let body = aes256_cbc_encrypt(key, &iv, name.as_bytes()).unwrap(); + let mut blob = wrapped.to_vec(); + blob.extend_from_slice(&body); + base64::encode(&blob) + } +} diff --git a/app/src/main/rust/stores/src/steam/crypto.rs b/app/src/main/rust/stores/src/steam/crypto.rs new file mode 100644 index 0000000000..103608bebe --- /dev/null +++ b/app/src/main/rust/stores/src/steam/crypto.rs @@ -0,0 +1,150 @@ +use aes::cipher::{ + block_padding::Pkcs7, BlockDecrypt, BlockDecryptMut, BlockEncrypt, BlockEncryptMut, KeyInit, + KeyIvInit, +}; +use aes::Aes256; +use hmac::{Hmac, Mac}; +use rand::{rngs::OsRng, RngCore}; +use rsa::pkcs8::DecodePublicKey; +use rsa::traits::PublicKeyParts; +use rsa::{Oaep, RsaPublicKey}; +use sha1::{Digest as Sha1DigestTrait, Sha1}; +use sha2::Sha256; +use zeroize::Zeroize; + +pub const SESSION_KEY_LENGTH: usize = 32; +pub const AES_BLOCK_BYTES: usize = 16; +pub const SHA1_BYTES: usize = 20; +pub const SHA256_BYTES: usize = 32; +pub const HMAC_KEY_LENGTH: usize = 16; + +pub type SessionKey = [u8; SESSION_KEY_LENGTH]; +pub type Sha1Digest = [u8; SHA1_BYTES]; +pub type Sha256Digest = [u8; SHA256_BYTES]; +pub type AesBlock = [u8; AES_BLOCK_BYTES]; + +#[derive(Clone)] +pub struct SecureSessionKey { + pub bytes: SessionKey, +} + +impl SecureSessionKey { + pub fn new(bytes: SessionKey) -> Self { + Self { bytes } + } +} + +impl Drop for SecureSessionKey { + fn drop(&mut self) { + self.bytes.zeroize(); + } +} + +pub fn secure_random_bytes(out: &mut [u8]) -> bool { + OsRng.try_fill_bytes(out).is_ok() +} + +pub fn generate_session_key() -> Option { + let mut bytes = [0u8; SESSION_KEY_LENGTH]; + secure_random_bytes(&mut bytes).then_some(SecureSessionKey::new(bytes)) +} + +pub fn sha1(data: &[u8]) -> Sha1Digest { + Sha1::digest(data).into() +} + +pub fn sha256(data: &[u8]) -> Sha256Digest { + Sha256::digest(data).into() +} + +pub fn crc32(data: &[u8]) -> u32 { + crc32fast::hash(data) +} + +pub fn hmac_sha1(key: &[u8], data: &[u8]) -> Option { + let mut mac = as Mac>::new_from_slice(key).ok()?; + mac.update(data); + Some(mac.finalize().into_bytes().into()) +} + +pub fn aes256_ecb_encrypt_block(key: &SessionKey, input: &AesBlock) -> Option { + let cipher = Aes256::new_from_slice(key).ok()?; + let mut block = (*input).into(); + cipher.encrypt_block(&mut block); + Some(block.into()) +} + +pub fn aes256_ecb_decrypt_block(key: &SessionKey, input: &AesBlock) -> Option { + let cipher = Aes256::new_from_slice(key).ok()?; + let mut block = (*input).into(); + cipher.decrypt_block(&mut block); + Some(block.into()) +} + +pub fn aes256_cbc_encrypt(key: &SessionKey, iv: &AesBlock, plaintext: &[u8]) -> Option> { + Some( + cbc::Encryptor::::new(key.into(), iv.into()) + .encrypt_padded_vec_mut::(plaintext), + ) +} + +pub fn aes256_cbc_decrypt(key: &SessionKey, iv: &AesBlock, ciphertext: &[u8]) -> Option> { + if ciphertext.is_empty() || !ciphertext.len().is_multiple_of(AES_BLOCK_BYTES) { + return None; + } + cbc::Decryptor::::new(key.into(), iv.into()) + .decrypt_padded_vec_mut::(ciphertext) + .ok() +} + +pub fn rsa_oaep_sha1_encrypt(spki_der: &[u8], plaintext: &[u8]) -> Option> { + let public_key = RsaPublicKey::from_public_key_der(spki_der).ok()?; + let modulus = public_key.size(); + if modulus < 2 + 2 * SHA1_BYTES || plaintext.len() > modulus - 2 - 2 * SHA1_BYTES { + return None; + } + public_key + .encrypt(&mut OsRng, Oaep::new::(), plaintext) + .ok() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn hashes_match_known_values() { + assert_eq!( + hex(&sha1(b"abc")), + "a9993e364706816aba3e25717850c26c9cd0d89d" + ); + assert_eq!( + hex(&sha256(b"abc")), + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" + ); + assert_eq!(crc32(b"123456789"), 0xcbf4_3926); + } + + #[test] + fn aes_cbc_roundtrips_with_pkcs7() { + let key = [7u8; SESSION_KEY_LENGTH]; + let iv = [3u8; AES_BLOCK_BYTES]; + let plaintext = b"steam manifest filename"; + let encrypted = aes256_cbc_encrypt(&key, &iv, plaintext).unwrap(); + assert_ne!(encrypted, plaintext); + let decrypted = aes256_cbc_decrypt(&key, &iv, &encrypted).unwrap(); + assert_eq!(decrypted, plaintext); + } + + #[test] + fn hmac_sha1_known_value() { + assert_eq!( + hex(&hmac_sha1(b"key", b"The quick brown fox jumps over the lazy dog").unwrap()), + "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9" + ); + } + + fn hex(bytes: &[u8]) -> String { + bytes.iter().map(|b| format!("{b:02x}")).collect() + } +} diff --git a/app/src/main/rust/stores/src/steam/depot_chunk.rs b/app/src/main/rust/stores/src/steam/depot_chunk.rs new file mode 100644 index 0000000000..728a34e0dc --- /dev/null +++ b/app/src/main/rust/stores/src/steam/depot_chunk.rs @@ -0,0 +1,258 @@ +use crate::steam::cdn; +use crate::steam::crypto::{ + aes256_cbc_decrypt, aes256_ecb_decrypt_block, AesBlock, SessionKey, AES_BLOCK_BYTES, + SESSION_KEY_LENGTH, +}; +use lzma_rs::decompress::raw::{LzmaDecoder, LzmaParams, LzmaProperties}; +use std::io::{Cursor, Read}; + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct DepotChunkResult { + pub data: Vec, + pub error: String, +} + +impl DepotChunkResult { + pub fn ok(&self) -> bool { + self.error.is_empty() + } +} + +pub fn process_depot_chunk( + raw: &[u8], + depot_key: &[u8], + expected_crc: u32, + expected_size: u32, +) -> DepotChunkResult { + if depot_key.len() != SESSION_KEY_LENGTH { + return fail("chunk: bad depot key length"); + } + if raw.is_empty() { + return fail("chunk: empty"); + } + let mut key = [0u8; SESSION_KEY_LENGTH]; + key.copy_from_slice(depot_key); + + let Some(dec) = steam_symmetric_decrypt(&key, raw) else { + return fail("chunk: AES decrypt failed"); + }; + if dec.is_empty() { + return fail("chunk: AES decrypt failed"); + } + + let result = if dec.starts_with(b"VSZa") { + decompress_vzstd(&dec, expected_size) + } else if dec.starts_with(b"VZa") { + decompress_vzip(&dec, expected_size) + } else if dec.starts_with(b"PK\x03\x04") { + match cdn::unzip_first_entry(&dec, expected_size as usize) { + Some(data) => DepotChunkResult { + data, + error: String::new(), + }, + None => fail("chunk: PKZip decompress failed"), + } + } else { + fail("chunk: unrecognised compression header") + }; + if !result.ok() { + return result; + } + if result.data.len() != expected_size as usize { + return fail(format!( + "chunk: size mismatch ({} != {expected_size})", + result.data.len() + )); + } + if steam_adler_hash(&result.data) != expected_crc { + return fail("chunk: Adler32 mismatch"); + } + result +} + +pub fn steam_symmetric_decrypt(key: &SessionKey, enc: &[u8]) -> Option> { + if enc.len() < AES_BLOCK_BYTES * 2 { + return None; + } + let mut wrapped = [0u8; AES_BLOCK_BYTES]; + wrapped.copy_from_slice(&enc[..AES_BLOCK_BYTES]); + let iv: AesBlock = aes256_ecb_decrypt_block(key, &wrapped)?; + aes256_cbc_decrypt(key, &iv, &enc[AES_BLOCK_BYTES..]) +} + +fn decompress_vzstd(dec: &[u8], expected_size: u32) -> DepotChunkResult { + if dec.len() <= 8 { + return fail("vzstd: chunk too small"); + } + let payload = &dec[8..]; + let reader = match ruzstd::decoding::StreamingDecoder::new(Cursor::new(payload)) { + Ok(reader) => reader, + Err(_) => return fail("vzstd: bad zstd frame"), + }; + let mut data = Vec::with_capacity(expected_size as usize); + // One byte past the expected size is enough for the size check to reject an oversized frame. + if reader + .take(expected_size as u64 + 1) + .read_to_end(&mut data) + .is_err() + { + return fail("vzstd: decode failed"); + } + DepotChunkResult { + data, + error: String::new(), + } +} + +fn decompress_vzip(dec: &[u8], expected_size: u32) -> DepotChunkResult { + const HEADER: usize = 3 + 4; + const PROPS: usize = 5; + const FOOTER: usize = 10; + if dec.len() < HEADER + PROPS + FOOTER { + return fail("vzip: chunk too small"); + } + if dec[dec.len() - 2] != b'z' || dec[dec.len() - 1] != b'v' { + return fail("vzip: bad footer"); + } + let props = &dec[HEADER..HEADER + PROPS]; + let comp = &dec[HEADER + PROPS..dec.len() - FOOTER]; + let Some(params) = lzma_params_from_steam_props(props, expected_size as u64) else { + return fail("vzip: bad LZMA properties"); + }; + let mut decoder = match LzmaDecoder::new(params, None) { + Ok(decoder) => decoder, + Err(_) => return fail("vzip: raw decoder init failed"), + }; + let mut output = Vec::with_capacity(expected_size as usize); + match decoder.decompress(&mut Cursor::new(comp), &mut output) { + Ok(()) => DepotChunkResult { + data: output, + error: String::new(), + }, + Err(_) => fail("vzip: LZMA decode failed"), + } +} + +fn lzma_params_from_steam_props(props: &[u8], expected_size: u64) -> Option { + if props.len() != 5 { + return None; + } + let mut packed = props[0] as u32; + if packed >= 225 { + return None; + } + let lc = packed % 9; + packed /= 9; + let lp = packed % 5; + let pb = packed / 5; + if lc > 8 || lp > 4 || pb > 4 { + return None; + } + let dict_size = u32::from_le_bytes(props[1..5].try_into().ok()?); + Some(LzmaParams::new( + LzmaProperties { lc, lp, pb }, + dict_size, + Some(expected_size), + )) +} + +pub fn steam_adler_hash(data: &[u8]) -> u32 { + let mut a = 0u32; + let mut b = 0u32; + for byte in data { + a = (a + *byte as u32) % 65_521; + b = (b + a) % 65_521; + } + a | (b << 16) +} + +fn fail(msg: impl Into) -> DepotChunkResult { + DepotChunkResult { + data: Vec::new(), + error: msg.into(), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::steam::crypto::{aes256_cbc_encrypt, aes256_ecb_encrypt_block}; + + #[test] + fn steam_adler_hash_uses_zero_seed() { + assert_eq!(steam_adler_hash(b""), 0); + assert_eq!(steam_adler_hash(b"abc"), 0x024a_0126); + } + + #[test] + fn decrypts_and_processes_pkzip_chunk() { + let key = [4u8; SESSION_KEY_LENGTH]; + let payload = b"chunk bytes"; + let mut zip = Vec::new(); + zip.extend_from_slice(&0x0403_4b50u32.to_le_bytes()); + zip.extend_from_slice(&20u16.to_le_bytes()); + zip.extend_from_slice(&0u16.to_le_bytes()); + zip.extend_from_slice(&0u16.to_le_bytes()); + zip.extend_from_slice(&0u16.to_le_bytes()); + zip.extend_from_slice(&0u16.to_le_bytes()); + zip.extend_from_slice(&0u32.to_le_bytes()); + zip.extend_from_slice(&(payload.len() as u32).to_le_bytes()); + zip.extend_from_slice(&(payload.len() as u32).to_le_bytes()); + zip.extend_from_slice(&1u16.to_le_bytes()); + zip.extend_from_slice(&0u16.to_le_bytes()); + zip.extend_from_slice(b"x"); + zip.extend_from_slice(payload); + + let raw = encrypt_steam_symmetric(&key, &zip); + let result = + process_depot_chunk(&raw, &key, steam_adler_hash(payload), payload.len() as u32); + assert_eq!(result.data, payload); + assert!(result.ok()); + } + + #[test] + fn decrypts_and_processes_vzip_raw_lzma_chunk() { + let key = [8u8; SESSION_KEY_LENGTH]; + let payload = b"legacy lzma chunk bytes"; + let mut lzma_alone = Vec::new(); + lzma_rs::lzma_compress(&mut Cursor::new(payload), &mut lzma_alone).unwrap(); + assert!(lzma_alone.len() > 13); + + let mut vzip = Vec::new(); + vzip.extend_from_slice(b"VZa"); + vzip.extend_from_slice(&0u32.to_le_bytes()); + vzip.extend_from_slice(&lzma_alone[..5]); + vzip.extend_from_slice(&lzma_alone[13..]); + vzip.extend_from_slice(&0u32.to_le_bytes()); + vzip.extend_from_slice(&(payload.len() as u32).to_le_bytes()); + vzip.extend_from_slice(b"zv"); + + let raw = encrypt_steam_symmetric(&key, &vzip); + let result = + process_depot_chunk(&raw, &key, steam_adler_hash(payload), payload.len() as u32); + assert_eq!(result.data, payload); + assert!(result.ok()); + } + + #[test] + fn vzip_rejects_bad_properties_before_raw_decode() { + let mut dec = Vec::new(); + dec.extend_from_slice(b"VZa"); + dec.extend_from_slice(&0u32.to_le_bytes()); + dec.extend_from_slice(&[225, 0, 0, 0, 0]); + dec.extend_from_slice(b"payload"); + dec.extend_from_slice(&0u32.to_le_bytes()); + dec.extend_from_slice(&0u32.to_le_bytes()); + dec.extend_from_slice(b"zv"); + assert_eq!(decompress_vzip(&dec, 1).error, "vzip: bad LZMA properties"); + } + + fn encrypt_steam_symmetric(key: &SessionKey, plaintext: &[u8]) -> Vec { + let iv = [6u8; AES_BLOCK_BYTES]; + let wrapped = aes256_ecb_encrypt_block(key, &iv).unwrap(); + let body = aes256_cbc_encrypt(key, &iv, plaintext).unwrap(); + let mut out = wrapped.to_vec(); + out.extend_from_slice(&body); + out + } +} diff --git a/app/src/main/rust/stores/src/steam/depot_config.rs b/app/src/main/rust/stores/src/steam/depot_config.rs new file mode 100644 index 0000000000..91a8b2c62a --- /dev/null +++ b/app/src/main/rust/stores/src/steam/depot_config.rs @@ -0,0 +1,191 @@ +//! Resume journal for one app's download, kept in a caller-given app-private directory (never in +//! the game folder, which must end up exactly like one the Steam client made). +//! +//! Layout of `//`: `depot.config` (JSON: the build the journal belongs to and +//! the finished manifest per depot, or the in-progress sentinel while a depot is being written) +//! and `_.manifest` (the raw CDN manifest, so a resumed run does not refetch it). + +use serde_json::{json, Value}; +use std::collections::BTreeMap; +use std::fs::{self, File}; +use std::io::Write; +use std::path::{Path, PathBuf}; + +pub const INVALID_MANIFEST_ID: u64 = 0x7fff_ffff_ffff_ffff; + +pub fn app_journal_dir(journal_root: impl AsRef, app_id: u32) -> PathBuf { + journal_root.as_ref().join(app_id.to_string()) +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct DepotConfigStore { + dir: PathBuf, + build_id: u64, + installed: BTreeMap, +} + +impl DepotConfigStore { + /// Loads the journal; a journal written for another build is dropped (its depot records and + /// cached manifests no longer describe what this run installs). + pub fn load(dir: impl Into, build_id: u64) -> Self { + let dir = dir.into(); + let mut store = Self { + dir, + build_id, + installed: BTreeMap::new(), + }; + let Ok(text) = fs::read_to_string(store.config_path()) else { + return store; + }; + let Ok(value) = serde_json::from_str::(&text) else { + return store; + }; + let journal_build = value.get("buildId").and_then(Value::as_u64).unwrap_or(0); + if journal_build != build_id { + store.discard(); + return store; + } + if let Some(obj) = value.get("installedManifestIDs").and_then(Value::as_object) { + for (key, value) in obj { + if let (Ok(depot_id), Some(manifest_id)) = (key.parse::(), value.as_u64()) { + store.installed.insert(depot_id, manifest_id); + } + } + } + store + } + + pub fn dir(&self) -> &Path { + &self.dir + } + + pub fn manifest_cache_path(&self, depot_id: u32, manifest_id: u64) -> PathBuf { + self.dir.join(format!("{depot_id}_{manifest_id}.manifest")) + } + + pub fn is_installed(&self, depot_id: u32, manifest_id: u64) -> bool { + self.installed + .get(&depot_id) + .is_some_and(|installed| *installed == manifest_id && *installed != INVALID_MANIFEST_ID) + } + + pub fn begin_depot(&mut self, depot_id: u32) -> bool { + self.installed.insert(depot_id, INVALID_MANIFEST_ID); + self.save() + } + + pub fn finish_depot(&mut self, depot_id: u32, manifest_id: u64) -> bool { + self.installed.insert(depot_id, manifest_id); + self.save() + } + + pub fn read_cached_manifest(&self, depot_id: u32, manifest_id: u64) -> Option> { + let bytes = fs::read(self.manifest_cache_path(depot_id, manifest_id)).ok()?; + (!bytes.is_empty()).then_some(bytes) + } + + pub fn write_cached_manifest(&self, depot_id: u32, manifest_id: u64, raw: &[u8]) -> bool { + atomic_write_synced(&self.manifest_cache_path(depot_id, manifest_id), raw) + } + + /// Drops a cached manifest that turned out unusable, so the next attempt fetches it again. + pub fn remove_cached_manifest(&self, depot_id: u32, manifest_id: u64) { + let _ = fs::remove_file(self.manifest_cache_path(depot_id, manifest_id)); + } + + /// Removes the whole journal directory (after a successful install, or when it is stale). + pub fn discard(&mut self) { + self.installed.clear(); + let _ = fs::remove_dir_all(&self.dir); + } + + fn config_path(&self) -> PathBuf { + self.dir.join("depot.config") + } + + fn save(&self) -> bool { + let ids: serde_json::Map = self + .installed + .iter() + .map(|(depot, manifest)| (depot.to_string(), json!(manifest))) + .collect(); + let Ok(bytes) = serde_json::to_string_pretty(&json!({ + "buildId": self.build_id, + "installedManifestIDs": ids, + })) else { + return false; + }; + atomic_write_synced(&self.config_path(), bytes.as_bytes()) + } +} + +pub fn atomic_write_synced(final_path: &Path, bytes: &[u8]) -> bool { + let Some(parent) = final_path.parent() else { + return false; + }; + if fs::create_dir_all(parent).is_err() { + return false; + } + let mut tmp_name = final_path + .file_name() + .map(|n| n.to_os_string()) + .unwrap_or_default(); + tmp_name.push(".tmp"); + let tmp_path = final_path.with_file_name(tmp_name); + let mut file = match File::create(&tmp_path) { + Ok(file) => file, + Err(_) => return false, + }; + if file.write_all(bytes).is_err() || file.sync_all().is_err() { + let _ = fs::remove_file(&tmp_path); + return false; + } + drop(file); + if fs::rename(&tmp_path, final_path).is_err() { + let _ = fs::remove_file(&tmp_path); + return false; + } + if let Ok(dir) = File::open(parent) { + let _ = dir.sync_all(); + } + true +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn journal_roundtrips_marks_in_progress_and_drops_other_builds() { + let root = temp_dir("journal"); + let dir = app_journal_dir(&root, 291550); + let mut store = DepotConfigStore::load(&dir, 26465982); + assert!(!store.is_installed(291551, 1)); + assert!(store.begin_depot(291551)); + assert!(!DepotConfigStore::load(&dir, 26465982).is_installed(291551, INVALID_MANIFEST_ID)); + assert!(store.finish_depot(291551, 4224536525702420323)); + assert!(store.write_cached_manifest(291551, 4224536525702420323, b"raw")); + let loaded = DepotConfigStore::load(&dir, 26465982); + assert!(loaded.is_installed(291551, 4224536525702420323)); + assert_eq!( + loaded.read_cached_manifest(291551, 4224536525702420323), + Some(b"raw".to_vec()) + ); + loaded.remove_cached_manifest(291551, 4224536525702420323); + assert_eq!(loaded.read_cached_manifest(291551, 4224536525702420323), None); + let other_build = DepotConfigStore::load(&dir, 1); + assert!(!other_build.is_installed(291551, 4224536525702420323)); + assert!(!dir.exists()); + let _ = fs::remove_dir_all(&root); + } + + fn temp_dir(name: &str) -> PathBuf { + std::env::temp_dir().join(format!( + "droiddeck_steam_{name}_{}", + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_nanos() + )) + } +} diff --git a/app/src/main/rust/stores/src/steam/depot_downloader.rs b/app/src/main/rust/stores/src/steam/depot_downloader.rs new file mode 100644 index 0000000000..34faa16731 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/depot_downloader.rs @@ -0,0 +1,162 @@ +//! One depot from key to files: depot decryption key, manifest request code, the manifest (from +//! the journal when a cancelled run already fetched it), filename decryption, then the writer. + +use crate::steam::cdn; +use crate::steam::content_manifest::ContentManifest; +use crate::steam::depot_config::DepotConfigStore; +use crate::steam::depot_writer::{write_depot, DepotWriteOutcome, DepotWriteRequest}; +use crate::steam::pb::ccontentserverdirectory::CContentServerDirectoryServerInfo; +use crate::steam::session::{CodeResolution, KeyResolution, Session}; +use std::path::Path; +use std::sync::atomic::AtomicBool; + +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum DepotError { + Cancelled, + AccessDenied(u32), + Failed(String), +} + +impl DepotError { + pub fn message(&self) -> String { + match self { + DepotError::Cancelled => "cancelled".to_string(), + DepotError::AccessDenied(depot) => format!("access_denied: depot {depot}"), + DepotError::Failed(msg) => msg.clone(), + } + } +} + +pub struct PreparedDepot { + pub depot_id: u32, + pub manifest_id: u64, + pub key: Vec, + pub manifest: ContentManifest, +} + +impl Drop for PreparedDepot { + fn drop(&mut self) { + zeroize::Zeroize::zeroize(&mut self.key); + } +} + +/// Resolves the key and the manifest of `depot_id` (owned by `app_id`, the app the key and +/// request code are asked for). +#[allow(clippy::too_many_arguments)] +pub fn prepare_depot( + session: &Session, + servers: &[CContentServerDirectoryServerInfo], + journal: Option<&DepotConfigStore>, + ca_bundle_path: &str, + app_id: u32, + depot_id: u32, + manifest_id: u64, + cancel: &AtomicBool, +) -> Result { + let key = match session.depot_key(app_id, depot_id, cancel) { + KeyResolution::Granted(key) => key, + KeyResolution::AccessDenied => return Err(DepotError::AccessDenied(depot_id)), + KeyResolution::Cancelled => return Err(DepotError::Cancelled), + KeyResolution::Unavailable => { + return Err(DepotError::Failed(format!( + "depot key unavailable for depot {depot_id}" + ))) + } + }; + let raw = match journal.and_then(|j| j.read_cached_manifest(depot_id, manifest_id)) { + Some(raw) => raw, + None => { + let servers = cdn::usable_servers(servers); + let code = match session.manifest_code(app_id, depot_id, manifest_id, cancel) { + CodeResolution::Code(code) => code, + CodeResolution::AccessDenied => return Err(DepotError::AccessDenied(depot_id)), + CodeResolution::Cancelled => return Err(DepotError::Cancelled), + CodeResolution::Unavailable => { + return Err(DepotError::Failed(format!( + "manifest request code unavailable for depot {depot_id}" + ))) + } + }; + let ca = ca_bundle_path; + let mut fetched = + cdn::fetch_manifest_with_retry(&servers, depot_id, manifest_id, code, ca, cancel); + if !fetched.ok() && fetched.error != "cancelled" { + // Request codes rotate every few minutes: one more pass with a fresh one. + match session.manifest_code(app_id, depot_id, manifest_id, cancel) { + CodeResolution::Code(fresh) if fresh != code => { + fetched = cdn::fetch_manifest_with_retry( + &servers, + depot_id, + manifest_id, + fresh, + ca, + cancel, + ); + } + CodeResolution::Cancelled => return Err(DepotError::Cancelled), + _ => {} + } + } + if fetched.error == "cancelled" { + return Err(DepotError::Cancelled); + } + if !fetched.ok() { + return Err(DepotError::Failed(format!( + "manifest fetch failed for depot {depot_id}: {}", + fetched.error + ))); + } + if let Some(journal) = journal { + let _ = journal.write_cached_manifest(depot_id, manifest_id, &fetched.raw_manifest); + } + fetched.raw_manifest + } + }; + let forget = || { + if let Some(journal) = journal { + journal.remove_cached_manifest(depot_id, manifest_id); + } + }; + let Some(mut manifest) = ContentManifest::parse(&raw) else { + forget(); + return Err(DepotError::Failed(format!( + "manifest parse failed for depot {depot_id}" + ))); + }; + if !manifest.decrypt_filenames(&key) { + forget(); + return Err(DepotError::Failed(format!( + "filename decryption failed for depot {depot_id}" + ))); + } + Ok(PreparedDepot { + depot_id, + manifest_id, + key, + manifest, + }) +} + +#[allow(clippy::too_many_arguments)] +pub fn download_prepared( + prepared: &PreparedDepot, + servers: &[CContentServerDirectoryServerInfo], + target_dir: &Path, + ca_bundle_path: &str, + max_workers: usize, + process_workers: usize, + cancel: &AtomicBool, + progress: &(dyn Fn(u64) + Sync), + log: &(dyn Fn(&str) + Sync), +) -> DepotWriteOutcome { + let request = DepotWriteRequest { + manifest: &prepared.manifest, + depot_key: &prepared.key, + servers, + target_dir, + ca_bundle_path, + max_workers, + process_workers, + }; + write_depot(&request, cancel, progress, log) +} diff --git a/app/src/main/rust/stores/src/steam/depot_writer.rs b/app/src/main/rust/stores/src/steam/depot_writer.rs new file mode 100644 index 0000000000..04fd789647 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/depot_writer.rs @@ -0,0 +1,1027 @@ +//! Writes one depot's files in place under the target folder, the way the Steam client lays them +//! out: no temp files, no space reservation (`fallocate`/zero-fill are slow on Android's FUSE +//! storage), each file trimmed to its exact size with `set_len` once its last chunk lands. +//! +//! Chunk bodies come from the shared fetch core (`crate::fetch_core`), which owns the adaptive +//! request window, host rotation and retries; this module is the sink (decrypt, decompress, +//! Adler-32 check, positioned write). A chunk that appears several times in the manifest is +//! fetched once and written to every place it belongs. On resume, chunks already on disk are +//! read back and checked before anything is fetched. + +use crate::fetch_core::{run_fetch, FetchItem, FetchOptions, FetchSink, SinkError}; +use crate::grow_write::{holes_supported, GrowFront}; +use crate::steam::cdn; +use crate::steam::content_manifest::{ChunkData, ContentManifest}; +use crate::steam::depot_chunk::{process_depot_chunk, steam_adler_hash}; +use crate::steam::pb::ccontentserverdirectory::CContentServerDirectoryServerInfo; +use sha1::{Digest, Sha1}; +use std::collections::HashMap; +use std::fs::{self, File, OpenOptions}; +use std::path::{Component, Path, PathBuf}; +use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; +use std::sync::{Arc, Mutex}; +use std::time::Duration; + +pub const DEPOT_FILE_FLAG_EXECUTABLE: u32 = 32; +pub const DEPOT_FILE_FLAG_DIRECTORY: u32 = 64; +/// Chunks per fetch-core run. Every chunk carries one URL per CDN host, so batches bound memory on +/// very large depots. +pub const FETCH_BATCH_ITEMS: usize = 8192; +/// Above this many open files a written file's handle is closed and reopened on its next chunk. +pub const MAX_OPEN_FILES: usize = 256; +pub const CHUNK_TIMEOUT: Duration = Duration::from_secs(60); +const FREE_SPACE_MARGIN_BYTES: u64 = 64 * 1024 * 1024; + +pub struct DepotWriteRequest<'a> { + /// Filenames already decrypted (see `ContentManifest::decrypt_filenames`). + pub manifest: &'a ContentManifest, + pub depot_key: &'a [u8], + pub servers: &'a [CContentServerDirectoryServerInfo], + pub target_dir: &'a Path, + pub ca_bundle_path: &'a str, + pub max_workers: usize, + pub process_workers: usize, +} + +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct DepotWriteOutcome { + /// Bytes of the depot that are complete on disk (verified + written). + pub bytes_done: u64, + /// Of those, bytes that were already correct on disk. + pub bytes_verified: u64, + pub error: Option, + pub cancelled: bool, +} + +impl DepotWriteOutcome { + pub fn ok(&self) -> bool { + self.error.is_none() && !self.cancelled + } + + fn fail(error: impl Into) -> Self { + Self { + error: Some(error.into()), + ..Default::default() + } + } +} + +pub fn path_is_safe(rel: &str) -> bool { + if rel.is_empty() || rel.starts_with('/') || rel.starts_with('\\') { + return false; + } + let path = Path::new(rel); + !path.is_absolute() + && path + .components() + .all(|c| matches!(c, Component::Normal(_) | Component::CurDir)) +} + +pub fn depot_total_bytes(manifest: &ContentManifest) -> u64 { + manifest + .files + .iter() + .filter(|f| is_regular(f.flags, &f.linktarget)) + .map(|f| f.size) + .sum() +} + +fn is_regular(flags: u32, linktarget: &str) -> bool { + linktarget.is_empty() && (flags & DEPOT_FILE_FLAG_DIRECTORY) == 0 +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +struct Target { + file_idx: u32, + offset: u64, +} + +#[derive(Clone, Debug)] +struct UniqueChunk { + sha: Vec, + crc: u32, + cb_original: u32, + cb_compressed: u32, + targets: Vec, +} + +struct FileSlot { + handle: Mutex>>, + remaining: AtomicUsize, + size: u64, + path: PathBuf, + mode: u32, + front: GrowFront, +} + +struct DepotFiles { + slots: Vec, + open_count: AtomicUsize, + /// The canonical target folder; every write must resolve beneath it. + root: PathBuf, +} + +impl DepotFiles { + fn acquire(&self, file_idx: usize) -> Result, String> { + let slot = &self.slots[file_idx]; + let mut handle = slot.handle.lock().expect("file slot poisoned"); + if let Some(file) = handle.as_ref() { + return Ok(Arc::clone(file)); + } + make_parent_dirs(&self.root, &slot.path)?; + check_file_target(&self.root, &slot.path)?; + let file = OpenOptions::new() + .create(true) + .write(true) + .read(true) + .truncate(false) + .open(&slot.path) + .map_err(|err| format!("open '{}': {err}", slot.path.display()))?; + set_file_mode(&file, &slot.path, slot.mode)?; + let file = Arc::new(file); + *handle = Some(Arc::clone(&file)); + self.open_count.fetch_add(1, Ordering::Relaxed); + Ok(file) + } + + fn release(&self, file_idx: usize) { + let slot = &self.slots[file_idx]; + if slot + .handle + .lock() + .expect("file slot poisoned") + .take() + .is_some() + { + self.open_count.fetch_sub(1, Ordering::Relaxed); + } + } + + fn write( + &self, + file_idx: usize, + offset: u64, + data: &[u8], + cancel: &AtomicBool, + ) -> Result<(), String> { + let file = self.acquire(file_idx)?; + let slot = &self.slots[file_idx]; + slot.front.write_all_at(&file, offset, data, cancel).map_err(|err| { + format!( + "write '{}' at {offset}: {err}", + self.slots[file_idx].path.display() + ) + })?; + if slot.remaining.fetch_sub(1, Ordering::AcqRel) == 1 { + finalize(&file, slot, cancel)?; + drop(file); + self.release(file_idx); + } else if self.open_count.load(Ordering::Relaxed) > MAX_OPEN_FILES { + drop(file); + self.release(file_idx); + } + Ok(()) + } + + /// Files with nothing left to fetch (zero chunks, or every chunk already correct on disk). + fn finalize_untouched(&self, idx: usize, cancel: &AtomicBool) -> Result<(), String> { + let slot = &self.slots[idx]; + make_parent_dirs(&self.root, &slot.path)?; + check_file_target(&self.root, &slot.path)?; + let file = OpenOptions::new() + .create(true) + .write(true) + .truncate(false) + .open(&slot.path) + .map_err(|err| format!("open '{}': {err}", slot.path.display()))?; + set_file_mode(&file, &slot.path, slot.mode)?; + let current = file.metadata().map(|m| m.len()).unwrap_or(u64::MAX); + if current < slot.size { + slot.front + .extend_to(&file, slot.size, cancel) + .map_err(|err| format!("extend '{}': {err}", slot.path.display()))?; + } + if current != slot.size { + file.set_len(slot.size) + .map_err(|err| format!("set_len '{}': {err}", slot.path.display()))?; + } + Ok(()) + } +} + +fn finalize(file: &File, slot: &FileSlot, cancel: &AtomicBool) -> Result<(), String> { + slot.front + .extend_to(file, slot.size, cancel) + .map_err(|err| format!("extend '{}': {err}", slot.path.display()))?; + file.set_len(slot.size) + .map_err(|err| format!("set_len '{}': {err}", slot.path.display()))?; + file.sync_all() + .map_err(|err| format!("sync '{}': {err}", slot.path.display())) +} + +struct ChunkSink<'a> { + chunks: &'a [UniqueChunk], + files: &'a DepotFiles, + depot_key: &'a [u8], + cancel: &'a AtomicBool, +} + +impl FetchSink for ChunkSink<'_> { + fn process(&self, item: &FetchItem, body: Vec) -> Result { + let Some(chunk) = self.chunks.get(item.id as usize) else { + return Err(SinkError::Fatal("bad chunk index".to_string())); + }; + let processed = process_depot_chunk(&body, self.depot_key, chunk.crc, chunk.cb_original); + if !processed.ok() { + return Err(SinkError::Retry(processed.error)); + } + // A chunk's id is the SHA-1 of its decompressed bytes. + if Sha1::digest(&processed.data).as_slice() != chunk.sha.as_slice() { + return Err(SinkError::Retry("chunk: SHA-1 mismatch".to_string())); + } + let mut credited = 0u64; + for target in &chunk.targets { + self.files + .write( + target.file_idx as usize, + target.offset, + &processed.data, + self.cancel, + ) + .map_err(SinkError::Fatal)?; + credited += processed.data.len() as u64; + } + Ok(credited) + } +} + +struct Prepared { + files: DepotFiles, + chunks: Vec, + bytes_verified: u64, + total: u64, +} + +/// Layout, free-space check, resume verify pass, and the de-duplicated chunk list still to fetch. +fn prepare( + request: &DepotWriteRequest<'_>, + cancel: &AtomicBool, +) -> Result { + let manifest = request.manifest; + if manifest.metadata.filenames_encrypted { + return Err(DepotWriteOutcome::fail( + "manifest filenames are still encrypted", + )); + } + if request.depot_key.len() != 32 { + return Err(DepotWriteOutcome::fail("bad depot key length")); + } + if let Some(bad) = manifest.files.iter().find(|f| !path_is_safe(&f.filename)) { + return Err(DepotWriteOutcome::fail(format!( + "unsafe path '{}'", + bad.filename + ))); + } + if let Err(err) = fs::create_dir_all(request.target_dir) { + return Err(DepotWriteOutcome::fail(format!( + "mkdir '{}': {err}", + request.target_dir.display() + ))); + } + let root = match fs::canonicalize(request.target_dir) { + Ok(root) => root, + Err(err) => { + return Err(DepotWriteOutcome::fail(format!( + "resolve '{}': {err}", + request.target_dir.display() + ))) + } + }; + + let holes = holes_supported(&root); + let mut slots = Vec::with_capacity(manifest.files.len()); + let mut existing = Vec::with_capacity(manifest.files.len()); + for file in &manifest.files { + let path = request.target_dir.join(&file.filename); + let regular = is_regular(file.flags, &file.linktarget); + let len = if regular { + fs::metadata(&path).map(|m| m.len()).unwrap_or(0) + } else { + 0 + }; + existing.push(len); + slots.push(FileSlot { + handle: Mutex::new(None), + remaining: AtomicUsize::new(0), + size: file.size, + path, + mode: if (file.flags & DEPOT_FILE_FLAG_EXECUTABLE) != 0 { + 0o755 + } else { + 0o644 + }, + front: GrowFront::new(holes), + }); + } + + let total = depot_total_bytes(manifest); + let present: u64 = manifest + .files + .iter() + .zip(&existing) + .map(|(f, len)| (*len).min(f.size)) + .sum(); + let needed = total.saturating_sub(present); + if let Some(available) = available_space_bytes(request.target_dir) { + if available > 0 && available.saturating_add(FREE_SPACE_MARGIN_BYTES) < needed { + return Err(DepotWriteOutcome::fail(format!( + "not_enough_space: need {} MiB, have {} MiB", + needed / (1024 * 1024), + available / (1024 * 1024) + ))); + } + } + + for file in &manifest.files { + let path = request.target_dir.join(&file.filename); + let result = if !file.linktarget.is_empty() { + create_symlink(&root, &path, &file.linktarget) + } else if (file.flags & DEPOT_FILE_FLAG_DIRECTORY) != 0 { + make_dirs(&root, &path) + } else { + Ok(()) + }; + if let Err(err) = result { + return Err(DepotWriteOutcome::fail(err)); + } + } + + let verified = verify_existing( + manifest, + &slots, + &existing, + &root, + request.process_workers, + cancel, + ); + if cancel.load(Ordering::Relaxed) { + return Err(DepotWriteOutcome { + cancelled: true, + ..Default::default() + }); + } + let mut bytes_verified = 0u64; + let mut chunks: Vec = Vec::new(); + let mut by_sha: HashMap, usize> = HashMap::new(); + for (file_idx, file) in manifest.files.iter().enumerate() { + if !is_regular(file.flags, &file.linktarget) { + continue; + } + let mut remaining = 0usize; + let mut by_offset: Vec = (0..file.chunks.len()).collect(); + by_offset.sort_by_key(|&idx| file.chunks[idx].offset); + for chunk_idx in by_offset { + let chunk = &file.chunks[chunk_idx]; + if verified[file_idx].get(chunk_idx).copied().unwrap_or(false) { + bytes_verified += chunk.cb_original as u64; + continue; + } + remaining += 1; + let target = Target { + file_idx: file_idx as u32, + offset: chunk.offset, + }; + match by_sha.get(&chunk.sha) { + Some(&idx) => chunks[idx].targets.push(target), + None => { + by_sha.insert(chunk.sha.clone(), chunks.len()); + chunks.push(UniqueChunk { + sha: chunk.sha.clone(), + crc: chunk.crc, + cb_original: chunk.cb_original, + cb_compressed: chunk.cb_compressed, + targets: vec![target], + }); + } + } + } + slots[file_idx] + .remaining + .store(remaining, Ordering::Relaxed); + } + drop(by_sha); + + let files = DepotFiles { + slots, + open_count: AtomicUsize::new(0), + root, + }; + for (idx, file) in manifest.files.iter().enumerate() { + if is_regular(file.flags, &file.linktarget) + && files.slots[idx].remaining.load(Ordering::Relaxed) == 0 + { + if let Err(err) = files.finalize_untouched(idx, cancel) { + if cancel.load(Ordering::Relaxed) { + return Err(DepotWriteOutcome { + cancelled: true, + ..Default::default() + }); + } + return Err(DepotWriteOutcome::fail(err)); + } + } + } + Ok(Prepared { + files, + chunks, + bytes_verified, + total, + }) +} + +/// Writes (or resumes) one depot. `progress` gets the depot's completed bytes; `log` gets the +/// fetch core's lines. +pub fn write_depot( + request: &DepotWriteRequest<'_>, + cancel: &AtomicBool, + progress: &(dyn Fn(u64) + Sync), + log: &(dyn Fn(&str) + Sync), +) -> DepotWriteOutcome { + let manifest = request.manifest; + let servers = cdn::usable_servers(request.servers); + let Prepared { + files, + chunks, + bytes_verified, + total, + } = match prepare(request, cancel) { + Ok(prepared) => prepared, + Err(outcome) => return outcome, + }; + if servers.is_empty() && !chunks.is_empty() { + return DepotWriteOutcome::fail("no usable CDN server"); + } + progress(bytes_verified); + log(&format!( + "depot={} files={} unique_chunks={} verified_bytes={bytes_verified} total_bytes={total}", + manifest.metadata.depot_id, + manifest.files.len(), + chunks.len() + )); + + let hosts: Vec = servers.iter().map(cdn::host_key).collect(); + let opts = FetchOptions { + max_workers: request.max_workers.max(1), + timeout: CHUNK_TIMEOUT, + ca_bundle_path: request.ca_bundle_path.to_string(), + process_workers: request.process_workers.max(1), + label: format!("steam depot={}", manifest.metadata.depot_id), + ..Default::default() + }; + let sink = ChunkSink { + chunks: &chunks, + files: &files, + depot_key: request.depot_key, + cancel, + }; + let depot_id = manifest.metadata.depot_id; + let done_before = AtomicU64::new(bytes_verified); + let mut start = 0usize; + while start < chunks.len() { + if cancel.load(Ordering::Relaxed) { + return DepotWriteOutcome { + bytes_done: done_before.load(Ordering::Relaxed), + bytes_verified, + cancelled: true, + error: None, + }; + } + let end = (start + FETCH_BATCH_ITEMS).min(chunks.len()); + let mut items = Vec::with_capacity(end - start); + for (idx, chunk) in chunks.iter().enumerate().take(end).skip(start) { + let mut urls = Vec::with_capacity(servers.len()); + for server in &servers { + match cdn::build_chunk_url(server, depot_id, &chunk.sha) { + Ok(url) => urls.push(url), + Err(err) => return DepotWriteOutcome::fail(err), + } + } + items.push(FetchItem { + id: idx as u64, + urls, + reserve: chunk.cb_compressed as u64, + range: None, + }); + } + let base = done_before.load(Ordering::Relaxed); + let batch_progress = |credited: u64, _items: u64| progress(base + credited); + let outcome = run_fetch(items, &hosts, &opts, &sink, cancel, &batch_progress, log); + done_before.fetch_add(outcome.bytes_credited, Ordering::Relaxed); + if outcome.cancelled { + return DepotWriteOutcome { + bytes_done: done_before.load(Ordering::Relaxed), + bytes_verified, + cancelled: true, + error: None, + }; + } + if let Some(error) = outcome.error { + return DepotWriteOutcome { + bytes_done: done_before.load(Ordering::Relaxed), + bytes_verified, + cancelled: false, + error: Some(error), + }; + } + start = end; + } + + if let Some((idx, _)) = files + .slots + .iter() + .enumerate() + .find(|(_, s)| s.remaining.load(Ordering::Relaxed) != 0) + { + return DepotWriteOutcome::fail(format!( + "file '{}' incomplete after fetch", + manifest.files[idx].filename + )); + } + DepotWriteOutcome { + bytes_done: done_before.load(Ordering::Relaxed), + bytes_verified, + error: None, + cancelled: false, + } +} + +/// Per file, per chunk: is the chunk already correct on disk? Only files that already have bytes +/// are read; a fresh install skips this entirely. +fn verify_existing( + manifest: &ContentManifest, + slots: &[FileSlot], + existing: &[u64], + root: &Path, + workers: usize, + cancel: &AtomicBool, +) -> Vec> { + let mut out: Vec> = manifest + .files + .iter() + .map(|f| vec![false; f.chunks.len()]) + .collect(); + let todo: Vec = (0..manifest.files.len()) + .filter(|&i| existing[i] > 0 && !manifest.files[i].chunks.is_empty()) + .collect(); + if todo.is_empty() { + return out; + } + let queue = Mutex::new(todo.into_iter()); + let results: Mutex)>> = Mutex::new(Vec::new()); + std::thread::scope(|scope| { + for _ in 0..workers.clamp(1, 8) { + scope.spawn(|| { + crate::priority::background(); + loop { + if cancel.load(Ordering::Relaxed) { + return; + } + let next = queue.lock().expect("verify queue poisoned").next(); + let Some(idx) = next else { + return; + }; + if check_file_target(root, &slots[idx].path).is_err() { + continue; + } + let Ok(file) = File::open(&slots[idx].path) else { + continue; + }; + let chunks = &manifest.files[idx].chunks; + let mut flags = vec![false; chunks.len()]; + for (flag, chunk) in flags.iter_mut().zip(chunks) { + if cancel.load(Ordering::Relaxed) { + break; + } + *flag = existing_chunk_matches(&file, existing[idx], chunk); + } + results + .lock() + .expect("verify results poisoned") + .push((idx, flags)); + } + }); + } + }); + for (idx, flags) in results.into_inner().expect("verify results poisoned") { + out[idx] = flags; + } + out +} + +pub fn existing_chunk_matches(file: &File, file_len: u64, chunk: &ChunkData) -> bool { + if chunk.cb_original == 0 { + return false; + } + let end = chunk.offset.saturating_add(chunk.cb_original as u64); + if file_len < end { + return false; + } + let mut buf = vec![0u8; chunk.cb_original as usize]; + if pread_exact_at(file, chunk.offset, &mut buf).is_err() { + return false; + } + steam_adler_hash(&buf) == chunk.crc +} + +/// Fails unless `path` (which must exist) resolves beneath `root`, so a symlink in the game folder +/// cannot carry a write outside it. +fn check_inside(root: &Path, path: &Path) -> Result<(), String> { + match fs::canonicalize(path) { + Ok(real) if real.starts_with(root) => Ok(()), + Ok(real) => Err(format!( + "'{}' resolves outside the install folder ({})", + path.display(), + real.display() + )), + Err(err) => Err(format!("resolve '{}': {err}", path.display())), + } +} + +/// Creates `dir` and its missing parents, refusing when an existing ancestor or the result +/// resolves outside `root`. +fn make_dirs(root: &Path, dir: &Path) -> Result<(), String> { + let mut existing = dir; + while fs::symlink_metadata(existing).is_err() { + match existing.parent() { + Some(parent) if !parent.as_os_str().is_empty() => existing = parent, + _ => break, + } + } + check_inside(root, existing)?; + fs::create_dir_all(dir).map_err(|err| format!("mkdir '{}': {err}", dir.display()))?; + check_inside(root, dir) +} + +fn make_parent_dirs(root: &Path, path: &Path) -> Result<(), String> { + match path.parent() { + Some(parent) if !parent.as_os_str().is_empty() => make_dirs(root, parent), + _ => Ok(()), + } +} + +/// A file about to be opened: its folder must be inside `root`, and if the path itself is a symlink +/// it must resolve inside `root` too (a dangling one would create its target wherever it points). +fn check_file_target(root: &Path, path: &Path) -> Result<(), String> { + if let Some(parent) = path.parent() { + check_inside(root, parent)?; + } + match fs::symlink_metadata(path) { + Ok(meta) if meta.file_type().is_symlink() => check_inside(root, path), + _ => Ok(()), + } +} + +fn create_symlink(root: &Path, path: &Path, target: &str) -> Result<(), String> { + make_parent_dirs(root, path)?; + if fs::symlink_metadata(path).is_ok() { + fs::remove_file(path).map_err(|err| format!("unlink '{}': {err}", path.display()))?; + } + #[cfg(unix)] + { + std::os::unix::fs::symlink(target, path) + .map_err(|err| format!("symlink '{}': {err}", path.display())) + } + #[cfg(not(unix))] + { + let _ = target; + Err(format!("symlink '{}': unsupported", path.display())) + } +} + +#[cfg(unix)] +fn set_file_mode(file: &File, path: &Path, mode: u32) -> Result<(), String> { + use std::os::unix::fs::PermissionsExt; + file.set_permissions(fs::Permissions::from_mode(mode)) + .map_err(|err| format!("chmod '{}': {err}", path.display())) +} + +#[cfg(not(unix))] +fn set_file_mode(_file: &File, _path: &Path, _mode: u32) -> Result<(), String> { + Ok(()) +} + +#[cfg(unix)] +fn pread_exact_at(file: &File, offset: u64, buf: &mut [u8]) -> std::io::Result<()> { + use std::os::unix::fs::FileExt; + file.read_exact_at(buf, offset) +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +pub fn available_space_bytes(path: &Path) -> Option { + use std::ffi::CString; + use std::os::unix::ffi::OsStrExt; + let c_path = CString::new(path.as_os_str().as_bytes()).ok()?; + let mut st: libc::statvfs = unsafe { std::mem::zeroed() }; + if unsafe { libc::statvfs(c_path.as_ptr(), &mut st) } != 0 { + return None; + } + Some((st.f_bavail as u64).saturating_mul(st.f_frsize as u64)) +} + +#[cfg(not(any(target_os = "linux", target_os = "android")))] +pub fn available_space_bytes(_path: &Path) -> Option { + None +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::steam::content_manifest::FileMapping; + + #[test] + fn rejects_unsafe_paths() { + assert!(path_is_safe("bin/game.exe")); + assert!(path_is_safe("./a")); + assert!(!path_is_safe("")); + assert!(!path_is_safe("/etc/passwd")); + assert!(!path_is_safe("../x")); + assert!(!path_is_safe("a/../../x")); + assert!(!path_is_safe("\\x")); + } + + #[test] + fn existing_chunk_check_reads_back_and_compares_adler() { + let dir = std::env::temp_dir().join(format!( + "droiddeck_steam_verify_{}", + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_nanos() + )); + fs::create_dir_all(&dir).unwrap(); + let path = dir.join("f.bin"); + fs::write(&path, b"helloworld").unwrap(); + let file = File::open(&path).unwrap(); + let good = ChunkData { + crc: steam_adler_hash(b"world"), + offset: 5, + cb_original: 5, + ..Default::default() + }; + let bad = ChunkData { + crc: steam_adler_hash(b"xxxxx"), + ..good.clone() + }; + let past_end = ChunkData { + offset: 8, + ..good.clone() + }; + assert!(existing_chunk_matches(&file, 10, &good)); + assert!(!existing_chunk_matches(&file, 10, &bad)); + assert!(!existing_chunk_matches(&file, 10, &past_end)); + let manifest = ContentManifest { + files: vec![FileMapping { + filename: "f.bin".into(), + size: 10, + chunks: vec![good.clone(), bad.clone()], + ..Default::default() + }], + ..Default::default() + }; + let slots = vec![FileSlot { + handle: Mutex::new(None), + remaining: AtomicUsize::new(0), + size: 10, + path: path.clone(), + mode: 0o644, + front: GrowFront::new(true), + }]; + let root = fs::canonicalize(&dir).unwrap(); + let flags = verify_existing(&manifest, &slots, &[10], &root, 2, &AtomicBool::new(false)); + assert_eq!(flags, vec![vec![true, false]]); + let cancelled = verify_existing(&manifest, &slots, &[10], &root, 2, &AtomicBool::new(true)); + assert_eq!(cancelled, vec![vec![false, false]]); + let _ = fs::remove_dir_all(&dir); + } + + fn zip_stored(payload: &[u8]) -> Vec { + let mut zip = Vec::new(); + zip.extend_from_slice(&0x0403_4b50u32.to_le_bytes()); + zip.extend_from_slice(&20u16.to_le_bytes()); + zip.extend_from_slice(&[0u8; 8]); + zip.extend_from_slice(&0u32.to_le_bytes()); + zip.extend_from_slice(&(payload.len() as u32).to_le_bytes()); + zip.extend_from_slice(&(payload.len() as u32).to_le_bytes()); + zip.extend_from_slice(&1u16.to_le_bytes()); + zip.extend_from_slice(&0u16.to_le_bytes()); + zip.push(b'x'); + zip.extend_from_slice(payload); + zip + } + + fn encrypted_chunk(key: &[u8; 32], payload: &[u8]) -> Vec { + use crate::steam::crypto::{aes256_cbc_encrypt, aes256_ecb_encrypt_block}; + let iv = [9u8; 16]; + let mut out = aes256_ecb_encrypt_block(key, &iv).unwrap().to_vec(); + out.extend(aes256_cbc_encrypt(key, &iv, &zip_stored(payload)).unwrap()); + out + } + + fn chunk(data: &[u8], offset: u64) -> ChunkData { + ChunkData { + sha: Sha1::digest(data).to_vec(), + crc: steam_adler_hash(data), + offset, + cb_original: data.len() as u32, + cb_compressed: data.len() as u32 + 64, + } + } + + #[test] + fn queues_each_files_chunks_in_offset_order() { + let dir = std::env::temp_dir().join(format!( + "droiddeck_steam_order_{}", + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_nanos() + )); + let key = [5u8; 32]; + let manifest = ContentManifest { + files: vec![FileMapping { + filename: "big.pak".into(), + size: 15, + chunks: vec![chunk(b"three", 10), chunk(b"first", 0), chunk(b"other", 5)], + ..Default::default() + }], + ..Default::default() + }; + let request = DepotWriteRequest { + manifest: &manifest, + depot_key: &key, + servers: &[], + target_dir: &dir, + ca_bundle_path: "", + max_workers: 1, + process_workers: 1, + }; + let prepared = prepare(&request, &AtomicBool::new(false)).unwrap(); + let offsets: Vec = prepared + .chunks + .iter() + .map(|c| c.targets[0].offset) + .collect(); + assert_eq!(offsets, vec![0, 5, 10]); + let _ = fs::remove_dir_all(&dir); + } + + #[test] + fn writes_in_place_dedupes_chunks_and_resumes_from_disk() { + let dir = std::env::temp_dir().join(format!( + "droiddeck_steam_write_{}", + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_nanos() + )); + let key = [3u8; 32]; + let manifest = ContentManifest { + files: vec![ + FileMapping { + filename: "bin".into(), + flags: DEPOT_FILE_FLAG_DIRECTORY, + ..Default::default() + }, + FileMapping { + filename: "bin/game.exe".into(), + size: 10, + flags: DEPOT_FILE_FLAG_EXECUTABLE, + chunks: vec![chunk(b"hello", 0), chunk(b"world", 5)], + ..Default::default() + }, + FileMapping { + filename: "data/copy.bin".into(), + size: 5, + chunks: vec![chunk(b"world", 0)], + ..Default::default() + }, + FileMapping { + filename: "empty.txt".into(), + ..Default::default() + }, + ], + ..Default::default() + }; + let request = DepotWriteRequest { + manifest: &manifest, + depot_key: &key, + servers: &[], + target_dir: &dir, + ca_bundle_path: "", + max_workers: 4, + process_workers: 2, + }; + let cancel = AtomicBool::new(false); + let prepared = prepare(&request, &cancel).unwrap(); + assert_eq!(prepared.total, 15); + assert_eq!(prepared.bytes_verified, 0); + assert_eq!(prepared.chunks.len(), 2); + assert_eq!(prepared.chunks[1].targets.len(), 2); + assert!(dir.join("bin").is_dir()); + assert_eq!(fs::metadata(dir.join("empty.txt")).unwrap().len(), 0); + + let sink = ChunkSink { + chunks: &prepared.chunks, + files: &prepared.files, + depot_key: &key, + cancel: &cancel, + }; + let item = |id: u64| FetchItem { + id, + urls: vec!["x".into()], + reserve: 0, + range: None, + }; + assert!(matches!( + sink.process(&item(0), b"garbage-garbage-garbage-garbage!".to_vec()), + Err(SinkError::Retry(_)) + )); + // Same size and Adler-32 as "hello" would need a collision; a different body of the right + // size is enough to show the SHA-1 is checked after the Adler-32 one passes. + let mut wrong = prepared.chunks.clone(); + wrong[0].crc = steam_adler_hash(b"HELLO"); + let wrong_sink = ChunkSink { + chunks: &wrong, + files: &prepared.files, + depot_key: &key, + cancel: &cancel, + }; + assert!(matches!( + wrong_sink.process(&item(0), encrypted_chunk(&key, b"HELLO")), + Err(SinkError::Retry(e)) if e.contains("SHA-1") + )); + assert_eq!( + sink.process(&item(1), encrypted_chunk(&key, b"world")) + .unwrap(), + 10 + ); + assert_eq!(fs::read(dir.join("data/copy.bin")).unwrap(), b"world"); + assert_eq!( + sink.process(&item(0), encrypted_chunk(&key, b"hello")) + .unwrap(), + 5 + ); + assert_eq!(fs::read(dir.join("bin/game.exe")).unwrap(), b"helloworld"); + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + let mode = fs::metadata(dir.join("bin/game.exe")) + .unwrap() + .permissions() + .mode(); + assert_eq!(mode & 0o777, 0o755); + } + drop(prepared); + + // A resumed run reads back what is on disk and fetches only what is wrong or missing. + fs::write(dir.join("bin/game.exe"), b"helloWORLD").unwrap(); + let again = prepare(&request, &cancel).unwrap(); + assert_eq!(again.bytes_verified, 10); + assert_eq!(again.chunks.len(), 1); + assert_eq!( + again.chunks[0].targets, + vec![Target { + file_idx: 1, + offset: 5 + }] + ); + let _ = fs::remove_dir_all(&dir); + } + + #[cfg(unix)] + #[test] + fn refuses_writes_through_a_symlink_out_of_the_install_folder() { + let base = std::env::temp_dir().join(format!( + "droiddeck_steam_escape_{}", + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_nanos() + )); + let dir = base.join("game"); + let outside = base.join("outside"); + fs::create_dir_all(&dir).unwrap(); + fs::create_dir_all(&outside).unwrap(); + std::os::unix::fs::symlink(&outside, dir.join("link")).unwrap(); + std::os::unix::fs::symlink("../game", dir.join("inner")).unwrap(); + let root = fs::canonicalize(&dir).unwrap(); + assert!(make_parent_dirs(&root, &dir.join("link/sub/f.bin")).is_err()); + assert!(!outside.join("sub").exists()); + assert!(check_file_target(&root, &dir.join("link/f.bin")).is_err()); + assert!(make_parent_dirs(&root, &dir.join("inner/sub/f.bin")).is_ok()); + assert!(check_file_target(&root, &dir.join("inner/sub/f.bin")).is_ok()); + std::os::unix::fs::symlink(outside.join("x"), dir.join("dangling")).unwrap(); + assert!(check_file_target(&root, &dir.join("dangling")).is_err()); + let _ = fs::remove_dir_all(&base); + } +} diff --git a/app/src/main/rust/stores/src/steam/emsg.rs b/app/src/main/rust/stores/src/steam/emsg.rs new file mode 100644 index 0000000000..7c7feb4975 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/emsg.rs @@ -0,0 +1,102 @@ +#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)] +#[repr(transparent)] +pub struct EMsg(pub u32); + +impl EMsg { + pub const INVALID: Self = Self(0); + pub const MULTI: Self = Self(1); + pub const CHANNEL_ENCRYPT_REQUEST: Self = Self(1303); + pub const CHANNEL_ENCRYPT_RESPONSE: Self = Self(1304); + pub const CHANNEL_ENCRYPT_RESULT: Self = Self(1305); + pub const CLIENT_HELLO: Self = Self(9805); + pub const CLIENT_LOGON: Self = Self(5514); + pub const CLIENT_LOGON_RESPONSE: Self = Self(751); + pub const CLIENT_LOG_OFF: Self = Self(706); + pub const CLIENT_LOGGED_OFF: Self = Self(757); + pub const CLIENT_HEART_BEAT: Self = Self(703); + pub const CLIENT_SESSION_TOKEN: Self = Self(850); + pub const CLIENT_SERVER_UNAVAILABLE: Self = Self(5500); + pub const CLIENT_LICENSE_LIST: Self = Self(780); + /// Free/F2P/demo license grant (verified against JavaSteam `EMsg.java`). + pub const CLIENT_REQUEST_FREE_LICENSE: Self = Self(5572); + pub const CLIENT_REQUEST_FREE_LICENSE_RESPONSE: Self = Self(5573); + pub const CLIENT_PICS_PRODUCT_INFO_REQUEST: Self = Self(8903); + pub const CLIENT_PICS_PRODUCT_INFO_RESPONSE: Self = Self(8904); + pub const CLIENT_PICS_ACCESS_TOKEN_REQUEST: Self = Self(8905); + pub const CLIENT_PICS_ACCESS_TOKEN_RESPONSE: Self = Self(8906); + pub const CLIENT_GET_DEPOT_DECRYPTION_KEY: Self = Self(5438); + pub const CLIENT_GET_DEPOT_DECRYPTION_KEY_RESPONSE: Self = Self(5439); + pub const SERVICE_METHOD: Self = Self(146); + pub const SERVICE_METHOD_CALL_FROM_CLIENT: Self = Self(151); + pub const SERVICE_METHOD_RESPONSE: Self = Self(147); + pub const SERVICE_METHOD_SEND_TO_CLIENT: Self = Self(152); + pub const SERVICE_METHOD_CALL_FROM_CLIENT_NON_AUTHED: Self = Self(9804); +} + +pub const EMSG_PROTO_FLAG: u32 = 0x8000_0000; +pub const EMSG_MASK: u32 = 0x7fff_ffff; + +pub const fn has_proto_flag(raw: u32) -> bool { + (raw & EMSG_PROTO_FLAG) != 0 +} + +pub const fn strip_proto_flag(raw: u32) -> EMsg { + EMsg(raw & EMSG_MASK) +} + +pub const fn with_proto_flag(msg: EMsg) -> u32 { + msg.0 | EMSG_PROTO_FLAG +} + +#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)] +#[repr(u32)] +pub enum EUniverse { + #[default] + Invalid = 0, + Public = 1, + Beta = 2, + Internal = 3, + Dev = 4, + Max = 5, +} + +impl EUniverse { + pub fn from_u32(v: u32) -> Option { + match v { + 1 => Some(Self::Public), + 2 => Some(Self::Beta), + 3 => Some(Self::Internal), + 4 => Some(Self::Dev), + 5 => Some(Self::Max), + _ => None, + } + } + + pub fn is_valid_universe(self) -> bool { + matches!(self, Self::Public | Self::Beta | Self::Internal | Self::Dev) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn universe_values_match_steam_enum() { + assert_eq!(EUniverse::Invalid as u32, 0); + assert_eq!(EUniverse::Public as u32, 1); + assert_eq!(EUniverse::Beta as u32, 2); + assert_eq!(EUniverse::Internal as u32, 3); + assert_eq!(EUniverse::Dev as u32, 4); + assert_eq!(EUniverse::Max as u32, 5); + assert!(!EUniverse::Max.is_valid_universe()); + assert!(EUniverse::Public.is_valid_universe()); + } + + #[test] + fn free_license_emsgs_match_steamkit() { + // JavaSteam EMsg.java: ClientRequestFreeLicense(5572) / ...Response(5573). + assert_eq!(EMsg::CLIENT_REQUEST_FREE_LICENSE.0, 5572); + assert_eq!(EMsg::CLIENT_REQUEST_FREE_LICENSE_RESPONSE.0, 5573); + } +} diff --git a/app/src/main/rust/stores/src/steam/encrypted_channel.rs b/app/src/main/rust/stores/src/steam/encrypted_channel.rs new file mode 100644 index 0000000000..c88f676379 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/encrypted_channel.rs @@ -0,0 +1,472 @@ +use crate::steam::crypto::{ + aes256_cbc_decrypt, aes256_cbc_encrypt, aes256_ecb_decrypt_block, aes256_ecb_encrypt_block, + hmac_sha1, secure_random_bytes, AesBlock, SecureSessionKey, SessionKey, AES_BLOCK_BYTES, + HMAC_KEY_LENGTH, +}; +use crate::steam::transport::{Transport, TransportDisconnectReason}; +use std::sync::atomic::{AtomicU8, Ordering}; +use std::sync::{Arc, Mutex}; + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[repr(u8)] +pub enum ChannelState { + Disconnected, + Connected, + Challenged, + Encrypted, + Closing, +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[repr(u8)] +pub enum ChannelDisconnectReason { + UserInitiated, + TransportError, + HandshakeProtocolError, + HandshakeFailed, + EnvelopeDecryptFailed, + HmacMismatch, +} + +type MessageCallback = Arc; +type ConnectedCallback = Arc; +type DisconnectedCallback = Arc; + +pub struct EncryptedChannel { + inner: Arc, + transport: Mutex>, +} + +struct EncryptedChannelInner { + state: AtomicU8, + on_message: Mutex>, + on_connected: Mutex>, + on_disconnected: Mutex>, +} + +impl Default for EncryptedChannelInner { + fn default() -> Self { + Self { + state: AtomicU8::new(ChannelState::Disconnected as u8), + on_message: Mutex::new(None), + on_connected: Mutex::new(None), + on_disconnected: Mutex::new(None), + } + } +} + +impl EncryptedChannel { + pub fn new(mut transport: Box) -> Self { + let inner = Arc::new(EncryptedChannelInner::default()); + + let weak = Arc::downgrade(&inner); + transport.set_on_connected(Box::new(move || { + if let Some(inner) = weak.upgrade() { + inner + .state + .store(ChannelState::Encrypted as u8, Ordering::Release); + let callback = inner + .on_connected + .lock() + .expect("encrypted channel callback poisoned") + .clone(); + if let Some(callback) = callback { + callback(); + } + } + })); + + let weak = Arc::downgrade(&inner); + transport.set_on_disconnected(Box::new(move |reason, detail| { + if let Some(inner) = weak.upgrade() { + inner + .state + .store(ChannelState::Disconnected as u8, Ordering::Release); + let reason = match reason { + TransportDisconnectReason::UserInitiated => { + ChannelDisconnectReason::UserInitiated + } + _ => ChannelDisconnectReason::TransportError, + }; + let callback = inner + .on_disconnected + .lock() + .expect("encrypted channel callback poisoned") + .clone(); + if let Some(callback) = callback { + callback(reason, detail); + } + } + })); + + let weak = Arc::downgrade(&inner); + transport.set_on_message(Box::new(move |bytes| { + if let Some(inner) = weak.upgrade() { + if inner.state() != ChannelState::Encrypted { + return; + } + let callback = inner + .on_message + .lock() + .expect("encrypted channel callback poisoned") + .clone(); + if let Some(callback) = callback { + callback(bytes); + } + } + })); + + Self { + inner, + transport: Mutex::new(transport), + } + } + + pub fn connect(&self, url: &str) -> bool { + if self + .inner + .state + .compare_exchange( + ChannelState::Disconnected as u8, + ChannelState::Connected as u8, + Ordering::AcqRel, + Ordering::Acquire, + ) + .is_err() + { + return false; + } + if !self + .transport + .lock() + .expect("encrypted channel transport poisoned") + .connect(url) + { + self.inner + .state + .store(ChannelState::Disconnected as u8, Ordering::Release); + return false; + } + true + } + + pub fn send(&self, plaintext: &[u8]) -> bool { + if self.state() != ChannelState::Encrypted { + return false; + } + self.transport + .lock() + .expect("encrypted channel transport poisoned") + .send(plaintext) + } + + pub fn disconnect(&self) { + if self.state() == ChannelState::Disconnected { + return; + } + self.inner + .state + .store(ChannelState::Closing as u8, Ordering::Release); + self.transport + .lock() + .expect("encrypted channel transport poisoned") + .disconnect(); + } + + pub fn state(&self) -> ChannelState { + self.inner.state() + } + + pub fn set_ca_bundle_path(&self, path: &str) { + self.transport + .lock() + .expect("encrypted channel transport poisoned") + .set_ca_bundle_path(path); + } + + pub fn set_on_message(&self, callback: F) + where + F: Fn(&[u8]) + Send + Sync + 'static, + { + *self + .inner + .on_message + .lock() + .expect("encrypted channel callback poisoned") = Some(Arc::new(callback)); + } + + pub fn set_on_connected(&self, callback: F) + where + F: Fn() + Send + Sync + 'static, + { + *self + .inner + .on_connected + .lock() + .expect("encrypted channel callback poisoned") = Some(Arc::new(callback)); + } + + pub fn set_on_disconnected(&self, callback: F) + where + F: Fn(ChannelDisconnectReason, &str) + Send + Sync + 'static, + { + *self + .inner + .on_disconnected + .lock() + .expect("encrypted channel callback poisoned") = Some(Arc::new(callback)); + } +} + +impl Drop for EncryptedChannel { + fn drop(&mut self) { + self.disconnect(); + } +} + +impl EncryptedChannelInner { + fn state(&self) -> ChannelState { + match self.state.load(Ordering::Acquire) { + 1 => ChannelState::Connected, + 2 => ChannelState::Challenged, + 3 => ChannelState::Encrypted, + 4 => ChannelState::Closing, + _ => ChannelState::Disconnected, + } + } +} + +#[derive(Clone)] +pub struct EncryptedEnvelope { + session_key: SecureSessionKey, + hmac_key: [u8; HMAC_KEY_LENGTH], +} + +impl EncryptedEnvelope { + pub fn new(session_key: SessionKey) -> Self { + let mut hmac_key = [0u8; HMAC_KEY_LENGTH]; + hmac_key.copy_from_slice(&session_key[..HMAC_KEY_LENGTH]); + Self { + session_key: SecureSessionKey::new(session_key), + hmac_key, + } + } + + pub fn encrypt(&self, plaintext: &[u8]) -> Option> { + let mut random_iv = [0u8; AES_BLOCK_BYTES - 4]; + if !secure_random_bytes(&mut random_iv) { + return None; + } + self.encrypt_with_random_iv(plaintext, random_iv) + } + + fn encrypt_with_random_iv( + &self, + plaintext: &[u8], + random_iv: [u8; AES_BLOCK_BYTES - 4], + ) -> Option> { + let mut hmac_input = Vec::with_capacity(random_iv.len() + plaintext.len()); + hmac_input.extend_from_slice(&random_iv); + hmac_input.extend_from_slice(plaintext); + let hmac = hmac_sha1(&self.hmac_key, &hmac_input)?; + + let mut iv_plaintext = [0u8; AES_BLOCK_BYTES]; + iv_plaintext[..4].copy_from_slice(&hmac[..4]); + iv_plaintext[4..].copy_from_slice(&random_iv); + + let iv_ciphertext = aes256_ecb_encrypt_block(&self.session_key.bytes, &iv_plaintext)?; + let body = aes256_cbc_encrypt(&self.session_key.bytes, &iv_plaintext, plaintext)?; + + let mut out = Vec::with_capacity(AES_BLOCK_BYTES + body.len()); + out.extend_from_slice(&iv_ciphertext); + out.extend_from_slice(&body); + Some(out) + } + + pub fn decrypt(&self, wire: &[u8]) -> Option> { + if wire.len() < AES_BLOCK_BYTES * 2 { + return None; + } + let iv_ciphertext: AesBlock = wire[..AES_BLOCK_BYTES].try_into().ok()?; + let iv_plaintext = aes256_ecb_decrypt_block(&self.session_key.bytes, &iv_ciphertext)?; + let plaintext = aes256_cbc_decrypt( + &self.session_key.bytes, + &iv_plaintext, + &wire[AES_BLOCK_BYTES..], + )?; + + let mut hmac_input = Vec::with_capacity((AES_BLOCK_BYTES - 4) + plaintext.len()); + hmac_input.extend_from_slice(&iv_plaintext[4..]); + hmac_input.extend_from_slice(&plaintext); + let expected = hmac_sha1(&self.hmac_key, &hmac_input)?; + ct_equal(&iv_plaintext[..4], &expected[..4]).then_some(plaintext) + } +} + +fn ct_equal(a: &[u8], b: &[u8]) -> bool { + if a.len() != b.len() { + return false; + } + let mut diff = 0u8; + for (x, y) in a.iter().zip(b.iter()) { + diff |= x ^ y; + } + diff == 0 +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::steam::transport::TransportState; + use std::sync::atomic::{AtomicBool, Ordering}; + use std::sync::mpsc; + + #[test] + fn envelope_roundtrips_with_fixed_iv() { + let key = [7u8; 32]; + let env = EncryptedEnvelope::new(key); + let encrypted = env + .encrypt_with_random_iv(b"hello steam", [3u8; AES_BLOCK_BYTES - 4]) + .unwrap(); + assert_ne!(encrypted, b"hello steam"); + assert_eq!(env.decrypt(&encrypted).unwrap(), b"hello steam"); + } + + #[test] + fn envelope_rejects_hmac_mismatch() { + let key = [7u8; 32]; + let env = EncryptedEnvelope::new(key); + let mut encrypted = env + .encrypt_with_random_iv(b"hello steam", [3u8; AES_BLOCK_BYTES - 4]) + .unwrap(); + // Change the HMAC prefix carried in the IV and re-encrypt it: the CBC padding stays valid, + // so only the HMAC check can refuse it. + let iv_ciphertext: AesBlock = encrypted[..AES_BLOCK_BYTES].try_into().unwrap(); + let mut iv = aes256_ecb_decrypt_block(&key, &iv_ciphertext).unwrap(); + iv[0] ^= 0x55; + assert!(aes256_cbc_decrypt(&key, &iv, &encrypted[AES_BLOCK_BYTES..]).is_some()); + encrypted[..AES_BLOCK_BYTES].copy_from_slice(&aes256_ecb_encrypt_block(&key, &iv).unwrap()); + assert!(env.decrypt(&encrypted).is_none()); + } + + #[test] + fn websocket_channel_skips_app_layer_handshake() { + let shared = Arc::new(MockTransportState::default()); + let channel = EncryptedChannel::new(Box::new(MockTransport { + shared: Arc::clone(&shared), + })); + let connected = Arc::new(AtomicBool::new(false)); + let connected_cb = Arc::clone(&connected); + let (tx, rx) = mpsc::channel(); + channel.set_on_connected(move || { + connected_cb.store(true, Ordering::SeqCst); + }); + channel.set_on_message(move |bytes| { + tx.send(bytes.to_vec()).unwrap(); + }); + + assert!(channel.connect("wss://cm.example.com:443/cmsocket/")); + assert_eq!(channel.state(), ChannelState::Connected); + shared.fire_connected(); + assert_eq!(channel.state(), ChannelState::Encrypted); + assert!(connected.load(Ordering::SeqCst)); + + assert!(channel.send(b"client hello")); + assert_eq!(shared.sent.lock().unwrap()[0], b"client hello"); + + shared.fire_message(b"server frame"); + assert_eq!(rx.recv().unwrap(), b"server frame"); + } + + #[test] + fn channel_maps_transport_disconnect_reasons() { + let shared = Arc::new(MockTransportState::default()); + let channel = EncryptedChannel::new(Box::new(MockTransport { + shared: Arc::clone(&shared), + })); + let (tx, rx) = mpsc::channel(); + channel.set_on_disconnected(move |reason, detail| { + tx.send((reason, detail.to_string())).unwrap(); + }); + assert!(channel.connect("wss://cm.example.com:443/cmsocket/")); + shared.fire_connected(); + shared.fire_disconnected(TransportDisconnectReason::NetworkError, "net down"); + assert_eq!( + rx.recv().unwrap(), + ( + ChannelDisconnectReason::TransportError, + "net down".to_string() + ) + ); + assert_eq!(channel.state(), ChannelState::Disconnected); + } + + #[derive(Default)] + struct MockTransportState { + connected: Mutex>, + disconnected: Mutex>, + message: Mutex>, + sent: Mutex>>, + ca_bundle_path: Mutex, + } + + impl MockTransportState { + fn fire_connected(&self) { + if let Some(callback) = self.connected.lock().unwrap().as_ref() { + callback(); + } + } + + fn fire_disconnected(&self, reason: TransportDisconnectReason, detail: &str) { + if let Some(callback) = self.disconnected.lock().unwrap().as_ref() { + callback(reason, detail); + } + } + + fn fire_message(&self, bytes: &[u8]) { + if let Some(callback) = self.message.lock().unwrap().as_ref() { + callback(bytes); + } + } + } + + struct MockTransport { + shared: Arc, + } + + impl Transport for MockTransport { + fn connect(&mut self, _url: &str) -> bool { + true + } + + fn send(&mut self, data: &[u8]) -> bool { + self.shared.sent.lock().unwrap().push(data.to_vec()); + true + } + + fn disconnect(&mut self) {} + + fn state(&self) -> TransportState { + TransportState::Connected + } + + fn set_on_message(&mut self, cb: Box) { + *self.shared.message.lock().unwrap() = Some(cb); + } + + fn set_on_connected(&mut self, cb: Box) { + *self.shared.connected.lock().unwrap() = Some(cb); + } + + fn set_on_disconnected( + &mut self, + cb: Box, + ) { + *self.shared.disconnected.lock().unwrap() = Some(cb); + } + + fn set_ca_bundle_path(&mut self, path: &str) { + *self.shared.ca_bundle_path.lock().unwrap() = path.to_string(); + } + } +} diff --git a/app/src/main/rust/stores/src/steam/handshake_messages.rs b/app/src/main/rust/stores/src/steam/handshake_messages.rs new file mode 100644 index 0000000000..14e59a556c --- /dev/null +++ b/app/src/main/rust/stores/src/steam/handshake_messages.rs @@ -0,0 +1,192 @@ +use crate::steam::emsg::{has_proto_flag, strip_proto_flag, EMsg, EUniverse}; +use crate::steam::wire_format; + +pub const INVALID_JOB_ID: u64 = u64::MAX; +pub const MSG_HDR_BYTES: usize = 20; + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct MsgHdr { + pub msg: EMsg, + pub target_job_id: u64, + pub source_job_id: u64, +} + +impl Default for MsgHdr { + fn default() -> Self { + Self { + msg: EMsg::INVALID, + target_job_id: INVALID_JOB_ID, + source_job_id: INVALID_JOB_ID, + } + } +} + +impl MsgHdr { + pub fn serialize(&self, out: &mut Vec) { + let mut writer = wire_format::Writer::new(out); + writer.u32(self.msg.0); + writer.u64(self.target_job_id); + writer.u64(self.source_job_id); + } + + pub fn deserialize(input: &[u8]) -> Option<(Self, usize)> { + if input.len() < MSG_HDR_BYTES { + return None; + } + let mut reader = wire_format::Reader::new(&input[..MSG_HDR_BYTES]); + let raw_msg = reader.u32(); + if has_proto_flag(raw_msg) { + return None; + } + let hdr = Self { + msg: strip_proto_flag(raw_msg), + target_job_id: reader.u64(), + source_job_id: reader.u64(), + }; + reader.ok().then_some((hdr, MSG_HDR_BYTES)) + } +} + +pub const CHANNEL_ENCRYPT_PROTOCOL_VERSION: u32 = 1; +pub const CHANNEL_ENCRYPT_REQUEST_FIXED_BODY: usize = 8; + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct MsgChannelEncryptRequest { + pub protocol_version: u32, + pub universe: EUniverse, + pub challenge: Vec, +} + +impl Default for MsgChannelEncryptRequest { + fn default() -> Self { + Self { + protocol_version: CHANNEL_ENCRYPT_PROTOCOL_VERSION, + universe: EUniverse::Invalid, + challenge: Vec::new(), + } + } +} + +impl MsgChannelEncryptRequest { + pub fn deserialize_body(body: &[u8]) -> Option { + if body.len() < CHANNEL_ENCRYPT_REQUEST_FIXED_BODY { + return None; + } + let mut reader = wire_format::Reader::new(body); + let protocol_version = reader.u32(); + let universe = EUniverse::from_u32(reader.u32())?; + if !reader.ok() { + return None; + } + let challenge = body[CHANNEL_ENCRYPT_REQUEST_FIXED_BODY..].to_vec(); + Some(Self { + protocol_version, + universe, + challenge, + }) + } +} + +pub const RSA_1024_CIPHER_BYTES: usize = 128; +pub const CHANNEL_ENCRYPT_RESPONSE_BODY_BYTES: usize = 144; + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct MsgChannelEncryptResponse { + pub protocol_version: u32, + pub key_size: u32, + pub encrypted_handshake_blob: [u8; RSA_1024_CIPHER_BYTES], + pub key_crc: u32, + pub unknown_zero: u32, +} + +impl Default for MsgChannelEncryptResponse { + fn default() -> Self { + Self { + protocol_version: CHANNEL_ENCRYPT_PROTOCOL_VERSION, + key_size: RSA_1024_CIPHER_BYTES as u32, + encrypted_handshake_blob: [0; RSA_1024_CIPHER_BYTES], + key_crc: 0, + unknown_zero: 0, + } + } +} + +impl MsgChannelEncryptResponse { + pub fn serialize_body(&self, out: &mut Vec) { + let mut writer = wire_format::Writer::new(out); + writer.u32(self.protocol_version); + writer.u32(self.key_size); + writer.bytes(&self.encrypted_handshake_blob); + writer.u32(self.key_crc); + writer.u32(self.unknown_zero); + } +} + +pub const CHANNEL_ENCRYPT_RESULT_BODY_BYTES: usize = 4; + +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub struct MsgChannelEncryptResult { + pub result: u32, +} + +impl MsgChannelEncryptResult { + pub fn deserialize_body(body: &[u8]) -> Option { + if body.len() < CHANNEL_ENCRYPT_RESULT_BODY_BYTES { + return None; + } + let mut reader = wire_format::Reader::new(body); + let result = reader.u32(); + reader.ok().then_some(Self { result }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::steam::emsg::with_proto_flag; + + #[test] + fn msg_hdr_roundtrips_and_rejects_proto_flag() { + let hdr = MsgHdr { + msg: EMsg::CHANNEL_ENCRYPT_REQUEST, + target_job_id: 7, + source_job_id: 9, + }; + let mut bytes = Vec::new(); + hdr.serialize(&mut bytes); + assert_eq!(bytes.len(), MSG_HDR_BYTES); + assert_eq!(MsgHdr::deserialize(&bytes), Some((hdr, MSG_HDR_BYTES))); + + bytes[..4].copy_from_slice(&with_proto_flag(EMsg::CHANNEL_ENCRYPT_REQUEST).to_le_bytes()); + assert_eq!(MsgHdr::deserialize(&bytes), None); + } + + #[test] + fn channel_encrypt_request_parses_challenge() { + let mut body = Vec::new(); + let mut writer = wire_format::Writer::new(&mut body); + writer.u32(1); + writer.u32(EUniverse::Public as u32); + writer.bytes(&[0xaa; 16]); + let msg = MsgChannelEncryptRequest::deserialize_body(&body).unwrap(); + assert_eq!(msg.protocol_version, 1); + assert_eq!(msg.universe, EUniverse::Public); + assert_eq!(msg.challenge, vec![0xaa; 16]); + } + + #[test] + fn channel_encrypt_response_is_144_bytes() { + let msg = MsgChannelEncryptResponse { + key_crc: 0xfeed_beef, + ..Default::default() + }; + let mut body = Vec::new(); + msg.serialize_body(&mut body); + assert_eq!(body.len(), CHANNEL_ENCRYPT_RESPONSE_BODY_BYTES); + assert_eq!(&body[0..4], &1u32.to_le_bytes()); + assert_eq!( + &body[8 + RSA_1024_CIPHER_BYTES..12 + RSA_1024_CIPHER_BYTES], + &0xfeed_beefu32.to_le_bytes() + ); + } +} diff --git a/app/src/main/rust/stores/src/steam/heartbeat.rs b/app/src/main/rust/stores/src/steam/heartbeat.rs new file mode 100644 index 0000000000..58e3c4769a --- /dev/null +++ b/app/src/main/rust/stores/src/steam/heartbeat.rs @@ -0,0 +1,128 @@ +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Condvar, Mutex}; +use std::thread::{self, JoinHandle}; +use std::time::Duration; +use std::{panic, panic::AssertUnwindSafe}; + +#[derive(Default)] +pub struct Heartbeat { + running: Arc, + stop: Arc<(Mutex, Condvar)>, + worker: Option>, +} + +impl Heartbeat { + pub fn start(&mut self, interval: Duration, cb: F) -> bool + where + F: Fn() + Send + 'static, + { + if interval.is_zero() { + return false; + } + self.stop(); + self.running.store(true, Ordering::Relaxed); + { + let (mu, _) = &*self.stop; + *mu.lock().expect("heartbeat poisoned") = false; + } + let running = Arc::clone(&self.running); + let stop = Arc::clone(&self.stop); + self.worker = Some(thread::spawn(move || run_loop(interval, cb, running, stop))); + true + } + + pub fn stop(&mut self) { + if !self.running.load(Ordering::Relaxed) { + return; + } + let (mu, cv) = &*self.stop; + *mu.lock().expect("heartbeat poisoned") = true; + cv.notify_all(); + if let Some(worker) = self.worker.take() { + let _ = worker.join(); + } + self.running.store(false, Ordering::Relaxed); + } + + pub fn running(&self) -> bool { + self.running.load(Ordering::Relaxed) + } +} + +impl Drop for Heartbeat { + fn drop(&mut self) { + self.stop(); + } +} + +fn run_loop( + interval: Duration, + cb: F, + running: Arc, + stop: Arc<(Mutex, Condvar)>, +) where + F: Fn() + Send + 'static, +{ + let (mu, cv) = &*stop; + loop { + let guard = mu.lock().expect("heartbeat poisoned"); + let (guard, _) = cv + .wait_timeout_while(guard, interval, |stop_requested| !*stop_requested) + .expect("heartbeat poisoned"); + if *guard { + return; + } + drop(guard); + let _ = panic::catch_unwind(AssertUnwindSafe(&cb)); + if !running.load(Ordering::Relaxed) { + return; + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::atomic::{AtomicUsize, Ordering}; + + #[test] + fn rejects_zero_interval() { + let mut hb = Heartbeat::default(); + assert!(!hb.start(Duration::ZERO, || {})); + assert!(!hb.running()); + } + + #[test] + fn ticks_and_stops() { + let ticks = Arc::new(AtomicUsize::new(0)); + let tick_copy = Arc::clone(&ticks); + let (tx, rx) = std::sync::mpsc::sync_channel(1); + let mut hb = Heartbeat::default(); + assert!(hb.start(Duration::from_millis(10), move || { + tick_copy.fetch_add(1, Ordering::Relaxed); + let _ = tx.try_send(()); + })); + rx.recv_timeout(Duration::from_secs(5)).unwrap(); + hb.stop(); + assert!(ticks.load(Ordering::Relaxed) > 0); + assert!(!hb.running()); + } + + #[test] + fn callback_panic_does_not_stop_worker() { + let ticks = Arc::new(AtomicUsize::new(0)); + let tick_copy = Arc::clone(&ticks); + let (tx, rx) = std::sync::mpsc::channel(); + let mut hb = Heartbeat::default(); + assert!(hb.start(Duration::from_millis(10), move || { + let n = tick_copy.fetch_add(1, Ordering::Relaxed); + if n == 0 { + panic!("first heartbeat panic"); + } + tx.send(()).unwrap(); + })); + rx.recv_timeout(Duration::from_secs(1)).unwrap(); + hb.stop(); + assert!(ticks.load(Ordering::Relaxed) > 1); + } +} diff --git a/app/src/main/rust/stores/src/steam/http.rs b/app/src/main/rust/stores/src/steam/http.rs new file mode 100644 index 0000000000..722eb4e3ab --- /dev/null +++ b/app/src/main/rust/stores/src/steam/http.rs @@ -0,0 +1,79 @@ +//! One-shot HTTPS GET for the few non-chunk requests (CM directory, manifests, HTTP-delivered +//! appinfo). Chunk downloads go through the shared fetch core instead. + +use std::fs; +use std::time::Duration; + +pub const USER_AGENT: &str = crate::fetch_tuning::USER_AGENT; +/// Largest body kept from a successful response (the biggest depot manifests are tens of MB). +pub const MAX_BODY_BYTES: usize = 256 << 20; +/// Largest body kept from any other status; callers only use it for diagnostics. +const MAX_ERROR_BODY_BYTES: usize = 64 << 10; + +pub struct Response { + pub status: u16, + pub content_length: Option, + pub body: Vec, +} + +pub fn get(url: &str, timeout: Duration, ca_bundle_path: &str) -> Result { + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .map_err(|err| format!("runtime: {err}"))?; + runtime.block_on(get_async(url, timeout, ca_bundle_path)) +} + +async fn get_async(url: &str, timeout: Duration, ca_bundle_path: &str) -> Result { + let mut builder = reqwest::Client::builder() + .user_agent(USER_AGENT) + .connect_timeout(crate::fetch_tuning::connect_timeout()) + .timeout(timeout); + if !ca_bundle_path.is_empty() { + let pem = fs::read(ca_bundle_path).map_err(|err| format!("read CA bundle: {err}"))?; + let certs = reqwest::Certificate::from_pem_bundle(&pem) + .map_err(|err| format!("parse CA bundle: {err}"))?; + for cert in certs { + builder = builder.add_root_certificate(cert); + } + } + let client = builder + .build() + .map_err(|err| format!("http client: {err}"))?; + let response = client + .get(url) + .send() + .await + .map_err(|err| format!("http get: {}", err.without_url()))?; + let status = response.status().as_u16(); + let content_length = response.content_length(); + let limit = if status == 200 { + MAX_BODY_BYTES + } else { + MAX_ERROR_BODY_BYTES + }; + if status == 200 && content_length.is_some_and(|len| len > limit as u64) { + return Err(format!("http body: larger than {limit} bytes")); + } + let mut response = response; + let mut body = Vec::new(); + while let Some(chunk) = response + .chunk() + .await + .map_err(|err| format!("http body: {}", err.without_url()))? + { + if body.len() + chunk.len() > limit { + if status == 200 { + return Err(format!("http body: larger than {limit} bytes")); + } + body.extend_from_slice(&chunk[..limit - body.len()]); + break; + } + body.extend_from_slice(&chunk); + } + Ok(Response { + status, + content_length, + body, + }) +} diff --git a/app/src/main/rust/stores/src/steam/install.rs b/app/src/main/rust/stores/src/steam/install.rs new file mode 100644 index 0000000000..5088ca591c --- /dev/null +++ b/app/src/main/rust/stores/src/steam/install.rs @@ -0,0 +1,467 @@ +//! One `nativeStart` run: plan, take over a half-finished client download, download the game's +//! depots into its library folder, install missing shared depots into their app's folder, then +//! register everything the way the Steam client does. The resume journal lives in the +//! caller-given journal directory and is removed once the game is registered. + +use crate::steam::depot_config::{app_journal_dir, DepotConfigStore}; +use crate::steam::depot_downloader::{download_prepared, prepare_depot, DepotError, PreparedDepot}; +use crate::steam::pb::ccontentserverdirectory::CContentServerDirectoryServerInfo; +use crate::steam::plan::AppPlan; +use crate::steam::register::{self, InstalledDepot, LibraryRoot, SharedInstall, Takeover}; +use crate::steam::session::Session; +use serde_json::{json, Value}; +use std::path::PathBuf; +use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::Mutex; +use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH}; + +pub const PHASE_PREPARING: &str = "preparing"; +pub const PHASE_DOWNLOADING: &str = "downloading"; +pub const PHASE_SHARED: &str = "shared"; +pub const PHASE_REGISTERING: &str = "registering"; +pub const DEFAULT_MAX_WORKERS: usize = 16; +const PROGRESS_INTERVAL: Duration = Duration::from_millis(250); + +pub struct StartRequest { + pub app_id: u32, + pub language: String, + pub steam_root: PathBuf, + pub game_library: LibraryRoot, + pub libraries: Vec, + pub journal_dir: PathBuf, + pub ca_bundle_path: String, + pub max_workers: usize, + pub process_workers: usize, +} + +/// Decode/write threads when the caller passes 0: half the cores, between 2 and 6. +pub fn default_process_workers() -> usize { + std::thread::available_parallelism() + .map(|n| n.get() / 2) + .unwrap_or(2) + .clamp(2, 6) +} + +pub trait Events: Sync { + fn progress(&self, done: u64, total: u64, phase: &str); +} + +/// The resume journal of one app in one library: depots finished in another library are not on this one. +fn journal_for(root: &std::path::Path, app_id: u32, library_guest: &str) -> PathBuf { + app_journal_dir(root, app_id).join(format!("{:08x}", crc32fast::hash(library_guest.trim_end_matches('/').as_bytes()))) +} + +fn fail(error: impl Into) -> Value { + json!({"ok": false, "error": error.into()}) +} + +fn now_unix() -> u64 { + SystemTime::now() + .duration_since(UNIX_EPOCH) + .map(|d| d.as_secs()) + .unwrap_or(0) +} + +/// The app's plan with shared depots resolved. An app the account does not own is refused, +/// except a free one: `request_free_license` asks Steam for its license first (an install), else +/// it is planned as is (sizes for the UI). +pub fn build_plan( + session: &Session, + app_id: u32, + language: &str, + request_free_license: bool, +) -> Result { + let appinfo = session + .app_info(app_id) + .ok_or_else(|| "appinfo unavailable".to_string())?; + let mut library = session.library()?; + if !library.owns(app_id) { + if !crate::steam::plan::is_free(&appinfo) { + return Err("not_owned".to_string()); + } + if request_free_license { + if !session.request_free_license(app_id) { + return Err("free_license_refused".to_string()); + } + library = session.library()?; + if !library.owns(app_id) { + return Err("not_owned".to_string()); + } + } + } + // An app planned without its license (a free one, for sizes) has no granted depots to go by. + let owned_depots = library.owns(app_id).then_some(&library.owned_depots); + let mut plan = crate::steam::plan::plan_app( + app_id, + &appinfo, + &library.owned_apps, + owned_depots, + language, + )?; + crate::steam::plan::resolve_shared(&mut plan, &|from| session.app_info(from))?; + Ok(plan) +} + +struct Progress<'a> { + events: &'a dyn Events, + total: AtomicU64, + base: AtomicU64, + phase: Mutex<&'static str>, + last: Mutex, +} + +impl<'a> Progress<'a> { + fn new(events: &'a dyn Events) -> Self { + Self { + events, + total: AtomicU64::new(0), + base: AtomicU64::new(0), + phase: Mutex::new(PHASE_PREPARING), + last: Mutex::new(Instant::now() - PROGRESS_INTERVAL), + } + } + + fn phase(&self, phase: &'static str) { + *self.phase.lock().expect("phase poisoned") = phase; + self.emit(self.base.load(Ordering::Relaxed), true); + } + + fn emit(&self, done: u64, force: bool) { + { + let mut last = self.last.lock().expect("progress poisoned"); + if !force && last.elapsed() < PROGRESS_INTERVAL { + return; + } + *last = Instant::now(); + } + let phase = *self.phase.lock().expect("phase poisoned"); + let total = self.total.load(Ordering::Relaxed); + self.events.progress(done, total, phase); + } + + /// Progress inside one depot: `done` bytes of it on top of what earlier depots finished. + fn depot(&self, done: u64) { + self.emit(self.base.load(Ordering::Relaxed) + done, false); + } + + fn finish_depot(&self, bytes: u64) { + self.base.fetch_add(bytes, Ordering::Relaxed); + self.emit(self.base.load(Ordering::Relaxed), true); + } +} + +fn servers_for( + servers: &[CContentServerDirectoryServerInfo], + app_id: u32, +) -> Vec { + servers + .iter() + .filter(|s| s.allowed_app_ids.is_empty() || s.allowed_app_ids.contains(&app_id)) + .cloned() + .collect() +} + +pub fn run( + session: &Session, + req: &StartRequest, + cancel: &AtomicBool, + events: &dyn Events, +) -> Value { + let progress = Progress::new(events); + progress.phase(PHASE_PREPARING); + let log = |line: &str| crate::steam::log(line); + let cancelled = || cancel.load(Ordering::Relaxed); + + let plan = match build_plan(session, req.app_id, &req.language, true) { + Ok(plan) => plan, + Err(err) => return fail(err), + }; + if cancelled() { + return fail("cancelled"); + } + // Checked before takeover, which removes a half-finished client download's staging. + if !register::library_registered(&req.steam_root, &req.game_library.guest) { + return fail("library_not_in_libraryfolders"); + } + let adopted = register::adopt_staged(&req.game_library, req.app_id, &plan.install_dir); + if adopted > 0 { + log(&format!("adopted {adopted} file(s) the client had staged")); + } + let takeover = match register::takeover(&req.game_library, req.app_id, plan.build_id) { + Ok(t) => t, + Err(err) => return fail(format!("takeover: {err}")), + }; + log(&format!( + "start app={} build={} depots={} shared={} takeover={takeover:?}", + req.app_id, + plan.build_id, + plan.depots.len(), + plan.shared.len() + )); + let mut journal = + DepotConfigStore::load(journal_for(&req.journal_dir, req.app_id, &req.game_library.guest), plan.build_id); + if takeover == Takeover::AlreadyInstalled { + // A run that wrote the app manifest may have stopped before the library index: finish it. + match register::update_libraryfolders( + &req.steam_root, + &req.game_library.guest, + req.app_id, + true, + ) { + Ok(0) => return fail("library_not_in_libraryfolders"), + Ok(_) => {} + Err(err) => return fail(format!("libraryfolders: {err}")), + } + journal.discard(); + return json!({"ok": true, "alreadyInstalled": true}); + } + if takeover == Takeover::Update { + // Updates stay with the Steam client: it removes files a new build dropped. + return fail("update_in_steam"); + } + if takeover == Takeover::TookOver { + journal.discard(); + } + + let Some(all_servers) = session.cdn_servers() else { + return fail("CDN server request failed"); + }; + let game_servers = servers_for(&all_servers, req.app_id); + + let mut game_depots: Vec<(PreparedDepot, u32)> = Vec::new(); + for depot in &plan.depots { + match prepare_depot( + session, + &game_servers, + Some(&journal), + &req.ca_bundle_path, + req.app_id, + depot.depot_id, + depot.manifest_id, + cancel, + ) { + Ok(prepared) => game_depots.push((prepared, depot.dlc_app_id)), + Err(DepotError::AccessDenied(id)) if depot.dlc_app_id != 0 => { + log(&format!("skipping DLC depot {id}: access denied")); + } + Err(err) => return fail(err.message()), + } + } + + let mut shared_jobs: Vec<(PreparedDepot, SharedInstall)> = Vec::new(); + let mut shared_present: Vec<(u32, u32)> = Vec::new(); + let mut shared_present_libraries: Vec<(u32, register::LibraryRoot)> = Vec::new(); + for shared in &plan.shared { + let library = + register::shared_app_library(shared.from_app_id, &req.steam_root, &req.libraries); + let installed = crate::steam::kv::parse_file(&library.acf_path(shared.from_app_id)) + .and_then(|acf| register::installed_manifest(&acf, shared.depot_id)); + if installed == Some(shared.manifest_id) { + shared_present.push((shared.depot_id, shared.from_app_id)); + shared_present_libraries.push((shared.from_app_id, library)); + continue; + } + let servers = servers_for(&all_servers, shared.from_app_id); + let prepared = match prepare_depot( + session, + &servers, + Some(&journal), + &req.ca_bundle_path, + shared.from_app_id, + shared.depot_id, + shared.manifest_id, + cancel, + ) { + Ok(p) => p, + Err(DepotError::AccessDenied(id)) => { + log(&format!("skipping shared depot {id}: access denied")); + continue; + } + Err(err) => return fail(err.message()), + }; + let install = SharedInstall { + depot_id: shared.depot_id, + from_app_id: shared.from_app_id, + from_name: shared.from_name.clone(), + from_install_dir: shared.from_install_dir.clone(), + from_build_id: shared.from_build_id, + manifest_id: shared.manifest_id, + size: prepared.manifest.metadata.cb_disk_original.max(shared.size), + install_script: register::install_script_path(&prepared.manifest), + library, + }; + shared_jobs.push((prepared, install)); + } + + let depot_bytes = + |p: &PreparedDepot| crate::steam::depot_writer::depot_total_bytes(&p.manifest); + let total: u64 = game_depots.iter().map(|(p, _)| depot_bytes(p)).sum::() + + shared_jobs.iter().map(|(p, _)| depot_bytes(p)).sum::(); + progress.total.store(total, Ordering::Relaxed); + + let max_workers = if req.max_workers == 0 { + DEFAULT_MAX_WORKERS + } else { + req.max_workers + }; + let process_workers = if req.process_workers == 0 { + default_process_workers() + } else { + req.process_workers + }; + let ca = req.ca_bundle_path.as_str(); + + if let Err(err) = + register::write_started_acf(&req.game_library, &plan, session.steam_id, now_unix()) + { + return fail(format!("app manifest: {err}")); + } + progress.phase(PHASE_DOWNLOADING); + let game_dir = req.game_library.common_dir(&plan.install_dir); + for (prepared, _) in &game_depots { + if journal.is_installed(prepared.depot_id, prepared.manifest_id) { + progress.finish_depot(depot_bytes(prepared)); + continue; + } + if cancelled() { + return fail("cancelled"); + } + journal.begin_depot(prepared.depot_id); + let outcome = download_prepared( + prepared, + &game_servers, + &game_dir, + ca, + max_workers, + process_workers, + cancel, + &|done| progress.depot(done), + &log, + ); + if outcome.cancelled { + return fail("cancelled"); + } + if let Some(err) = outcome.error { + return fail(format!("depot {}: {err}", prepared.depot_id)); + } + journal.finish_depot(prepared.depot_id, prepared.manifest_id); + progress.finish_depot(depot_bytes(prepared)); + } + + progress.phase(PHASE_SHARED); + for (prepared, install) in &shared_jobs { + if cancelled() { + return fail("cancelled"); + } + let servers = servers_for(&all_servers, install.from_app_id); + let target = install.library.common_dir(&install.from_install_dir); + // The journal belongs to the game's library; a shared depot written to another library is + // checked on disk instead (only missing or wrong chunks are fetched). + let recorded = install.library.guest.trim_end_matches('/') + == req.game_library.guest.trim_end_matches('/') + && journal.is_installed(prepared.depot_id, prepared.manifest_id); + if !recorded { + journal.begin_depot(prepared.depot_id); + let outcome = download_prepared( + prepared, + &servers, + &target, + ca, + max_workers, + process_workers, + cancel, + &|done| progress.depot(done), + &log, + ); + if outcome.cancelled { + return fail("cancelled"); + } + if let Some(err) = outcome.error { + return fail(format!("shared depot {}: {err}", prepared.depot_id)); + } + journal.finish_depot(prepared.depot_id, prepared.manifest_id); + } + progress.finish_depot(depot_bytes(prepared)); + } + + progress.phase(PHASE_REGISTERING); + let now = now_unix(); + let owner = session.steam_id; + for (_, install) in &shared_jobs { + if let Err(err) = register::register_shared_depot(install, owner, now) { + return fail(format!("register shared depot: {err}")); + } + if let Err(err) = register::update_libraryfolders( + &req.steam_root, + &install.library.guest, + install.from_app_id, + true, + ) { + return fail(format!("libraryfolders: {err}")); + } + } + // A shared app already installed may still be missing from its library's index (an earlier + // run stopped between its manifest and the index); the update is idempotent. + for (from_app_id, library) in &shared_present_libraries { + if let Err(err) = + register::update_libraryfolders(&req.steam_root, &library.guest, *from_app_id, true) + { + return fail(format!("libraryfolders: {err}")); + } + } + let installed: Vec = game_depots + .iter() + .map(|(p, dlc)| InstalledDepot { + depot_id: p.depot_id, + manifest_id: p.manifest_id, + size: p.manifest.metadata.cb_disk_original, + dlc_app_id: *dlc, + }) + .collect(); + let scripts: Vec<(u32, String)> = game_depots + .iter() + .filter_map(|(p, _)| register::install_script_path(&p.manifest).map(|s| (p.depot_id, s))) + .collect(); + let mut shared_list: Vec<(u32, u32)> = shared_jobs + .iter() + .map(|(_, s)| (s.depot_id, s.from_app_id)) + .collect(); + shared_list.extend(shared_present); + shared_list.sort_unstable(); + let downloaded = game_depots + .iter() + .map(|(p, _)| p.manifest.metadata.cb_disk_compressed) + .sum::() + + shared_jobs + .iter() + .map(|(p, _)| p.manifest.metadata.cb_disk_compressed) + .sum::(); + let staged = installed.iter().map(|d| d.size).sum::() + + shared_jobs.iter().map(|(_, s)| s.size).sum::(); + let registration = register::GameRegistration { + plan: &plan, + owner_steam_id: owner, + depots: &installed, + shared: &shared_list, + install_scripts: &scripts, + bytes_downloaded: downloaded, + bytes_staged: staged, + now, + }; + if let Err(err) = register::write_game_acf(&req.game_library, ®istration) { + return fail(format!("app manifest: {err}")); + } + match register::update_libraryfolders(&req.steam_root, &req.game_library.guest, req.app_id, true) + { + Ok(0) => return fail("library_not_in_libraryfolders"), + Ok(_) => {} + Err(err) => return fail(format!("libraryfolders: {err}")), + } + journal.discard(); + progress.emit(total, true); + log(&format!( + "installed app={} build={} bytes={total} downloaded={downloaded}", + req.app_id, plan.build_id + )); + json!({"ok": true, "alreadyInstalled": false}) +} diff --git a/app/src/main/rust/stores/src/steam/jni.rs b/app/src/main/rust/stores/src/steam/jni.rs new file mode 100644 index 0000000000..0eeafb60f5 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/jni.rs @@ -0,0 +1,446 @@ +//! JNI surface of the Steam store: `com.droiddeck.launcher.stores.steam.SteamNative` +//! (see `JNI.md`). Every answer is a JSON object with `"ok"`; failures carry `"error"`. + +use crate::steam::install::{self, Events, StartRequest}; +use crate::steam::register::{self, LibraryRoot}; +use crate::steam::session; +use crate::steam::signin; +use jni::objects::{GlobalRef, JClass, JObject, JString, JValue}; +use jni::sys::{jint, jlong, jstring, JNI_FALSE, JNI_TRUE}; +use jni::{JNIEnv, JavaVM}; +use serde_json::{json, Value}; +use std::collections::HashSet; +use std::panic::{catch_unwind, AssertUnwindSafe}; +use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex}; +use std::thread; + +static RUNNING: Mutex>> = Mutex::new(None); + +fn jstring_to_string(env: &mut JNIEnv, value: &JString) -> String { + if value.is_null() { + return String::new(); + } + env.get_string(value) + .map(|s| s.to_string_lossy().into_owned()) + .unwrap_or_default() +} + +fn answer(env: &mut JNIEnv, value: Value) -> jstring { + env.new_string(value.to_string()) + .map(|s| s.into_raw()) + .unwrap_or(std::ptr::null_mut()) +} + +fn error(message: impl Into) -> Value { + json!({"ok": false, "error": message.into()}) +} + +/// Runs `f`, turning a panic into an `internal_error` answer. +fn guarded(f: impl FnOnce() -> Value) -> Value { + catch_unwind(AssertUnwindSafe(f)).unwrap_or_else(|_| error("internal_error")) +} + +fn parse_string_array(text: &str) -> Vec { + serde_json::from_str::(text) + .ok() + .and_then(|v| v.as_array().cloned()) + .unwrap_or_default() + .iter() + .filter_map(|v| v.as_str()) + .filter(|s| !s.is_empty()) + .map(PathBuf::from) + .collect() +} + +pub fn parse_library_roots(text: &str) -> Vec { + serde_json::from_str::(text) + .ok() + .and_then(|v| v.as_array().cloned()) + .unwrap_or_default() + .iter() + .filter_map(|v| { + let host = v.get("host")?.as_str()?; + let guest = v.get("guest")?.as_str()?; + (!host.is_empty()).then(|| LibraryRoot { + host: PathBuf::from(host), + guest: guest.to_string(), + }) + }) + .collect() +} + +/// All libraries, with the game library first when the list misses it. +fn libraries_with(game: &LibraryRoot, mut libraries: Vec) -> Vec { + if !libraries.iter().any(|l| l.host == game.host) { + libraries.insert(0, game.clone()); + } + libraries +} + +#[no_mangle] +pub extern "system" fn Java_com_droiddeck_launcher_stores_steam_SteamNative_nativeSignIn( + mut env: JNIEnv, + _class: JClass, + steam_roots_json: JString, + registry_vdf_path: JString, + ca_bundle_path: JString, +) -> jstring { + let roots = parse_string_array(&jstring_to_string(&mut env, &steam_roots_json)); + let registry = jstring_to_string(&mut env, ®istry_vdf_path); + let ca = jstring_to_string(&mut env, &ca_bundle_path); + let value = guarded(|| { + if let Some(live) = session::current() { + return json!({"ok": true, "account": live.account, "steamId": live.steam_id.to_string()}); + } + let registry = (!registry.is_empty()).then(|| Path::new(®istry)); + let login = match signin::load_saved_login(&roots, registry) { + Ok(login) => login, + Err(err) => { + crate::steam::log(&format!("sign-in: {}", err.code())); + return error(err.code()); + } + }; + match session::sign_in(&login, &ca) { + Ok(live) => { + json!({"ok": true, "account": live.account, "steamId": live.steam_id.to_string()}) + } + Err(err) => error(err), + } + }); + answer(&mut env, value) +} + +#[no_mangle] +pub extern "system" fn Java_com_droiddeck_launcher_stores_steam_SteamNative_nativeSignOut( + _env: JNIEnv, + _class: JClass, +) { + let _ = catch_unwind(session::sign_out); +} + +#[no_mangle] +pub extern "system" fn Java_com_droiddeck_launcher_stores_steam_SteamNative_nativeLibrary( + mut env: JNIEnv, + _class: JClass, +) -> jstring { + let value = guarded(|| { + let Some(live) = session::current() else { + return error("not_signed_in"); + }; + match live.games() { + Ok(games) => crate::steam::library::games_json(&games), + Err(err) => error(err), + } + }); + answer(&mut env, value) +} + +#[no_mangle] +pub extern "system" fn Java_com_droiddeck_launcher_stores_steam_SteamNative_nativePlan( + mut env: JNIEnv, + _class: JClass, + app_id: jint, + language: JString, +) -> jstring { + let language = jstring_to_string(&mut env, &language); + let value = guarded(|| { + let Some(live) = session::current() else { + return error("not_signed_in"); + }; + if app_id <= 0 { + return error("bad app id"); + } + match install::build_plan(&live, app_id as u32, &language, false) { + Ok(plan) => plan.to_json(), + Err(err) => error(err), + } + }); + answer(&mut env, value) +} + +pub struct SteamRunHandle { + pub cancel: Arc, +} + +struct JniEvents { + vm: JavaVM, + listener: GlobalRef, +} + +impl JniEvents { + fn with_env(&self, f: impl FnOnce(&mut JNIEnv)) { + let Ok(mut env) = self.vm.attach_current_thread_as_daemon() else { + return; + }; + f(&mut env); + if env.exception_check().unwrap_or(false) { + let _ = env.exception_clear(); + } + } + + fn complete(&self, result: &Value) { + let ok = result.get("ok").and_then(Value::as_bool).unwrap_or(false); + let text = result.to_string(); + self.with_env(|env| { + let Ok(text) = env.new_string(&text) else { + return; + }; + let text = JObject::from(text); + let _ = env.call_method( + self.listener.as_obj(), + "onComplete", + "(ZLjava/lang/String;)V", + &[ + JValue::Bool(if ok { JNI_TRUE } else { JNI_FALSE }), + JValue::Object(&text), + ], + ); + let _ = env.delete_local_ref(text); + }); + } +} + +impl Events for JniEvents { + fn progress(&self, done: u64, total: u64, phase: &str) { + self.with_env(|env| { + let Ok(phase) = env.new_string(phase) else { + return; + }; + let phase = JObject::from(phase); + let _ = env.call_method( + self.listener.as_obj(), + "onProgress", + "(JJLjava/lang/String;)V", + &[ + JValue::Long(done as jlong), + JValue::Long(total as jlong), + JValue::Object(&phase), + ], + ); + let _ = env.delete_local_ref(phase); + }); + } +} + +fn claim(app_id: u32) -> bool { + let mut guard = RUNNING.lock().expect("running poisoned"); + guard.get_or_insert_with(HashSet::new).insert(app_id) +} + +fn release_claim(app_id: u32) { + if let Some(set) = RUNNING.lock().expect("running poisoned").as_mut() { + set.remove(&app_id); + } +} + +#[no_mangle] +#[allow(clippy::too_many_arguments)] +pub extern "system" fn Java_com_droiddeck_launcher_stores_steam_SteamNative_nativeStart( + mut env: JNIEnv, + _class: JClass, + app_id: jint, + language: JString, + steam_root: JString, + game_library_host: JString, + game_library_guest: JString, + library_roots_json: JString, + journal_dir: JString, + ca_bundle_path: JString, + max_workers: jint, + process_workers: jint, + listener: JObject, +) -> jlong { + if listener.is_null() || app_id <= 0 { + crate::steam::log("nativeStart: null listener or bad app id"); + return 0; + } + let Ok(vm) = env.get_java_vm() else { + return 0; + }; + let Ok(listener) = env.new_global_ref(&listener) else { + return 0; + }; + let game_library = LibraryRoot { + host: PathBuf::from(jstring_to_string(&mut env, &game_library_host)), + guest: jstring_to_string(&mut env, &game_library_guest), + }; + let libraries = parse_library_roots(&jstring_to_string(&mut env, &library_roots_json)); + let request = StartRequest { + app_id: app_id as u32, + language: jstring_to_string(&mut env, &language), + steam_root: PathBuf::from(jstring_to_string(&mut env, &steam_root)), + libraries: libraries_with(&game_library, libraries), + game_library, + journal_dir: PathBuf::from(jstring_to_string(&mut env, &journal_dir)), + ca_bundle_path: jstring_to_string(&mut env, &ca_bundle_path), + max_workers: max_workers.max(0) as usize, + process_workers: process_workers.max(0) as usize, + }; + if request.steam_root.as_os_str().is_empty() + || request.game_library.host.as_os_str().is_empty() + || request.game_library.guest.is_empty() + || request.journal_dir.as_os_str().is_empty() + { + crate::steam::log("nativeStart: empty path argument"); + return 0; + } + let cancel = Arc::new(AtomicBool::new(false)); + let handle = SteamRunHandle { + cancel: Arc::clone(&cancel), + }; + let spawned = thread::Builder::new() + .name("steam-dl".to_string()) + .spawn(move || { + crate::priority::background(); + let events = JniEvents { vm, listener }; + let result = if !claim(request.app_id) { + error("already_running") + } else { + let result = guarded(|| match session::current() { + Some(live) => install::run(&live, &request, &cancel, &events), + None => error("not_signed_in"), + }); + release_claim(request.app_id); + result + }; + crate::steam::log(&format!("run app={} result={result}", request.app_id)); + events.complete(&result); + }); + if spawned.is_err() { + crate::steam::log("nativeStart: worker thread spawn failed"); + return 0; + } + Box::into_raw(Box::new(handle)) as jlong +} + +#[no_mangle] +pub extern "system" fn Java_com_droiddeck_launcher_stores_steam_SteamNative_nativeCancel( + _env: JNIEnv, + _class: JClass, + handle: jlong, +) { + let ptr = handle as *const SteamRunHandle; + if let Some(run) = unsafe { ptr.as_ref() } { + run.cancel.store(true, Ordering::Relaxed); + } +} + +#[no_mangle] +pub extern "system" fn Java_com_droiddeck_launcher_stores_steam_SteamNative_nativeRelease( + _env: JNIEnv, + _class: JClass, + handle: jlong, +) { + let ptr = handle as *mut SteamRunHandle; + if !ptr.is_null() { + unsafe { drop(Box::from_raw(ptr)) }; + } +} + +/// The file list of a shared depot for uninstall: the client's `depotcache` copy of the manifest +/// (it stores decrypted file names), else the manifest from the CDN through the live session. +fn shared_depot_files( + steam_root: &Path, + from_app: u32, + depot_id: u32, + manifest_id: u64, +) -> Option> { + let cached = steam_root + .join("depotcache") + .join(format!("{depot_id}_{manifest_id}.manifest")); + if let Some(mut manifest) = std::fs::read(&cached) + .ok() + .and_then(|raw| crate::steam::content_manifest::ContentManifest::parse(&raw)) + { + if !manifest.metadata.filenames_encrypted && manifest.decrypt_filenames(&[]) { + return Some(register::manifest_file_list(&manifest)); + } + } + let live = session::current()?; + let servers = live.cdn_servers()?; + let ca = live.ca_bundle_path.clone(); + let prepared = crate::steam::depot_downloader::prepare_depot( + &live, + &servers, + None, + &ca, + from_app, + depot_id, + manifest_id, + &AtomicBool::new(false), + ) + .ok()?; + Some(register::manifest_file_list(&prepared.manifest)) +} + +#[no_mangle] +pub extern "system" fn Java_com_droiddeck_launcher_stores_steam_SteamNative_nativeUninstall( + mut env: JNIEnv, + _class: JClass, + app_id: jint, + steam_root: JString, + game_library_host: JString, + game_library_guest: JString, + library_roots_json: JString, +) -> jstring { + let steam_root = PathBuf::from(jstring_to_string(&mut env, &steam_root)); + let game_library = LibraryRoot { + host: PathBuf::from(jstring_to_string(&mut env, &game_library_host)), + guest: jstring_to_string(&mut env, &game_library_guest), + }; + let libraries = libraries_with( + &game_library, + parse_library_roots(&jstring_to_string(&mut env, &library_roots_json)), + ); + let value = guarded(|| { + if app_id <= 0 || steam_root.as_os_str().is_empty() { + return error("bad arguments"); + } + let root = steam_root.clone(); + let files = move |from_app: u32, depot: u32, manifest: u64| { + shared_depot_files(&root, from_app, depot, manifest) + }; + match register::uninstall( + app_id as u32, + &steam_root, + &game_library, + &libraries, + &files, + ) { + Ok(report) => json!({ + "ok": true, + "removedShared": report.removed_shared, + "keptShared": report.kept_shared, + }), + Err(err) => error(err), + } + }); + answer(&mut env, value) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_library_roots_and_keeps_the_game_library() { + let libs = parse_library_roots( + r#"[{"host":"/data/Steam","guest":"/root/.local/share/Steam"},{"host":"","guest":"x"},{"guest":"y"}]"#, + ); + assert_eq!(libs.len(), 1); + let game = LibraryRoot { + host: "/sd/steam".into(), + guest: "/mnt/droiddeck-sd".into(), + }; + let all = libraries_with(&game, libs); + assert_eq!(all[0], game); + assert_eq!(all.len(), 2); + assert_eq!( + parse_string_array(r#"["/a", "", 3, "/b"]"#), + vec![PathBuf::from("/a"), PathBuf::from("/b")] + ); + assert!(parse_library_roots("not json").is_empty()); + } +} diff --git a/app/src/main/rust/stores/src/steam/job_manager.rs b/app/src/main/rust/stores/src/steam/job_manager.rs new file mode 100644 index 0000000000..8d6b4975fe --- /dev/null +++ b/app/src/main/rust/stores/src/steam/job_manager.rs @@ -0,0 +1,267 @@ +use std::collections::HashMap; +use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::{Arc, Condvar, Mutex}; +use std::thread::{self, JoinHandle}; +use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH}; +use std::{panic, panic::AssertUnwindSafe}; + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct JobResult { + pub eresult: i32, + pub error_message: String, + pub body: Vec, + pub synthetic_failure: bool, +} + +impl Default for JobResult { + fn default() -> Self { + Self { + eresult: 2, + error_message: String::new(), + body: Vec::new(), + synthetic_failure: false, + } + } +} + +type JobContinuation = Box; + +struct Entry { + cb: JobContinuation, + deadline: Instant, +} + +#[derive(Default)] +struct Pending { + jobs: HashMap, +} + +pub struct JobManager { + next_counter: AtomicU64, + process_epoch: u64, + default_timeout: Duration, + pending: Arc<(Mutex, Condvar)>, + stop: Arc, + timeout_thread: Option>, +} + +impl JobManager { + pub fn new(default_timeout: Duration) -> Self { + let pending = Arc::new((Mutex::new(Pending::default()), Condvar::new())); + let stop = Arc::new(AtomicBool::new(false)); + let thread_pending = Arc::clone(&pending); + let thread_stop = Arc::clone(&stop); + let timeout_thread = thread::spawn(move || timeout_loop(thread_pending, thread_stop)); + Self { + next_counter: AtomicU64::new(1), + process_epoch: make_process_epoch(), + default_timeout, + pending, + stop, + timeout_thread: Some(timeout_thread), + } + } + + pub fn next_job_id(&self) -> u64 { + let lo = self.next_counter.fetch_add(1, Ordering::Relaxed); + ((self.process_epoch & 0xFF_FFFF) << 40) | (lo & 0xFF_FFFF_FFFF) + } + + pub fn track(&self, job_id: u64, cb: F, timeout: Option) + where + F: FnOnce(JobResult) + Send + 'static, + { + let timeout = timeout.unwrap_or(self.default_timeout); + let (mu, cv) = &*self.pending; + let mut pending = mu.lock().expect("job manager poisoned"); + pending.jobs.insert( + job_id, + Entry { + cb: Box::new(cb), + deadline: Instant::now() + timeout, + }, + ); + cv.notify_all(); + } + + pub fn is_tracked(&self, job_id: u64) -> bool { + let (mu, _) = &*self.pending; + mu.lock() + .expect("job manager poisoned") + .jobs + .contains_key(&job_id) + } + + pub fn deliver( + &self, + job_id_target: u64, + mut eresult: i32, + error_message: String, + body: &[u8], + ) { + let cb = { + let (mu, _) = &*self.pending; + let mut pending = mu.lock().expect("job manager poisoned"); + pending.jobs.remove(&job_id_target).map(|entry| entry.cb) + }; + if let Some(cb) = cb { + if eresult == -1 { + eresult = 1; + } + invoke_continuation( + cb, + JobResult { + eresult, + error_message, + body: body.to_vec(), + synthetic_failure: false, + }, + ); + } + } + + pub fn fail_all(&self, reason: &str) { + let drained = { + let (mu, _) = &*self.pending; + let mut pending = mu.lock().expect("job manager poisoned"); + std::mem::take(&mut pending.jobs) + }; + for (_, entry) in drained { + invoke_continuation( + entry.cb, + JobResult { + eresult: -1, + error_message: reason.to_string(), + body: Vec::new(), + synthetic_failure: true, + }, + ); + } + } +} + +impl Default for JobManager { + fn default() -> Self { + Self::new(Duration::from_secs(30)) + } +} + +impl Drop for JobManager { + fn drop(&mut self) { + { + // Under the lock, so the worker cannot start waiting between the store and the notify. + let _guard = self.pending.0.lock().expect("job manager poisoned"); + self.stop.store(true, Ordering::Relaxed); + self.pending.1.notify_all(); + } + if let Some(handle) = self.timeout_thread.take() { + let _ = handle.join(); + } + self.fail_all("JobManager shutting down"); + } +} + +fn timeout_loop(pending: Arc<(Mutex, Condvar)>, stop: Arc) { + let (mu, cv) = &*pending; + loop { + let mut guard = mu.lock().expect("job manager poisoned"); + while guard.jobs.is_empty() && !stop.load(Ordering::Relaxed) { + guard = cv.wait(guard).expect("job manager poisoned"); + } + if stop.load(Ordering::Relaxed) { + return; + } + let earliest = guard + .jobs + .values() + .map(|entry| entry.deadline) + .min() + .unwrap_or_else(Instant::now); + let now = Instant::now(); + if earliest > now { + let (g, _) = cv + .wait_timeout(guard, earliest - now) + .expect("job manager poisoned"); + guard = g; + } + if stop.load(Ordering::Relaxed) { + return; + } + let now = Instant::now(); + let expired_ids: Vec = guard + .jobs + .iter() + .filter_map(|(id, entry)| (entry.deadline <= now).then_some(*id)) + .collect(); + let expired: Vec = expired_ids + .into_iter() + .filter_map(|id| guard.jobs.remove(&id)) + .collect(); + drop(guard); + for entry in expired { + invoke_continuation( + entry.cb, + JobResult { + eresult: -1, + error_message: "job timeout".to_string(), + body: Vec::new(), + synthetic_failure: true, + }, + ); + } + } +} + +fn invoke_continuation(cb: JobContinuation, result: JobResult) { + let _ = panic::catch_unwind(AssertUnwindSafe(|| cb(result))); +} + +fn make_process_epoch() -> u64 { + SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_secs() +} + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::mpsc; + + #[test] + fn deliver_maps_missing_eresult_to_ok() { + let jm = JobManager::new(Duration::from_secs(30)); + let id = jm.next_job_id(); + let (tx, rx) = mpsc::channel(); + jm.track(id, move |result| tx.send(result).unwrap(), None); + jm.deliver(id, -1, String::new(), b"body"); + let result = rx.recv_timeout(Duration::from_secs(1)).unwrap(); + assert_eq!(result.eresult, 1); + assert_eq!(result.body, b"body"); + } + + #[test] + fn timeout_fails_jobs_synthetically() { + let jm = JobManager::new(Duration::from_millis(20)); + let id = jm.next_job_id(); + let (tx, rx) = mpsc::channel(); + jm.track(id, move |result| tx.send(result).unwrap(), None); + let result = rx.recv_timeout(Duration::from_secs(2)).unwrap(); + assert!(result.synthetic_failure); + assert_eq!(result.error_message, "job timeout"); + } + + #[test] + fn continuation_panic_is_caught() { + let jm = JobManager::new(Duration::from_secs(30)); + let id = jm.next_job_id(); + jm.track( + id, + |_| { + panic!("continuation panic"); + }, + None, + ); + jm.deliver(id, 1, String::new(), b"body"); + } +} diff --git a/app/src/main/rust/stores/src/steam/key_dictionary.rs b/app/src/main/rust/stores/src/steam/key_dictionary.rs new file mode 100644 index 0000000000..87fb030aab --- /dev/null +++ b/app/src/main/rust/stores/src/steam/key_dictionary.rs @@ -0,0 +1,91 @@ +use crate::steam::emsg::EUniverse; + +pub const PUBLIC_UNIVERSE_KEY: [u8; 160] = [ + 0x30, 0x81, 0x9D, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, + 0x05, 0x00, 0x03, 0x81, 0x8B, 0x00, 0x30, 0x81, 0x87, 0x02, 0x81, 0x81, 0x00, 0xDF, 0xEC, 0x1A, + 0xD6, 0x2C, 0x10, 0x66, 0x2C, 0x17, 0x35, 0x3A, 0x14, 0xB0, 0x7C, 0x59, 0x11, 0x7F, 0x9D, 0xD3, + 0xD8, 0x2B, 0x7A, 0xE3, 0xE0, 0x15, 0xCD, 0x19, 0x1E, 0x46, 0xE8, 0x7B, 0x87, 0x74, 0xA2, 0x18, + 0x46, 0x31, 0xA9, 0x03, 0x14, 0x79, 0x82, 0x8E, 0xE9, 0x45, 0xA2, 0x49, 0x12, 0xA9, 0x23, 0x68, + 0x73, 0x89, 0xCF, 0x69, 0xA1, 0xB1, 0x61, 0x46, 0xBD, 0xC1, 0xBE, 0xBF, 0xD6, 0x01, 0x1B, 0xD8, + 0x81, 0xD4, 0xDC, 0x90, 0xFB, 0xFE, 0x4F, 0x52, 0x73, 0x66, 0xCB, 0x95, 0x70, 0xD7, 0xC5, 0x8E, + 0xBA, 0x1C, 0x7A, 0x33, 0x75, 0xA1, 0x62, 0x34, 0x46, 0xBB, 0x60, 0xB7, 0x80, 0x68, 0xFA, 0x13, + 0xA7, 0x7A, 0x8A, 0x37, 0x4B, 0x9E, 0xC6, 0xF4, 0x5D, 0x5F, 0x3A, 0x99, 0xF9, 0x9E, 0xC4, 0x3A, + 0xE9, 0x63, 0xA2, 0xBB, 0x88, 0x19, 0x28, 0xE0, 0xE7, 0x14, 0xC0, 0x42, 0x89, 0x02, 0x01, 0x11, +]; + +pub const BETA_UNIVERSE_KEY: [u8; 160] = [ + 0x30, 0x81, 0x9D, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, + 0x05, 0x00, 0x03, 0x81, 0x8B, 0x00, 0x30, 0x81, 0x87, 0x02, 0x81, 0x81, 0x00, 0xAE, 0xD1, 0x4B, + 0xC0, 0xA3, 0x36, 0x8B, 0xA0, 0x39, 0x0B, 0x43, 0xDC, 0xED, 0x6A, 0xC8, 0xF2, 0xA3, 0xE4, 0x7E, + 0x09, 0x8C, 0x55, 0x2E, 0xE7, 0xE9, 0x3C, 0xBB, 0xE5, 0x5E, 0x0F, 0x18, 0x74, 0x54, 0x8F, 0xF3, + 0xBD, 0x56, 0x69, 0x5B, 0x13, 0x09, 0xAF, 0xC8, 0xBE, 0xB3, 0xA1, 0x48, 0x69, 0xE9, 0x83, 0x49, + 0x65, 0x8D, 0xD2, 0x93, 0x21, 0x2F, 0xB9, 0x1E, 0xFA, 0x74, 0x3B, 0x55, 0x22, 0x79, 0xBF, 0x85, + 0x18, 0xCB, 0x6D, 0x52, 0x44, 0x4E, 0x05, 0x92, 0x89, 0x6A, 0xA8, 0x99, 0xED, 0x44, 0xAE, 0xE2, + 0x66, 0x46, 0x42, 0x0C, 0xFB, 0x6E, 0x4C, 0x30, 0xC6, 0x6C, 0x5C, 0x16, 0xFF, 0xBA, 0x9C, 0xB9, + 0x78, 0x3F, 0x17, 0x4B, 0xCB, 0xC9, 0x01, 0x5D, 0x3E, 0x37, 0x70, 0xEC, 0x67, 0x5A, 0x33, 0x48, + 0xF7, 0x46, 0xCE, 0x58, 0xAA, 0xEC, 0xD9, 0xFF, 0x4A, 0x78, 0x6C, 0x83, 0x4B, 0x02, 0x01, 0x11, +]; + +pub const INTERNAL_UNIVERSE_KEY: [u8; 160] = [ + 0x30, 0x81, 0x9D, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, + 0x05, 0x00, 0x03, 0x81, 0x8B, 0x00, 0x30, 0x81, 0x87, 0x02, 0x81, 0x81, 0x00, 0xA8, 0xFE, 0x01, + 0x3B, 0xB6, 0xD7, 0x21, 0x4B, 0x53, 0x23, 0x6F, 0xA1, 0xAB, 0x4E, 0xF1, 0x07, 0x30, 0xA7, 0xC6, + 0x7E, 0x6A, 0x2C, 0xC2, 0x5D, 0x3A, 0xB8, 0x40, 0xCA, 0x59, 0x4D, 0x16, 0x2D, 0x74, 0xEB, 0x0E, + 0x72, 0x46, 0x29, 0xF9, 0xDE, 0x9B, 0xCE, 0x4B, 0x8C, 0xD0, 0xCA, 0xF4, 0x08, 0x94, 0x46, 0xA5, + 0x11, 0xAF, 0x3A, 0xCB, 0xB8, 0x4E, 0xDE, 0xC6, 0xD8, 0x85, 0x0A, 0x7D, 0xAA, 0x96, 0x0A, 0xEA, + 0x7B, 0x51, 0xD6, 0x22, 0x62, 0x5C, 0x1E, 0x58, 0xD7, 0x46, 0x1E, 0x09, 0xAE, 0x43, 0xA7, 0xC4, + 0x34, 0x69, 0xA2, 0xA5, 0xE8, 0x44, 0x76, 0x18, 0xE2, 0x3D, 0xB7, 0xC5, 0xA8, 0x96, 0xFD, 0xE5, + 0xB4, 0x4B, 0xF8, 0x40, 0x12, 0xA6, 0x17, 0x4E, 0xC4, 0xC1, 0x60, 0x0E, 0xB0, 0xC2, 0xB8, 0x40, + 0x4D, 0x9E, 0x76, 0x4C, 0x44, 0xF4, 0xFC, 0x6F, 0x14, 0x89, 0x73, 0xB4, 0x13, 0x02, 0x01, 0x11, +]; + +pub const DEV_UNIVERSE_KEY: [u8; 160] = [ + 0x30, 0x81, 0x9D, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, + 0x05, 0x00, 0x03, 0x81, 0x8B, 0x00, 0x30, 0x81, 0x87, 0x02, 0x81, 0x81, 0x00, 0xD0, 0x05, 0x2C, + 0xE9, 0x80, 0x95, 0xCD, 0x30, 0x83, 0xA8, 0xE9, 0x25, 0x96, 0x63, 0xCE, 0xCC, 0x48, 0x5D, 0x5C, + 0x52, 0x00, 0xDB, 0x1E, 0x78, 0xD7, 0x6A, 0x4C, 0x2C, 0xC8, 0x41, 0x8C, 0xCC, 0x87, 0x46, 0xFB, + 0x1B, 0xC9, 0xE8, 0x6E, 0x4F, 0x7A, 0x6B, 0xC3, 0xE7, 0x0F, 0xD5, 0xA9, 0x5D, 0x6C, 0xD4, 0xEE, + 0xA2, 0xCC, 0x80, 0x5A, 0xD3, 0xCE, 0x53, 0x59, 0xE6, 0x80, 0x91, 0xC4, 0xC0, 0xD5, 0xF0, 0x63, + 0x23, 0x91, 0x69, 0x70, 0xC5, 0xBB, 0xBD, 0x05, 0xE2, 0x4F, 0x7D, 0x90, 0x12, 0xED, 0xAC, 0x4F, + 0x86, 0x96, 0x3C, 0x89, 0xCC, 0x92, 0x15, 0x63, 0xCB, 0x57, 0x70, 0xB9, 0xC3, 0xAE, 0x08, 0x4F, + 0xC8, 0x56, 0x16, 0xB0, 0x0C, 0xC6, 0xC8, 0x8A, 0x80, 0xD2, 0x37, 0xF7, 0x7F, 0xAB, 0x93, 0xBB, + 0xE6, 0xDE, 0x95, 0x78, 0xB8, 0x11, 0xC9, 0xE5, 0x62, 0xAD, 0xBC, 0x0C, 0x87, 0x02, 0x01, 0x11, +]; + +pub fn get_universe_public_key(universe: EUniverse) -> &'static [u8] { + match universe { + EUniverse::Public => &PUBLIC_UNIVERSE_KEY, + EUniverse::Beta => &BETA_UNIVERSE_KEY, + EUniverse::Internal => &INTERNAL_UNIVERSE_KEY, + EUniverse::Dev => &DEV_UNIVERSE_KEY, + EUniverse::Invalid | EUniverse::Max => &[], + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn returns_keys_for_known_universes_only() { + assert_eq!(get_universe_public_key(EUniverse::Public).len(), 160); + assert_eq!(get_universe_public_key(EUniverse::Beta).len(), 160); + assert_eq!(get_universe_public_key(EUniverse::Internal).len(), 160); + assert_eq!(get_universe_public_key(EUniverse::Dev).len(), 160); + assert!(get_universe_public_key(EUniverse::Invalid).is_empty()); + } + + #[test] + fn keys_are_spki_rsa_with_exponent_17() { + for universe in [ + EUniverse::Public, + EUniverse::Beta, + EUniverse::Internal, + EUniverse::Dev, + ] { + let key = get_universe_public_key(universe); + assert_eq!(&key[..8], &[0x30, 0x81, 0x9D, 0x30, 0x0D, 0x06, 0x09, 0x2A]); + assert_eq!(&key[157..], &[0x02, 0x01, 0x11]); + } + } +} diff --git a/app/src/main/rust/stores/src/steam/kv.rs b/app/src/main/rust/stores/src/steam/kv.rs new file mode 100644 index 0000000000..22e313c75a --- /dev/null +++ b/app/src/main/rust/stores/src/steam/kv.rs @@ -0,0 +1,177 @@ +//! Valve KeyValues text files (`.acf`, `libraryfolders.vdf`) as the Steam client writes them: +//! `"key"\t\t"value"`, tab indentation, `{`/`}` on their own lines, LF line endings, `\` and `"` +//! escaped. Parsing reuses `vdf::parse_text`, which keeps the file's key order, so a rewrite only +//! changes the keys that were set. + +use crate::steam::vdf::{KVNode, KVValue}; +use std::fs; +use std::path::Path; + +pub fn parse_file(path: &Path) -> Option { + let bytes = fs::read(path).ok()?; + crate::steam::vdf::parse_text(&bytes) +} + +pub fn escape(text: &str) -> String { + let mut out = String::with_capacity(text.len()); + for c in text.chars() { + match c { + '\\' => out.push_str("\\\\"), + '"' => out.push_str("\\\""), + '\n' => out.push_str("\\n"), + '\t' => out.push_str("\\t"), + '\r' => out.push_str("\\r"), + other => out.push(other), + } + } + out +} + +pub fn serialize(root: &KVNode) -> String { + let mut out = String::new(); + write_node(&mut out, root, 0); + out +} + +fn write_node(out: &mut String, node: &KVNode, depth: usize) { + let indent = "\t".repeat(depth); + if node.is_object() { + out.push_str(&format!("{indent}\"{}\"\n{indent}{{\n", escape(&node.name))); + for child in &node.children { + write_node(out, child, depth + 1); + } + out.push_str(&format!("{indent}}}\n")); + } else { + out.push_str(&format!( + "{indent}\"{}\"\t\t\"{}\"\n", + escape(&node.name), + escape(&node.as_string("")) + )); + } +} + +/// Writes `root` to `path` through a temp file in the same folder + rename. +pub fn write_file(path: &Path, root: &KVNode) -> Result<(), String> { + let text = serialize(root); + if crate::steam::depot_config::atomic_write_synced(path, text.as_bytes()) { + Ok(()) + } else { + Err(format!("write '{}' failed", path.display())) + } +} + +pub fn object(name: &str) -> KVNode { + KVNode::new(name) +} + +pub fn string(name: &str, value: impl Into) -> KVNode { + KVNode { + name: name.to_string(), + value: KVValue::String(value.into()), + children: Vec::new(), + } +} + +pub fn get<'a>(node: &'a KVNode, key: &str) -> Option<&'a KVNode> { + node.child(key) +} + +pub fn get_str(node: &KVNode, key: &str) -> Option { + node.child(key) + .filter(|c| !c.is_object()) + .map(|c| c.as_string("")) +} + +pub fn get_u64(node: &KVNode, key: &str) -> u64 { + get_str(node, key) + .and_then(|v| v.trim().parse().ok()) + .unwrap_or(0) +} + +pub fn get_mut<'a>(node: &'a mut KVNode, key: &str) -> Option<&'a mut KVNode> { + node.children + .iter_mut() + .find(|c| c.name.eq_ignore_ascii_case(key)) +} + +/// Sets `key` to a string value, in place when present (keeping its position and spelling), +/// appended otherwise. +pub fn set(node: &mut KVNode, key: &str, value: impl Into) { + let value = value.into(); + match get_mut(node, key) { + Some(child) => { + child.value = KVValue::String(value); + child.children.clear(); + } + None => node.children.push(string(key, value)), + } +} + +/// The object child `key`, created (appended) when missing. +pub fn object_mut<'a>(node: &'a mut KVNode, key: &str) -> &'a mut KVNode { + let idx = match node + .children + .iter() + .position(|c| c.name.eq_ignore_ascii_case(key)) + { + Some(idx) => { + if !node.children[idx].is_object() { + node.children[idx] = object(key); + } + idx + } + None => { + node.children.push(object(key)); + node.children.len() - 1 + } + }; + &mut node.children[idx] +} + +pub fn remove(node: &mut KVNode, key: &str) -> bool { + let before = node.children.len(); + node.children.retain(|c| !c.name.eq_ignore_ascii_case(key)); + before != node.children.len() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn writes_steam_layout_and_round_trips_escapes() { + let mut root = object("AppState"); + set(&mut root, "appid", "228980"); + let scripts = object_mut(&mut root, "InstallScripts"); + set( + scripts, + "228988", + "_CommonRedist\\vcredist\\2019\\installscript.vdf", + ); + object_mut(&mut root, "UserConfig"); + let text = serialize(&root); + assert_eq!( + text, + "\"AppState\"\n{\n\t\"appid\"\t\t\"228980\"\n\t\"InstallScripts\"\n\t{\n\t\t\"228988\"\t\t\"_CommonRedist\\\\vcredist\\\\2019\\\\installscript.vdf\"\n\t}\n\t\"UserConfig\"\n\t{\n\t}\n}\n" + ); + let parsed = crate::steam::vdf::parse_text(text.as_bytes()).unwrap(); + assert_eq!(parsed, root); + } + + #[test] + fn set_keeps_position_and_spelling_and_appends_new_keys() { + let mut root = crate::steam::vdf::parse_text( + b"\"AppState\"\n{\n\t\"Name\"\t\t\"a\"\n\t\"x\"\t\t\"1\"\n}\n", + ) + .unwrap(); + set(&mut root, "name", "b"); + set(&mut root, "y", "2"); + assert_eq!( + serialize(&root), + "\"AppState\"\n{\n\t\"Name\"\t\t\"b\"\n\t\"x\"\t\t\"1\"\n\t\"y\"\t\t\"2\"\n}\n" + ); + assert!(remove(&mut root, "X")); + assert!(!remove(&mut root, "x")); + assert_eq!(get_u64(&root, "y"), 2); + } +} diff --git a/app/src/main/rust/stores/src/steam/library.rs b/app/src/main/rust/stores/src/steam/library.rs new file mode 100644 index 0000000000..903c366c3b --- /dev/null +++ b/app/src/main/rust/stores/src/steam/library.rs @@ -0,0 +1,277 @@ +//! The signed-in account's library: licenses → packages (PICS) → apps (PICS, with access +//! tokens). Only apps of type `game` are listed. + +use crate::steam::pb::cmsg_client_pics::{PicsAppInfoReq, PicsPackageInfoReq}; +use crate::steam::session::Session; +use crate::steam::vdf::{self, KVNode}; +use serde_json::{json, Value}; +use std::collections::{HashMap, HashSet}; + +const PACKAGE_BATCH: usize = 200; +const APP_BATCH: usize = 100; + +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct Game { + pub app_id: u32, + pub name: String, + pub install_dir: String, + pub app_type: String, + pub free: bool, +} + +#[derive(Clone, Debug, Default)] +pub struct Library { + /// Every app id the account's licenses grant (games, DLC, tools …). + pub owned_apps: HashSet, + /// Every depot id the account's licenses grant; the client installs no other depot of an app. + pub owned_depots: HashSet, + games: Option>, +} + +fn package_ids(buffer: &[u8], key: &str) -> Vec { + let Some((_id, root)) = vdf::parse_binary_package(buffer) else { + return Vec::new(); + }; + root.child(key) + .map(|node| { + node.children + .iter() + .map(|c| c.as_uint(0) as u32) + .filter(|id| *id != 0) + .collect() + }) + .unwrap_or_default() +} + +pub fn package_app_ids(buffer: &[u8]) -> Vec { + package_ids(buffer, "appids") +} + +pub fn package_depot_ids(buffer: &[u8]) -> Vec { + package_ids(buffer, "depotids") +} + +/// A library entry for an app, or `None` when it is not a game. +pub fn game_from_appinfo(app_id: u32, appinfo: &KVNode) -> Option { + let info = crate::steam::plan::appinfo_root(appinfo); + let app_type = crate::steam::plan::app_type(info); + if !app_type.eq_ignore_ascii_case("game") { + return None; + } + let name = crate::steam::plan::app_name(info); + if name.is_empty() { + return None; + } + Some(Game { + app_id, + name, + install_dir: crate::steam::plan::app_install_dir(info), + app_type: app_type.to_ascii_lowercase(), + free: crate::steam::plan::is_free(info), + }) +} + +pub fn sort_games(games: &mut [Game]) { + games.sort_by(|a, b| { + a.name + .to_lowercase() + .cmp(&b.name.to_lowercase()) + .then(a.app_id.cmp(&b.app_id)) + }); +} + +pub fn games_json(games: &[Game]) -> Value { + json!({ + "ok": true, + "games": games.iter().map(|g| json!({ + "appId": g.app_id, + "name": g.name, + "installDir": g.install_dir, + "type": g.app_type, + "free": g.free, + })).collect::>(), + }) +} + +impl Library { + /// Licenses → package PICS → owned app ids. Package 0 (the basic Steam license every account + /// has) is skipped. + pub fn load(session: &Session) -> Result { + let licenses = session + .core() + .license_list() + .ok_or_else(|| "no license list from Steam".to_string())?; + let mut tokens: HashMap = HashMap::new(); + for license in &licenses { + if license.package_id == 0 { + continue; + } + let entry = tokens.entry(license.package_id).or_insert(0); + if license.access_token != 0 { + *entry = license.access_token; + } + } + let mut package_ids: Vec = tokens.keys().copied().collect(); + package_ids.sort_unstable(); + let mut owned_apps = HashSet::new(); + let mut owned_depots = HashSet::new(); + // A package the CM left out of its answer (neither info nor unknown) is asked once more; + // ownership is not published while one is still unanswered. + let mut pending = package_ids.clone(); + for attempt in 0..2 { + let mut unanswered = Vec::new(); + for batch in pending.chunks(PACKAGE_BATCH) { + let request = batch + .iter() + .map(|id| PicsPackageInfoReq { + packageid: *id, + access_token: tokens.get(id).copied().unwrap_or(0), + }) + .collect(); + let response = session + .pics_product_info(request, Vec::new()) + .ok_or_else(|| "package info request failed".to_string())?; + let answered: HashSet = response + .packages + .iter() + .map(|p| p.packageid) + .chain(response.unknown_packageids.iter().copied()) + .collect(); + for package in &response.packages { + owned_apps.extend(package_app_ids(&package.buffer)); + owned_depots.extend(package_depot_ids(&package.buffer)); + } + unanswered.extend(batch.iter().copied().filter(|id| !answered.contains(id))); + } + pending = unanswered; + if pending.is_empty() { + break; + } + if attempt == 1 { + return Err(format!("package info incomplete ({} unanswered)", pending.len())); + } + } + crate::steam::log(&format!( + "library: licenses={} packages={} apps={}", + licenses.len(), + package_ids.len(), + owned_apps.len() + )); + Ok(Library { + owned_apps, + owned_depots, + games: None, + }) + } + + pub fn cached_games(&self) -> Option> { + self.games.clone() + } + + pub fn owns(&self, app_id: u32) -> bool { + self.owned_apps.contains(&app_id) + } + + /// App PICS for every owned app (access tokens first), filtered to games, sorted by name. + pub fn load_games(&self, session: &Session) -> Result, String> { + if let Some(games) = &self.games { + return Ok(games.clone()); + } + let mut app_ids: Vec = self.owned_apps.iter().copied().collect(); + app_ids.sort_unstable(); + let mut tokens: HashMap = HashMap::new(); + // A failed token batch is asked once more, then fails the load: without its tokens the + // apps would come back `missing_token` and be cached as non-games. + for batch in app_ids.chunks(APP_BATCH * 5) { + let response = session + .pics_access_tokens(Vec::new(), batch.to_vec()) + .or_else(|| session.pics_access_tokens(Vec::new(), batch.to_vec())) + .ok_or_else(|| "access token request failed".to_string())?; + for token in response.app_access_tokens { + tokens.insert(token.appid, token.access_token); + } + } + let mut games = Vec::new(); + // An app whose appinfo did not arrive (left out, or its HTTP delivery failed) is asked + // once more; it is not taken for a non-game while its metadata is missing. + let mut pending = app_ids; + for attempt in 0..2 { + let mut unresolved = Vec::new(); + for batch in pending.chunks(APP_BATCH) { + let request = batch + .iter() + .map(|id| PicsAppInfoReq { + appid: *id, + access_token: tokens.get(id).copied().unwrap_or(0), + only_public_obsolete: false, + }) + .collect(); + let response = session + .pics_product_info(Vec::new(), request) + .ok_or_else(|| "app info request failed".to_string())?; + let mut settled: HashSet = response.unknown_appids.iter().copied().collect(); + for app in &response.apps { + if app.buffer.is_empty() { + if app.missing_token { + settled.insert(app.appid); + } + continue; + } + settled.insert(app.appid); + let Some(root) = vdf::parse_auto(&app.buffer) else { + continue; + }; + if let Some(game) = game_from_appinfo(app.appid, &root) { + games.push(game); + } + } + unresolved.extend(batch.iter().copied().filter(|id| !settled.contains(id))); + } + pending = unresolved; + if pending.is_empty() { + break; + } + if attempt == 1 { + return Err(format!("app info incomplete ({} unresolved)", pending.len())); + } + } + sort_games(&mut games); + Ok(games) + } + + pub fn with_games(&self, games: Vec) -> Library { + Library { + owned_apps: self.owned_apps.clone(), + owned_depots: self.owned_depots.clone(), + games: Some(games), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn keeps_games_only_and_sorts_by_name() { + let parse = |t: &str| vdf::parse_text(t.as_bytes()).unwrap(); + let game = parse( + r#""appinfo" { "common" { "name" "brawlhalla" "type" "Game" "freetogame" "1" } "config" { "installdir" "Brawlhalla" } }"#, + ); + let tool = parse(r#""appinfo" { "common" { "name" "Proton" "type" "Tool" } }"#); + let other = parse(r#""appinfo" { "common" { "name" "Alpha" "type" "game" } }"#); + assert!(game_from_appinfo(5, &tool).is_none()); + let mut games = vec![ + game_from_appinfo(291550, &game).unwrap(), + game_from_appinfo(10, &other).unwrap(), + ]; + sort_games(&mut games); + assert_eq!(games[0].name, "Alpha"); + assert_eq!(games[1].install_dir, "Brawlhalla"); + assert!(games[1].free); + let json = games_json(&games); + assert_eq!(json["games"][1]["appId"], 291550); + assert_eq!(json["games"][1]["type"], "game"); + assert_eq!(json["games"][0]["free"], false); + } +} diff --git a/app/src/main/rust/stores/src/steam/mod.rs b/app/src/main/rust/stores/src/steam/mod.rs new file mode 100644 index 0000000000..d2701e078a --- /dev/null +++ b/app/src/main/rust/stores/src/steam/mod.rs @@ -0,0 +1,69 @@ +//! Steam store: signs in with the Linux Steam client's saved login, downloads a game straight into +//! the client's library folder and registers it the way the client does. Derived from WinNative's +//! wn-steam-client (GPL-3.0-or-later); see `NOTICE.md` in this directory. + +pub mod base64; +pub mod cdn; +pub mod cm_client; +pub mod cm_runtime; +pub mod cm_server; +pub mod cm_server_list; +pub mod cmsg_protobuf_header; +pub mod content_manifest; +pub mod crypto; +pub mod depot_chunk; +pub mod depot_config; +pub mod depot_downloader; +pub mod depot_writer; +pub mod emsg; +pub mod encrypted_channel; +pub mod handshake_messages; +pub mod heartbeat; +pub mod http; +pub mod install; +pub mod jni; +pub mod job_manager; +pub mod key_dictionary; +pub mod kv; +pub mod library; +pub mod pb; +pub mod plan; +pub mod proto_envelope; +pub mod proto_wire; +pub mod register; +pub mod session; +pub mod signin; +pub mod steam_directory; +pub mod transport; +pub mod vdf; +pub mod wire_format; +pub mod ws_connection; + +pub const LOG_TAG: &str = "DroidDeckSteam"; + +#[cfg(target_os = "android")] +#[link(name = "log")] +unsafe extern "C" { + fn __android_log_write(prio: i32, tag: *const i8, text: *const i8) -> i32; +} + +/// One line to logcat under [`LOG_TAG`]. Never pass a token or any other secret. +pub fn log(message: &str) { + #[cfg(target_os = "android")] + { + use std::ffi::CString; + let Ok(tag) = CString::new(LOG_TAG) else { + return; + }; + let Ok(text) = CString::new(message.replace('\0', " ")) else { + return; + }; + unsafe { + let _ = __android_log_write(4, tag.as_ptr().cast(), text.as_ptr().cast()); + } + } + #[cfg(not(target_os = "android"))] + { + let _ = message; + } +} diff --git a/app/src/main/rust/stores/src/steam/pb/ccontentserverdirectory.rs b/app/src/main/rust/stores/src/steam/pb/ccontentserverdirectory.rs new file mode 100644 index 0000000000..68e99e80c0 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/pb/ccontentserverdirectory.rs @@ -0,0 +1,217 @@ +use crate::steam::proto_wire::{Reader, WireType, Writer}; + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct CContentServerDirectoryGetManifestRequestCodeRequest { + pub app_id: u32, + pub depot_id: u32, + pub manifest_id: u64, + pub app_branch: String, + pub branch_password_hash: String, +} + +impl CContentServerDirectoryGetManifestRequestCodeRequest { + pub fn serialize(&self) -> Vec { + let mut out = Vec::new(); + let mut w = Writer::new(&mut out); + w.uint32_field(1, self.app_id); + w.uint32_field(2, self.depot_id); + w.uint64_field(3, self.manifest_id); + w.string_field(4, &self.app_branch); + w.string_field(5, &self.branch_password_hash); + out + } +} + +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub struct CContentServerDirectoryGetManifestRequestCodeResponse { + pub manifest_request_code: u64, +} + +impl CContentServerDirectoryGetManifestRequestCodeResponse { + pub fn deserialize(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = Self::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg.manifest_request_code = reader.u64()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct CContentServerDirectoryServerInfo { + pub server_type: String, + pub source_id: i32, + pub cell_id: i32, + pub load: i32, + pub weighted_load: f32, + pub num_entries_in_client_list: i32, + pub steam_china_only: bool, + pub host: String, + pub vhost: String, + pub use_as_proxy: bool, + pub proxy_request_path_template: String, + pub https_support: String, + pub allowed_app_ids: Vec, + pub priority_class: u32, +} + +impl CContentServerDirectoryServerInfo { + pub fn use_https(&self) -> bool { + self.https_support.eq_ignore_ascii_case("mandatory") + } + + pub fn port(&self) -> u16 { + if self.use_https() { + 443 + } else { + 80 + } + } + + pub fn deserialize(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = Self::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg.server_type = reader.string()?, + 2 => msg.source_id = reader.i32()?, + 3 => msg.cell_id = reader.i32()?, + 4 => msg.load = reader.i32()?, + 5 => msg.weighted_load = f32::from_bits(reader.fixed32()?), + 6 => msg.num_entries_in_client_list = reader.i32()?, + 7 => msg.steam_china_only = reader.boolean()?, + 8 => msg.host = reader.string()?, + 9 => msg.vhost = reader.string()?, + 10 => msg.use_as_proxy = reader.boolean()?, + 11 => msg.proxy_request_path_template = reader.string()?, + 12 => msg.https_support = reader.string()?, + 13 => match tag.wire_type { + WireType::LengthDelimited => { + let mut packed = Reader::new(reader.bytes()?); + while !packed.eof() { + msg.allowed_app_ids.push(packed.varint()? as u32); + } + } + WireType::Varint => msg.allowed_app_ids.push(reader.u32()?), + other => { + if !reader.skip(other) { + return None; + } + } + }, + 15 => msg.priority_class = reader.u32()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) + } +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct CContentServerDirectoryGetServersForSteamPipeRequest { + pub cell_id: u32, + pub max_servers: u32, +} + +impl Default for CContentServerDirectoryGetServersForSteamPipeRequest { + fn default() -> Self { + Self { + cell_id: 0, + max_servers: 20, + } + } +} + +impl CContentServerDirectoryGetServersForSteamPipeRequest { + pub fn serialize(&self) -> Vec { + let mut out = Vec::new(); + let mut w = Writer::new(&mut out); + w.uint32_field(1, self.cell_id); + w.uint32_field_force(2, self.max_servers); + out + } +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct CContentServerDirectoryGetServersForSteamPipeResponse { + pub servers: Vec, + pub no_change: bool, +} + +impl CContentServerDirectoryGetServersForSteamPipeResponse { + pub fn deserialize(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = Self::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg + .servers + .push(CContentServerDirectoryServerInfo::deserialize( + reader.bytes()?, + )?), + 2 => msg.no_change = reader.boolean()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_server_info_with_packed_and_unpacked_app_ids() { + let mut server = Vec::new(); + { + let mut w = Writer::new(&mut server); + w.string_field(1, "SteamCache"); + w.int32_field(2, 5); + w.int32_field(3, 6); + w.int32_field(4, 7); + w.tag(5, WireType::Fixed32); + w.raw_bytes(&1.25f32.to_bits().to_le_bytes()); + w.bool_field(7, true); + w.string_field(8, "cache.example"); + w.string_field(12, "MANDATORY"); + w.uint32_field(13, 480); + let mut packed = Vec::new(); + Writer::new(&mut packed).varint(730); + w.bytes_field(13, &packed); + w.uint32_field(15, 2); + } + + let parsed = CContentServerDirectoryServerInfo::deserialize(&server).unwrap(); + assert_eq!(parsed.server_type, "SteamCache"); + assert_eq!(parsed.weighted_load, 1.25); + assert_eq!(parsed.allowed_app_ids, [480, 730]); + assert!(parsed.use_https()); + assert_eq!(parsed.port(), 443); + } +} diff --git a/app/src/main/rust/stores/src/steam/pb/cmsg_client_get_depot_decryption_key.rs b/app/src/main/rust/stores/src/steam/pb/cmsg_client_get_depot_decryption_key.rs new file mode 100644 index 0000000000..4e16666a70 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/pb/cmsg_client_get_depot_decryption_key.rs @@ -0,0 +1,79 @@ +use crate::steam::proto_wire::{Reader, WireType, Writer}; + +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub struct CMsgClientGetDepotDecryptionKey { + pub depot_id: u32, + pub app_id: u32, +} + +impl CMsgClientGetDepotDecryptionKey { + pub fn serialize(&self) -> Vec { + let mut out = Vec::new(); + let mut w = Writer::new(&mut out); + w.uint32_field(1, self.depot_id); + w.uint32_field(2, self.app_id); + out + } +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct CMsgClientGetDepotDecryptionKeyResponse { + pub eresult: i32, + pub depot_id: u32, + pub depot_encryption_key: Vec, +} + +impl Default for CMsgClientGetDepotDecryptionKeyResponse { + fn default() -> Self { + Self { + eresult: 2, + depot_id: 0, + depot_encryption_key: Vec::new(), + } + } +} + +impl CMsgClientGetDepotDecryptionKeyResponse { + pub fn deserialize(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = Self::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match (tag.field_number, tag.wire_type) { + (1, WireType::Varint) => msg.eresult = reader.i32()?, + (2, WireType::Varint) => msg.depot_id = reader.u32()?, + (3, WireType::LengthDelimited) => { + msg.depot_encryption_key = reader.bytes()?.to_vec() + } + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn reads_fields_only_with_their_wire_type() { + let mut ok = Vec::new(); + let mut w = Writer::new(&mut ok); + w.int32_field(1, 1); + w.uint32_field(2, 7); + w.bytes_field(3, &[9u8; 32]); + let r = CMsgClientGetDepotDecryptionKeyResponse::deserialize(&ok).unwrap(); + assert_eq!((r.eresult, r.depot_id, r.depot_encryption_key.len()), (1, 7, 32)); + // Field 1 as a length-delimited value is skipped, not read as the eresult. + let mismatched = [0x0a, 0x01, 0x01]; + let r = CMsgClientGetDepotDecryptionKeyResponse::deserialize(&mismatched).unwrap(); + assert_eq!(r.eresult, 2); + } +} diff --git a/app/src/main/rust/stores/src/steam/pb/cmsg_client_license_list.rs b/app/src/main/rust/stores/src/steam/pb/cmsg_client_license_list.rs new file mode 100644 index 0000000000..616de9a117 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/pb/cmsg_client_license_list.rs @@ -0,0 +1,143 @@ +use crate::steam::proto_wire::{Reader, WireType}; + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct License { + pub package_id: u32, + pub time_created: u32, + pub time_next_process: u32, + pub minute_limit: i32, + pub minutes_used: i32, + pub payment_method: u32, + pub flags: u32, + pub purchase_country_code: String, + pub license_type: u32, + pub territory_code: i32, + pub change_number: i32, + pub owner_id: u32, + pub initial_period: u32, + pub initial_time_unit: u32, + pub renewal_period: u32, + pub renewal_time_unit: u32, + pub access_token: u64, + pub master_package_id: u32, +} + +impl License { + pub fn deserialize(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = Self::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg.package_id = reader.u32()?, + 2 => { + if tag.wire_type != WireType::Fixed32 { + return None; + } + msg.time_created = reader.fixed32()?; + } + 3 => { + if tag.wire_type != WireType::Fixed32 { + return None; + } + msg.time_next_process = reader.fixed32()?; + } + 4 => msg.minute_limit = reader.i32()?, + 5 => msg.minutes_used = reader.i32()?, + 6 => msg.payment_method = reader.u32()?, + 7 => msg.flags = reader.u32()?, + 8 => msg.purchase_country_code = reader.string()?, + 9 => msg.license_type = reader.u32()?, + 10 => msg.territory_code = reader.i32()?, + 11 => msg.change_number = reader.i32()?, + 12 => msg.owner_id = reader.u32()?, + 13 => msg.initial_period = reader.u32()?, + 14 => msg.initial_time_unit = reader.u32()?, + 15 => msg.renewal_period = reader.u32()?, + 16 => msg.renewal_time_unit = reader.u32()?, + 17 => msg.access_token = reader.u64()?, + 18 => msg.master_package_id = reader.u32()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) + } +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct CMsgClientLicenseList { + pub eresult: i32, + pub licenses: Vec, +} + +impl Default for CMsgClientLicenseList { + fn default() -> Self { + Self { + eresult: 2, + licenses: Vec::new(), + } + } +} + +impl CMsgClientLicenseList { + pub fn deserialize(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = Self::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg.eresult = reader.i32()?, + 2 => msg.licenses.push(License::deserialize(reader.bytes()?)?), + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::steam::proto_wire::Writer; + + #[test] + fn parses_license_with_fixed_times_and_two_byte_tags() { + let mut lic = Vec::new(); + { + let mut w = Writer::new(&mut lic); + w.uint32_field(1, 123); + w.tag(2, WireType::Fixed32); + w.raw_bytes(&1000u32.to_le_bytes()); + w.tag(3, WireType::Fixed32); + w.raw_bytes(&2000u32.to_le_bytes()); + w.string_field(8, "US"); + w.uint32_field(16, 7); + w.uint64_field(17, 0x1234); + w.uint32_field(18, 456); + } + let mut body = Vec::new(); + { + let mut w = Writer::new(&mut body); + w.int32_field(1, 1); + w.submessage_field(2, &lic); + } + let parsed = CMsgClientLicenseList::deserialize(&body).unwrap(); + assert_eq!(parsed.eresult, 1); + assert_eq!(parsed.licenses[0].package_id, 123); + assert_eq!(parsed.licenses[0].time_created, 1000); + assert_eq!(parsed.licenses[0].renewal_time_unit, 7); + assert_eq!(parsed.licenses[0].master_package_id, 456); + } +} diff --git a/app/src/main/rust/stores/src/steam/pb/cmsg_client_pics.rs b/app/src/main/rust/stores/src/steam/pb/cmsg_client_pics.rs new file mode 100644 index 0000000000..c0069fabc0 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/pb/cmsg_client_pics.rs @@ -0,0 +1,432 @@ +use crate::steam::proto_wire::{Reader, WireType, Writer}; + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct CMsgClientPICSAccessTokenRequest { + pub packageids: Vec, + pub appids: Vec, +} + +impl CMsgClientPICSAccessTokenRequest { + pub fn serialize(&self) -> Vec { + let mut out = Vec::new(); + let mut w = Writer::new(&mut out); + for id in &self.packageids { + w.tag(1, WireType::Varint); + w.varint(*id as u64); + } + for id in &self.appids { + w.tag(2, WireType::Varint); + w.varint(*id as u64); + } + out + } +} + +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub struct PicsPackageToken { + pub packageid: u32, + pub access_token: u64, +} + +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub struct PicsAppToken { + pub appid: u32, + pub access_token: u64, +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct CMsgClientPICSAccessTokenResponse { + pub package_access_tokens: Vec, + pub package_denied_tokens: Vec, + pub app_access_tokens: Vec, + pub app_denied_tokens: Vec, +} + +impl CMsgClientPICSAccessTokenResponse { + pub fn deserialize(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = Self::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg + .package_access_tokens + .push(parse_package_token(reader.bytes()?)?), + 2 => read_repeated_uint32( + &mut reader, + tag.wire_type, + &mut msg.package_denied_tokens, + )?, + 3 => msg + .app_access_tokens + .push(parse_app_token(reader.bytes()?)?), + 4 => read_repeated_uint32(&mut reader, tag.wire_type, &mut msg.app_denied_tokens)?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) + } +} + +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub struct PicsAppInfoReq { + pub appid: u32, + pub access_token: u64, + pub only_public_obsolete: bool, +} + +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub struct PicsPackageInfoReq { + pub packageid: u32, + pub access_token: u64, +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct CMsgClientPICSProductInfoRequest { + pub packages: Vec, + pub apps: Vec, + pub meta_data_only: bool, + pub num_prev_failed: u32, + pub sequence_number: u32, + pub single_response: bool, +} + +impl CMsgClientPICSProductInfoRequest { + pub fn serialize(&self) -> Vec { + let mut out = Vec::new(); + let mut w = Writer::new(&mut out); + for package in &self.packages { + let mut sub = Vec::new(); + let mut sw = Writer::new(&mut sub); + sw.uint32_field(1, package.packageid); + sw.uint64_field(2, package.access_token); + w.submessage_field(1, &sub); + } + for app in &self.apps { + let mut sub = Vec::new(); + let mut sw = Writer::new(&mut sub); + sw.uint32_field(1, app.appid); + sw.uint64_field(2, app.access_token); + sw.bool_field(3, app.only_public_obsolete); + w.submessage_field(2, &sub); + } + w.bool_field(3, self.meta_data_only); + w.uint32_field(4, self.num_prev_failed); + w.uint32_field(6, self.sequence_number); + w.bool_field(7, self.single_response); + out + } +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct PicsAppInfoResp { + pub appid: u32, + pub change_number: u32, + pub missing_token: bool, + pub sha: Vec, + pub buffer: Vec, + pub only_public: bool, + pub size: u32, +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct PicsPackageInfoResp { + pub packageid: u32, + pub change_number: u32, + pub missing_token: bool, + pub sha: Vec, + pub buffer: Vec, + pub size: u32, +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct CMsgClientPICSProductInfoResponse { + pub apps: Vec, + pub unknown_appids: Vec, + pub packages: Vec, + pub unknown_packageids: Vec, + pub meta_data_only: bool, + pub response_pending: bool, + pub http_min_size: u32, + pub http_host: String, +} + +impl CMsgClientPICSProductInfoResponse { + pub fn deserialize(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = Self::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg.apps.push(parse_app_info_resp(reader.bytes()?)?), + 2 => read_repeated_uint32(&mut reader, tag.wire_type, &mut msg.unknown_appids)?, + 3 => msg.packages.push(parse_package_info_resp(reader.bytes()?)?), + 4 => read_repeated_uint32(&mut reader, tag.wire_type, &mut msg.unknown_packageids)?, + 5 => msg.meta_data_only = reader.boolean()?, + 6 => msg.response_pending = reader.boolean()?, + 7 => msg.http_min_size = reader.u32()?, + 8 => msg.http_host = reader.string()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) + } + + pub fn serialize(&self) -> Vec { + let mut out = Vec::new(); + let mut w = Writer::new(&mut out); + for app in &self.apps { + w.submessage_field(1, &app.serialize()); + } + for appid in &self.unknown_appids { + w.uint32_field(2, *appid); + } + for package in &self.packages { + w.submessage_field(3, &package.serialize()); + } + for packageid in &self.unknown_packageids { + w.uint32_field(4, *packageid); + } + w.bool_field(5, self.meta_data_only); + w.bool_field(6, self.response_pending); + w.uint32_field(7, self.http_min_size); + w.string_field(8, &self.http_host); + out + } +} + +fn parse_package_token(body: &[u8]) -> Option { + let raw = parse_token(body)?; + Some(PicsPackageToken { + packageid: raw.id, + access_token: raw.access_token, + }) +} + +fn parse_app_token(body: &[u8]) -> Option { + let raw = parse_token(body)?; + Some(PicsAppToken { + appid: raw.id, + access_token: raw.access_token, + }) +} + +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +struct TokenRaw { + id: u32, + access_token: u64, +} + +fn parse_token(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = TokenRaw::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg.id = reader.u32()?, + 2 => msg.access_token = reader.u64()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) +} + +fn parse_app_info_resp(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = PicsAppInfoResp::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg.appid = reader.u32()?, + 2 => msg.change_number = reader.u32()?, + 3 => msg.missing_token = reader.boolean()?, + 4 => msg.sha = reader.bytes()?.to_vec(), + 5 => msg.buffer = reader.bytes()?.to_vec(), + 6 => msg.only_public = reader.boolean()?, + 7 => msg.size = reader.u32()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) +} + +impl PicsAppInfoResp { + fn serialize(&self) -> Vec { + let mut out = Vec::new(); + let mut w = Writer::new(&mut out); + w.uint32_field(1, self.appid); + w.uint32_field(2, self.change_number); + w.bool_field(3, self.missing_token); + w.bytes_field(4, &self.sha); + w.bytes_field(5, &self.buffer); + w.bool_field(6, self.only_public); + w.uint32_field(7, self.size); + out + } +} + +fn parse_package_info_resp(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = PicsPackageInfoResp::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg.packageid = reader.u32()?, + 2 => msg.change_number = reader.u32()?, + 3 => msg.missing_token = reader.boolean()?, + 4 => msg.sha = reader.bytes()?.to_vec(), + 5 => msg.buffer = reader.bytes()?.to_vec(), + 6 => msg.size = reader.u32()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) +} + +impl PicsPackageInfoResp { + fn serialize(&self) -> Vec { + let mut out = Vec::new(); + let mut w = Writer::new(&mut out); + w.uint32_field(1, self.packageid); + w.uint32_field(2, self.change_number); + w.bool_field(3, self.missing_token); + w.bytes_field(4, &self.sha); + w.bytes_field(5, &self.buffer); + w.uint32_field(6, self.size); + out + } +} + +fn read_repeated_uint32( + reader: &mut Reader<'_>, + wire_type: WireType, + out: &mut Vec, +) -> Option<()> { + match wire_type { + WireType::Varint => out.push(reader.u32()?), + WireType::LengthDelimited => { + let mut packed = Reader::new(reader.bytes()?); + while !packed.eof() { + out.push(packed.varint()? as u32); + } + } + _ => return None, + } + Some(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn token_body(id: u32, token: u64) -> Vec { + let mut body = Vec::new(); + let mut w = Writer::new(&mut body); + w.uint32_field(1, id); + w.uint64_field(2, token); + body + } + + #[test] + fn parses_access_tokens_and_packed_denied_lists() { + let mut packed = Vec::new(); + { + let mut w = Writer::new(&mut packed); + w.varint(10); + w.varint(11); + } + + let mut body = Vec::new(); + { + let mut w = Writer::new(&mut body); + w.submessage_field(1, &token_body(100, 555)); + w.uint32_field(2, 9); + w.bytes_field(2, &packed); + w.submessage_field(3, &token_body(480, 777)); + w.uint32_field(4, 12); + } + + let parsed = CMsgClientPICSAccessTokenResponse::deserialize(&body).unwrap(); + assert_eq!(parsed.package_access_tokens[0].packageid, 100); + assert_eq!(parsed.package_denied_tokens, [9, 10, 11]); + assert_eq!(parsed.app_access_tokens[0].appid, 480); + assert_eq!(parsed.app_denied_tokens, [12]); + } + + #[test] + fn parses_product_info_response_without_stripping_package_prefix() { + let mut app = Vec::new(); + { + let mut w = Writer::new(&mut app); + w.uint32_field(1, 480); + w.uint32_field(2, 22); + w.bool_field(3, true); + w.bytes_field(4, &[1; 20]); + w.bytes_field(5, b"appvdf"); + w.bool_field(6, true); + w.uint32_field(7, 6); + } + + let mut package = Vec::new(); + { + let mut w = Writer::new(&mut package); + w.uint32_field(1, 100); + w.uint32_field(2, 33); + w.bytes_field(5, &[100, 0, 0, 0, b'v', b'd', b'f']); + w.uint32_field(6, 7); + } + + let mut packed_unknown = Vec::new(); + Writer::new(&mut packed_unknown).varint(888); + + let mut body = Vec::new(); + { + let mut w = Writer::new(&mut body); + w.submessage_field(1, &app); + w.uint32_field(2, 404); + w.submessage_field(3, &package); + w.bytes_field(4, &packed_unknown); + w.bool_field(6, true); + w.uint32_field(7, 1024); + w.string_field(8, "cdn.example"); + } + + let parsed = CMsgClientPICSProductInfoResponse::deserialize(&body).unwrap(); + assert_eq!(parsed.apps[0].appid, 480); + assert_eq!(parsed.unknown_appids, [404]); + assert_eq!(parsed.unknown_packageids, [888]); + assert_eq!(parsed.packages[0].buffer, [100, 0, 0, 0, b'v', b'd', b'f']); + assert!(parsed.response_pending); + assert_eq!(parsed.http_host, "cdn.example"); + } +} diff --git a/app/src/main/rust/stores/src/steam/pb/cmsg_client_request_free_license.rs b/app/src/main/rust/stores/src/steam/pb/cmsg_client_request_free_license.rs new file mode 100644 index 0000000000..413e6ab28a --- /dev/null +++ b/app/src/main/rust/stores/src/steam/pb/cmsg_client_request_free_license.rs @@ -0,0 +1,188 @@ +//! `CMsgClientRequestFreeLicense` / `...Response` (SteamKit +//! `steammessages_clientserver_2.proto`, EMsg 5572 / 5573) — the legitimate "add a free/F2P/demo +//! title to my library" grant. +//! +//! Field numbers and the EMsg pair are verified against the JavaSteam protobufs bundled with the +//! app (`SteammessagesClientserver2.java`, `EMsg.java`), and corroborated by the field-name +//! strings (`granted_packageids` / `granted_appids`) in the reference Rust Steam engine. +//! +//! Two details that a guess would have got wrong, both taken from the real definition: +//! * the request's `appids` is field **2**, not 1; +//! * the response's `eresult` carries an explicit proto2 `[default = 2]` (EResult.Fail), so an +//! absent field must read as *failure*, never as 0/Invalid and never as success. + +use crate::steam::proto_wire::{Reader, WireType, Writer}; + +/// Proto2 `[default = 2]` on `CMsgClientRequestFreeLicenseResponse.eresult` — EResult.Fail. +/// An omitted field means the grant did NOT happen. +pub const FREE_LICENSE_DEFAULT_ERESULT: i32 = 2; + +/// `CMsgClientRequestFreeLicense` (EMsg 5572): `repeated uint32 appids = 2;` +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct CMsgClientRequestFreeLicense { + pub appids: Vec, +} + +impl CMsgClientRequestFreeLicense { + pub fn serialize(&self) -> Vec { + let mut out = Vec::new(); + let mut w = Writer::new(&mut out); + for appid in &self.appids { + // Field 2 (not 1). Force-emit so an appid of 0 still occupies a slot rather than + // silently shortening the request. + w.uint32_field_force(2, *appid); + } + out + } +} + +/// `CMsgClientRequestFreeLicenseResponse` (EMsg 5573): +/// `eresult = 1 [default = 2]`, `granted_packageids = 2`, `granted_appids = 3`. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct CMsgClientRequestFreeLicenseResponse { + pub eresult: i32, + pub granted_packageids: Vec, + pub granted_appids: Vec, +} + +impl Default for CMsgClientRequestFreeLicenseResponse { + fn default() -> Self { + Self { + eresult: FREE_LICENSE_DEFAULT_ERESULT, + granted_packageids: Vec::new(), + granted_appids: Vec::new(), + } + } +} + +impl CMsgClientRequestFreeLicenseResponse { + /// True only when Steam reported EResult.OK *and* actually handed something over. + pub fn is_granted(&self) -> bool { + self.eresult == 1 && !(self.granted_packageids.is_empty() && self.granted_appids.is_empty()) + } + + pub fn deserialize(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = Self::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match (tag.field_number, tag.wire_type) { + (1, WireType::Varint) => msg.eresult = reader.i32()?, + // Repeated uint32 is unpacked in proto2, but accept a packed block too so a + // server-side encoding change cannot silently empty the grant list. + (2, WireType::Varint) => msg.granted_packageids.push(reader.u32()?), + (2, WireType::LengthDelimited) => { + read_packed_u32(reader.bytes()?, &mut msg.granted_packageids)? + } + (3, WireType::Varint) => msg.granted_appids.push(reader.u32()?), + (3, WireType::LengthDelimited) => { + read_packed_u32(reader.bytes()?, &mut msg.granted_appids)? + } + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) + } +} + +/// Drain a packed repeated-varint block into `out`. +fn read_packed_u32(block: &[u8], out: &mut Vec) -> Option<()> { + let mut reader = Reader::new(block); + while !reader.eof() { + out.push(reader.u32()?); + } + Some(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn request_puts_appids_on_field_two() { + let body = CMsgClientRequestFreeLicense { + appids: vec![440, 570], + } + .serialize(); + // tag = (2 << 3) | 0 = 0x10. Field 1 (0x08) would be the wrong-by-one guess. + assert_eq!(body[0], 0x10); + let mut expected = Vec::new(); + { + let mut w = Writer::new(&mut expected); + w.uint32_field_force(2, 440); + w.uint32_field_force(2, 570); + } + assert_eq!(body, expected); + } + + #[test] + fn absent_eresult_defaults_to_fail_not_success() { + // Proto2 [default = 2]: an empty body must NEVER read as granted. + let parsed = CMsgClientRequestFreeLicenseResponse::deserialize(&[]).unwrap(); + assert_eq!(parsed.eresult, FREE_LICENSE_DEFAULT_ERESULT); + assert_eq!(parsed.eresult, 2); + assert!(!parsed.is_granted()); + } + + #[test] + fn parses_unpacked_grant_response() { + let mut body = Vec::new(); + { + let mut w = Writer::new(&mut body); + w.int32_field(1, 1); + w.uint32_field_force(2, 303_386); + w.uint32_field_force(3, 440); + } + let parsed = CMsgClientRequestFreeLicenseResponse::deserialize(&body).unwrap(); + assert_eq!(parsed.eresult, 1); + assert_eq!(parsed.granted_packageids, vec![303_386]); + assert_eq!(parsed.granted_appids, vec![440]); + assert!(parsed.is_granted()); + } + + #[test] + fn parses_packed_grant_response() { + let mut packed_packages = Vec::new(); + { + let mut w = Writer::new(&mut packed_packages); + w.varint(100); + w.varint(300); + } + let mut body = Vec::new(); + { + let mut w = Writer::new(&mut body); + w.int32_field(1, 1); + w.submessage_field(2, &packed_packages); + } + let parsed = CMsgClientRequestFreeLicenseResponse::deserialize(&body).unwrap(); + assert_eq!(parsed.granted_packageids, vec![100, 300]); + } + + #[test] + fn ok_with_no_grant_is_not_a_grant() { + // eresult OK but nothing handed over: must not be reported as success. + let mut body = Vec::new(); + Writer::new(&mut body).int32_field(1, 1); + let parsed = CMsgClientRequestFreeLicenseResponse::deserialize(&body).unwrap(); + assert_eq!(parsed.eresult, 1); + assert!(!parsed.is_granted()); + } + + #[test] + fn failure_eresult_is_preserved_verbatim() { + // A paid/unowned title comes back with a non-OK EResult; surface it, don't flatten it. + for eresult in [2, 8, 15, 16] { + let mut body = Vec::new(); + Writer::new(&mut body).int32_field(1, eresult); + let parsed = CMsgClientRequestFreeLicenseResponse::deserialize(&body).unwrap(); + assert_eq!(parsed.eresult, eresult); + assert!(!parsed.is_granted()); + } + } +} diff --git a/app/src/main/rust/stores/src/steam/pb/cmsg_clientserver_login.rs b/app/src/main/rust/stores/src/steam/pb/cmsg_clientserver_login.rs new file mode 100644 index 0000000000..ae1db1cf91 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/pb/cmsg_clientserver_login.rs @@ -0,0 +1,286 @@ +use crate::steam::proto_wire::{Reader, WireType, Writer}; + +pub const MSG_CLIENT_CURRENT_PROTOCOL: u32 = 65_581; + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct CMsgClientHello { + pub protocol_version: u32, +} + +impl Default for CMsgClientHello { + fn default() -> Self { + Self { + protocol_version: MSG_CLIENT_CURRENT_PROTOCOL, + } + } +} + +impl CMsgClientHello { + pub fn serialize(&self) -> Vec { + let mut out = Vec::new(); + Writer::new(&mut out).uint32_field(1, self.protocol_version); + out + } +} + +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub struct CMsgClientHeartBeat { + pub send_reply: bool, +} + +impl CMsgClientHeartBeat { + pub fn serialize(&self) -> Vec { + let mut out = Vec::new(); + Writer::new(&mut out).bool_field(1, self.send_reply); + out + } +} + +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub struct CMsgClientLogOff; + +impl CMsgClientLogOff { + pub fn serialize(&self) -> Vec { + Vec::new() + } +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct CMsgClientLoggedOff { + pub eresult: i32, +} + +impl Default for CMsgClientLoggedOff { + fn default() -> Self { + Self { eresult: 2 } + } +} + +impl CMsgClientLoggedOff { + pub fn deserialize(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = Self::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg.eresult = reader.i32()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) + } +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct CMsgClientLogon { + pub protocol_version: u32, + pub cell_id: u32, + pub client_package_version: u32, + pub client_language: String, + pub client_os_type: u32, + pub should_remember_password: bool, + pub qos_level: u32, + pub client_supplied_steam_id: u64, + pub machine_id: Vec, + pub ui_mode: u32, + pub chat_mode: u32, + pub account_name: String, + pub machine_name: String, + pub client_instance_id: u64, + pub supports_rate_limit_response: bool, + pub access_token: String, + pub obfuscated_private_ip: u32, +} + +impl Default for CMsgClientLogon { + fn default() -> Self { + Self { + protocol_version: MSG_CLIENT_CURRENT_PROTOCOL, + cell_id: 0, + client_package_version: 1771, + client_language: "english".to_string(), + client_os_type: 16, + should_remember_password: true, + qos_level: 2, + client_supplied_steam_id: 0, + machine_id: Vec::new(), + ui_mode: 7, + chat_mode: 2, + account_name: String::new(), + machine_name: "DroidDeck".to_string(), + client_instance_id: 0, + supports_rate_limit_response: true, + access_token: String::new(), + obfuscated_private_ip: 0, + } + } +} + +impl CMsgClientLogon { + pub fn serialize(&self) -> Vec { + let mut out = Vec::new(); + let mut w = Writer::new(&mut out); + w.uint32_field(1, self.protocol_version); + w.uint32_field(3, self.cell_id); + w.uint32_field(5, self.client_package_version); + w.string_field(6, &self.client_language); + w.uint32_field(7, self.client_os_type); + w.bool_field(8, self.should_remember_password); + w.uint32_field(21, self.qos_level); + if self.client_supplied_steam_id != 0 { + w.tag(22, WireType::Fixed64); + w.raw_bytes(&self.client_supplied_steam_id.to_le_bytes()); + } + w.bytes_field(30, &self.machine_id); + if self.obfuscated_private_ip != 0 { + // The LoginID: deprecated_obfustucated_private_ip = 2 and + // obfuscated_private_ip = 11 (CMsgIPAddress { fixed32 v4 = 1 }). + w.uint32_field(2, self.obfuscated_private_ip); + let mut ip_msg = Vec::new(); + let mut ip = Writer::new(&mut ip_msg); + ip.tag(1, WireType::Fixed32); + ip.raw_bytes(&self.obfuscated_private_ip.to_le_bytes()); + w.bytes_field(11, &ip_msg); + } + w.uint32_field(32, self.ui_mode); + w.uint32_field(33, self.chat_mode); + w.string_field(50, &self.account_name); + w.string_field(96, &self.machine_name); + w.uint64_field(100, self.client_instance_id); + w.bool_field(102, self.supports_rate_limit_response); + w.string_field(108, &self.access_token); + out + } +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct CMsgClientLogonResponse { + pub eresult: i32, + pub heartbeat_seconds: i32, + pub rtime32_server_time: u32, + pub cell_id: u32, + pub eresult_extended: i32, + pub vanity_url: String, + pub client_supplied_steamid: u64, + pub client_instance_id: u64, + pub force_client_update_check: bool, + pub agreement_session_url: String, + pub token_id: u64, + pub family_group_id: u64, +} + +impl Default for CMsgClientLogonResponse { + fn default() -> Self { + Self { + eresult: 2, + heartbeat_seconds: 0, + rtime32_server_time: 0, + cell_id: 0, + eresult_extended: 0, + vanity_url: String::new(), + client_supplied_steamid: 0, + client_instance_id: 0, + force_client_update_check: false, + agreement_session_url: String::new(), + token_id: 0, + family_group_id: 0, + } + } +} + +impl CMsgClientLogonResponse { + pub fn deserialize(body: &[u8]) -> Option { + let mut reader = Reader::new(body); + let mut msg = Self::default(); + while !reader.eof() { + let Some(tag) = reader.next_tag() else { + return reader.ok().then_some(msg); + }; + match tag.field_number { + 1 => msg.eresult = reader.i32()?, + 3 => msg.heartbeat_seconds = reader.i32()?, + 5 => { + if tag.wire_type != WireType::Fixed32 { + return None; + } + msg.rtime32_server_time = reader.fixed32()?; + } + 7 => msg.cell_id = reader.u32()?, + 10 => msg.eresult_extended = reader.i32()?, + 14 => msg.vanity_url = reader.string()?, + 20 => { + if tag.wire_type != WireType::Fixed64 { + return None; + } + msg.client_supplied_steamid = reader.fixed64()?; + } + 27 => msg.client_instance_id = reader.u64()?, + 28 => msg.force_client_update_check = reader.boolean()?, + 29 => msg.agreement_session_url = reader.string()?, + 30 => msg.token_id = reader.u64()?, + 31 => msg.family_group_id = reader.u64()?, + _ => { + if !reader.skip(tag.wire_type) { + return None; + } + } + } + } + Some(msg) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn logon_serializes_canonical_fields() { + let msg = CMsgClientLogon { + account_name: "user".to_string(), + access_token: "refresh.jwt".to_string(), + client_instance_id: 99, + obfuscated_private_ip: 0x0102_0304, + ..Default::default() + }; + let bytes = msg.serialize(); + let mut reader = Reader::new(&bytes); + let mut fields = Vec::new(); + let mut ip_message = Vec::new(); + while let Some(tag) = reader.next_tag() { + fields.push((tag.field_number, tag.wire_type)); + if tag.field_number == 11 { + ip_message = reader.bytes().unwrap().to_vec(); + } else { + reader.skip(tag.wire_type); + } + } + assert!(fields.contains(&(2, WireType::Varint))); + assert!(fields.contains(&(11, WireType::LengthDelimited))); + assert_eq!(ip_message, [0x0d, 0x04, 0x03, 0x02, 0x01]); + assert!(fields.contains(&(50, WireType::LengthDelimited))); + assert!(fields.contains(&(108, WireType::LengthDelimited))); + assert!(!fields.iter().any(|(f, _)| *f == 31 || *f == 95 || *f == 10)); + } + + #[test] + fn logon_response_reads_token_id_as_varint() { + let mut bytes = Vec::new(); + let mut w = Writer::new(&mut bytes); + w.int32_field(1, 1); + w.int32_field(3, 10); + w.tag(5, WireType::Fixed32); + w.raw_bytes(&123u32.to_le_bytes()); + w.uint64_field(30, 987); + let msg = CMsgClientLogonResponse::deserialize(&bytes).unwrap(); + assert_eq!(msg.eresult, 1); + assert_eq!(msg.rtime32_server_time, 123); + assert_eq!(msg.token_id, 987); + } +} diff --git a/app/src/main/rust/stores/src/steam/pb/mod.rs b/app/src/main/rust/stores/src/steam/pb/mod.rs new file mode 100644 index 0000000000..e514428e7a --- /dev/null +++ b/app/src/main/rust/stores/src/steam/pb/mod.rs @@ -0,0 +1,8 @@ +//! Hand-written protobuf messages for the CM requests the download store sends. + +pub mod ccontentserverdirectory; +pub mod cmsg_client_get_depot_decryption_key; +pub mod cmsg_client_license_list; +pub mod cmsg_client_pics; +pub mod cmsg_client_request_free_license; +pub mod cmsg_clientserver_login; diff --git a/app/src/main/rust/stores/src/steam/plan.rs b/app/src/main/rust/stores/src/steam/plan.rs new file mode 100644 index 0000000000..03628acecf --- /dev/null +++ b/app/src/main/rust/stores/src/steam/plan.rs @@ -0,0 +1,685 @@ +//! Which depots to install: what the Steam client picks for a Windows game run through Proton +//! (DroidDeck maps Proton globally), from the app's PICS appinfo. +//! +//! - `config.oslist` empty or containing `windows`; +//! - `config.osarch` empty or `64`; depots marked `32` only when the set has no `64` depot; +//! - `config.language` empty or the client language (english when the game has no depot for the +//! requested language but has english ones); +//! - `config.lowviolence` depots skipped; +//! - DLC depots (`dlcappid`) only when that DLC is owned; +//! - `depotfromapp` / `sharedinstall` depots are shared depots of another app (e.g. 228980 +//! Steamworks Common Redistributables) and go into that app's folder; +//! - the public branch's manifest gid, and the app's public `buildid`. + +use crate::steam::vdf::KVNode; +use serde_json::{json, Value}; +use std::collections::HashSet; + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct PlannedDepot { + pub depot_id: u32, + pub manifest_id: u64, + pub size: u64, + pub download: u64, + pub dlc_app_id: u32, +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct SharedRef { + pub depot_id: u32, + pub from_app_id: u32, +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct SharedDepot { + pub depot_id: u32, + pub from_app_id: u32, + pub manifest_id: u64, + pub size: u64, + pub download: u64, + pub from_name: String, + pub from_install_dir: String, + pub from_build_id: u64, +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct AppPlan { + pub app_id: u32, + pub name: String, + pub install_dir: String, + pub build_id: u64, + /// The language written to the app manifest (the requested one, or english, see above). + pub language: String, + /// The app ships a Linux build (`common.oslist`). The client installs it, not these Windows + /// depots, unless the game is mapped to a Proton; the caller checks that mapping. + pub linux_build: bool, + pub depots: Vec, + pub shared_refs: Vec, + pub shared: Vec, +} + +impl AppPlan { + pub fn install_bytes(&self) -> u64 { + self.depots.iter().map(|d| d.size).sum::() + + self.shared.iter().map(|d| d.size).sum::() + } + + pub fn download_bytes(&self) -> u64 { + self.depots.iter().map(|d| d.download).sum::() + + self.shared.iter().map(|d| d.download).sum::() + } + + pub fn to_json(&self) -> Value { + json!({ + "ok": true, + "appId": self.app_id, + "name": self.name, + "installDir": self.install_dir, + "buildId": self.build_id, + "language": self.language, + "linuxBuild": self.linux_build, + "downloadBytes": self.download_bytes(), + "installBytes": self.install_bytes(), + "depots": self.depots.iter().map(|d| json!({ + "depotId": d.depot_id, + "manifestId": d.manifest_id.to_string(), + "size": d.size, + "dlcAppId": d.dlc_app_id, + })).collect::>(), + "shared": self.shared.iter().map(|d| json!({ + "depotId": d.depot_id, + "fromAppId": d.from_app_id, + "manifestId": d.manifest_id.to_string(), + "size": d.size, + })).collect::>(), + }) + } +} + +/// `appinfo` as PICS delivers it: either the `appinfo` node itself or a root holding it. +pub fn appinfo_root(root: &KVNode) -> &KVNode { + if root.name.eq_ignore_ascii_case("appinfo") { + root + } else { + root.child("appinfo").unwrap_or(root) + } +} + +fn str_at(node: &KVNode, path: &[&str]) -> String { + let mut cur = node; + for key in path { + match cur.child(key) { + Some(next) => cur = next, + None => return String::new(), + } + } + if cur.is_object() { + String::new() + } else { + cur.as_string("") + } +} + +fn uint_at(node: &KVNode, path: &[&str]) -> u64 { + str_at(node, path).trim().parse().unwrap_or(0) +} + +pub fn app_name(appinfo: &KVNode) -> String { + str_at(appinfo, &["common", "name"]) +} + +pub fn app_type(appinfo: &KVNode) -> String { + str_at(appinfo, &["common", "type"]) +} + +pub fn app_install_dir(appinfo: &KVNode) -> String { + str_at(appinfo, &["config", "installdir"]) +} + +pub fn public_build_id(appinfo: &KVNode) -> u64 { + uint_at(appinfo, &["depots", "branches", "public", "buildid"]) +} + +/// Free to play / free app, as appinfo marks it. +pub fn is_free(appinfo: &KVNode) -> bool { + str_at(appinfo, &["common", "freetogame"]) == "1" + || str_at(appinfo, &["extended", "isfreeapp"]) == "1" +} + +/// Public manifest gid, size and download size of one depot entry (new layout +/// `manifests.public { gid size download }`, or the old `manifests.public ""` + `maxsize`). +pub fn public_manifest(depot: &KVNode) -> Option<(u64, u64, u64)> { + let public = depot.child("manifests")?.child("public")?; + if public.is_object() { + let gid = uint_at(public, &["gid"]); + if gid == 0 { + return None; + } + let size = uint_at(public, &["size"]); + let download = uint_at(public, &["download"]); + Some((gid, size, download)) + } else { + let gid = public.as_uint(0); + if gid == 0 { + return None; + } + Some((gid, uint_at(depot, &["maxsize"]), 0)) + } +} + +fn os_ok(config: Option<&KVNode>) -> bool { + let oslist = config.map(|c| str_at(c, &["oslist"])).unwrap_or_default(); + oslist.trim().is_empty() + || oslist + .split(',') + .any(|os| os.trim().eq_ignore_ascii_case("windows")) +} + +fn arch_of(config: Option<&KVNode>) -> String { + config + .map(|c| str_at(c, &["osarch"]).trim().to_string()) + .unwrap_or_default() +} + +fn language_of(config: Option<&KVNode>) -> String { + config + .map(|c| str_at(c, &["language"]).trim().to_ascii_lowercase()) + .unwrap_or_default() +} + +fn low_violence(config: Option<&KVNode>) -> bool { + config.is_some_and(|c| str_at(c, &["lowviolence"]) == "1") +} + +struct Candidate<'a> { + depot_id: u32, + node: &'a KVNode, + arch: String, + language: String, +} + +/// Applies the osarch preference and the language choice to a candidate set. +fn narrow<'a>(mut set: Vec>, language: &str) -> Vec> { + if set.iter().any(|c| c.arch == "64") { + set.retain(|c| c.arch != "32"); + } + set.retain(|c| c.arch.is_empty() || c.arch == "64" || c.arch == "32"); + set.retain(|c| c.language.is_empty() || c.language == language); + set +} + +/// The language to install: the requested one when the game has a depot for it (or has no +/// language-tagged depots at all), else english when the game has english depots. +pub fn effective_language(appinfo: &KVNode, requested: &str) -> String { + let requested = requested.trim().to_ascii_lowercase(); + let requested = if requested.is_empty() { + "english".to_string() + } else { + requested + }; + let Some(depots) = appinfo.child("depots") else { + return requested; + }; + let tags: HashSet = depots + .children + .iter() + .filter(|d| d.name.parse::().is_ok()) + .map(|d| language_of(d.child("config"))) + .filter(|l| !l.is_empty()) + .collect(); + language_from(&tags, requested) +} + +fn language_from(tags: &HashSet, requested: String) -> String { + if tags.is_empty() || tags.contains(&requested) || !tags.contains("english") { + requested + } else { + "english".to_string() + } +} + +/// Plans the app's own depots and lists the shared depots it references (resolved later with +/// [`resolve_shared`] from the owning apps' appinfo). +pub fn plan_app( + app_id: u32, + appinfo: &KVNode, + owned_apps: &HashSet, + owned_depots: Option<&HashSet>, + language: &str, +) -> Result { + let appinfo = appinfo_root(appinfo); + let mut plan = AppPlan { + app_id, + name: app_name(appinfo), + install_dir: app_install_dir(appinfo), + build_id: public_build_id(appinfo), + linux_build: str_at(appinfo, &["common", "oslist"]) + .split(',') + .any(|os| os.trim().eq_ignore_ascii_case("linux")), + ..Default::default() + }; + if plan.install_dir.is_empty() { + return Err("appinfo has no installdir".to_string()); + } + if !crate::steam::register::is_plain_name(&plan.install_dir) { + return Err("appinfo installdir is not a plain folder name".to_string()); + } + let Some(depots) = appinfo.child("depots") else { + return Err("appinfo has no depots".to_string()); + }; + + let mut own: Vec = Vec::new(); + let mut shared: Vec = Vec::new(); + for depot in &depots.children { + let Ok(depot_id) = depot.name.parse::() else { + continue; + }; + if !depot.is_object() { + continue; + } + let config = depot.child("config"); + if !os_ok(config) || low_violence(config) { + continue; + } + let dlc = uint_at(depot, &["dlcappid"]) as u32; + if dlc != 0 && !owned_apps.contains(&dlc) { + continue; + } + let from_app = uint_at(depot, &["depotfromapp"]) as u32; + let shared_install = str_at(depot, &["sharedinstall"]) == "1"; + let is_shared = from_app != 0 || shared_install; + if !is_shared && owned_depots.is_some_and(|owned| !owned.contains(&depot_id)) { + continue; + } + let candidate = Candidate { + depot_id, + node: depot, + arch: arch_of(config), + language: language_of(config), + }; + if is_shared { + shared.push(candidate); + } else if public_manifest(depot).is_some() { + // Only a depot with a public manifest can be installed, so only those take part in + // the language and architecture choice. + own.push(candidate); + } + } + + let requested = language.trim().to_ascii_lowercase(); + let requested = if requested.is_empty() { + "english".to_string() + } else { + requested + }; + let tags: HashSet = own + .iter() + .map(|c| c.language.clone()) + .filter(|l| !l.is_empty()) + .collect(); + let language = language_from(&tags, requested); + plan.language = language.clone(); + + for candidate in narrow(own, &language) { + let Some((manifest_id, size, download)) = public_manifest(candidate.node) else { + continue; + }; + plan.depots.push(PlannedDepot { + depot_id: candidate.depot_id, + manifest_id, + size, + download, + dlc_app_id: uint_at(candidate.node, &["dlcappid"]) as u32, + }); + } + for candidate in narrow(shared, &language) { + let from_app = uint_at(candidate.node, &["depotfromapp"]) as u32; + if from_app == 0 || from_app == app_id { + continue; + } + plan.shared_refs.push(SharedRef { + depot_id: candidate.depot_id, + from_app_id: from_app, + }); + } + if plan.depots.is_empty() { + // The client installs the Linux build of a game that has no Windows depot. + return Err(if plan.linux_build { + "linux_build".to_string() + } else { + "no installable Windows depot".to_string() + }); + } + Ok(plan) +} + +/// Fills [`AppPlan::shared`] from the owning apps' appinfo (`lookup(from_app_id)`); a shared +/// depot without a public manifest there is left out. Fails when an owning app's appinfo could +/// not be fetched, so a plan never goes ahead without a shared depot it may need. +pub fn resolve_shared( + plan: &mut AppPlan, + lookup: &dyn Fn(u32) -> Option, +) -> Result<(), String> { + plan.shared.clear(); + let mut cache: Vec<(u32, Option)> = Vec::new(); + for shared_ref in plan.shared_refs.clone() { + let pos = match cache + .iter() + .position(|(id, _)| *id == shared_ref.from_app_id) + { + Some(pos) => pos, + None => { + cache.push((shared_ref.from_app_id, lookup(shared_ref.from_app_id))); + cache.len() - 1 + } + }; + let Some(info) = cache[pos].1.as_ref() else { + return Err(format!( + "appinfo unavailable for shared app {}", + shared_ref.from_app_id + )); + }; + let info = appinfo_root(info); + let Some(depot) = info + .child("depots") + .and_then(|d| d.child(&shared_ref.depot_id.to_string())) + else { + continue; + }; + let Some((manifest_id, size, download)) = public_manifest(depot) else { + continue; + }; + let install_dir = app_install_dir(info); + if !crate::steam::register::is_plain_name(&install_dir) { + continue; + } + plan.shared.push(SharedDepot { + depot_id: shared_ref.depot_id, + from_app_id: shared_ref.from_app_id, + manifest_id, + size, + download, + from_name: app_name(info), + from_install_dir: install_dir, + from_build_id: public_build_id(info), + }); + } + Ok(()) +} + +#[cfg(test)] +pub mod tests { + use super::*; + + /// Shaped like Brawlhalla's (291550) appinfo. Depot 291551/228988 gids and sizes and the + /// build ids are the captured install's; `download` values and depots 291552-291556 are made + /// up for the selection rules. + pub const BRAWLHALLA: &str = r#""appinfo" +{ + "appid" "291550" + "common" + { + "name" "Brawlhalla" + "type" "Game" + "freetogame" "1" + } + "config" + { + "installdir" "Brawlhalla" + } + "depots" + { + "228988" + { + "config" + { + "oslist" "windows" + } + "depotfromapp" "228980" + "sharedinstall" "1" + } + "291551" + { + "config" + { + "oslist" "windows" + } + "manifests" + { + "public" + { + "gid" "4224536525702420323" + "size" "1565156559" + "download" "1521899507" + } + } + } + "291552" + { + "config" + { + "oslist" "macos" + } + "manifests" + { + "public" + { + "gid" "11" + "size" "5" + } + } + } + "291553" + { + "config" + { + "oslist" "windows" + "osarch" "32" + } + "manifests" + { + "public" + { + "gid" "12" + "size" "5" + } + } + } + "291554" + { + "config" + { + "oslist" "windows" + "osarch" "64" + "language" "german" + } + "manifests" + { + "public" + { + "gid" "13" + "size" "7" + } + } + } + "291555" + { + "config" + { + "lowviolence" "1" + } + "manifests" + { + "public" "14" + } + "maxsize" "9" + } + "291556" + { + "dlcappid" "291560" + "manifests" + { + "public" + { + "gid" "15" + "size" "3" + } + } + } + "branches" + { + "public" + { + "buildid" "26465982" + } + } + } +} +"#; + + pub const REDIST: &str = r#""appinfo" +{ + "appid" "228980" + "common" + { + "name" "Steamworks Common Redistributables" + "type" "Config" + } + "config" + { + "installdir" "Steamworks Shared" + } + "depots" + { + "228988" + { + "config" + { + "oslist" "windows" + } + "manifests" + { + "public" + { + "gid" "6645201662696499616" + "size" "29212173" + "download" "29212496" + } + } + } + "branches" + { + "public" + { + "buildid" "24098430" + } + } + } +} +"#; + + pub fn parse(text: &str) -> KVNode { + crate::steam::vdf::parse_text(text.as_bytes()).unwrap() + } + + #[test] + fn picks_windows_64bit_language_and_shared_depots_like_the_client() { + let info = parse(BRAWLHALLA); + let mut plan = plan_app(291550, &info, &HashSet::new(), None, "english").unwrap(); + assert_eq!(plan.name, "Brawlhalla"); + assert_eq!(plan.install_dir, "Brawlhalla"); + assert_eq!(plan.build_id, 26465982); + assert_eq!(plan.language, "english"); + let ids: Vec = plan.depots.iter().map(|d| d.depot_id).collect(); + // 291552 macOS, 291553 32-bit (a 64-bit depot exists), 291554 german, 291555 low + // violence and 291556 unowned DLC are all left out. + assert_eq!(ids, vec![291551]); + assert_eq!(plan.depots[0].manifest_id, 4224536525702420323); + assert_eq!(plan.depots[0].size, 1565156559); + assert_eq!( + plan.shared_refs, + vec![SharedRef { + depot_id: 228988, + from_app_id: 228980 + }] + ); + resolve_shared(&mut plan, &|app| (app == 228980).then(|| parse(REDIST))).unwrap(); + assert_eq!(plan.shared.len(), 1); + let shared = &plan.shared[0]; + assert_eq!(shared.manifest_id, 6645201662696499616); + assert_eq!(shared.size, 29212173); + assert_eq!(shared.from_install_dir, "Steamworks Shared"); + assert_eq!(shared.from_build_id, 24098430); + // BytesToStage of the captured install = game depot + shared depot. + assert_eq!(plan.install_bytes(), 1594368732); + let json = plan.to_json(); + assert_eq!(json["depots"][0]["manifestId"], "4224536525702420323"); + assert_eq!(json["shared"][0]["fromAppId"], 228980); + } + + #[test] + fn owned_dlc_german_and_32bit_fallback() { + let info = parse(BRAWLHALLA); + let owned: HashSet = [291560].into_iter().collect(); + let plan = plan_app(291550, &info, &owned, None, "german").unwrap(); + let ids: Vec = plan.depots.iter().map(|d| d.depot_id).collect(); + assert_eq!(ids, vec![291551, 291554, 291556]); + assert_eq!(plan.depots[2].dlc_app_id, 291560); + + let only32 = parse( + r#""appinfo" { "config" { "installdir" "X" } "depots" { "1" { "config" { "osarch" "32" } "manifests" { "public" "5" } "maxsize" "10" } } }"#, + ); + let plan = plan_app(1, &only32, &HashSet::new(), None, "english").unwrap(); + assert_eq!(plan.depots[0].depot_id, 1); + assert_eq!(plan.depots[0].manifest_id, 5); + assert_eq!(plan.depots[0].size, 10); + } + + #[test] + fn unsupported_language_falls_back_to_english_depots() { + let info = parse( + r#""appinfo" { "config" { "installdir" "X" } "depots" { + "1" { "manifests" { "public" { "gid" "1" "size" "1" } } } + "2" { "config" { "language" "english" } "manifests" { "public" { "gid" "2" "size" "1" } } } + "3" { "config" { "language" "german" } "manifests" { "public" { "gid" "3" "size" "1" } } } } }"#, + ); + let plan = plan_app(9, &info, &HashSet::new(), None, "koreana").unwrap(); + assert_eq!(plan.language, "english"); + let ids: Vec = plan.depots.iter().map(|d| d.depot_id).collect(); + assert_eq!(ids, vec![1, 2]); + assert!(plan_app( + 9, + &parse(r#""appinfo" { "depots" { } }"#), + &HashSet::new(), + None, + "english" + ) + .is_err()); + } + + #[test] + fn skips_depots_the_licenses_do_not_grant() { + let info = parse( + r#""appinfo" { "config" { "installdir" "X" } "depots" { + "11" { "config" { "oslist" "windows" } "manifests" { "public" { "gid" "1" "size" "1" } } } + "12" { "config" { "oslist" "windows" } "manifests" { "public" { "gid" "2" "size" "1" } } } + "13" { "config" { "oslist" "windows" } "depotfromapp" "228980" "sharedinstall" "1" } } }"#, + ); + let owned: HashSet = [11].into_iter().collect(); + let plan = plan_app(10, &info, &HashSet::new(), Some(&owned), "english").unwrap(); + let ids: Vec = plan.depots.iter().map(|d| d.depot_id).collect(); + assert_eq!(ids, vec![11]); + assert_eq!(plan.shared_refs.len(), 1); + let all = plan_app(10, &info, &HashSet::new(), None, "english").unwrap(); + assert_eq!(all.depots.len(), 2); + } + + #[test] + fn flags_a_linux_build() { + let info = parse( + r#""appinfo" { "common" { "oslist" "windows,linux" } "config" { "installdir" "X" } "depots" { + "1" { "config" { "oslist" "windows" } "manifests" { "public" { "gid" "1" "size" "1" } } } } }"#, + ); + assert!(plan_app(1, &info, &HashSet::new(), None, "english").unwrap().linux_build); + } +} diff --git a/app/src/main/rust/stores/src/steam/proto_envelope.rs b/app/src/main/rust/stores/src/steam/proto_envelope.rs new file mode 100644 index 0000000000..903a0821a7 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/proto_envelope.rs @@ -0,0 +1,87 @@ +use crate::steam::cmsg_protobuf_header::CMsgProtoBufHeader; +use crate::steam::emsg::{has_proto_flag, strip_proto_flag, with_proto_flag, EMsg}; +use crate::steam::wire_format; + +pub const PROTO_ENVELOPE_PREFIX_BYTES: usize = 8; + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct ProtoEnvelope { + pub emsg: EMsg, + pub header: CMsgProtoBufHeader, + pub body: Vec, +} + +impl Default for ProtoEnvelope { + fn default() -> Self { + Self { + emsg: EMsg::INVALID, + header: CMsgProtoBufHeader::default(), + body: Vec::new(), + } + } +} + +pub fn encode_proto_envelope(emsg: EMsg, header: &CMsgProtoBufHeader, body: &[u8]) -> Vec { + let mut hdr_bytes = Vec::with_capacity(64); + header.serialize(&mut hdr_bytes); + + let mut out = Vec::with_capacity(PROTO_ENVELOPE_PREFIX_BYTES + hdr_bytes.len() + body.len()); + let mut writer = wire_format::Writer::new(&mut out); + writer.u32(with_proto_flag(emsg)); + writer.u32(hdr_bytes.len() as u32); + writer.bytes(&hdr_bytes); + writer.bytes(body); + out +} + +pub fn decode_proto_envelope(wire: &[u8]) -> Option { + if wire.len() < PROTO_ENVELOPE_PREFIX_BYTES { + return None; + } + let mut reader = wire_format::Reader::new(wire); + let raw_emsg = reader.u32(); + let hdr_len = reader.u32() as usize; + if !reader.ok() || !has_proto_flag(raw_emsg) || reader.remaining() < hdr_len { + return None; + } + let header = CMsgProtoBufHeader::deserialize(reader.bytes(hdr_len))?; + if !reader.ok() { + return None; + } + let body_off = reader.position(); + Some(ProtoEnvelope { + emsg: strip_proto_flag(raw_emsg), + header, + body: wire[body_off..].to_vec(), + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn proto_envelope_roundtrips() { + let header = CMsgProtoBufHeader { + steamid: 76561197960287930, + jobid_source: 42, + target_job_name: "Player.GetOwnedGames#1".to_string(), + ..Default::default() + }; + let body = [1, 2, 3, 4, 5]; + let bytes = encode_proto_envelope(EMsg::SERVICE_METHOD_CALL_FROM_CLIENT, &header, &body); + let decoded = decode_proto_envelope(&bytes).unwrap(); + assert_eq!(decoded.emsg, EMsg::SERVICE_METHOD_CALL_FROM_CLIENT); + assert_eq!(decoded.header, header); + assert_eq!(decoded.body, body); + } + + #[test] + fn decode_rejects_non_proto_messages() { + let mut bytes = Vec::new(); + let mut writer = wire_format::Writer::new(&mut bytes); + writer.u32(EMsg::MULTI.0); + writer.u32(0); + assert_eq!(decode_proto_envelope(&bytes), None); + } +} diff --git a/app/src/main/rust/stores/src/steam/proto_wire.rs b/app/src/main/rust/stores/src/steam/proto_wire.rs new file mode 100644 index 0000000000..bdb10f5a4c --- /dev/null +++ b/app/src/main/rust/stores/src/steam/proto_wire.rs @@ -0,0 +1,459 @@ +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[repr(u8)] +pub enum WireType { + Varint = 0, + Fixed64 = 1, + LengthDelimited = 2, + StartGroup = 3, + EndGroup = 4, + Fixed32 = 5, +} + +impl TryFrom for WireType { + type Error = (); + + fn try_from(value: u8) -> Result { + match value { + 0 => Ok(Self::Varint), + 1 => Ok(Self::Fixed64), + 2 => Ok(Self::LengthDelimited), + 3 => Ok(Self::StartGroup), + 4 => Ok(Self::EndGroup), + 5 => Ok(Self::Fixed32), + _ => Err(()), + } + } +} + +pub const MAX_VARINT_BYTES: usize = 10; + +pub const fn zigzag_encode_i64(v: i64) -> u64 { + ((v as u64) << 1) ^ ((v >> 63) as u64) +} + +pub const fn zigzag_decode_i64(v: u64) -> i64 { + ((v >> 1) as i64) ^ -((v & 1) as i64) +} + +pub const fn zigzag_encode_i32(v: i32) -> u32 { + ((v as u32) << 1) ^ ((v >> 31) as u32) +} + +pub const fn zigzag_decode_i32(v: u32) -> i32 { + ((v >> 1) as i32) ^ -((v & 1) as i32) +} + +pub const fn make_tag(field_number: i32, wire_type: WireType) -> u32 { + ((field_number as u32) << 3) | wire_type as u32 +} + +pub struct Writer<'a> { + out: &'a mut Vec, +} + +impl<'a> Writer<'a> { + pub fn new(out: &'a mut Vec) -> Self { + Self { out } + } + + pub fn varint(&mut self, mut v: u64) { + while v >= 0x80 { + self.out.push((v as u8) | 0x80); + v >>= 7; + } + self.out.push(v as u8); + } + + pub fn tag(&mut self, field_number: i32, wire_type: WireType) { + self.varint(make_tag(field_number, wire_type) as u64); + } + + pub fn uint32_field(&mut self, field_number: i32, v: u32) { + if v == 0 { + return; + } + self.tag(field_number, WireType::Varint); + self.varint(v as u64); + } + + pub fn uint64_field(&mut self, field_number: i32, v: u64) { + if v == 0 { + return; + } + self.tag(field_number, WireType::Varint); + self.varint(v); + } + + pub fn int32_field(&mut self, field_number: i32, v: i32) { + if v == 0 { + return; + } + self.tag(field_number, WireType::Varint); + self.varint(v as i64 as u64); + } + + pub fn int64_field(&mut self, field_number: i32, v: i64) { + if v == 0 { + return; + } + self.tag(field_number, WireType::Varint); + self.varint(v as u64); + } + + pub fn bool_field(&mut self, field_number: i32, v: bool) { + if !v { + return; + } + self.tag(field_number, WireType::Varint); + self.varint(1); + } + + pub fn fixed32_field(&mut self, field_number: i32, v: u32) { + if v == 0 { + return; + } + self.tag(field_number, WireType::Fixed32); + self.out.extend_from_slice(&v.to_le_bytes()); + } + + pub fn fixed64_field(&mut self, field_number: i32, v: u64) { + if v == 0 { + return; + } + self.tag(field_number, WireType::Fixed64); + self.out.extend_from_slice(&v.to_le_bytes()); + } + + pub fn string_field(&mut self, field_number: i32, s: &str) { + if s.is_empty() { + return; + } + self.tag(field_number, WireType::LengthDelimited); + self.varint(s.len() as u64); + self.out.extend_from_slice(s.as_bytes()); + } + + pub fn bytes_field(&mut self, field_number: i32, bytes: &[u8]) { + if bytes.is_empty() { + return; + } + self.tag(field_number, WireType::LengthDelimited); + self.varint(bytes.len() as u64); + self.out.extend_from_slice(bytes); + } + + pub fn submessage_field(&mut self, field_number: i32, body: &[u8]) { + self.tag(field_number, WireType::LengthDelimited); + self.varint(body.len() as u64); + self.out.extend_from_slice(body); + } + + pub fn raw_bytes(&mut self, bytes: &[u8]) { + self.out.extend_from_slice(bytes); + } + + pub fn uint32_field_force(&mut self, field_number: i32, v: u32) { + self.tag(field_number, WireType::Varint); + self.varint(v as u64); + } + + pub fn bool_field_force(&mut self, field_number: i32, v: bool) { + self.tag(field_number, WireType::Varint); + self.varint(u64::from(v)); + } +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct Tag { + pub field_number: i32, + pub wire_type: WireType, +} + +pub struct Reader<'a> { + buf: &'a [u8], + pos: usize, + ok: bool, +} + +impl<'a> Reader<'a> { + pub fn new(buf: &'a [u8]) -> Self { + Self { + buf, + pos: 0, + ok: true, + } + } + + pub fn ok(&self) -> bool { + self.ok + } + + pub fn eof(&self) -> bool { + self.pos >= self.buf.len() + } + + pub fn position(&self) -> usize { + self.pos + } + + pub fn next_tag(&mut self) -> Option { + if self.eof() { + return None; + } + let raw = self.varint()? as u32; + let wire_type = match WireType::try_from((raw & 0x07) as u8) { + Ok(wire_type) => wire_type, + Err(_) => { + self.ok = false; + return None; + } + }; + let field_number = (raw >> 3) as i32; + if matches!(wire_type, WireType::StartGroup | WireType::EndGroup) || field_number <= 0 { + self.ok = false; + return None; + } + Some(Tag { + field_number, + wire_type, + }) + } + + pub fn varint(&mut self) -> Option { + let mut result = 0u64; + for i in 0..MAX_VARINT_BYTES { + if self.pos >= self.buf.len() { + self.ok = false; + return None; + } + let b = self.buf[self.pos]; + self.pos += 1; + result |= ((b & 0x7f) as u64) << (i * 7); + if (b & 0x80) == 0 { + return Some(result); + } + } + self.ok = false; + None + } + + pub fn skip(&mut self, wire_type: WireType) -> bool { + match wire_type { + WireType::Varint => self.varint().is_some(), + WireType::Fixed64 => self.advance(8), + WireType::LengthDelimited => { + let Some(len) = self.varint() else { + return false; + }; + if len > usize::MAX as u64 { + self.ok = false; + return false; + } + self.advance(len as usize) + } + WireType::Fixed32 => self.advance(4), + WireType::StartGroup | WireType::EndGroup => { + self.ok = false; + false + } + } + } + + pub fn u32(&mut self) -> Option { + self.varint().map(|v| v as u32) + } + + pub fn u64(&mut self) -> Option { + self.varint() + } + + pub fn i32(&mut self) -> Option { + self.varint().map(|v| v as i32) + } + + pub fn i64(&mut self) -> Option { + self.varint().map(|v| v as i64) + } + + pub fn boolean(&mut self) -> Option { + self.varint().map(|v| v != 0) + } + + pub fn fixed32(&mut self) -> Option { + let Some(end) = self.pos.checked_add(4) else { + self.ok = false; + return None; + }; + if end > self.buf.len() { + self.ok = false; + return None; + } + let bytes: [u8; 4] = self.buf[self.pos..end].try_into().ok()?; + self.pos = end; + Some(u32::from_le_bytes(bytes)) + } + + pub fn fixed64(&mut self) -> Option { + let Some(end) = self.pos.checked_add(8) else { + self.ok = false; + return None; + }; + if end > self.buf.len() { + self.ok = false; + return None; + } + let bytes: [u8; 8] = self.buf[self.pos..end].try_into().ok()?; + self.pos = end; + Some(u64::from_le_bytes(bytes)) + } + + pub fn bytes(&mut self) -> Option<&'a [u8]> { + let len = self.varint()?; + if len > usize::MAX as u64 { + self.ok = false; + return None; + } + let len = len as usize; + let Some(end) = self.pos.checked_add(len) else { + self.ok = false; + return None; + }; + if end > self.buf.len() { + self.ok = false; + return None; + } + let out = &self.buf[self.pos..end]; + self.pos = end; + Some(out) + } + + pub fn string(&mut self) -> Option { + Some(String::from_utf8_lossy(self.bytes()?).into_owned()) + } + + fn advance(&mut self, amount: usize) -> bool { + let Some(end) = self.pos.checked_add(amount) else { + self.ok = false; + return false; + }; + if end > self.buf.len() { + self.ok = false; + return false; + } + self.pos = end; + true + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn varint_roundtrips_common_edges() { + let cases = [0, 1, 127, 128, 300, u32::MAX as u64, u64::MAX]; + for case in cases { + let mut buf = Vec::new(); + Writer::new(&mut buf).varint(case); + let mut reader = Reader::new(&buf); + assert_eq!(reader.varint(), Some(case)); + assert!(reader.ok()); + assert!(reader.eof()); + } + } + + #[test] + fn writes_and_reads_typed_fields() { + let mut buf = Vec::new(); + let mut writer = Writer::new(&mut buf); + writer.uint32_field(1, 42); + writer.fixed32_field(2, 0x1234_5678); + writer.string_field(3, "steam"); + writer.bool_field_force(4, false); + + let mut reader = Reader::new(&buf); + assert_eq!( + reader.next_tag(), + Some(Tag { + field_number: 1, + wire_type: WireType::Varint + }) + ); + assert_eq!(reader.u32(), Some(42)); + assert_eq!( + reader.next_tag(), + Some(Tag { + field_number: 2, + wire_type: WireType::Fixed32 + }) + ); + assert_eq!(reader.fixed32(), Some(0x1234_5678)); + assert_eq!( + reader.next_tag(), + Some(Tag { + field_number: 3, + wire_type: WireType::LengthDelimited + }) + ); + assert_eq!(reader.string(), Some("steam".to_string())); + assert_eq!( + reader.next_tag(), + Some(Tag { + field_number: 4, + wire_type: WireType::Varint + }) + ); + assert_eq!(reader.boolean(), Some(false)); + assert!(reader.eof()); + } + + #[test] + fn rejects_deprecated_groups_and_truncated_data() { + let mut group = Vec::new(); + Writer::new(&mut group).tag(1, WireType::StartGroup); + let mut reader = Reader::new(&group); + assert_eq!(reader.next_tag(), None); + assert!(!reader.ok()); + + let mut truncated = Reader::new(&[0x0a, 0x05, b'a']); + assert_eq!( + truncated.next_tag(), + Some(Tag { + field_number: 1, + wire_type: WireType::LengthDelimited + }) + ); + assert_eq!(truncated.bytes(), None); + assert!(!truncated.ok()); + } + + #[test] + fn rejects_invalid_wire_type_and_oversized_length() { + let mut invalid = Reader::new(&[0x0e]); + assert_eq!(invalid.next_tag(), None); + assert!(!invalid.ok()); + + let mut oversized = Vec::new(); + Writer::new(&mut oversized).varint(make_tag(1, WireType::LengthDelimited) as u64); + Writer::new(&mut oversized).varint(u64::MAX); + let mut reader = Reader::new(&oversized); + assert_eq!( + reader.next_tag(), + Some(Tag { + field_number: 1, + wire_type: WireType::LengthDelimited + }) + ); + assert_eq!(reader.bytes(), None); + assert!(!reader.ok()); + } + + #[test] + fn zigzag_matches_known_values() { + assert_eq!(zigzag_encode_i32(0), 0); + assert_eq!(zigzag_encode_i32(-1), 1); + assert_eq!(zigzag_encode_i32(1), 2); + assert_eq!(zigzag_decode_i32(1), -1); + assert_eq!(zigzag_decode_i64(3), -2); + } +} diff --git a/app/src/main/rust/stores/src/steam/register.rs b/app/src/main/rust/stores/src/steam/register.rs new file mode 100644 index 0000000000..ca5d58938c --- /dev/null +++ b/app/src/main/rust/stores/src/steam/register.rs @@ -0,0 +1,1253 @@ +//! What the Steam client writes around an install, so it sees a game we downloaded as installed +//! (and does not update or verify it), and what it removes on uninstall. Modelled on a captured +//! client install and uninstall of Brawlhalla (291550) to an SD-card library: +//! +//! - `/steamapps/appmanifest_.acf` (key order as the client writes it); +//! - shared depots (e.g. 228988 VC++ 2019 of 228980) in the library holding that app's manifest, +//! under `steamapps/common/`, recorded in its `InstalledDepots` and +//! `InstallScripts`, with its `SizeOnDisk` adjusted; +//! - `"" "0"` under the library's `apps` in both `libraryfolders.vdf` copies (the client +//! fills in the size later). +//! +//! `config.vdf`, `localconfig.vdf` and `registry.vdf` are never written; the client regenerates +//! them. `depotcache/` is not written either: the client keeps manifests there with decrypted +//! file names, not in the CDN form this engine caches. + +use crate::steam::content_manifest::ContentManifest; +use crate::steam::kv; +use crate::steam::plan::AppPlan; +use crate::steam::vdf::KVNode; +use std::collections::HashSet; +use std::fs; +use std::path::{Path, PathBuf}; + +pub const STATE_UPDATE_REQUIRED: u64 = 2; +pub const STATE_FULLY_INSTALLED: u64 = 4; +/// StateFlags bits that mean "not a finished install": update required, files missing or +/// corrupt, update running/paused/started, uninstalling, reconfiguring, validating, adding files, +/// preallocating, downloading, staging, committing, update stopping. +pub const STATE_UNFINISHED_MASK: u64 = 2 + | 32 + | 128 + | 256 + | 512 + | 1024 + | 2048 + | 65536 + | 131072 + | 262144 + | 524288 + | 1048576 + | 2097152 + | 4194304 + | 8388608; +/// `EDepotFileFlag::InstallScript`. +pub const DEPOT_FILE_FLAG_INSTALL_SCRIPT: u32 = 256; + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct LibraryRoot { + pub host: PathBuf, + /// The path as the Steam client sees it inside proot (what `libraryfolders.vdf` holds). + pub guest: String, +} + +impl LibraryRoot { + pub fn steamapps(&self) -> PathBuf { + self.host.join("steamapps") + } + + pub fn acf_path(&self, app_id: u32) -> PathBuf { + self.steamapps().join(format!("appmanifest_{app_id}.acf")) + } + + pub fn common_dir(&self, install_dir: &str) -> PathBuf { + self.steamapps().join("common").join(install_dir) + } +} + +/// Orders a block's entries by numeric key (depot ids), the way the client lists them. +fn sort_by_numeric_key(node: &mut crate::steam::vdf::KVNode) { + node.children + .sort_by_key(|c| c.name.parse::().unwrap_or(u64::MAX)); +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Takeover { + /// No app manifest, or an unfinished one with no client staging left (an earlier run of + /// ours): installed as fresh, merging into that manifest. + Fresh, + /// Fully installed at the build being installed: nothing to do. + AlreadyInstalled, + /// Fully installed at another build: left to the Steam client, which updates it. + Update, + /// A half-finished client download was taken over: its `downloading/` and + /// `temp/` staging went; its manifest stays so its user settings carry into the one + /// written when the install finishes. + TookOver, +} + +pub fn state_is_finished(flags: u64) -> bool { + flags & STATE_FULLY_INSTALLED != 0 && flags & STATE_UNFINISHED_MASK == 0 +} + +pub fn takeover( + game_library: &LibraryRoot, + app_id: u32, + build_id: u64, +) -> Result { + let acf_path = game_library.acf_path(app_id); + if !acf_path.exists() { + return Ok(Takeover::Fresh); + } + let acf = kv::parse_file(&acf_path); + if let Some(acf) = acf.as_ref() { + let flags = kv::get_u64(acf, "StateFlags"); + if state_is_finished(flags) && kv::get_u64(acf, "buildid") == build_id { + return Ok(Takeover::AlreadyInstalled); + } + // A build is on disk (e.g. 6: installed, update required): updating it is the client's. + if flags & STATE_FULLY_INSTALLED != 0 { + return Ok(Takeover::Update); + } + } + let steamapps = game_library.steamapps(); + let mut took_over = false; + for dir in [ + steamapps.join("downloading").join(app_id.to_string()), + steamapps.join("temp").join(app_id.to_string()), + ] { + if dir.exists() { + fs::remove_dir_all(&dir).map_err(|err| format!("remove '{}': {err}", dir.display()))?; + took_over = true; + } + } + let prefix = format!("state_{app_id}_"); + if let Ok(entries) = fs::read_dir(steamapps.join("downloading")) { + for entry in entries.flatten() { + let name = entry.file_name().to_string_lossy().to_string(); + if name.starts_with(&prefix) && name.ends_with(".patch") { + let _ = fs::remove_file(entry.path()); + } + } + } + Ok(if took_over { + Takeover::TookOver + } else { + Takeover::Fresh + }) +} + +/// Moves the files a stopped client download staged in `downloading/` (full-size files at +/// their final offsets) into the install folder where that file is not there yet, so resuming +/// verifies their chunks instead of fetching them again. What stays behind goes with the takeover. +/// Returns how many files were moved. +pub fn adopt_staged(library: &LibraryRoot, app_id: u32, install_dir: &str) -> usize { + if !is_plain_name(install_dir) { + return 0; + } + let installed = kv::parse_file(&library.acf_path(app_id)) + .is_some_and(|acf| kv::get_u64(&acf, "StateFlags") & STATE_FULLY_INSTALLED != 0); + if installed { + return 0; + } + let staging = library.steamapps().join("downloading").join(app_id.to_string()); + let target = library.common_dir(install_dir); + let mut moved = 0; + let mut pending = vec![staging.clone()]; + while let Some(dir) = pending.pop() { + let Ok(entries) = fs::read_dir(&dir) else { + continue; + }; + for entry in entries.flatten() { + let path = entry.path(); + let Ok(meta) = fs::symlink_metadata(&path) else { + continue; + }; + if meta.is_dir() { + pending.push(path); + continue; + } + if !meta.is_file() { + continue; + } + let Ok(rel) = path.strip_prefix(&staging) else { + continue; + }; + let dest = target.join(rel); + if fs::symlink_metadata(&dest).is_ok() { + continue; + } + let Some(parent) = dest.parent() else { + continue; + }; + if fs::create_dir_all(parent).is_ok() && fs::rename(&path, &dest).is_ok() { + moved += 1; + } + } + } + moved +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct InstalledDepot { + pub depot_id: u32, + pub manifest_id: u64, + pub size: u64, + pub dlc_app_id: u32, +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct SharedInstall { + pub depot_id: u32, + pub from_app_id: u32, + pub from_name: String, + pub from_install_dir: String, + pub from_build_id: u64, + pub manifest_id: u64, + pub size: u64, + /// Windows-style path of the depot's install script, if it has one. + pub install_script: Option, + pub library: LibraryRoot, +} + +/// The install script of a depot (`InstallScript` file flag; `installscript.vdf` by name as a +/// fallback), as the Windows-style relative path the client records. +pub fn install_script_path(manifest: &ContentManifest) -> Option { + let flagged = manifest + .files + .iter() + .find(|f| f.flags & DEPOT_FILE_FLAG_INSTALL_SCRIPT != 0 && f.linktarget.is_empty()); + let named = || { + manifest.files.iter().find(|f| { + f.filename + .rsplit('/') + .next() + .is_some_and(|n| n.eq_ignore_ascii_case("installscript.vdf")) + }) + }; + flagged + .or_else(named) + .map(|f| f.filename.replace('/', "\\")) +} + +/// Where a shared app lives: the library that already holds its manifest, else the Steam root's +/// own library (its guest path taken from `libraryfolders.vdf` entry `0` when the caller did not +/// list it). +pub fn shared_app_library( + from_app_id: u32, + steam_root: &Path, + libraries: &[LibraryRoot], +) -> LibraryRoot { + if let Some(lib) = libraries.iter().find(|l| l.acf_path(from_app_id).exists()) { + return lib.clone(); + } + if let Some(lib) = libraries.iter().find(|l| same_path(&l.host, steam_root)) { + return lib.clone(); + } + let guest = libraryfolders_paths(steam_root) + .iter() + .find_map(|path| { + let root = kv::parse_file(path)?; + kv::get_str(root.child("0")?, "path") + }) + .unwrap_or_default(); + LibraryRoot { + host: steam_root.to_path_buf(), + guest, + } +} + +fn same_path(a: &Path, b: &Path) -> bool { + let norm = |p: &Path| p.to_string_lossy().trim_end_matches('/').to_string(); + norm(a) == norm(b) +} + +/// The manifest's InstalledDepots entry for `depot_id` (manifest gid), if any. +pub fn installed_manifest(acf: &KVNode, depot_id: u32) -> Option { + let entry = acf.child("InstalledDepots")?.child(&depot_id.to_string())?; + kv::get_str(entry, "manifest")?.parse().ok() +} + +pub struct GameRegistration<'a> { + pub plan: &'a AppPlan, + pub owner_steam_id: u64, + pub depots: &'a [InstalledDepot], + /// Every shared depot the game uses (installed now or already present). + pub shared: &'a [(u32, u32)], + pub install_scripts: &'a [(u32, String)], + pub bytes_downloaded: u64, + pub bytes_staged: u64, + pub now: u64, +} + +/// Writes (or merges into) `appmanifest_.acf` in the client's key order. +pub fn write_game_acf(library: &LibraryRoot, reg: &GameRegistration<'_>) -> Result<(), String> { + let path = library.acf_path(reg.plan.app_id); + let mut root = kv::parse_file(&path) + .filter(|r| r.name.eq_ignore_ascii_case("AppState")) + .unwrap_or_else(|| kv::object("AppState")); + let size_on_disk: u64 = reg.depots.iter().map(|d| d.size).sum(); + let build = reg.plan.build_id.to_string(); + kv::set(&mut root, "appid", reg.plan.app_id.to_string()); + kv::set(&mut root, "Universe", "1"); + kv::set(&mut root, "name", reg.plan.name.as_str()); + kv::set(&mut root, "StateFlags", "4"); + kv::set(&mut root, "installdir", reg.plan.install_dir.as_str()); + kv::set(&mut root, "LastUpdated", reg.now.to_string()); + set_default(&mut root, "LastPlayed", "0"); + kv::set(&mut root, "SizeOnDisk", size_on_disk.to_string()); + kv::set(&mut root, "StagingSize", "0"); + kv::set(&mut root, "buildid", build.as_str()); + kv::set(&mut root, "LastOwner", reg.owner_steam_id.to_string()); + kv::set(&mut root, "DownloadType", "1"); + kv::set(&mut root, "UpdateResult", "0"); + kv::set( + &mut root, + "BytesToDownload", + reg.bytes_downloaded.to_string(), + ); + kv::set( + &mut root, + "BytesDownloaded", + reg.bytes_downloaded.to_string(), + ); + kv::set(&mut root, "BytesToStage", reg.bytes_staged.to_string()); + kv::set(&mut root, "BytesStaged", reg.bytes_staged.to_string()); + kv::set(&mut root, "TargetBuildID", build.as_str()); + set_default(&mut root, "AutoUpdateBehavior", "0"); + set_default(&mut root, "AllowOtherDownloadsWhileRunning", "0"); + set_default(&mut root, "ScheduledAutoUpdate", "0"); + kv::remove(&mut root, "FullValidateAfterNextUpdate"); + + let installed = kv::object_mut(&mut root, "InstalledDepots"); + installed.children.clear(); + for depot in reg.depots { + let mut entry = kv::object(&depot.depot_id.to_string()); + kv::set(&mut entry, "manifest", depot.manifest_id.to_string()); + kv::set(&mut entry, "size", depot.size.to_string()); + if depot.dlc_app_id != 0 { + kv::set(&mut entry, "dlcappid", depot.dlc_app_id.to_string()); + } + installed.children.push(entry); + } + if reg.install_scripts.is_empty() { + kv::remove(&mut root, "InstallScripts"); + } else { + let scripts = kv::object_mut(&mut root, "InstallScripts"); + scripts.children.clear(); + for (depot, path) in reg.install_scripts { + kv::set(scripts, &depot.to_string(), path.as_str()); + } + } + if reg.shared.is_empty() { + kv::remove(&mut root, "SharedDepots"); + } else { + let shared = kv::object_mut(&mut root, "SharedDepots"); + shared.children.clear(); + for (depot, from) in reg.shared { + kv::set(shared, &depot.to_string(), from.to_string()); + } + } + kv::set( + kv::object_mut(&mut root, "UserConfig"), + "language", + reg.plan.language.as_str(), + ); + kv::set( + kv::object_mut(&mut root, "MountedConfig"), + "language", + reg.plan.language.as_str(), + ); + fs::create_dir_all(library.steamapps()).map_err(|err| format!("mkdir steamapps: {err}"))?; + kv::write_file(&path, &root) +} + +/// Before any file lands, records the install the way the client does when it starts one +/// (`StateFlags` 1026: update required and started, nothing installed yet), so a paused or +/// interrupted download shows in the client as a resumable install. Leaves an existing manifest. +pub fn write_started_acf( + library: &LibraryRoot, + plan: &AppPlan, + owner_steam_id: u64, + now: u64, +) -> Result<(), String> { + let path = library.acf_path(plan.app_id); + if path.exists() { + return Ok(()); + } + let mut root = kv::object("AppState"); + let build = plan.build_id.to_string(); + kv::set(&mut root, "appid", plan.app_id.to_string()); + kv::set(&mut root, "Universe", "1"); + kv::set(&mut root, "name", plan.name.as_str()); + kv::set(&mut root, "StateFlags", "1026"); + kv::set(&mut root, "installdir", plan.install_dir.as_str()); + kv::set(&mut root, "LastUpdated", now.to_string()); + kv::set(&mut root, "LastPlayed", "0"); + kv::set(&mut root, "SizeOnDisk", "0"); + kv::set(&mut root, "StagingSize", "0"); + kv::set(&mut root, "buildid", "0"); + kv::set(&mut root, "LastOwner", owner_steam_id.to_string()); + kv::set(&mut root, "DownloadType", "1"); + kv::set(&mut root, "UpdateResult", "0"); + kv::set(&mut root, "BytesToDownload", plan.download_bytes().to_string()); + kv::set(&mut root, "BytesDownloaded", "0"); + kv::set(&mut root, "BytesToStage", plan.install_bytes().to_string()); + kv::set(&mut root, "BytesStaged", "0"); + kv::set(&mut root, "TargetBuildID", build.as_str()); + kv::set(&mut root, "AutoUpdateBehavior", "0"); + kv::set(&mut root, "AllowOtherDownloadsWhileRunning", "0"); + kv::set(&mut root, "ScheduledAutoUpdate", "0"); + kv::object_mut(&mut root, "InstalledDepots"); + kv::set(kv::object_mut(&mut root, "UserConfig"), "language", plan.language.as_str()); + kv::set(kv::object_mut(&mut root, "MountedConfig"), "language", plan.language.as_str()); + fs::create_dir_all(library.steamapps()).map_err(|err| format!("mkdir steamapps: {err}"))?; + kv::write_file(&path, &root) +} + +fn set_default(node: &mut KVNode, key: &str, value: &str) { + if node.child(key).is_none() { + kv::set(node, key, value); + } +} + +/// Records a shared depot in its app's manifest (creating the manifest when the app has none +/// yet), as the client does: `InstalledDepots`, `InstallScripts`, `SizeOnDisk`. +/// Serializes read-modify-write of a shared app's manifest between installs and uninstalls. +static SHARED_ACF_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); + +pub fn register_shared_depot( + shared: &SharedInstall, + owner_steam_id: u64, + now: u64, +) -> Result { + let _guard = SHARED_ACF_LOCK + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()); + let path = shared.library.acf_path(shared.from_app_id); + let existing = kv::parse_file(&path).filter(|r| r.name.eq_ignore_ascii_case("AppState")); + let created = existing.is_none(); + let mut root = match existing { + Some(root) => root, + None => { + let mut root = kv::object("AppState"); + let build = shared.from_build_id.to_string(); + for (key, value) in [ + ("appid", shared.from_app_id.to_string()), + ("Universe", "1".to_string()), + ("name", shared.from_name.clone()), + ("StateFlags", "4".to_string()), + ("installdir", shared.from_install_dir.clone()), + ("LastUpdated", now.to_string()), + ("LastPlayed", "0".to_string()), + ("SizeOnDisk", "0".to_string()), + ("StagingSize", "0".to_string()), + ("buildid", build.clone()), + ("LastOwner", owner_steam_id.to_string()), + ("DownloadType", "1".to_string()), + ("UpdateResult", "0".to_string()), + ("BytesToDownload", "0".to_string()), + ("BytesDownloaded", "0".to_string()), + ("BytesToStage", "0".to_string()), + ("BytesStaged", "0".to_string()), + ("TargetBuildID", build), + ("AutoUpdateBehavior", "0".to_string()), + ("AllowOtherDownloadsWhileRunning", "0".to_string()), + ("ScheduledAutoUpdate", "0".to_string()), + ] { + kv::set(&mut root, key, value); + } + kv::object_mut(&mut root, "InstalledDepots"); + root + } + }; + let depot_key = shared.depot_id.to_string(); + let old_size = root + .child("InstalledDepots") + .and_then(|d| d.child(&depot_key)) + .map(|e| kv::get_u64(e, "size")) + .unwrap_or(0); + let size_on_disk = kv::get_u64(&root, "SizeOnDisk") + .saturating_sub(old_size) + .saturating_add(shared.size); + kv::set(&mut root, "SizeOnDisk", size_on_disk.to_string()); + { + let installed = kv::object_mut(&mut root, "InstalledDepots"); + kv::remove(installed, &depot_key); + let mut entry = kv::object(&depot_key); + kv::set(&mut entry, "manifest", shared.manifest_id.to_string()); + kv::set(&mut entry, "size", shared.size.to_string()); + installed.children.push(entry); + sort_by_numeric_key(installed); + } + if let Some(script) = &shared.install_script { + let scripts = insert_after(&mut root, "InstallScripts", "InstalledDepots"); + kv::set(scripts, &depot_key, script.as_str()); + sort_by_numeric_key(scripts); + } else if let Some(scripts) = kv::get_mut(&mut root, "InstallScripts") { + kv::remove(scripts, &depot_key); + } + if root.child("UserConfig").is_none() { + kv::object_mut(&mut root, "UserConfig"); + } + if root.child("MountedConfig").is_none() { + kv::object_mut(&mut root, "MountedConfig"); + } + fs::create_dir_all(shared.library.steamapps()) + .map_err(|err| format!("mkdir steamapps: {err}"))?; + kv::write_file(&path, &root)?; + Ok(created) +} + +/// The object `key`, created right after `after` when missing (the client's section order). +fn insert_after<'a>(root: &'a mut KVNode, key: &str, after: &str) -> &'a mut KVNode { + if root.child(key).is_none() { + let pos = root + .children + .iter() + .position(|c| c.name.eq_ignore_ascii_case(after)) + .map(|p| p + 1) + .unwrap_or(root.children.len()); + root.children.insert(pos, kv::object(key)); + } + kv::object_mut(root, key) +} + +pub fn libraryfolders_paths(steam_root: &Path) -> [PathBuf; 2] { + [ + steam_root.join("steamapps").join("libraryfolders.vdf"), + steam_root.join("config").join("libraryfolders.vdf"), + ] +} + +fn normalize_guest(path: &str) -> String { + let trimmed = path.trim_end_matches('/'); + if trimmed.is_empty() { + "/".to_string() + } else { + trimmed.to_string() + } +} + +/// Does either `libraryfolders.vdf` copy have an entry whose `path` is `guest_path`? +pub fn library_registered(steam_root: &Path, guest_path: &str) -> bool { + let want = normalize_guest(guest_path); + libraryfolders_paths(steam_root).iter().any(|path| { + kv::parse_file(path).is_some_and(|root| { + root.children.iter().any(|entry| { + entry.is_object() + && kv::get_str(entry, "path").is_some_and(|p| normalize_guest(&p) == want) + }) + }) + }) +} + +/// Adds (`add = true`) or removes `""` in the `apps` block of the entry whose `path` is +/// `guest_path`, in both copies. Returns how many copies had that entry. +/// Serializes the read-modify-write of `libraryfolders.vdf` between installs and uninstalls. +static LIBRARYFOLDERS_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); + +pub fn update_libraryfolders( + steam_root: &Path, + guest_path: &str, + app_id: u32, + add: bool, +) -> Result { + let _guard = LIBRARYFOLDERS_LOCK + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()); + let want = normalize_guest(guest_path); + let mut matched = 0usize; + for path in libraryfolders_paths(steam_root) { + let Some(mut root) = kv::parse_file(&path) else { + continue; + }; + let app_key = app_id.to_string(); + let mut changed = false; + let mut found = false; + for entry in root.children.iter_mut().filter(|c| c.is_object()) { + let matches = kv::get_str(entry, "path") + .map(|p| normalize_guest(&p) == want) + .unwrap_or(false); + if add { + if !matches { + continue; + } + found = true; + let apps = kv::object_mut(entry, "apps"); + if apps.child(&app_key).is_none() { + apps.children.push(kv::string(&app_key, "0")); + changed = true; + } + } else if let Some(apps) = kv::get_mut(entry, "apps") { + if matches { + found = true; + } + if kv::remove(apps, &app_key) { + changed = true; + } + } + } + if found { + matched += 1; + } + if changed { + kv::write_file(&path, &root)?; + } + } + Ok(matched) +} + +pub(crate) fn is_plain_name(name: &str) -> bool { + !name.is_empty() && name != "." && name != ".." && !name.contains('/') && !name.contains('\\') +} + +/// Every app manifest in the libraries, except `skip` (path), parsed, and whether every library +/// and manifest could be read (a library without `steamapps` counts as read). +fn all_app_manifests(libraries: &[LibraryRoot], skip: &[PathBuf]) -> (Vec, bool) { + let mut out = Vec::new(); + let mut complete = true; + let mut seen: HashSet = HashSet::new(); + for lib in libraries { + let entries = match fs::read_dir(lib.steamapps()) { + Ok(entries) => entries, + Err(err) => { + if err.kind() != std::io::ErrorKind::NotFound { + complete = false; + } + continue; + } + }; + for entry in entries { + let Ok(entry) = entry else { + complete = false; + continue; + }; + let path = entry.path(); + let name = entry.file_name().to_string_lossy().to_string(); + if !name.starts_with("appmanifest_") || !name.ends_with(".acf") { + continue; + } + if skip.contains(&path) || !seen.insert(path.clone()) { + continue; + } + match kv::parse_file(&path) { + Some(acf) => out.push(acf), + None => complete = false, + } + } + } + (out, complete) +} + +/// Is `depot_id` listed in the `SharedDepots` of any of these manifests? +pub fn shared_depot_in_use(manifests: &[KVNode], depot_id: u32) -> bool { + let key = depot_id.to_string(); + manifests.iter().any(|acf| { + acf.child("SharedDepots") + .and_then(|s| s.child(&key)) + .is_some() + }) +} + +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct UninstallReport { + pub removed_shared: Vec, + /// Shared depots no other game uses whose file list was not available; left installed. + pub kept_shared: Vec, +} + +/// Uninstalls like the client: game folder, app manifest, `depotcache` manifests of the game's +/// depots and `steamapps/shadercache/` under the Steam root go; `compatdata/` +/// (the Proton prefix, i.e. saves) stays. A shared depot no other installed game lists loses its +/// files (from the depot's file list, `shared_files(app, depot, manifest)`; empty folders stay) +/// and +/// its entries in the shared app's manifest. The app leaves `apps` in both `libraryfolders.vdf`. +pub fn uninstall( + app_id: u32, + steam_root: &Path, + game_library: &LibraryRoot, + libraries: &[LibraryRoot], + shared_files: &dyn Fn(u32, u32, u64) -> Option>, +) -> Result { + let acf_path = game_library.acf_path(app_id); + let acf = kv::parse_file(&acf_path).ok_or_else(|| "not_installed".to_string())?; + let install_dir = kv::get_str(&acf, "installdir").unwrap_or_default(); + if !is_plain_name(&install_dir) { + return Err("bad installdir in app manifest".to_string()); + } + let game_dir = game_library.common_dir(&install_dir); + if game_dir.exists() { + fs::remove_dir_all(&game_dir) + .map_err(|err| format!("remove '{}': {err}", game_dir.display()))?; + } + if let Some(depots) = acf.child("InstalledDepots") { + for depot in &depots.children { + let manifest = kv::get_str(depot, "manifest").unwrap_or_default(); + if depot.name.parse::().is_err() || manifest.parse::().is_err() { + continue; + } + let cached = steam_root + .join("depotcache") + .join(format!("{}_{manifest}.manifest", depot.name)); + let _ = fs::remove_file(cached); + } + } + let shader = steam_root + .join("steamapps") + .join("shadercache") + .join(app_id.to_string()); + if shader.exists() { + let _ = fs::remove_dir_all(shader); + } + + let mut report = UninstallReport::default(); + let (others, complete) = all_app_manifests(libraries, std::slice::from_ref(&acf_path)); + if let Some(shared) = acf.child("SharedDepots") { + for entry in &shared.children { + let (Ok(depot_id), Ok(from_app)) = ( + entry.name.parse::(), + entry.as_string("").parse::(), + ) else { + continue; + }; + if shared_depot_in_use(&others, depot_id) { + continue; + } + // A library or manifest that could not be read may hold another game using it. + if !complete { + report.kept_shared.push(depot_id); + continue; + } + if remove_shared_depot(depot_id, from_app, libraries, shared_files)? { + report.removed_shared.push(depot_id); + } else { + report.kept_shared.push(depot_id); + } + } + } + + update_libraryfolders(steam_root, &game_library.guest, app_id, false)?; + // The manifest goes last, so a run that stopped early is retried rather than "not_installed". + match fs::remove_file(&acf_path) { + Ok(()) => {} + Err(err) if err.kind() == std::io::ErrorKind::NotFound => {} + Err(err) => return Err(format!("remove '{}': {err}", acf_path.display())), + } + Ok(report) +} + +/// Removes one shared depot's files and its entries in the owning app's manifest. `false` when +/// the depot is not recorded there or its file list is unknown (nothing changed). +fn remove_shared_depot( + depot_id: u32, + from_app: u32, + libraries: &[LibraryRoot], + shared_files: &dyn Fn(u32, u32, u64) -> Option>, +) -> Result { + let _guard = SHARED_ACF_LOCK + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()); + let Some(lib) = libraries.iter().find(|l| l.acf_path(from_app).exists()) else { + return Ok(false); + }; + let path = lib.acf_path(from_app); + let Some(mut root) = kv::parse_file(&path) else { + return Ok(false); + }; + let Some(manifest_id) = installed_manifest(&root, depot_id) else { + return Ok(false); + }; + let install_dir = kv::get_str(&root, "installdir").unwrap_or_default(); + if !is_plain_name(&install_dir) { + return Ok(false); + } + let Some(files) = shared_files(from_app, depot_id, manifest_id) else { + return Ok(false); + }; + let base = lib.common_dir(&install_dir); + let Ok(real_base) = fs::canonicalize(&base) else { + return Ok(false); + }; + let mut removed_any = false; + for rel in files { + if !crate::steam::depot_writer::path_is_safe(&rel) { + continue; + } + let target = base.join(&rel); + // The final component is unlinked without following it; its folder must resolve inside + // the shared app's folder, so a linked ancestor cannot send the removal elsewhere. + let inside = target + .parent() + .and_then(|parent| fs::canonicalize(parent).ok()) + .is_some_and(|parent| parent.starts_with(&real_base)); + if !inside { + continue; + } + if fs::symlink_metadata(&target).is_ok_and(|m| !m.is_dir()) { + match fs::remove_file(&target) { + Ok(()) => removed_any = true, + Err(err) if err.kind() == std::io::ErrorKind::NotFound => {} + // Untouched, the depot stays recorded so a later uninstall can retry. Once files + // are gone it must not read as installed at its manifest, or an install would skip + // it; manifest 0 makes the client and the engine download it again. + Err(_) => { + if removed_any { + if let Some(entry) = kv::get_mut(&mut root, "InstalledDepots") + .and_then(|d| kv::get_mut(d, &depot_id.to_string())) + { + kv::set(entry, "manifest", "0"); + kv::write_file(&path, &root)?; + } + } + return Ok(false); + } + } + } + } + let key = depot_id.to_string(); + let size = root + .child("InstalledDepots") + .and_then(|d| d.child(&key)) + .map(|e| kv::get_u64(e, "size")) + .unwrap_or(0); + let size_on_disk = kv::get_u64(&root, "SizeOnDisk").saturating_sub(size); + kv::set(&mut root, "SizeOnDisk", size_on_disk.to_string()); + if let Some(installed) = kv::get_mut(&mut root, "InstalledDepots") { + kv::remove(installed, &key); + } + if let Some(scripts) = kv::get_mut(&mut root, "InstallScripts") { + kv::remove(scripts, &key); + } + kv::write_file(&path, &root)?; + Ok(true) +} + +/// Regular files and links of a manifest (relative, `/`-separated), for shared-depot removal. +pub fn manifest_file_list(manifest: &ContentManifest) -> Vec { + manifest + .files + .iter() + .filter(|f| f.flags & crate::steam::depot_writer::DEPOT_FILE_FLAG_DIRECTORY == 0) + .map(|f| f.filename.clone()) + .collect() +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::steam::content_manifest::FileMapping; + + const OWNER: u64 = 76561198000000001; + + fn temp_root(name: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!( + "droiddeck_steam_register_{name}_{}", + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_nanos() + )); + fs::create_dir_all(&dir).unwrap(); + dir + } + + const LIBRARYFOLDERS: &str = "\"libraryfolders\"\n{\n\t\"0\"\n\t{\n\t\t\"path\"\t\t\"/root/.local/share/Steam\"\n\t\t\"label\"\t\t\"Internal Storage\"\n\t\t\"contentid\"\t\t\"4468340155036637738\"\n\t\t\"totalsize\"\t\t\"0\"\n\t\t\"update_clean_bytes_tally\"\t\t\"2147547047\"\n\t\t\"time_last_update_verified\"\t\t\"1792656438\"\n\t\t\"apps\"\n\t\t{\n\t\t\t\"228980\"\t\t\"172268093\"\n\t\t}\n\t}\n\t\"1\"\n\t{\n\t\t\"path\"\t\t\"/mnt/droiddeck-sd\"\n\t\t\"label\"\t\t\"SD card\"\n\t\t\"contentid\"\t\t\"-5681848553336386775\"\n\t\t\"totalsize\"\t\t\"989672112128\"\n\t\t\"update_clean_bytes_tally\"\t\t\"0\"\n\t\t\"time_last_update_verified\"\t\t\"0\"\n\t\t\"apps\"\n\t\t{\n\t\t}\n\t}\n\t\"2\"\n\t{\n\t\t\"path\"\t\t\"/root/.droiddeck-x64/shared/x86-64\"\n\t\t\"label\"\t\t\"x86-64 client games\"\n\t\t\"apps\"\n\t\t{\n\t\t\t\"550\"\t\t\"15100020676\"\n\t\t}\n\t}\n}\n"; + + const REDIST_ACF: &str = "\"AppState\"\n{\n\t\"appid\"\t\t\"228980\"\n\t\"Universe\"\t\t\"1\"\n\t\"name\"\t\t\"Steamworks Common Redistributables\"\n\t\"StateFlags\"\t\t\"4\"\n\t\"installdir\"\t\t\"Steamworks Shared\"\n\t\"LastUpdated\"\t\t\"1792892508\"\n\t\"LastPlayed\"\t\t\"0\"\n\t\"SizeOnDisk\"\t\t\"143055920\"\n\t\"StagingSize\"\t\t\"0\"\n\t\"buildid\"\t\t\"24098430\"\n\t\"LastOwner\"\t\t\"76561198000000001\"\n\t\"DownloadType\"\t\t\"1\"\n\t\"UpdateResult\"\t\t\"0\"\n\t\"BytesToDownload\"\t\t\"0\"\n\t\"BytesDownloaded\"\t\t\"0\"\n\t\"BytesToStage\"\t\t\"0\"\n\t\"BytesStaged\"\t\t\"0\"\n\t\"TargetBuildID\"\t\t\"24098430\"\n\t\"AutoUpdateBehavior\"\t\t\"0\"\n\t\"AllowOtherDownloadsWhileRunning\"\t\t\"0\"\n\t\"ScheduledAutoUpdate\"\t\t\"0\"\n\t\"InstalledDepots\"\n\t{\n\t\t\"228989\"\n\t\t{\n\t\t\t\"manifest\"\t\t\"5753583882400741046\"\n\t\t\t\"size\"\t\t\"25674515\"\n\t\t}\n\t\t\"229007\"\n\t\t{\n\t\t\t\"manifest\"\t\t\"4477590687906973371\"\n\t\t\t\"size\"\t\t\"117381405\"\n\t\t}\n\t}\n\t\"InstallScripts\"\n\t{\n\t\t\"228989\"\t\t\"_CommonRedist\\\\vcredist\\\\2022\\\\installscript.vdf\"\n\t\t\"229007\"\t\t\"_CommonRedist\\\\DotNet\\\\4.8\\\\installscript.vdf\"\n\t}\n\t\"UserConfig\"\n\t{\n\t}\n\t\"MountedConfig\"\n\t{\n\t}\n}\n"; + + /// The captured client acf for Brawlhalla (LastOwner replaced). + const BRAWLHALLA_ACF: &str = "\"AppState\"\n{\n\t\"appid\"\t\t\"291550\"\n\t\"Universe\"\t\t\"1\"\n\t\"name\"\t\t\"Brawlhalla\"\n\t\"StateFlags\"\t\t\"4\"\n\t\"installdir\"\t\t\"Brawlhalla\"\n\t\"LastUpdated\"\t\t\"1794027736\"\n\t\"LastPlayed\"\t\t\"0\"\n\t\"SizeOnDisk\"\t\t\"1565156559\"\n\t\"StagingSize\"\t\t\"0\"\n\t\"buildid\"\t\t\"26465982\"\n\t\"LastOwner\"\t\t\"76561198000000001\"\n\t\"DownloadType\"\t\t\"1\"\n\t\"UpdateResult\"\t\t\"0\"\n\t\"BytesToDownload\"\t\t\"1551111680\"\n\t\"BytesDownloaded\"\t\t\"1551111680\"\n\t\"BytesToStage\"\t\t\"1594368732\"\n\t\"BytesStaged\"\t\t\"1594368732\"\n\t\"TargetBuildID\"\t\t\"26465982\"\n\t\"AutoUpdateBehavior\"\t\t\"0\"\n\t\"AllowOtherDownloadsWhileRunning\"\t\t\"0\"\n\t\"ScheduledAutoUpdate\"\t\t\"0\"\n\t\"InstalledDepots\"\n\t{\n\t\t\"291551\"\n\t\t{\n\t\t\t\"manifest\"\t\t\"4224536525702420323\"\n\t\t\t\"size\"\t\t\"1565156559\"\n\t\t}\n\t}\n\t\"SharedDepots\"\n\t{\n\t\t\"228988\"\t\t\"228980\"\n\t}\n\t\"UserConfig\"\n\t{\n\t\t\"language\"\t\t\"english\"\n\t}\n\t\"MountedConfig\"\n\t{\n\t\t\"language\"\t\t\"english\"\n\t}\n}\n"; + + struct Fixture { + base: PathBuf, + steam_root: PathBuf, + internal: LibraryRoot, + sd: LibraryRoot, + } + + impl Fixture { + fn new(name: &str) -> Self { + let base = temp_root(name); + let steam_root = base.join("Steam"); + let sd_host = base.join("sd").join("steam"); + fs::create_dir_all(steam_root.join("steamapps")).unwrap(); + fs::create_dir_all(steam_root.join("config")).unwrap(); + fs::create_dir_all(steam_root.join("depotcache")).unwrap(); + fs::create_dir_all(sd_host.join("steamapps")).unwrap(); + for path in libraryfolders_paths(&steam_root) { + fs::write(path, LIBRARYFOLDERS).unwrap(); + } + fs::write( + steam_root.join("steamapps").join("appmanifest_228980.acf"), + REDIST_ACF, + ) + .unwrap(); + Fixture { + internal: LibraryRoot { + host: steam_root.clone(), + guest: "/root/.local/share/Steam".into(), + }, + sd: LibraryRoot { + host: sd_host, + guest: "/mnt/droiddeck-sd".into(), + }, + steam_root, + base, + } + } + + fn libraries(&self) -> Vec { + vec![self.internal.clone(), self.sd.clone()] + } + } + + fn brawlhalla_plan() -> AppPlan { + AppPlan { + app_id: 291550, + name: "Brawlhalla".into(), + install_dir: "Brawlhalla".into(), + build_id: 26465982, + language: "english".into(), + ..Default::default() + } + } + + fn vc2019_manifest() -> ContentManifest { + let file = |name: &str, flags: u32| FileMapping { + filename: name.into(), + flags, + ..Default::default() + }; + ContentManifest { + files: vec![ + file("_CommonRedist/vcredist/2019", 64), + file("_CommonRedist/vcredist/2019/VC_redist.x64.exe", 0), + file("_CommonRedist/vcredist/2019/VC_redist.x86.exe", 0), + file("_CommonRedist/vcredist/2019/installscript.vdf", 256), + ], + ..Default::default() + } + } + + fn register_brawlhalla(fx: &Fixture) { + let plan = brawlhalla_plan(); + let depots = [InstalledDepot { + depot_id: 291551, + manifest_id: 4224536525702420323, + size: 1565156559, + dlc_app_id: 0, + }]; + let shared = SharedInstall { + depot_id: 228988, + from_app_id: 228980, + from_name: "Steamworks Common Redistributables".into(), + from_install_dir: "Steamworks Shared".into(), + from_build_id: 24098430, + manifest_id: 6645201662696499616, + size: 29212173, + install_script: install_script_path(&vc2019_manifest()), + library: shared_app_library(228980, &fx.steam_root, &fx.libraries()), + }; + assert_eq!(shared.library, fx.internal); + assert!(!register_shared_depot(&shared, OWNER, 1794027736).unwrap()); + write_game_acf( + &fx.sd, + &GameRegistration { + plan: &plan, + owner_steam_id: OWNER, + depots: &depots, + shared: &[(228988, 228980)], + install_scripts: &[], + bytes_downloaded: 1551111680, + bytes_staged: 1594368732, + now: 1794027736, + }, + ) + .unwrap(); + assert!(library_registered(&fx.steam_root, "/mnt/droiddeck-sd/")); + assert!(!library_registered(&fx.steam_root, "/mnt/elsewhere")); + assert_eq!( + update_libraryfolders(&fx.steam_root, &fx.sd.guest, 291550, true).unwrap(), + 2 + ); + } + + #[test] + fn registration_reproduces_the_captured_client_install() { + let fx = Fixture::new("install"); + register_brawlhalla(&fx); + + let acf = fs::read_to_string(fx.sd.acf_path(291550)).unwrap(); + assert_eq!(acf, BRAWLHALLA_ACF); + + let redist = kv::parse_file(&fx.internal.acf_path(228980)).unwrap(); + assert_eq!(kv::get_u64(&redist, "SizeOnDisk"), 143055920 + 29212173); + assert_eq!( + installed_manifest(&redist, 228988), + Some(6645201662696499616) + ); + let text = fs::read_to_string(fx.internal.acf_path(228980)).unwrap(); + assert!(text.contains( + "\t\t\"228988\"\t\t\"_CommonRedist\\\\vcredist\\\\2019\\\\installscript.vdf\"\n" + )); + assert!(text.contains("\t\t\"228988\"\n\t\t{\n\t\t\t\"manifest\"\t\t\"6645201662696499616\"\n\t\t\t\"size\"\t\t\"29212173\"\n\t\t}\n")); + // Depot entries are listed by id, as the client lists them. + let pos = |s: &str| text.find(s).unwrap(); + assert!(pos("\t\t\"228988\"\n") < pos("\t\t\"228989\"\n")); + assert!( + pos("\t\t\"228988\"\t\t\"_CommonRedist") < pos("\t\t\"228989\"\t\t\"_CommonRedist") + ); + // Unknown keys and order of the shared manifest are kept. + assert!(text.starts_with("\"AppState\"\n{\n\t\"appid\"\t\t\"228980\"\n")); + + for path in libraryfolders_paths(&fx.steam_root) { + let text = fs::read_to_string(path).unwrap(); + assert!(text.contains("\t\t\"path\"\t\t\"/mnt/droiddeck-sd\"\n\t\t\"label\"\t\t\"SD card\"\n\t\t\"contentid\"\t\t\"-5681848553336386775\"\n\t\t\"totalsize\"\t\t\"989672112128\"\n\t\t\"update_clean_bytes_tally\"\t\t\"0\"\n\t\t\"time_last_update_verified\"\t\t\"0\"\n\t\t\"apps\"\n\t\t{\n\t\t\t\"291550\"\t\t\"0\"\n\t\t}\n")); + assert!(text.contains("\t\t\t\"228980\"\t\t\"172268093\"\n")); + } + // Registering twice changes nothing. + register_brawlhalla(&fx); + assert_eq!( + fs::read_to_string(fx.sd.acf_path(291550)).unwrap(), + BRAWLHALLA_ACF + ); + let redist = kv::parse_file(&fx.internal.acf_path(228980)).unwrap(); + assert_eq!(kv::get_u64(&redist, "SizeOnDisk"), 143055920 + 29212173); + let _ = fs::remove_dir_all(&fx.base); + } + + #[test] + fn merge_keeps_unknown_keys_and_user_settings() { + let fx = Fixture::new("merge"); + let path = fx.sd.acf_path(291550); + fs::write( + &path, + "\"AppState\"\n{\n\t\"appid\"\t\t\"291550\"\n\t\"LastPlayed\"\t\t\"1700000000\"\n\t\"AutoUpdateBehavior\"\t\t\"1\"\n\t\"UserConfig\"\n\t{\n\t\t\"BetaKey\"\t\t\"\"\n\t}\n\t\"SomethingNew\"\t\t\"x\"\n}\n", + ) + .unwrap(); + register_brawlhalla(&fx); + let acf = kv::parse_file(&path).unwrap(); + assert_eq!(kv::get_str(&acf, "LastPlayed").unwrap(), "1700000000"); + assert_eq!(kv::get_str(&acf, "AutoUpdateBehavior").unwrap(), "1"); + assert_eq!(kv::get_str(&acf, "SomethingNew").unwrap(), "x"); + let user = acf.child("UserConfig").unwrap(); + assert!(user.child("BetaKey").is_some()); + assert_eq!(kv::get_str(user, "language").unwrap(), "english"); + let _ = fs::remove_dir_all(&fx.base); + } + + #[test] + fn takeover_removes_a_half_finished_client_download() { + let fx = Fixture::new("takeover"); + assert_eq!(takeover(&fx.sd, 291550, 26465982).unwrap(), Takeover::Fresh); + let steamapps = fx.sd.steamapps(); + fs::create_dir_all(steamapps.join("downloading/291550/x")).unwrap(); + fs::create_dir_all(steamapps.join("temp/291550")).unwrap(); + fs::write( + fx.sd.acf_path(291550), + "\"AppState\"\n{\n\t\"StateFlags\"\t\t\"1026\"\n\t\"buildid\"\t\t\"0\"\n}\n", + ) + .unwrap(); + assert_eq!( + takeover(&fx.sd, 291550, 26465982).unwrap(), + Takeover::TookOver + ); + assert!(fx.sd.acf_path(291550).exists()); // its settings merge into the final one + assert!(!steamapps.join("downloading/291550").exists()); + assert!(!steamapps.join("temp/291550").exists()); + assert_eq!(takeover(&fx.sd, 291550, 26465982).unwrap(), Takeover::Fresh); // a retry + fs::write( + fx.sd.acf_path(291550), + "\"AppState\"\n{\n\t\"StateFlags\"\t\t\"6\"\n\t\"buildid\"\t\t\"1\"\n}\n", + ) + .unwrap(); + fs::create_dir_all(steamapps.join("downloading/291550")).unwrap(); + assert_eq!(takeover(&fx.sd, 291550, 26465982).unwrap(), Takeover::Update); + assert!(steamapps.join("downloading/291550").exists()); // the client's update staging stays + fs::write(fx.sd.acf_path(291550), BRAWLHALLA_ACF).unwrap(); + assert_eq!( + takeover(&fx.sd, 291550, 26465982).unwrap(), + Takeover::AlreadyInstalled + ); + assert_eq!(takeover(&fx.sd, 291550, 1).unwrap(), Takeover::Update); // left to the client + assert!(state_is_finished(4)); + assert!(!state_is_finished(6)); + assert!(!state_is_finished(1)); + let _ = fs::remove_dir_all(&fx.base); + } + + #[test] + fn uninstall_matches_the_captured_client_uninstall() { + let fx = Fixture::new("uninstall"); + register_brawlhalla(&fx); + let game_dir = fx.sd.common_dir("Brawlhalla"); + fs::create_dir_all(game_dir.join("bin")).unwrap(); + fs::write(game_dir.join("bin/Brawlhalla.exe"), b"x").unwrap(); + let shared_dir = fx + .internal + .common_dir("Steamworks Shared") + .join("_CommonRedist/vcredist/2019"); + fs::create_dir_all(&shared_dir).unwrap(); + for name in [ + "VC_redist.x64.exe", + "VC_redist.x86.exe", + "installscript.vdf", + ] { + fs::write(shared_dir.join(name), b"x").unwrap(); + } + let compat = fx.sd.steamapps().join("compatdata/291550/pfx"); + fs::create_dir_all(&compat).unwrap(); + let shader = fx.steam_root.join("steamapps/shadercache/291550"); + fs::create_dir_all(&shader).unwrap(); + let cached = fx + .steam_root + .join("depotcache/291551_4224536525702420323.manifest"); + fs::write(&cached, b"m").unwrap(); + let shared_cached = fx + .steam_root + .join("depotcache/228988_6645201662696499616.manifest"); + fs::write(&shared_cached, b"m").unwrap(); + + let files = |app: u32, depot: u32, manifest: u64| { + (app == 228980 && depot == 228988 && manifest == 6645201662696499616) + .then(|| manifest_file_list(&vc2019_manifest())) + }; + let report = uninstall(291550, &fx.steam_root, &fx.sd, &fx.libraries(), &files).unwrap(); + assert_eq!(report.removed_shared, vec![228988]); + assert!(!game_dir.exists()); + assert!(!fx.sd.acf_path(291550).exists()); + assert!(!cached.exists()); + assert!(shared_cached.exists()); + assert!(!shader.exists()); + assert!(compat.exists()); + assert!(shared_dir.exists()); + assert_eq!(fs::read_dir(&shared_dir).unwrap().count(), 0); + assert_eq!( + fs::read_to_string(fx.internal.acf_path(228980)).unwrap(), + REDIST_ACF + ); + for path in libraryfolders_paths(&fx.steam_root) { + assert_eq!(fs::read_to_string(path).unwrap(), LIBRARYFOLDERS); + } + assert_eq!( + uninstall(291550, &fx.steam_root, &fx.sd, &fx.libraries(), &files).unwrap_err(), + "not_installed" + ); + let _ = fs::remove_dir_all(&fx.base); + } + + #[test] + fn shared_depot_used_by_another_game_is_kept() { + let fx = Fixture::new("shared_in_use"); + register_brawlhalla(&fx); + let other = BRAWLHALLA_ACF + .replace("291550", "993090") + .replace("\"Brawlhalla\"", "\"Lossless Scaling\""); + fs::write(fx.internal.acf_path(993090), other).unwrap(); + let report = uninstall( + 291550, + &fx.steam_root, + &fx.sd, + &fx.libraries(), + &|_, _, _| Some(vec!["_CommonRedist/vcredist/2019/VC_redist.x64.exe".into()]), + ) + .unwrap(); + assert!(report.removed_shared.is_empty()); + assert!(report.kept_shared.is_empty()); + let redist = kv::parse_file(&fx.internal.acf_path(228980)).unwrap(); + assert_eq!( + installed_manifest(&redist, 228988), + Some(6645201662696499616) + ); + let _ = fs::remove_dir_all(&fx.base); + } + + #[test] + fn shared_library_defaults_to_the_steam_root() { + let fx = Fixture::new("shared_default"); + let only_sd = vec![fx.sd.clone()]; + assert_eq!( + shared_app_library(228980, &fx.steam_root, &only_sd), + fx.internal + ); + assert_eq!( + shared_app_library(1, &fx.steam_root, &fx.libraries()), + fx.internal + ); + let _ = fs::remove_dir_all(&fx.base); + } + + #[test] + fn new_shared_app_manifest_is_created_when_missing() { + let fx = Fixture::new("new_shared"); + fs::remove_file(fx.internal.acf_path(228980)).unwrap(); + let shared = SharedInstall { + depot_id: 228988, + from_app_id: 228980, + from_name: "Steamworks Common Redistributables".into(), + from_install_dir: "Steamworks Shared".into(), + from_build_id: 24098430, + manifest_id: 6645201662696499616, + size: 29212173, + install_script: Some("_CommonRedist\\vcredist\\2019\\installscript.vdf".into()), + library: fx.internal.clone(), + }; + assert!(register_shared_depot(&shared, OWNER, 5).unwrap()); + let text = fs::read_to_string(fx.internal.acf_path(228980)).unwrap(); + let acf = kv::parse_file(&fx.internal.acf_path(228980)).unwrap(); + assert_eq!(kv::get_u64(&acf, "SizeOnDisk"), 29212173); + let names: Vec<&str> = acf.children.iter().map(|c| c.name.as_str()).collect(); + let pos = |n: &str| names.iter().position(|x| *x == n).unwrap(); + assert!(pos("InstalledDepots") + 1 == pos("InstallScripts")); + assert!(pos("InstallScripts") < pos("UserConfig")); + assert!(text.ends_with("\t\"UserConfig\"\n\t{\n\t}\n\t\"MountedConfig\"\n\t{\n\t}\n}\n")); + let _ = fs::remove_dir_all(&fx.base); + } + + #[test] + fn a_started_install_reads_as_unfinished_and_leaves_a_manifest_alone() { + let dir = std::env::temp_dir().join(format!("dd-started-{}", std::process::id())); + let _ = fs::remove_dir_all(&dir); + let library = LibraryRoot { host: dir.clone(), guest: "/lib".to_string() }; + let plan = AppPlan { + app_id: 42, + name: "Game".to_string(), + install_dir: "Game".to_string(), + build_id: 7, + language: "english".to_string(), + ..Default::default() + }; + write_started_acf(&library, &plan, 1, 2).unwrap(); + let acf = kv::parse_file(&library.acf_path(42)).unwrap(); + assert_eq!(kv::get_u64(&acf, "StateFlags"), 1026); + assert_eq!(kv::get_u64(&acf, "TargetBuildID"), 7); + assert_eq!(takeover(&library, 42, 7).unwrap(), Takeover::Fresh); + fs::write(library.acf_path(42), "\"AppState\"\n{\n\t\"StateFlags\"\t\t\"4\"\n}\n").unwrap(); + write_started_acf(&library, &plan, 1, 2).unwrap(); + assert_eq!(kv::get_u64(&kv::parse_file(&library.acf_path(42)).unwrap(), "StateFlags"), 4); + let _ = fs::remove_dir_all(&dir); + } + + #[test] + fn staged_client_files_move_into_the_install_folder_without_replacing_files_there() { + let dir = std::env::temp_dir().join(format!("dd-adopt-{}", std::process::id())); + let _ = fs::remove_dir_all(&dir); + let library = LibraryRoot { host: dir.clone(), guest: "/lib".to_string() }; + let staging = library.steamapps().join("downloading/42"); + fs::create_dir_all(staging.join("sub")).unwrap(); + fs::write(staging.join("a.bin"), b"client").unwrap(); + fs::write(staging.join("sub/b.bin"), b"client").unwrap(); + let common = library.common_dir("Game"); + fs::create_dir_all(&common).unwrap(); + fs::write(common.join("a.bin"), b"ours").unwrap(); + assert_eq!(adopt_staged(&library, 42, "Game"), 1); + assert_eq!(fs::read(common.join("a.bin")).unwrap(), b"ours"); + assert_eq!(fs::read(common.join("sub/b.bin")).unwrap(), b"client"); + assert_eq!(adopt_staged(&library, 42, ".."), 0); + fs::write(staging.join("c.bin"), b"client").unwrap(); + fs::write(library.acf_path(42), "\"AppState\"\n{\n\t\"StateFlags\"\t\t\"6\"\n}\n").unwrap(); + assert_eq!(adopt_staged(&library, 42, "Game"), 0); + let _ = fs::remove_dir_all(&dir); + } +} diff --git a/app/src/main/rust/stores/src/steam/session.rs b/app/src/main/rust/stores/src/steam/session.rs new file mode 100644 index 0000000000..14fe32b448 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/session.rs @@ -0,0 +1,556 @@ +//! The one process-wide Steam session: connect to a CM over WebSocket, log on with the saved +//! refresh token, then answer the store's requests (PICS, depot keys, manifest request codes, +//! CDN servers, free licenses) as blocking calls with timeouts. + +use crate::steam::cm_client::{ + CMClientCore, ClientState, OutboundProtoMessage, OutboundServiceCall, +}; +use crate::steam::cm_runtime::CMClientRuntime; +use crate::steam::library::Library; +use crate::steam::pb::ccontentserverdirectory::{ + CContentServerDirectoryGetManifestRequestCodeResponse, + CContentServerDirectoryGetServersForSteamPipeResponse, CContentServerDirectoryServerInfo, +}; +use crate::steam::pb::cmsg_client_get_depot_decryption_key::CMsgClientGetDepotDecryptionKeyResponse; +use crate::steam::pb::cmsg_client_pics::{ + CMsgClientPICSAccessTokenResponse, CMsgClientPICSProductInfoResponse, PicsAppInfoReq, + PicsPackageInfoReq, +}; +use crate::steam::pb::cmsg_client_request_free_license::CMsgClientRequestFreeLicenseResponse; +use crate::steam::signin::SavedLogin; +use crate::steam::vdf::KVNode; +use crate::steam::ws_connection::WsConnection; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{mpsc, Arc, Mutex}; +use std::thread; +use std::time::{Duration, Instant}; + +pub const REQUEST_TIMEOUT: Duration = Duration::from_secs(30); +const CONNECT_TIMEOUT: Duration = Duration::from_secs(15); +const LOGON_TIMEOUT: Duration = Duration::from_secs(20); +const LICENSE_LIST_TIMEOUT: Duration = Duration::from_secs(10); +const MAX_CM_ATTEMPTS: usize = 4; +const MAX_RESOLVE_ATTEMPTS: u32 = 4; +const ERESULT_OK: i32 = 1; +/// EResults after which another CM is worth a try (the token itself was not refused). +const RETRY_ON_ANOTHER_CM: [i32; 3] = [20, 48, 3]; + +pub struct Session { + runtime: Arc, + pub account: String, + pub steam_id: u64, + pub ca_bundle_path: String, + library: Mutex>>, + /// Bumped by [`Session::forget_library`]; a load started before it is not published. + library_generation: std::sync::atomic::AtomicU64, +} + +static SESSION: Mutex>> = Mutex::new(None); + +pub fn eresult_name(eresult: i32) -> &'static str { + match eresult { + 1 => "OK", + 2 => "Fail", + 3 => "NoConnection", + 5 => "InvalidPassword", + 6 => "LoggedInElsewhere", + 15 => "AccessDenied", + 18 => "AccountNotFound", + 20 => "ServiceUnavailable", + 26 => "Revoked", + 27 => "Expired", + 48 => "TryAnotherCM", + 63 => "AccountLogonDenied", + 84 => "RateLimitExceeded", + 87 => "AccountLoginDeniedThrottle", + _ => "", + } +} + +/// The live session, if one is logged on. +pub fn current() -> Option> { + let guard = SESSION.lock().expect("session poisoned"); + guard.as_ref().filter(|s| s.is_logged_on()).cloned() +} + +/// Logs on with `login` unless a live session exists; returns the live session. +pub fn sign_in(login: &SavedLogin, ca_bundle_path: &str) -> Result, String> { + if let Some(live) = current() { + return Ok(live); + } + sign_out(); + let runtime = connect_and_logon(login, ca_bundle_path)?; + let steam_id = runtime.core().steam_id(); + let session = Arc::new(Session { + runtime, + account: login.account.clone(), + steam_id: if steam_id != 0 { + steam_id + } else { + login.steam_id + }, + ca_bundle_path: ca_bundle_path.to_string(), + library: Mutex::new(None), + library_generation: std::sync::atomic::AtomicU64::new(0), + }); + *SESSION.lock().expect("session poisoned") = Some(Arc::clone(&session)); + Ok(session) +} + +/// Logs off and drops the session. Never touches the Steam client's files. +pub fn sign_out() { + let previous = SESSION.lock().expect("session poisoned").take(); + if let Some(session) = previous { + session.log_off(); + } +} + +fn cm_urls(ca_bundle_path: &str) -> Vec { + let directory = crate::steam::steam_directory::SteamDirectoryClient::new(ca_bundle_path); + let result = directory.fetch(0, crate::steam::steam_directory::DEFAULT_TIMEOUT); + let mut urls: Vec = Vec::new(); + let servers = if result.ok() { + result.servers + } else { + crate::steam::log(&format!("cm directory failed: {}", result.error)); + Vec::new() + }; + for server in servers + .into_iter() + .chain(crate::steam::cm_server_list::hardcoded_fallback_servers()) + { + let url = server.websocket_url(); + if !url.is_empty() && !urls.contains(&url) { + urls.push(url); + } + } + urls +} + +fn wait_until(timeout: Duration, mut done: impl FnMut() -> bool) -> bool { + let deadline = Instant::now() + timeout; + loop { + if done() { + return true; + } + if Instant::now() >= deadline { + return false; + } + thread::sleep(Duration::from_millis(50)); + } +} + +fn connect_and_logon( + login: &SavedLogin, + ca_bundle_path: &str, +) -> Result, String> { + let urls = cm_urls(ca_bundle_path); + let mut last_error = "logon_failed: no CM server".to_string(); + for url in urls.iter().take(MAX_CM_ATTEMPTS) { + let core = Arc::new(CMClientCore::default()); + let runtime = CMClientRuntime::new(Arc::clone(&core), Box::new(WsConnection::new())); + if !ca_bundle_path.is_empty() { + runtime.set_ca_bundle_path(ca_bundle_path); + } + if !runtime.connect(url) { + last_error = "logon_failed: connect".to_string(); + continue; + } + if !wait_until(CONNECT_TIMEOUT, || core.state() == ClientState::Connected) { + runtime.disconnect(); + last_error = "logon_failed: CM did not answer".to_string(); + continue; + } + let message = + core.build_logon_with_refresh_token(&login.token, &login.account, login.steam_id); + if !core.enqueue_proto_message(message) { + runtime.disconnect(); + last_error = "logon_failed: connection dropped".to_string(); + continue; + } + runtime.flush_outbound(); + let settled = wait_until(LOGON_TIMEOUT, || { + core.state() == ClientState::LoggedOn + || core.last_logon_eresult() != 0 + || core.state() == ClientState::Disconnected + }); + if core.state() == ClientState::LoggedOn { + crate::steam::log(&format!( + "logged on steam_id={} cell={}", + core.steam_id(), + core.cell_id() + )); + wait_until(LICENSE_LIST_TIMEOUT, || core.license_list().is_some()); + return Ok(runtime); + } + let eresult = core.last_logon_eresult(); + runtime.disconnect(); + if !settled { + last_error = "logon_failed: no logon response".to_string(); + continue; + } + if eresult == 0 { + last_error = "logon_failed: connection dropped".to_string(); + continue; + } + last_error = format!("logon_failed: eresult={eresult} {}", eresult_name(eresult)) + .trim_end() + .to_string(); + crate::steam::log(&last_error); + if !RETRY_ON_ANOTHER_CM.contains(&eresult) { + break; + } + } + Err(last_error) +} + +pub enum KeyResolution { + Granted(Vec), + AccessDenied, + Cancelled, + Unavailable, +} + +pub enum CodeResolution { + Code(u64), + AccessDenied, + Cancelled, + Unavailable, +} + +impl Session { + pub fn is_logged_on(&self) -> bool { + self.runtime.core().state() == ClientState::LoggedOn + } + + fn log_off(&self) { + let core = self.runtime.core(); + if core.enqueue_proto_message(core.build_logoff()) { + self.runtime.flush_outbound(); + thread::sleep(Duration::from_millis(500)); + } + self.runtime.disconnect(); + } + + pub fn core(&self) -> &Arc { + self.runtime.core() + } + + fn proto_response(&self, timeout: Duration, build: F) -> Option<(i32, Vec)> + where + F: FnOnce(&CMClientCore, u64) -> Option, + { + if !self.is_logged_on() { + return None; + } + let job_id = self.runtime.next_job_id(); + let message = build(self.runtime.core(), job_id)?; + let (tx, rx) = mpsc::channel(); + self.runtime.track_job( + job_id, + move |job| { + let _ = tx.send((!job.synthetic_failure).then_some((job.eresult, job.body))); + }, + Some(timeout), + ); + if !self.runtime.core().enqueue_wire(message.wire) { + return None; + } + self.runtime.flush_outbound(); + rx.recv_timeout(timeout + Duration::from_secs(1)) + .ok() + .flatten() + } + + fn service_response(&self, timeout: Duration, build: F) -> Option<(i32, Vec)> + where + F: FnOnce(&CMClientCore, u64) -> Option, + { + if !self.is_logged_on() { + return None; + } + let job_id = self.runtime.next_job_id(); + let call = build(self.runtime.core(), job_id)?; + let (tx, rx) = mpsc::channel(); + self.runtime.track_job( + job_id, + move |job| { + let _ = tx.send((!job.synthetic_failure).then_some((job.eresult, job.body))); + }, + Some(timeout), + ); + if !self.runtime.core().enqueue_wire(call.wire) { + return None; + } + self.runtime.flush_outbound(); + rx.recv_timeout(timeout + Duration::from_secs(1)) + .ok() + .flatten() + } + + pub fn pics_access_tokens( + &self, + packages: Vec, + apps: Vec, + ) -> Option { + let (eresult, body) = self.proto_response(REQUEST_TIMEOUT, |core, job| { + core.build_pics_access_tokens(packages, apps, job) + })?; + if eresult <= 0 { + return None; + } + CMsgClientPICSAccessTokenResponse::deserialize(&body) + } + + /// PICS product info; large appinfo the CM delivers over HTTP is fetched here. + pub fn pics_product_info( + &self, + packages: Vec, + apps: Vec, + ) -> Option { + let (eresult, body) = self.proto_response(Duration::from_secs(60), |core, job| { + core.build_pics_product_info(packages, apps, false, job) + })?; + if eresult <= 0 { + return None; + } + let mut response = CMsgClientPICSProductInfoResponse::deserialize(&body)?; + self.hydrate_http_appinfo(&mut response); + Some(response) + } + + fn hydrate_http_appinfo(&self, response: &mut CMsgClientPICSProductInfoResponse) { + if response.http_host.is_empty() { + return; + } + let host = response.http_host.clone(); + let targets: Vec = response + .apps + .iter() + .enumerate() + .filter(|(_, app)| !app.missing_token && app.buffer.is_empty() && !app.sha.is_empty()) + .map(|(idx, _)| idx) + .collect(); + if targets.is_empty() { + return; + } + let queue = Mutex::new(targets.into_iter()); + let results: Mutex)>> = Mutex::new(Vec::new()); + let apps = &response.apps; + let workers = queue.lock().expect("queue poisoned").len().clamp(1, 8); + thread::scope(|scope| { + for _ in 0..workers { + scope.spawn(|| loop { + let next = queue.lock().expect("queue poisoned").next(); + let Some(idx) = next else { + return; + }; + let app = &apps[idx]; + if let Some(buffer) = crate::steam::cdn::fetch_appinfo( + &host, + app.appid, + &app.sha, + &self.ca_bundle_path, + REQUEST_TIMEOUT, + ) { + results + .lock() + .expect("results poisoned") + .push((idx, buffer)); + } + }); + } + }); + for (idx, buffer) in results.into_inner().expect("results poisoned") { + response.apps[idx].buffer = buffer; + } + } + + /// The app's appinfo (`appinfo` node), with its PICS access token. + pub fn app_info(&self, app_id: u32) -> Option { + let token = self + .pics_access_tokens(Vec::new(), vec![app_id]) + .and_then(|r| { + r.app_access_tokens + .iter() + .find(|t| t.appid == app_id) + .map(|t| t.access_token) + }) + .unwrap_or(0); + let response = self.pics_product_info( + Vec::new(), + vec![PicsAppInfoReq { + appid: app_id, + access_token: token, + only_public_obsolete: false, + }], + )?; + let app = response + .apps + .into_iter() + .find(|a| a.appid == app_id && !a.buffer.is_empty())?; + let root = crate::steam::vdf::parse_auto(&app.buffer)?; + Some(crate::steam::plan::appinfo_root(&root).clone()) + } + + pub fn library(&self) -> Result, String> { + if let Some(lib) = self.library.lock().expect("library poisoned").as_ref() { + return Ok(Arc::clone(lib)); + } + let generation = self.library_generation.load(Ordering::Acquire); + let lib = Arc::new(Library::load(self)?); + self.publish_library(generation, &lib); + Ok(lib) + } + + /// The owned games, loaded once per session. + pub fn games(&self) -> Result, String> { + let generation = self.library_generation.load(Ordering::Acquire); + let lib = self.library()?; + if let Some(games) = lib.cached_games() { + return Ok(games); + } + let games = lib.load_games(self)?; + self.publish_library(generation, &Arc::new(lib.with_games(games.clone()))); + Ok(games) + } + + fn publish_library(&self, generation: u64, lib: &Arc) { + let mut slot = self.library.lock().expect("library poisoned"); + if self.library_generation.load(Ordering::Acquire) == generation { + *slot = Some(Arc::clone(lib)); + } + } + + pub fn forget_library(&self) { + let mut slot = self.library.lock().expect("library poisoned"); + self.library_generation.fetch_add(1, Ordering::AcqRel); + *slot = None; + } + + /// `CMsgClientRequestFreeLicense` for one app; true when Steam granted it and the license + /// list shows the new package. + pub fn request_free_license(&self, app_id: u32) -> bool { + let Some((_header, body)) = self.proto_response(Duration::from_secs(20), |core, job| { + core.build_request_free_license(&[app_id], job) + }) else { + return false; + }; + let Some(response) = CMsgClientRequestFreeLicenseResponse::deserialize(&body) else { + return false; + }; + let granted = response.is_granted(); + crate::steam::log(&format!( + "free license app={app_id} eresult={} packages={:?}", + response.eresult, response.granted_packageids + )); + if !granted { + return false; + } + let packages = response.granted_packageids.clone(); + let core = self.runtime.core(); + let visible = wait_until(Duration::from_secs(8), || { + core.license_list().is_some_and(|list| { + packages + .iter() + .all(|p| list.iter().any(|l| l.package_id == *p)) + }) + }); + self.forget_library(); + visible || packages.is_empty() + } + + pub fn cdn_servers(&self) -> Option> { + let (eresult, body) = self.service_response(REQUEST_TIMEOUT, |core, job| { + core.build_get_cdn_servers_call(0, job) + })?; + if eresult != ERESULT_OK { + return None; + } + let servers = + CContentServerDirectoryGetServersForSteamPipeResponse::deserialize(&body)?.servers; + let preview = servers + .iter() + .take(4) + .map(|s| s.host.as_str()) + .collect::>() + .join(","); + crate::steam::log(&format!( + "cdn pool: {} server(s) first=[{preview}]", + servers.len() + )); + Some(servers) + } + + pub fn depot_key(&self, app_id: u32, depot_id: u32, cancel: &AtomicBool) -> KeyResolution { + for attempt in 0..MAX_RESOLVE_ATTEMPTS { + if cancel.load(Ordering::Relaxed) { + return KeyResolution::Cancelled; + } + if attempt > 0 { + thread::sleep(Duration::from_millis( + crate::fetch_tuning::retry_backoff_millis(attempt), + )); + if cancel.load(Ordering::Relaxed) { + return KeyResolution::Cancelled; + } + } + let Some((header, body)) = self.proto_response(REQUEST_TIMEOUT, |core, job| { + core.build_get_depot_decryption_key(depot_id, app_id, job) + }) else { + continue; + }; + // An undecodable reply is retried like a missing one. + let Some(r) = CMsgClientGetDepotDecryptionKeyResponse::deserialize(&body) else { + continue; + }; + if r.eresult == ERESULT_OK && r.depot_encryption_key.len() == 32 { + return KeyResolution::Granted(r.depot_encryption_key); + } + crate::steam::log(&format!( + "depot key refused depot={depot_id} header_eresult={header} body_eresult={}", + r.eresult + )); + return KeyResolution::AccessDenied; + } + KeyResolution::Unavailable + } + + pub fn manifest_code( + &self, + app_id: u32, + depot_id: u32, + manifest_id: u64, + cancel: &AtomicBool, + ) -> CodeResolution { + for attempt in 0..MAX_RESOLVE_ATTEMPTS { + if cancel.load(Ordering::Relaxed) { + return CodeResolution::Cancelled; + } + if attempt > 0 { + thread::sleep(Duration::from_millis( + crate::fetch_tuning::retry_backoff_millis(attempt), + )); + if cancel.load(Ordering::Relaxed) { + return CodeResolution::Cancelled; + } + } + let Some((eresult, body)) = self.service_response(REQUEST_TIMEOUT, |core, job| { + core.build_manifest_request_code_call(app_id, depot_id, manifest_id, "public", job) + }) else { + continue; + }; + if eresult == ERESULT_OK { + match CContentServerDirectoryGetManifestRequestCodeResponse::deserialize(&body) { + Some(r) => return CodeResolution::Code(r.manifest_request_code), + None => continue, + } + } + crate::steam::log(&format!( + "manifest code refused depot={depot_id} eresult={eresult}" + )); + return CodeResolution::AccessDenied; + } + CodeResolution::Unavailable + } +} diff --git a/app/src/main/rust/stores/src/steam/signin.rs b/app/src/main/rust/stores/src/steam/signin.rs new file mode 100644 index 0000000000..2248f3c154 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/signin.rs @@ -0,0 +1,519 @@ +//! Reuses the sign-in the Linux Steam client saved ("Remember me"), so the user never signs in +//! twice. Read-only: nothing here writes to the client's files, and the token is never renewed, +//! refreshed or replaced (that would sign the client out). +//! +//! Where it lives, per Steam root: +//! - `config/loginusers.vdf`: the accounts (` { AccountName, RememberPassword, +//! MostRecent, Timestamp … }`). +//! - `local.vdf`: `MachineUserConfigStore/Software/Valve/Steam/ConnectCache`, one entry per +//! remembered account whose key starts with the 8-hex-digit CRC32 of the lowercased account +//! name (e.g. `9a410a9b` + `1`) and whose value is a hex blob. +//! - `~/.steam/registry.vdf`: `Registry/HKCU/Software/Valve/Steam/AutoLoginUser`. +//! +//! The blob: key = SHA-256(lowercased account name); the first 16 bytes are the IV encrypted with +//! AES-256-ECB; the rest is AES-256-CBC with PKCS#7 padding; the plaintext is the refresh-token +//! JWT. Method as documented by deadlock-api-ingest, `src/gc/auth.rs` (MIT, +//! https://github.com/deadlock-api/deadlock-api-ingest). Keys are matched case-insensitively +//! because clients mix casings. +//! +//! The token stays in memory only, is never logged or written anywhere, and is zeroized on drop. + +use crate::steam::crypto::{aes256_cbc_decrypt, aes256_ecb_decrypt_block, sha256}; +use crate::steam::vdf::{self, KVNode}; +use std::fs; +use std::path::{Path, PathBuf}; +use zeroize::{Zeroize, Zeroizing}; + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum SigninError { + /// No Steam root has an account in `loginusers.vdf`. + NoSavedLogin, + /// The account exists but the client kept no token for it (Remember me off, or signed out). + RememberMeOff, + /// A token blob exists but does not decrypt to this account's Steam JWT. + DecryptFailed, +} + +impl SigninError { + pub fn code(self) -> &'static str { + match self { + SigninError::NoSavedLogin => "no_saved_login", + SigninError::RememberMeOff => "remember_me_off", + SigninError::DecryptFailed => "decrypt_failed", + } + } +} + +/// The saved login of one account. `Debug` keeps the token out of any output. +pub struct SavedLogin { + pub account: String, + pub steam_id: u64, + pub steam_root: PathBuf, + pub token: Zeroizing, +} + +impl std::fmt::Debug for SavedLogin { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("SavedLogin") + .field("account", &self.account) + .field("steam_id", &self.steam_id) + .field("steam_root", &self.steam_root) + .field("token", &"") + .finish() + } +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Account { + pub steam_id: u64, + pub account_name: String, + pub remember_password: Option, + pub most_recent: bool, + pub timestamp: u64, + pub root_index: usize, +} + +pub fn child_ci<'a>(node: &'a KVNode, key: &str) -> Option<&'a KVNode> { + node.child(key) +} + +/// Follows `path` from `root` (whose own name is `path[0]`), matching every key case-insensitively. +pub fn find_path<'a>(root: &'a KVNode, path: &[&str]) -> Option<&'a KVNode> { + let (first, rest) = path.split_first()?; + if !root.name.eq_ignore_ascii_case(first) { + return None; + } + rest.iter().try_fold(root, |node, key| child_ci(node, key)) +} + +fn read_vdf(path: &Path) -> Option { + let bytes = fs::read(path).ok()?; + vdf::parse_text(&bytes) +} + +pub fn parse_login_users(root: &KVNode, root_index: usize) -> Vec { + if !root.name.eq_ignore_ascii_case("users") { + return Vec::new(); + } + let mut out = Vec::new(); + for user in &root.children { + let Ok(steam_id) = user.name.parse::() else { + continue; + }; + let Some(name) = child_ci(user, "AccountName").map(|n| n.as_string("")) else { + continue; + }; + if name.is_empty() { + continue; + } + let flag = |key: &str| child_ci(user, key).map(|n| n.as_string("") == "1"); + out.push(Account { + steam_id, + account_name: name, + remember_password: flag("RememberPassword"), + most_recent: flag("MostRecent").unwrap_or(false), + timestamp: child_ci(user, "Timestamp") + .map(|n| n.as_uint(0)) + .unwrap_or(0), + root_index, + }); + } + out +} + +pub fn auto_login_user(registry: &KVNode) -> Option { + let user = find_path( + registry, + &[ + "Registry", + "HKCU", + "Software", + "Valve", + "Steam", + "AutoLoginUser", + ], + )? + .as_string(""); + (!user.is_empty()).then_some(user) +} + +/// `AutoLoginUser` when it names a known account, else the `MostRecent` one, else the newest +/// `Timestamp` (Linux clients may omit `MostRecent`). +pub fn choose_account<'a>( + accounts: &'a [Account], + auto_login: Option<&str>, +) -> Option<&'a Account> { + if let Some(user) = auto_login { + if let Some(found) = accounts + .iter() + .find(|a| a.account_name.eq_ignore_ascii_case(user)) + { + return Some(found); + } + } + if let Some(found) = accounts.iter().find(|a| a.most_recent) { + return Some(found); + } + accounts.iter().max_by_key(|a| a.timestamp) +} + +pub fn connect_cache_key_prefix(account_name: &str) -> String { + format!( + "{:08x}", + crc32fast::hash(account_name.to_lowercase().as_bytes()) + ) +} + +/// The hex blob for `account_name` in a parsed `local.vdf`. +pub fn connect_cache_blob(local: &KVNode, account_name: &str) -> Option { + let cache = find_path( + local, + &[ + "MachineUserConfigStore", + "Software", + "Valve", + "Steam", + "ConnectCache", + ], + )?; + let prefix = connect_cache_key_prefix(account_name); + cache + .children + .iter() + .find(|entry| { + entry + .name + .get(..prefix.len()) + .is_some_and(|p| p.eq_ignore_ascii_case(&prefix)) + }) + .map(|entry| entry.as_string("")) + .filter(|value| !value.is_empty()) +} + +fn decode_hex(text: &str) -> Option> { + let text = text.trim(); + if !text.len().is_multiple_of(2) { + return None; + } + let digit = |c: u8| -> Option { + match c { + b'0'..=b'9' => Some(c - b'0'), + b'a'..=b'f' => Some(c - b'a' + 10), + b'A'..=b'F' => Some(c - b'A' + 10), + _ => None, + } + }; + text.as_bytes() + .chunks(2) + .map(|pair| Some((digit(pair[0])? << 4) | digit(pair[1])?)) + .collect() +} + +/// Decrypts a ConnectCache blob (hex) into the refresh-token JWT. +pub fn decrypt_connect_cache(hex_blob: &str, account_name: &str) -> Option> { + let blob = Zeroizing::new(decode_hex(hex_blob)?); + if blob.len() < 32 { + return None; + } + let mut key = sha256(account_name.to_lowercase().as_bytes()); + let mut wrapped = [0u8; 16]; + wrapped.copy_from_slice(&blob[..16]); + let iv = aes256_ecb_decrypt_block(&key, &wrapped); + let plain = iv.and_then(|iv| aes256_cbc_decrypt(&key, &iv, &blob[16..])); + key.zeroize(); + let mut plain = plain?; + let text = match String::from_utf8(std::mem::take(&mut plain)) { + Ok(text) => Zeroizing::new(text), + Err(err) => { + let mut bytes = err.into_bytes(); + bytes.zeroize(); + return None; + } + }; + Some(text) +} + +fn base64url_decode(text: &str) -> Option> { + let mut s: String = text + .chars() + .map(|c| match c { + '-' => '+', + '_' => '/', + other => other, + }) + .collect(); + while !s.len().is_multiple_of(4) { + s.push('='); + } + crate::steam::base64::decode(&s) +} + +/// The SteamID64 a Steam JWT was issued for (`sub`), if it is a Steam JWT. +pub fn jwt_steam_id(jwt: &str) -> Option { + let mut parts = jwt.split('.'); + let (_header, payload, _sig) = (parts.next()?, parts.next()?, parts.next()?); + if parts.next().is_some() { + return None; + } + let bytes = base64url_decode(payload)?; + let json: serde_json::Value = serde_json::from_slice(&bytes).ok()?; + if json.get("iss").and_then(|v| v.as_str()) != Some("steam") { + return None; + } + json.get("sub")?.as_str()?.parse().ok() +} + +/// Loads the saved login. `steam_roots` are host paths of Steam roots, searched in order; +/// `registry_vdf` is `~/.steam/registry.vdf` (may be missing). +pub fn load_saved_login( + steam_roots: &[PathBuf], + registry_vdf: Option<&Path>, +) -> Result { + let mut accounts = Vec::new(); + for (idx, root) in steam_roots.iter().enumerate() { + if let Some(users) = read_vdf(&root.join("config").join("loginusers.vdf")) { + accounts.extend(parse_login_users(&users, idx)); + } + } + let auto_login = registry_vdf + .and_then(read_vdf) + .and_then(|reg| auto_login_user(®)); + let mut account = choose_account(&accounts, auto_login.as_deref()) + .ok_or(SigninError::NoSavedLogin)? + .clone(); + if account.remember_password == Some(false) { + // The same account may be remembered by the other client's root. + account = accounts + .iter() + .find(|a| a.steam_id == account.steam_id && a.remember_password != Some(false)) + .ok_or(SigninError::RememberMeOff)? + .clone(); + } + + let mut order: Vec = vec![account.root_index]; + order.extend((0..steam_roots.len()).filter(|&i| i != account.root_index)); + let mut found_blob = false; + for idx in order { + let Some(local) = read_vdf(&steam_roots[idx].join("local.vdf")) else { + continue; + }; + let Some(mut blob) = connect_cache_blob(&local, &account.account_name) else { + continue; + }; + found_blob = true; + let token = decrypt_connect_cache(&blob, &account.account_name); + blob.zeroize(); + let Some(token) = token else { + continue; + }; + if jwt_steam_id(&token) != Some(account.steam_id) { + continue; + } + return Ok(SavedLogin { + account: account.account_name.clone(), + steam_id: account.steam_id, + steam_root: steam_roots[idx].clone(), + token, + }); + } + Err(if found_blob { + SigninError::DecryptFailed + } else { + SigninError::RememberMeOff + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::steam::crypto::{aes256_cbc_encrypt, aes256_ecb_encrypt_block}; + + const ID: u64 = 76561198000000001; + + fn jwt_for(steam_id: u64) -> String { + let payload = format!(r#"{{"iss":"steam","sub":"{steam_id}","aud":["client","web"]}}"#); + let b64 = crate::steam::base64::encode(payload.as_bytes()) + .trim_end_matches('=') + .replace('+', "-") + .replace('/', "_"); + format!("eyJhbGciOiJFZERTQSJ9.{b64}.c2ln") + } + + /// Same scheme the client uses: IV wrapped with AES-256-ECB, body AES-256-CBC + PKCS#7. + fn encrypt_blob(token: &str, account: &str) -> String { + let key = sha256(account.to_lowercase().as_bytes()); + let iv = [0x5au8; 16]; + let mut out = aes256_ecb_encrypt_block(&key, &iv).unwrap().to_vec(); + out.extend(aes256_cbc_encrypt(&key, &iv, token.as_bytes()).unwrap()); + out.iter().map(|b| format!("{b:02x}")).collect() + } + + fn temp_dir(name: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!( + "droiddeck_steam_signin_{name}_{}", + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_nanos() + )); + fs::create_dir_all(dir.join("config")).unwrap(); + dir + } + + fn write_root(root: &Path, users: &str, cache_entries: &str) { + fs::write(root.join("config").join("loginusers.vdf"), users).unwrap(); + fs::write( + root.join("local.vdf"), + format!( + "\"MachineUserConfigStore\"\n{{\n\t\"Software\"\n\t{{\n\t\t\"valve\"\n\t\t{{\n\t\t\t\"steam\"\n\t\t\t{{\n\t\t\t\t\"ConnectCache\"\n\t\t\t\t{{\n{cache_entries}\t\t\t\t}}\n\t\t\t}}\n\t\t}}\n\t}}\n}}\n" + ), + ) + .unwrap(); + } + + fn user_block(id: u64, name: &str, extra: &str) -> String { + format!("\t\"{id}\"\n\t{{\n\t\t\"AccountName\"\t\t\"{name}\"\n{extra}\t}}\n") + } + + #[test] + fn crc_prefix_is_zero_padded_lowercase_hex_of_lowercased_name() { + assert_eq!( + connect_cache_key_prefix("Ada"), + format!("{:08x}", crc32fast::hash(b"ada")) + ); + assert_eq!(connect_cache_key_prefix("x").len(), 8); + } + + #[test] + fn encrypts_a_known_token_and_decrypts_it_back() { + let token = jwt_for(ID); + let blob = encrypt_blob(&token, "AdaLovelace"); + let clear = decrypt_connect_cache(&blob, "adalovelace").unwrap(); + assert_eq!(clear.as_str(), token); + assert_eq!(jwt_steam_id(&clear), Some(ID)); + assert!(decrypt_connect_cache(&blob, "someone_else").is_none()); + assert!(decrypt_connect_cache("zz", "adalovelace").is_none()); + assert!(decrypt_connect_cache("00ff", "adalovelace").is_none()); + } + + #[test] + fn loads_saved_login_with_mixed_case_keys_and_auto_login_user() { + let root = temp_dir("load"); + let token = jwt_for(ID); + let other = ID + 1; + let users = format!( + "\"users\"\n{{\n{}{}}}\n", + user_block(other, "second", "\t\t\"MostRecent\"\t\t\"1\"\n"), + user_block(ID, "AdaLovelace", "\t\t\"RememberPassword\"\t\t\"1\"\n"), + ); + let entry = format!( + "\t\t\t\t\t\"{}1\"\t\t\"{}\"\n", + connect_cache_key_prefix("AdaLovelace").to_uppercase(), + encrypt_blob(&token, "AdaLovelace") + ); + write_root(&root, &users, &entry); + let registry = root.join("registry.vdf"); + fs::write( + ®istry, + "\"Registry\"\n{\n\t\"HKCU\"\n\t{\n\t\t\"Software\"\n\t\t{\n\t\t\t\"Valve\"\n\t\t\t{\n\t\t\t\t\"Steam\"\n\t\t\t\t{\n\t\t\t\t\t\"AutoLoginUser\"\t\t\"adalovelace\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", + ) + .unwrap(); + + let login = load_saved_login(std::slice::from_ref(&root), Some(®istry)).unwrap(); + assert_eq!(login.account, "AdaLovelace"); + assert_eq!(login.steam_id, ID); + assert_eq!(login.token.as_str(), token); + assert!(!format!("{login:?}").contains(&token)); + + // Without AutoLoginUser the MostRecent account wins; it has no token saved. + assert_eq!( + load_saved_login(std::slice::from_ref(&root), None).unwrap_err(), + SigninError::RememberMeOff + ); + let _ = fs::remove_dir_all(&root); + } + + #[test] + fn reports_no_login_remember_me_off_and_decrypt_failures() { + let empty = temp_dir("empty"); + assert_eq!( + load_saved_login(std::slice::from_ref(&empty), None).unwrap_err(), + SigninError::NoSavedLogin + ); + + let off = temp_dir("off"); + write_root( + &off, + &format!( + "\"users\"\n{{\n{}}}\n", + user_block(ID, "ada", "\t\t\"RememberPassword\"\t\t\"0\"\n") + ), + "", + ); + assert_eq!( + load_saved_login(std::slice::from_ref(&off), None).unwrap_err(), + SigninError::RememberMeOff + ); + + let wrong = temp_dir("wrong"); + let entry = format!( + "\t\t\t\t\t\"{}1\"\t\t\"{}\"\n", + connect_cache_key_prefix("ada"), + encrypt_blob(&jwt_for(ID + 5), "ada") + ); + write_root( + &wrong, + &format!("\"users\"\n{{\n{}}}\n", user_block(ID, "ada", "")), + &entry, + ); + assert_eq!( + load_saved_login(std::slice::from_ref(&wrong), None).unwrap_err(), + SigninError::DecryptFailed + ); + let remembered = temp_dir("remembered"); + let good = format!( + "\t\t\t\t\t\"{}1\"\t\t\"{}\"\n", + connect_cache_key_prefix("ada"), + encrypt_blob(&jwt_for(ID), "ada") + ); + write_root( + &remembered, + &format!("\"users\"\n{{\n{}}}\n", user_block(ID, "ada", "")), + &good, + ); + let login = load_saved_login(&[off.clone(), remembered.clone()], None).unwrap(); + assert_eq!(login.steam_root, remembered); + for dir in [empty, off, wrong, remembered] { + let _ = fs::remove_dir_all(dir); + } + } + + #[test] + fn newest_timestamp_wins_when_most_recent_is_absent() { + let accounts = vec![ + Account { + steam_id: 1, + account_name: "old".into(), + remember_password: None, + most_recent: false, + timestamp: 10, + root_index: 0, + }, + Account { + steam_id: 2, + account_name: "new".into(), + remember_password: None, + most_recent: false, + timestamp: 20, + root_index: 0, + }, + ]; + assert_eq!(choose_account(&accounts, None).unwrap().steam_id, 2); + assert_eq!(choose_account(&accounts, Some("OLD")).unwrap().steam_id, 1); + assert_eq!( + choose_account(&accounts, Some("nobody")).unwrap().steam_id, + 2 + ); + assert!(choose_account(&[], None).is_none()); + } +} diff --git a/app/src/main/rust/stores/src/steam/steam_directory.rs b/app/src/main/rust/stores/src/steam/steam_directory.rs new file mode 100644 index 0000000000..cc9780a787 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/steam_directory.rs @@ -0,0 +1,238 @@ +use crate::steam::cm_server::{parse_endpoint, CmServer, CmTransport}; +use serde_json::Value; +use std::time::Duration; + +pub const DEFAULT_USER_AGENT: &str = "Valve/Steam HTTP Client 1.0"; +pub const DIRECTORY_ENDPOINT: &str = + "https://api.steampowered.com/ISteamDirectory/GetCMListForConnect/v1/"; +pub const DEFAULT_TIMEOUT: Duration = Duration::from_secs(10); + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct SteamDirectoryResult { + pub servers: Vec, + pub error: String, + pub http_status: i32, +} + +impl SteamDirectoryResult { + pub fn ok(&self) -> bool { + self.error.is_empty() && !self.servers.is_empty() + } +} + +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub struct SteamDirectoryClient { + ca_bundle_path: String, +} + +impl SteamDirectoryClient { + pub fn new(ca_bundle_path: impl Into) -> Self { + Self { + ca_bundle_path: ca_bundle_path.into(), + } + } + + pub fn ca_bundle_path(&self) -> &str { + &self.ca_bundle_path + } + + pub fn build_url(cell_id: u32) -> String { + format!( + "{DIRECTORY_ENDPOINT}?cellid={cell_id}&cmtype=websockets&maxcount=20&realm=steamglobal" + ) + } + + pub fn fetch(&self, cell_id: u32, timeout: Duration) -> SteamDirectoryResult { + self.fetch_with_user_agent(cell_id, timeout, DEFAULT_USER_AGENT) + } + + pub fn fetch_with_user_agent( + &self, + cell_id: u32, + timeout: Duration, + user_agent: &str, + ) -> SteamDirectoryResult { + let url = SteamDirectoryClient::build_url(cell_id); + match self.http_get_text(&url, timeout, user_agent) { + Ok(response) => { + SteamDirectoryClient::validate_response(response.http_status, &response.body) + } + Err(error) => SteamDirectoryResult { + error, + ..Default::default() + }, + } + } + + pub fn validate_response(http_status: i32, body: &str) -> SteamDirectoryResult { + if http_status != 200 { + return SteamDirectoryResult { + error: "non-200 HTTP status".to_string(), + http_status, + ..Default::default() + }; + } + let mut result = parse_directory_response(body); + result.http_status = http_status; + result + } + + pub fn default_timeout() -> Duration { + DEFAULT_TIMEOUT + } + + fn http_get_text( + &self, + url: &str, + timeout: Duration, + _user_agent: &str, + ) -> Result { + let response = crate::steam::http::get(url, timeout, &self.ca_bundle_path)?; + Ok(HttpTextResponse { + http_status: response.status as i32, + body: String::from_utf8_lossy(&response.body).into_owned(), + }) + } +} + +struct HttpTextResponse { + http_status: i32, + body: String, +} + +pub fn parse_directory_response(body: &str) -> SteamDirectoryResult { + let mut result = SteamDirectoryResult::default(); + let root: Value = match serde_json::from_str(body) { + Ok(v) => v, + Err(e) => { + result.error = format!("json parse error: {e}"); + return result; + } + }; + let Some(response) = root.get("response") else { + result.error = "directory response: missing response".to_string(); + return result; + }; + let ok = response + .get("success") + .map(|s| { + s.as_bool() + .unwrap_or_else(|| s.as_i64().is_some_and(|n| n == 1)) + }) + .unwrap_or(false); + if !ok { + result.error = "directory response: success=false".to_string(); + return result; + } + let Some(list) = response.get("serverlist").and_then(|v| v.as_array()) else { + result.error = "directory response: missing serverlist".to_string(); + return result; + }; + + for entry in list { + let Some(endpoint) = entry.get("endpoint").and_then(|v| v.as_str()) else { + continue; + }; + let Some((host, port)) = parse_endpoint(endpoint) else { + continue; + }; + let transport = entry + .get("type") + .and_then(|v| v.as_str()) + .map(parse_transport) + .unwrap_or(CmTransport::Unknown); + if transport != CmTransport::WebSocket { + continue; + } + result.servers.push(CmServer { + endpoint: endpoint.to_string(), + host, + port, + transport, + realm: entry + .get("realm") + .and_then(|v| v.as_str()) + .unwrap_or("") + .to_string(), + datacenter: entry + .get("dc") + .and_then(|v| v.as_str()) + .unwrap_or("") + .to_string(), + load: entry.get("load").and_then(|v| v.as_i64()).unwrap_or(0) as i32, + weighted_load: entry + .get("wtd_load") + .and_then(|v| v.as_f64()) + .unwrap_or(0.0) as f32, + }); + } + result +} + +pub fn parse_transport(s: &str) -> CmTransport { + match s { + "websockets" | "websocket" => CmTransport::WebSocket, + "netfilter" => CmTransport::Tcp, + _ => CmTransport::Unknown, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_websocket_entries_and_filters_tcp() { + let json = r#"{ + "response": { + "success": 1, + "serverlist": [ + {"endpoint":"ext1-sea1.steamserver.net:443","type":"websockets","realm":"steamglobal","dc":"sea1","load":1,"wtd_load":2.5}, + {"endpoint":"tcp.example.com:27017","type":"netfilter"}, + {"endpoint":"bad","type":"websockets"} + ] + } + }"#; + let result = parse_directory_response(json); + assert!(result.error.is_empty()); + assert_eq!(result.servers.len(), 1); + assert_eq!(result.servers[0].host, "ext1-sea1.steamserver.net"); + assert_eq!(result.servers[0].weighted_load, 2.5); + } + + #[test] + fn accepts_boolean_success() { + let json = r#"{"response":{"success":true,"serverlist":[]}}"#; + let result = parse_directory_response(json); + assert!(result.error.is_empty()); + assert!(result.servers.is_empty()); + } + + #[test] + fn builds_directory_url_and_tracks_ca_bundle() { + let client = SteamDirectoryClient::new("/cacert.pem"); + assert_eq!(client.ca_bundle_path(), "/cacert.pem"); + assert_eq!( + SteamDirectoryClient::default_timeout(), + Duration::from_secs(10) + ); + assert_eq!( + SteamDirectoryClient::build_url(123), + "https://api.steampowered.com/ISteamDirectory/GetCMListForConnect/v1/?cellid=123&cmtype=websockets&maxcount=20&realm=steamglobal" + ); + } + + #[test] + fn validates_http_status_before_json() { + let result = SteamDirectoryClient::validate_response(503, "{}"); + assert_eq!(result.http_status, 503); + assert_eq!(result.error, "non-200 HTTP status"); + + let ok = SteamDirectoryClient::validate_response( + 200, + r#"{"response":{"success":1,"serverlist":[{"endpoint":"ext1-sea1.steamserver.net:443","type":"websockets"}]}}"#, + ); + assert_eq!(ok.http_status, 200); + assert!(ok.ok()); + } +} diff --git a/app/src/main/rust/stores/src/steam/transport.rs b/app/src/main/rust/stores/src/steam/transport.rs new file mode 100644 index 0000000000..12456d4bcb --- /dev/null +++ b/app/src/main/rust/stores/src/steam/transport.rs @@ -0,0 +1,36 @@ +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[repr(u8)] +pub enum TransportState { + Disconnected, + Connecting, + Connected, + Disconnecting, +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[repr(u8)] +pub enum TransportDisconnectReason { + UserInitiated, + RemoteClose, + TlsHandshakeFailed, + NetworkError, + HandshakeTimeout, + Unknown, +} + +pub type MessageCallback = Box; +pub type ConnectedCallback = Box; +pub type DisconnectedCallback = Box; + +pub trait Transport: Send { + fn connect(&mut self, url: &str) -> bool; + fn send(&mut self, data: &[u8]) -> bool; + fn disconnect(&mut self); + fn state(&self) -> TransportState; + + fn set_on_message(&mut self, cb: MessageCallback); + fn set_on_connected(&mut self, cb: ConnectedCallback); + fn set_on_disconnected(&mut self, cb: DisconnectedCallback); + + fn set_ca_bundle_path(&mut self, _path: &str) {} +} diff --git a/app/src/main/rust/stores/src/steam/vdf.rs b/app/src/main/rust/stores/src/steam/vdf.rs new file mode 100644 index 0000000000..b4d9f625df --- /dev/null +++ b/app/src/main/rust/stores/src/steam/vdf.rs @@ -0,0 +1,523 @@ +#[derive(Clone, Debug, PartialEq)] +pub enum KVValue { + Object, + String(String), + Int32(i32), + Float32(f32), + UInt32(u32), + WideString(Vec), + UInt64(u64), + Int64(i64), +} + +#[derive(Clone, Debug, PartialEq)] +pub struct KVNode { + pub name: String, + pub value: KVValue, + pub children: Vec, +} + +impl KVNode { + pub fn new(name: impl Into) -> Self { + Self { + name: name.into(), + value: KVValue::Object, + children: Vec::new(), + } + } + + pub fn is_object(&self) -> bool { + matches!(self.value, KVValue::Object) + } + + pub fn child(&self, key: &str) -> Option<&KVNode> { + self.children + .iter() + .find(|c| c.name.eq_ignore_ascii_case(key)) + } + + pub fn as_string(&self, fallback: &str) -> String { + match &self.value { + KVValue::String(v) => v.clone(), + KVValue::Int32(v) => v.to_string(), + KVValue::Float32(v) => v.to_string(), + KVValue::UInt32(v) => v.to_string(), + KVValue::UInt64(v) => v.to_string(), + KVValue::Int64(v) => v.to_string(), + _ => fallback.to_string(), + } + } + + pub fn as_int(&self, fallback: i64) -> i64 { + match &self.value { + KVValue::Int32(v) => *v as i64, + KVValue::Int64(v) => *v, + KVValue::UInt32(v) => *v as i64, + KVValue::UInt64(v) => *v as i64, + KVValue::String(v) => v.parse().unwrap_or(fallback), + _ => fallback, + } + } + + pub fn as_uint(&self, fallback: u64) -> u64 { + match &self.value { + KVValue::UInt32(v) => *v as u64, + KVValue::UInt64(v) => *v, + KVValue::Int32(v) => *v as u64, + KVValue::Int64(v) => *v as u64, + KVValue::String(v) => v.parse().unwrap_or(fallback), + _ => fallback, + } + } + + pub fn as_bool(&self, fallback: bool) -> bool { + match &self.value { + KVValue::Int32(v) => *v != 0, + KVValue::Int64(v) => *v != 0, + KVValue::UInt32(v) => *v != 0, + KVValue::UInt64(v) => *v != 0, + KVValue::String(v) + if v == "1" || v.eq_ignore_ascii_case("true") || v.eq_ignore_ascii_case("yes") => + { + true + } + KVValue::String(v) + if v == "0" || v.eq_ignore_ascii_case("false") || v.eq_ignore_ascii_case("no") => + { + false + } + _ => fallback, + } + } +} + +const TYPE_NONE: u8 = 0x00; +const TYPE_STRING: u8 = 0x01; +const TYPE_INT32: u8 = 0x02; +const TYPE_FLOAT32: u8 = 0x03; +const TYPE_POINTER: u8 = 0x04; +const TYPE_WIDE_STRING: u8 = 0x05; +const TYPE_COLOR: u8 = 0x06; +const TYPE_UINT64: u8 = 0x07; +const TYPE_END: u8 = 0x08; +const TYPE_INT64: u8 = 0x09; +const TYPE_END_ALT: u8 = 0x0b; + +struct Cursor<'a> { + buf: &'a [u8], + pos: usize, + ok: bool, +} + +impl<'a> Cursor<'a> { + fn new(buf: &'a [u8]) -> Self { + Self { + buf, + pos: 0, + ok: true, + } + } + + fn read_u8(&mut self) -> u8 { + if self.pos + 1 > self.buf.len() { + self.ok = false; + return 0; + } + let v = self.buf[self.pos]; + self.pos += 1; + v + } + + fn read_u32_le(&mut self) -> u32 { + if self.pos + 4 > self.buf.len() { + self.ok = false; + return 0; + } + let v = u32::from_le_bytes(self.buf[self.pos..self.pos + 4].try_into().unwrap()); + self.pos += 4; + v + } + + fn read_u64_le(&mut self) -> u64 { + let lo = self.read_u32_le() as u64; + let hi = self.read_u32_le() as u64; + lo | (hi << 32) + } + + fn read_f32_le(&mut self) -> f32 { + f32::from_bits(self.read_u32_le()) + } + + fn read_cstring(&mut self) -> String { + let mut out = Vec::new(); + while self.pos < self.buf.len() { + let b = self.buf[self.pos]; + self.pos += 1; + if b == 0 { + return String::from_utf8_lossy(&out).into_owned(); + } + out.push(b); + } + self.ok = false; + String::from_utf8_lossy(&out).into_owned() + } + + fn read_wide_cstring(&mut self) -> Vec { + let mut out = Vec::new(); + while self.pos + 1 < self.buf.len() { + let u = u16::from_le_bytes([self.buf[self.pos], self.buf[self.pos + 1]]); + self.pos += 2; + if u == 0 { + return out; + } + out.push(u); + } + self.ok = false; + out + } +} + +fn parse_value(cursor: &mut Cursor<'_>, ty: u8, node: &mut KVNode) -> bool { + match ty { + TYPE_NONE => { + while cursor.ok { + let inner_type = cursor.read_u8(); + if !cursor.ok { + return false; + } + if inner_type == TYPE_END || inner_type == TYPE_END_ALT { + return true; + } + let name = cursor.read_cstring(); + if !cursor.ok { + return false; + } + let mut child = KVNode::new(name); + if !parse_value(cursor, inner_type, &mut child) { + return false; + } + node.children.push(child); + } + false + } + TYPE_STRING => { + node.value = KVValue::String(cursor.read_cstring()); + cursor.ok + } + TYPE_INT32 => { + node.value = KVValue::Int32(cursor.read_u32_le() as i32); + cursor.ok + } + TYPE_FLOAT32 => { + node.value = KVValue::Float32(cursor.read_f32_le()); + cursor.ok + } + TYPE_POINTER | TYPE_COLOR => { + node.value = KVValue::UInt32(cursor.read_u32_le()); + cursor.ok + } + TYPE_WIDE_STRING => { + node.value = KVValue::WideString(cursor.read_wide_cstring()); + cursor.ok + } + TYPE_UINT64 => { + node.value = KVValue::UInt64(cursor.read_u64_le()); + cursor.ok + } + TYPE_INT64 => { + node.value = KVValue::Int64(cursor.read_u64_le() as i64); + cursor.ok + } + _ => false, + } +} + +pub fn parse_binary(body: &[u8]) -> Option { + if body.is_empty() { + return None; + } + let mut cursor = Cursor::new(body); + let ty = cursor.read_u8(); + if !cursor.ok { + return None; + } + let mut root = KVNode::new(cursor.read_cstring()); + if !cursor.ok || !parse_value(&mut cursor, ty, &mut root) { + return None; + } + Some(root) +} + +pub fn parse_binary_package(body: &[u8]) -> Option<(u32, KVNode)> { + if body.len() < 4 { + return None; + } + let package_id = u32::from_le_bytes(body[..4].try_into().unwrap()); + Some((package_id, parse_binary(&body[4..])?)) +} + +pub fn parse_auto(body: &[u8]) -> Option { + let first = body + .iter() + .copied() + .find(|b| !matches!(b, b' ' | b'\t' | b'\n' | b'\r'))?; + if first == b'"' { + parse_text(body) + } else { + parse_binary(body) + } +} + +struct TextCursor<'a> { + buf: &'a [u8], + pos: usize, + ok: bool, +} + +impl<'a> TextCursor<'a> { + fn new(buf: &'a [u8]) -> Self { + Self { + buf, + pos: 0, + ok: true, + } + } + + fn eof(&self) -> bool { + self.pos >= self.buf.len() + } + + fn peek(&self) -> u8 { + self.buf.get(self.pos).copied().unwrap_or(0) + } + + fn next(&mut self) -> u8 { + let b = self.peek(); + if !self.eof() { + self.pos += 1; + } + b + } + + fn skip_ws_and_comments(&mut self) { + while self.pos < self.buf.len() { + match self.buf[self.pos] { + b' ' | b'\t' | b'\n' | b'\r' => self.pos += 1, + b'/' if self.buf.get(self.pos + 1) == Some(&b'/') => { + self.pos += 2; + while self.pos < self.buf.len() && self.buf[self.pos] != b'\n' { + self.pos += 1; + } + } + b'/' if self.buf.get(self.pos + 1) == Some(&b'*') => { + self.pos += 2; + while self.pos + 1 < self.buf.len() + && !(self.buf[self.pos] == b'*' && self.buf[self.pos + 1] == b'/') + { + self.pos += 1; + } + self.pos = (self.pos + 2).min(self.buf.len()); + } + _ => break, + } + } + } + + fn read_token(&mut self) -> Option { + self.skip_ws_and_comments(); + if self.eof() { + return None; + } + if self.peek() == b'"' { + self.pos += 1; + let mut out = Vec::new(); + while !self.eof() { + let c = self.next(); + if c == b'"' { + return Some(String::from_utf8_lossy(&out).into_owned()); + } + if c == b'\\' && !self.eof() { + out.push(match self.next() { + b'n' => b'\n', + b't' => b'\t', + b'r' => b'\r', + b'\\' => b'\\', + b'"' => b'"', + other => other, + }); + } else { + out.push(c); + } + } + self.ok = false; + return None; + } + + let start = self.pos; + while !self.eof() { + let c = self.peek(); + if matches!(c, b' ' | b'\t' | b'\n' | b'\r' | b'{' | b'}' | b'"') { + break; + } + self.pos += 1; + } + (self.pos > start).then(|| String::from_utf8_lossy(&self.buf[start..self.pos]).into_owned()) + } +} + +fn parse_text_object(cursor: &mut TextCursor<'_>, parent: &mut KVNode) -> bool { + loop { + cursor.skip_ws_and_comments(); + // An object that ends before its closing brace is a truncated file, not a complete one. + if cursor.eof() { + return false; + } + if cursor.peek() == b'}' { + cursor.pos += 1; + return true; + } + let Some(key) = cursor.read_token() else { + return false; + }; + cursor.skip_ws_and_comments(); + if cursor.eof() { + return false; + } + let mut child = KVNode::new(key); + if cursor.peek() == b'{' { + cursor.pos += 1; + if !parse_text_object(cursor, &mut child) { + return false; + } + } else { + let Some(value) = cursor.read_token() else { + return false; + }; + child.value = KVValue::String(value); + } + parent.children.push(child); + } +} + +pub fn parse_text(body: &[u8]) -> Option { + let mut cursor = TextCursor::new(body); + cursor.skip_ws_and_comments(); + let key = cursor.read_token()?; + cursor.skip_ws_and_comments(); + if cursor.peek() != b'{' { + return None; + } + cursor.pos += 1; + let mut root = KVNode::new(key); + parse_text_object(&mut cursor, &mut root).then_some(root) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn refuses_a_truncated_text_object() { + assert!(parse_text(b"\"a\" { \"b\" \"1\" }").is_some()); + assert!(parse_text(b"\"a\" { \"b\" \"1\"").is_none()); + assert!(parse_text(b"\"a\" { \"b\" { \"c\" \"1\" }").is_none()); + assert!(parse_text(b"\"a\" { { }").is_none()); + } + + #[test] + fn parses_text_vdf_with_comments_and_case_insensitive_lookup() { + let text = br#" + // comment + "appinfo" { + "appid" "480" + "Common" { "name" "Spacewar" "type" "Game" } + /* block */ "enabled" "true" + } + "#; + let root = parse_text(text).unwrap(); + assert_eq!(root.name, "appinfo"); + assert_eq!(root.child("APPID").unwrap().as_int(0), 480); + assert_eq!( + root.child("common") + .unwrap() + .child("NAME") + .unwrap() + .as_string(""), + "Spacewar" + ); + assert!(root.child("enabled").unwrap().as_bool(false)); + } + + #[test] + fn parses_binary_tree() { + let mut bytes = Vec::new(); + bytes.extend_from_slice(&[TYPE_NONE]); + bytes.extend_from_slice(b"root\0"); + bytes.extend_from_slice(&[TYPE_STRING]); + bytes.extend_from_slice(b"name\0Spacewar\0"); + bytes.extend_from_slice(&[TYPE_INT32]); + bytes.extend_from_slice(b"appid\0"); + bytes.extend_from_slice(&480i32.to_le_bytes()); + bytes.extend_from_slice(&[TYPE_END]); + + let root = parse_binary(&bytes).unwrap(); + assert!(root.is_object()); + assert_eq!(root.child("name").unwrap().as_string(""), "Spacewar"); + assert_eq!(root.child("appid").unwrap().as_int(0), 480); + } + + #[test] + fn parses_package_prefix() { + let mut bytes = 123u32.to_le_bytes().to_vec(); + bytes.extend_from_slice(&[TYPE_NONE]); + bytes.extend_from_slice(b"package\0"); + bytes.extend_from_slice(&[TYPE_END]); + let (package_id, root) = parse_binary_package(&bytes).unwrap(); + assert_eq!(package_id, 123); + assert_eq!(root.name, "package"); + } + + // Manifest gid/size/download: proves the parser reads download (the 3rd value) + // correctly, ruling out a parser cause for the stale corrupt download sizes. + #[test] + fn parses_manifest_uint64_gid_size_download() { + let gid: u64 = 8072044898226043193; + let size: u64 = 30738676601; + let download: u64 = 15000000000; + let mut b = vec![TYPE_NONE]; + b.extend_from_slice(b"public\0"); + b.push(TYPE_UINT64); + b.extend_from_slice(b"gid\0"); + b.extend_from_slice(&gid.to_le_bytes()); + b.push(TYPE_UINT64); + b.extend_from_slice(b"size\0"); + b.extend_from_slice(&size.to_le_bytes()); + b.push(TYPE_UINT64); + b.extend_from_slice(b"download\0"); + b.extend_from_slice(&download.to_le_bytes()); + b.push(TYPE_END); + + let root = parse_binary(&b).unwrap(); + assert_eq!(root.child("gid").unwrap().as_string(""), gid.to_string()); + assert_eq!(root.child("size").unwrap().as_string(""), size.to_string()); + assert_eq!( + root.child("download").unwrap().as_string(""), + download.to_string() + ); + } + + #[test] + fn parses_manifest_text_vdf() { + let text = br#" + "public" + { + "gid" "8072044898226043193" + "size" "30738676601" + "download" "15000000000" + } + "#; + let root = parse_text(text).unwrap(); + assert_eq!(root.child("size").unwrap().as_string(""), "30738676601"); + assert_eq!(root.child("download").unwrap().as_string(""), "15000000000"); + } +} diff --git a/app/src/main/rust/stores/src/steam/wire_format.rs b/app/src/main/rust/stores/src/steam/wire_format.rs new file mode 100644 index 0000000000..6f7c3d7323 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/wire_format.rs @@ -0,0 +1,154 @@ +pub fn read_u16_le(p: &[u8]) -> u16 { + u16::from_le_bytes([p[0], p[1]]) +} + +pub fn read_u32_le(p: &[u8]) -> u32 { + u32::from_le_bytes([p[0], p[1], p[2], p[3]]) +} + +pub fn read_u64_le(p: &[u8]) -> u64 { + u64::from_le_bytes([p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]]) +} + +pub fn write_u16_le(out: &mut [u8], v: u16) { + out[..2].copy_from_slice(&v.to_le_bytes()); +} + +pub fn write_u32_le(out: &mut [u8], v: u32) { + out[..4].copy_from_slice(&v.to_le_bytes()); +} + +pub fn write_u64_le(out: &mut [u8], v: u64) { + out[..8].copy_from_slice(&v.to_le_bytes()); +} + +pub struct Reader<'a> { + buf: &'a [u8], + pos: usize, + ok: bool, +} + +impl<'a> Reader<'a> { + pub fn new(buf: &'a [u8]) -> Self { + Self { + buf, + pos: 0, + ok: true, + } + } + + pub fn ok(&self) -> bool { + self.ok + } + + pub fn position(&self) -> usize { + self.pos + } + + pub fn remaining(&self) -> usize { + self.buf.len().saturating_sub(self.pos) + } + + pub fn u16(&mut self) -> u16 { + if !self.check(2) { + return 0; + } + let v = read_u16_le(&self.buf[self.pos..]); + self.pos += 2; + v + } + + pub fn u32(&mut self) -> u32 { + if !self.check(4) { + return 0; + } + let v = read_u32_le(&self.buf[self.pos..]); + self.pos += 4; + v + } + + pub fn u64(&mut self) -> u64 { + if !self.check(8) { + return 0; + } + let v = read_u64_le(&self.buf[self.pos..]); + self.pos += 8; + v + } + + pub fn bytes(&mut self, n: usize) -> &'a [u8] { + if !self.check(n) { + return &[]; + } + let out = &self.buf[self.pos..self.pos + n]; + self.pos += n; + out + } + + fn check(&mut self, n: usize) -> bool { + if !self.ok || self.remaining() < n { + self.ok = false; + return false; + } + true + } +} + +pub struct Writer<'a> { + out: &'a mut Vec, +} + +impl<'a> Writer<'a> { + pub fn new(out: &'a mut Vec) -> Self { + Self { out } + } + + pub fn u16(&mut self, v: u16) { + self.out.extend_from_slice(&v.to_le_bytes()); + } + + pub fn u32(&mut self, v: u32) { + self.out.extend_from_slice(&v.to_le_bytes()); + } + + pub fn u64(&mut self, v: u64) { + self.out.extend_from_slice(&v.to_le_bytes()); + } + + pub fn bytes(&mut self, bytes: &[u8]) { + self.out.extend_from_slice(bytes); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn reader_writer_little_endian_roundtrip() { + let mut buf = Vec::new(); + let mut writer = Writer::new(&mut buf); + writer.u16(0x1234); + writer.u32(0x89ab_cdef); + writer.u64(0x0123_4567_89ab_cdef); + + assert_eq!( + buf, + [0x34, 0x12, 0xef, 0xcd, 0xab, 0x89, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01] + ); + + let mut reader = Reader::new(&buf); + assert_eq!(reader.u16(), 0x1234); + assert_eq!(reader.u32(), 0x89ab_cdef); + assert_eq!(reader.u64(), 0x0123_4567_89ab_cdef); + assert!(reader.ok()); + assert_eq!(reader.remaining(), 0); + } + + #[test] + fn reader_short_input_flips_ok() { + let mut reader = Reader::new(&[1, 2, 3]); + assert_eq!(reader.u32(), 0); + assert!(!reader.ok()); + } +} diff --git a/app/src/main/rust/stores/src/steam/ws_connection.rs b/app/src/main/rust/stores/src/steam/ws_connection.rs new file mode 100644 index 0000000000..ccb8fabcd1 --- /dev/null +++ b/app/src/main/rust/stores/src/steam/ws_connection.rs @@ -0,0 +1,536 @@ +use crate::steam::transport::{Transport, TransportDisconnectReason, TransportState}; +use std::sync::atomic::{AtomicBool, AtomicU8, Ordering}; +use std::sync::{mpsc, Arc, Mutex}; +use std::thread::{self, JoinHandle}; +use std::time::Duration; +use tungstenite::error::Error as WsError; +use tungstenite::stream::MaybeTlsStream; +use tungstenite::client::IntoClientRequest; +use tungstenite::Message; + +const NORMAL_CLOSE_CODE: u16 = 1000; +const READ_POLL_TIMEOUT: Duration = Duration::from_millis(100); +const CONNECT_TIMEOUT: Duration = Duration::from_secs(10); +const HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(15); +/// A send that cannot progress for this long fails the connection instead of blocking the worker. +const SEND_TIMEOUT: Duration = Duration::from_secs(30); + +type MessageCallback = Arc; +type ConnectedCallback = Arc; +type DisconnectedCallback = Arc; + +pub struct WsConnection { + shared: Arc, + sender: Mutex>>, + worker: Mutex>>, +} + +#[derive(Default)] +struct WsConnectionShared { + state: AtomicU8, + user_initiated_close: AtomicBool, + ca_bundle_path: Mutex, + on_message: Mutex>, + on_connected: Mutex>, + on_disconnected: Mutex>, +} + +enum WsCommand { + Send(Vec), + Disconnect, +} + +impl WsConnection { + pub fn new() -> Self { + Self { + shared: Arc::new(WsConnectionShared { + state: AtomicU8::new(TransportState::Disconnected as u8), + user_initiated_close: AtomicBool::new(false), + ca_bundle_path: Mutex::new(String::new()), + on_message: Mutex::new(None), + on_connected: Mutex::new(None), + on_disconnected: Mutex::new(None), + }), + sender: Mutex::new(None), + worker: Mutex::new(None), + } + } + + pub fn set_ca_bundle_path(&self, path: &str) { + *self + .shared + .ca_bundle_path + .lock() + .expect("ws connection poisoned") = path.to_string(); + } + + pub fn ca_bundle_path(&self) -> String { + self.shared + .ca_bundle_path + .lock() + .expect("ws connection poisoned") + .clone() + } + + pub fn state(&self) -> TransportState { + match self.shared.state.load(Ordering::Relaxed) { + 1 => TransportState::Connecting, + 2 => TransportState::Connected, + 3 => TransportState::Disconnecting, + _ => TransportState::Disconnected, + } + } + + pub fn transition_connecting(&self) -> bool { + self.shared + .user_initiated_close + .store(false, Ordering::Relaxed); + self.shared + .state + .compare_exchange( + TransportState::Disconnected as u8, + TransportState::Connecting as u8, + Ordering::AcqRel, + Ordering::Acquire, + ) + .is_ok() + } + + pub fn mark_connected(&self) { + self.shared.mark_connected(); + } + + pub fn mark_disconnected(&self, close_code: u16, detail: &str, tls_failed: bool) { + self.shared + .mark_disconnected(close_code, detail, tls_failed); + } + + pub fn mark_user_disconnect(&self) { + self.shared + .user_initiated_close + .store(true, Ordering::Relaxed); + self.shared + .state + .store(TransportState::Disconnecting as u8, Ordering::Release); + } + + pub fn deliver_binary(&self, data: &[u8]) { + self.shared.deliver_binary(data); + } + + pub fn set_on_message(&self, cb: F) + where + F: Fn(&[u8]) + Send + Sync + 'static, + { + *self + .shared + .on_message + .lock() + .expect("ws connection poisoned") = Some(Arc::new(cb)); + } + + pub fn set_on_connected(&self, cb: F) + where + F: Fn() + Send + Sync + 'static, + { + *self + .shared + .on_connected + .lock() + .expect("ws connection poisoned") = Some(Arc::new(cb)); + } + + pub fn set_on_disconnected(&self, cb: F) + where + F: Fn(TransportDisconnectReason, &str) + Send + Sync + 'static, + { + *self + .shared + .on_disconnected + .lock() + .expect("ws connection poisoned") = Some(Arc::new(cb)); + } + + fn connect_worker(&self, url: &str) -> bool { + if !self.transition_connecting() { + return false; + } + let (tx, rx) = mpsc::channel(); + *self.sender.lock().expect("ws connection poisoned") = Some(tx); + let shared = Arc::clone(&self.shared); + let url = url.to_string(); + let worker = thread::spawn(move || run_ws_worker(shared, url, rx)); + *self.worker.lock().expect("ws connection poisoned") = Some(worker); + true + } +} + +impl Transport for WsConnection { + fn connect(&mut self, url: &str) -> bool { + self.connect_worker(url) + } + + fn send(&mut self, data: &[u8]) -> bool { + if self.state() != TransportState::Connected { + return false; + } + self.sender + .lock() + .expect("ws connection poisoned") + .as_ref() + .is_some_and(|tx| tx.send(WsCommand::Send(data.to_vec())).is_ok()) + } + + fn disconnect(&mut self) { + if self.state() == TransportState::Disconnected { + return; + } + self.mark_user_disconnect(); + let sent = self + .sender + .lock() + .expect("ws connection poisoned") + .as_ref() + .is_some_and(|tx| tx.send(WsCommand::Disconnect).is_ok()); + if !sent { + self.mark_disconnected(NORMAL_CLOSE_CODE, "client disconnect", false); + } + } + + fn state(&self) -> TransportState { + WsConnection::state(self) + } + + fn set_on_message(&mut self, cb: Box) { + *self + .shared + .on_message + .lock() + .expect("ws connection poisoned") = Some(Arc::from(cb)); + } + + fn set_on_connected(&mut self, cb: Box) { + *self + .shared + .on_connected + .lock() + .expect("ws connection poisoned") = Some(Arc::from(cb)); + } + + fn set_on_disconnected( + &mut self, + cb: Box, + ) { + *self + .shared + .on_disconnected + .lock() + .expect("ws connection poisoned") = Some(Arc::from(cb)); + } + + fn set_ca_bundle_path(&mut self, path: &str) { + WsConnection::set_ca_bundle_path(self, path); + } +} + +impl Default for WsConnection { + fn default() -> Self { + Self::new() + } +} + +impl Drop for WsConnection { + fn drop(&mut self) { + self.disconnect(); + } +} + +impl WsConnectionShared { + fn mark_connected(&self) { + self.state + .store(TransportState::Connected as u8, Ordering::Release); + self.fire_connected(); + } + + /// Publishes Connected only while still Connecting, so a disconnect queued during the + /// handshake wins. + fn mark_connected_if_connecting(&self) -> bool { + let won = self + .state + .compare_exchange( + TransportState::Connecting as u8, + TransportState::Connected as u8, + Ordering::AcqRel, + Ordering::Acquire, + ) + .is_ok(); + if won { + self.fire_connected(); + } + won + } + + fn fire_connected(&self) { + let cb = self + .on_connected + .lock() + .expect("ws connection poisoned") + .clone(); + if let Some(cb) = cb { + cb(); + } + } + + fn mark_disconnected(&self, close_code: u16, detail: &str, tls_failed: bool) { + self.state + .store(TransportState::Disconnected as u8, Ordering::Release); + let reason = if self.user_initiated_close.load(Ordering::Relaxed) { + TransportDisconnectReason::UserInitiated + } else { + map_close_reason(close_code, tls_failed) + }; + let cb = self + .on_disconnected + .lock() + .expect("ws connection poisoned") + .clone(); + if let Some(cb) = cb { + cb(reason, detail); + } + } + + fn deliver_binary(&self, data: &[u8]) { + let cb = self + .on_message + .lock() + .expect("ws connection poisoned") + .clone(); + if let Some(cb) = cb { + cb(data); + } + } +} + +type WsSocket = tungstenite::WebSocket>; + +/// One TLS WebSocket handshake with bounded connect and handshake times. Redirects are not +/// followed, so a CM cannot move the session to another scheme or host. +fn open_socket(url: &str) -> Result { + if !url.starts_with("wss://") { + return Err(format!("refusing non-TLS CM url {url}")); + } + let request = url.into_client_request().map_err(|e| e.to_string())?; + let host = request + .uri() + .host() + .ok_or_else(|| "CM url has no host".to_string())? + .trim_start_matches('[') + .trim_end_matches(']') + .to_string(); + let port = request.uri().port_u16().unwrap_or(443); + let addrs = std::net::ToSocketAddrs::to_socket_addrs(&(host.as_str(), port)) + .map_err(|e| e.to_string())?; + let mut last = "no address for CM host".to_string(); + for addr in addrs { + match std::net::TcpStream::connect_timeout(&addr, CONNECT_TIMEOUT) { + Ok(stream) => { + let _ = stream.set_read_timeout(Some(HANDSHAKE_TIMEOUT)); + let _ = stream.set_write_timeout(Some(HANDSHAKE_TIMEOUT)); + return tungstenite::client_tls(request, stream) + .map(|(socket, _)| socket) + .map_err(|e| e.to_string()); + } + Err(err) => last = err.to_string(), + } + } + Err(last) +} + +fn run_ws_worker(shared: Arc, url: String, rx: mpsc::Receiver) { + let mut socket = match open_socket(&url) { + Ok(socket) => socket, + Err(detail) => { + let reason = map_error_reason(&detail, false); + shared.mark_disconnected(reason_to_close_code(reason), &detail, false); + return; + } + }; + let _ = set_read_timeout(socket.get_mut(), Some(READ_POLL_TIMEOUT)); + if let MaybeTlsStream::Rustls(stream) = socket.get_mut() { + let _ = stream.sock.set_write_timeout(Some(SEND_TIMEOUT)); + } + if !shared.mark_connected_if_connecting() { + let _ = socket.close(None); + shared.mark_disconnected(NORMAL_CLOSE_CODE, "client disconnect", false); + return; + } + + loop { + while let Ok(cmd) = rx.try_recv() { + match cmd { + WsCommand::Send(data) => { + if let Err(err) = socket.send(Message::Binary(data.into())) { + let detail = err.to_string(); + let reason = map_error_reason(&detail, false); + shared.mark_disconnected(reason_to_close_code(reason), &detail, false); + return; + } + } + WsCommand::Disconnect => { + let _ = socket.close(None); + shared.mark_disconnected(NORMAL_CLOSE_CODE, "client disconnect", false); + return; + } + } + } + + match socket.read() { + Ok(Message::Binary(bytes)) => shared.deliver_binary(&bytes), + Ok(Message::Close(frame)) => { + let detail = frame + .as_ref() + .map(|frame| frame.reason.to_string()) + .unwrap_or_else(|| "remote close".to_string()); + let code = frame + .map(|frame| u16::from(frame.code)) + .unwrap_or(NORMAL_CLOSE_CODE); + shared.mark_disconnected(code, &detail, false); + return; + } + Ok(Message::Ping(_) | Message::Pong(_) | Message::Text(_) | Message::Frame(_)) => {} + Err(err) if is_timeout_error(&err) => {} + Err(WsError::ConnectionClosed | WsError::AlreadyClosed) => { + shared.mark_disconnected(NORMAL_CLOSE_CODE, "remote close", false); + return; + } + Err(err) => { + let detail = err.to_string(); + let reason = map_error_reason(&detail, false); + shared.mark_disconnected(reason_to_close_code(reason), &detail, false); + return; + } + } + } +} + +fn set_read_timeout( + stream: &mut MaybeTlsStream, + timeout: Option, +) -> std::io::Result<()> { + match stream { + MaybeTlsStream::Plain(stream) => stream.set_read_timeout(timeout), + MaybeTlsStream::Rustls(stream) => stream.sock.set_read_timeout(timeout), + #[allow(unreachable_patterns)] + _ => Ok(()), + } +} + +fn is_timeout_error(err: &WsError) -> bool { + matches!(err, WsError::Io(io) if matches!( + io.kind(), + std::io::ErrorKind::WouldBlock | std::io::ErrorKind::TimedOut + )) +} + +fn reason_to_close_code(reason: TransportDisconnectReason) -> u16 { + match reason { + TransportDisconnectReason::RemoteClose | TransportDisconnectReason::UserInitiated => { + NORMAL_CLOSE_CODE + } + _ => 0, + } +} + +pub fn map_close_reason(close_code: u16, tls_handshake_failed: bool) -> TransportDisconnectReason { + if tls_handshake_failed { + TransportDisconnectReason::TlsHandshakeFailed + } else if (1000..1016).contains(&close_code) { + TransportDisconnectReason::RemoteClose + } else { + TransportDisconnectReason::Unknown + } +} + +pub fn map_error_reason(reason: &str, user_initiated: bool) -> TransportDisconnectReason { + if user_initiated { + return TransportDisconnectReason::UserInitiated; + } + let tls_failed = reason.contains("tls") + || reason.contains("TLS") + || reason.contains("SSL") + || reason.contains("certificate"); + map_close_reason(0, tls_failed) +} + +pub fn normal_close_code() -> u16 { + NORMAL_CLOSE_CODE +} + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::mpsc; + + #[test] + fn maps_close_reasons() { + assert_eq!( + map_close_reason(0, true), + TransportDisconnectReason::TlsHandshakeFailed + ); + assert_eq!( + map_close_reason(1000, false), + TransportDisconnectReason::RemoteClose + ); + assert_eq!( + map_close_reason(2000, false), + TransportDisconnectReason::Unknown + ); + assert_eq!(normal_close_code(), 1000); + assert_eq!( + map_error_reason("TLS certificate verify failed", false), + TransportDisconnectReason::TlsHandshakeFailed + ); + assert_eq!( + map_error_reason("connection reset", false), + TransportDisconnectReason::Unknown + ); + assert_eq!( + map_error_reason("connection reset", true), + TransportDisconnectReason::UserInitiated + ); + } + + #[test] + fn transitions_and_callbacks_fire() { + let ws = WsConnection::new(); + let (tx, rx) = mpsc::channel(); + ws.set_on_connected(move || tx.send("connected").unwrap()); + assert!(ws.transition_connecting()); + assert!(!ws.transition_connecting()); + ws.mark_connected(); + assert_eq!(ws.state(), TransportState::Connected); + assert_eq!(rx.recv().unwrap(), "connected"); + } + + #[test] + fn a_disconnect_during_the_handshake_keeps_connected_unpublished() { + let ws = WsConnection::new(); + assert!(ws.transition_connecting()); + ws.mark_user_disconnect(); + assert!(!ws.shared.mark_connected_if_connecting()); + assert_eq!(ws.state(), TransportState::Disconnecting); + } + + #[test] + fn a_callback_may_replace_itself() { + let ws = Arc::new(WsConnection::new()); + let inner = Arc::clone(&ws); + ws.set_on_message(move |_| inner.set_on_message(|_| {})); + ws.deliver_binary(b"x"); + } + + #[test] + fn refuses_plain_ws_urls() { + assert!(open_socket("ws://example.invalid/cmsocket/").is_err()); + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/MaliAutoRouteTest.kt b/app/src/test/java/com/droiddeck/launcher/MaliAutoRouteTest.kt index 6e7895c5e5..d30092f25e 100644 --- a/app/src/test/java/com/droiddeck/launcher/MaliAutoRouteTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/MaliAutoRouteTest.kt @@ -50,4 +50,28 @@ class MaliAutoRouteTest { assertTrue(MaliAutoRoute.userChoice(true, MaliAutoRoute.VENUS, MaliAutoRoute.BRIDGE)) assertFalse(MaliAutoRoute.userChoice(false, MaliAutoRoute.NONE, MaliAutoRoute.BRIDGE)) } + + @Test + fun venusTheUserSwitchedOffIsNotSwitchedBackOn() { + assertFalse(MaliAutoRoute.venusStandsIn(true, true, false, true, "Mali-G715")) + assertTrue(MaliAutoRoute.venusStandsIn(true, true, true, true, "Mali-G2-Ultra-NX MC12")) + } + + @Test + fun venusIsAutosStandInOnlyWhereSteamStartsThroughIt() { + assertTrue(MaliAutoRoute.venusStandsIn(true, true, false, false, "Mali-G715")) + assertFalse(MaliAutoRoute.venusStandsIn(true, true, false, false, "Mali-G2-Ultra-NX MC12")) + assertFalse(MaliAutoRoute.venusStandsIn(true, true, true, false, "Mali-G2-Ultra-NX MC16")) + assertFalse(MaliAutoRoute.venusStandsIn(false, true, true, true, "Mali-G715")) + assertFalse(MaliAutoRoute.venusStandsIn(true, false, true, true, "Mali-G715")) + } + + @Test + fun venusThatAutoTurnedOffIsStillAutosToTurnOn() { + // Auto clears the stored key when it moves to the bridge: a stored "off" would read as the user's own choice. + val cleared = MaliAutoRoute.userChoice(keyStored = false, owner = MaliAutoRoute.BRIDGE, route = MaliAutoRoute.VENUS) + val writtenOff = MaliAutoRoute.userChoice(keyStored = true, owner = MaliAutoRoute.BRIDGE, route = MaliAutoRoute.VENUS) + assertTrue(MaliAutoRoute.venusStandsIn(true, true, false, cleared, "Mali-G715")) + assertFalse(MaliAutoRoute.venusStandsIn(true, true, false, writtenOff, "Mali-G715")) + } } diff --git a/app/src/test/java/com/droiddeck/launcher/QuestSteamVrWatchTest.kt b/app/src/test/java/com/droiddeck/launcher/QuestSteamVrWatchTest.kt new file mode 100644 index 0000000000..e19c65a5cc --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/QuestSteamVrWatchTest.kt @@ -0,0 +1,50 @@ +package com.droiddeck.launcher + +import com.droiddeck.launcher.gpu.SteamVr.Status +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +class QuestSteamVrWatchTest { + @Test + fun steamVrThatNeverStartsFailsAfterTheStartupWindow() { + val watch = QuestSteamVrWatch(0) + assertFalse(watch.stopped(29_999, Status.READY, paused = false)) + assertTrue(watch.stopped(30_000, Status.READY, paused = false)) + } + + @Test + fun steamVrThatStopsFailsAfterTheRunningGrace() { + val watch = QuestSteamVrWatch(0) + assertFalse(watch.stopped(10_000, Status.RUNNING, paused = false)) + assertFalse(watch.stopped(14_999, Status.UNAVAILABLE, paused = false)) + assertTrue(watch.stopped(15_000, Status.UNAVAILABLE, paused = false)) + } + + @Test + fun aFrozenGuestNeverCountsAsStopped() { + val watch = QuestSteamVrWatch(0) + assertFalse(watch.stopped(10_000, Status.RUNNING, paused = false)) + for (now in 11_000L..600_000L step 10_000) assertFalse(watch.stopped(now, Status.UNAVAILABLE, paused = true)) + } + + @Test + fun aResumedGuestGetsTheFullGraceFromItsFirstAnswerAfterTheFreeze() { + val watch = QuestSteamVrWatch(0) + watch.stopped(10_000, Status.RUNNING, paused = false) + watch.stopped(300_000, Status.UNAVAILABLE, paused = true) + assertFalse(watch.stopped(310_000, Status.UNAVAILABLE, paused = false)) + assertFalse(watch.stopped(324_999, Status.UNAVAILABLE, paused = false)) + assertTrue(watch.stopped(325_000, Status.UNAVAILABLE, paused = false)) + } + + @Test + fun steamVrAnsweringAfterAResumeKeepsTheSessionOpen() { + val watch = QuestSteamVrWatch(0) + watch.stopped(10_000, Status.RUNNING, paused = false) + watch.stopped(300_000, Status.UNAVAILABLE, paused = true) + assertFalse(watch.stopped(312_000, Status.RUNNING, paused = false)) + assertFalse(watch.stopped(316_999, Status.UNAVAILABLE, paused = false)) + assertTrue(watch.stopped(317_000, Status.UNAVAILABLE, paused = false)) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/agent/AgentSetupInstallScriptTest.kt b/app/src/test/java/com/droiddeck/launcher/agent/AgentSetupInstallScriptTest.kt new file mode 100644 index 0000000000..bc36c84fe6 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/agent/AgentSetupInstallScriptTest.kt @@ -0,0 +1,50 @@ +package com.droiddeck.launcher.agent + +import java.io.File +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Assume.assumeTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder + +class AgentSetupInstallScriptTest { + @get:Rule val tmp = TemporaryFolder() + + private fun run(updateSucceedsOnCall: Int): Pair> { + val sh = listOf("/bin/sh", "/usr/bin/sh").firstOrNull { File(it).canExecute() } + assumeTrue(sh != null) + val bin = tmp.newFolder("bin") + val calls = File(tmp.root, "calls") + fun tool(name: String, body: String) = File(bin, name).apply { writeText("#!/bin/sh\n$body\n"); setExecutable(true) } + tool("dpkg", "exit 0") + tool("sleep", "exit 0") + tool("apt-get", """ + echo "${'$'}*" >> '${calls.path}' + case "${'$'}*" in + *" update "*) n=${'$'}(grep -c ' update ' '${calls.path}'); [ "${'$'}n" -ge $updateSucceedsOnCall ] ;; + *) exit 0 ;; + esac + """.trimIndent()) + val child = ProcessBuilder(sh, "-c", AgentSetup.installScript("echo harness-installed >> '${calls.path}'")) + .apply { environment()["PATH"] = bin.path + File.pathSeparator + System.getenv("PATH") } + .redirectErrorStream(true).start() + child.inputStream.readBytes() + val exit = child.waitFor() + return exit to (if (calls.exists()) calls.readLines() else emptyList()) + } + + @Test fun theInstallStopsWhenEveryUpdateAttemptFails() { + val (exit, calls) = run(updateSucceedsOnCall = 99) + assertTrue(exit != 0) + assertEquals(3, calls.count { " update " in "$it " }) + assertTrue(calls.none { "install" in it }) + } + + @Test fun theInstallContinuesWhenALaterUpdateAttemptSucceeds() { + val (exit, calls) = run(updateSucceedsOnCall = 3) + assertEquals(0, exit) + assertTrue(calls.any { "install -y --no-install-recommends" in it }) + assertTrue("harness-installed" in calls.last()) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/core/DeviceReportExitTest.kt b/app/src/test/java/com/droiddeck/launcher/core/DeviceReportExitTest.kt index 733b1e4d7a..1552e24f95 100644 --- a/app/src/test/java/com/droiddeck/launcher/core/DeviceReportExitTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/core/DeviceReportExitTest.kt @@ -11,6 +11,7 @@ class DeviceReportExitTest { assertEquals("CRASH_NATIVE", DeviceReport.exitReasonName(5)) assertEquals("EXCESSIVE_RESOURCE_USAGE", DeviceReport.exitReasonName(9)) assertEquals("FREEZER", DeviceReport.exitReasonName(14)) + assertEquals("MEMORY_LIMITER", DeviceReport.exitReasonName(17)) } @Test fun anUnknownCodeStillShowsItsNumber() { diff --git a/app/src/test/java/com/droiddeck/launcher/core/GameEnvironmentTest.kt b/app/src/test/java/com/droiddeck/launcher/core/GameEnvironmentTest.kt index 219ecad5a1..f4a27ea825 100644 --- a/app/src/test/java/com/droiddeck/launcher/core/GameEnvironmentTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/core/GameEnvironmentTest.kt @@ -20,6 +20,24 @@ class GameEnvironmentTest { assertEquals("1", GameEnvironment.effective(config, "", "43", forceSsbs = true)[GameEnvironment.FORCE_SSBS]) } + @Test fun knownGameFixesBeatSharedSettingsButNotTheGamesOwn() { + val shared = GameEnvironment.Config(shared = mapOf("FEX_X87REDUCEDPRECISION" to "1")) + assertEquals("0", GameEnvironment.effective(shared, "PERFORMANCE_TSO", "12100")["FEX_X87REDUCEDPRECISION"]) + assertEquals("1", GameEnvironment.effective(shared, "PERFORMANCE_TSO", "12110")["FEX_X87REDUCEDPRECISION"]) + val own = shared.withEntries("12100", mapOf("FEX_X87REDUCEDPRECISION" to "1")) + assertEquals("1", GameEnvironment.effective(own, "PERFORMANCE_TSO", "12100")["FEX_X87REDUCEDPRECISION"]) + assertEquals("1", GameEnvironment.withKnownGames(own).games["12100"]?.get("FEX_X87REDUCEDPRECISION")) + assertEquals("0", GameEnvironment.withKnownGames(shared).games["12100"]?.get("FEX_X87REDUCEDPRECISION")) + } + + @Test fun aGamePresetKeepsTheGamesKnownFix() { + val picked = GameEnvironment.withGameFexPreset(GameEnvironment.Config(), "12100", "PERFORMANCE") + assertEquals("0", GameEnvironment.effective(picked, "PERFORMANCE_TSO", "12100")["FEX_X87REDUCEDPRECISION"]) + assertEquals("PERFORMANCE", GameEnvironment.gameFexPreset(picked, "12100")) + val other = GameEnvironment.withGameFexPreset(GameEnvironment.Config(), "12110", "PERFORMANCE") + assertEquals("1", GameEnvironment.effective(other, "PERFORMANCE_TSO", "12110")["FEX_X87REDUCEDPRECISION"]) + } + @Test fun gameOverridesSharedAndPresetWithoutLeakingToOtherGames() { val config = GameEnvironment.Config( shared = mapOf("FEX_MULTIBLOCK" to "0", "VKD3D_FEATURE_LEVEL" to "12_2"), diff --git a/app/src/test/java/com/droiddeck/launcher/files/AllFilesAccessTest.kt b/app/src/test/java/com/droiddeck/launcher/files/AllFilesAccessTest.kt index a5eba9c3e0..0737cac0f7 100644 --- a/app/src/test/java/com/droiddeck/launcher/files/AllFilesAccessTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/files/AllFilesAccessTest.kt @@ -21,4 +21,20 @@ class AllFilesAccessTest { assertTrue(AllFilesAccess.missing(sdk = 35) { false }) assertFalse(AllFilesAccess.missing(sdk = 35) { true }) } + + @Test + fun onlySharedStorageNeedsIt() { + assertTrue(AllFilesAccess.covers("/storage/emulated/0")) + assertTrue(AllFilesAccess.covers("/storage/1A2B-3C4D/Games")) + assertTrue(AllFilesAccess.covers("/sdcard/Download")) + assertFalse(AllFilesAccess.covers("/storage/emulated/0/Android/data")) + assertFalse(AllFilesAccess.covers("/storage/1A2B-3C4D/Android/obb")) + assertTrue(AllFilesAccess.covers("/storage/emulated/0/Android")) + assertTrue(AllFilesAccess.covers("/storage/emulated/0/Android/database")) + assertTrue(AllFilesAccess.covers("/storage/emulated/0/Download/Android/data")) + assertTrue(AllFilesAccess.covers("/storage/1A2B-3C4D/Games/Android/obb/x")) + assertFalse(AllFilesAccess.covers("/storage/emulated/0/Android/data/com.droiddeck.launcher/files")) + assertFalse(AllFilesAccess.covers("/storage/1A2B-3C4D/Android/obb/com.droiddeck.launcher")) + assertFalse(AllFilesAccess.covers("/data/user/0/com.droiddeck.launcher/files")) + } } diff --git a/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesCandidatesTest.kt b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesCandidatesTest.kt index f2881c712f..c55b2e1557 100644 --- a/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesCandidatesTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesCandidatesTest.kt @@ -145,4 +145,15 @@ class AddedGamesCandidatesTest { SessionPrefs.setAddedGamesDirs(app, listOf(games.path)) assertEquals("My Game [Repack]", AddedGames.scan(app).single().name) } + + @Test fun linksAndFoldersNamedLikeAnExeAreNotCandidates() { + val elsewhere = tmp.newFolder("Elsewhere") + exe(elsewhere, "Other.exe") + val game = tmp.newFolder("Linked") + exe(game, "bin/Linked.exe") + File(game, "Folder.exe").mkdirs() + java.nio.file.Files.createSymbolicLink(File(game, "other").toPath(), elsewhere.toPath()) + java.nio.file.Files.createSymbolicLink(File(game, "Alias.exe").toPath(), File(elsewhere, "Other.exe").toPath()) + assertEquals(listOf("bin/Linked.exe"), names(game)) + } } diff --git a/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesSessionListingTest.kt b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesSessionListingTest.kt new file mode 100644 index 0000000000..2dffb85772 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesSessionListingTest.kt @@ -0,0 +1,213 @@ +package com.droiddeck.launcher.frontend + +import com.droiddeck.launcher.session.SessionPhase +import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.session.SessionState +import com.droiddeck.launcher.stores.SteamLiveShortcuts +import java.io.File +import java.util.Collections +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit +import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.RuntimeEnvironment +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33]) +class AddedGamesSessionListingTest { + private val app get() = RuntimeEnvironment.getApplication() + @get:Rule val tmp = TemporaryFolder() + + @After fun restore() { + AddedGamesPublisher.now = false + AddedGamesPublisher.live = SteamLiveShortcuts::sync + SessionState.running = false + SessionState.stopRequested = false + SessionState.sessionId = null + SessionState.phase = SessionPhase.IDLE + } + + private val stale = """[{"name":"Old","exe":"/root/Games/Old/Old.exe","folder":"/root/Games/Old","dir":"/root/Games/Old","appid":2147483649,"seen":0}]""" + + private fun gamesFolder(vararg names: String): File { + val games = tmp.newFolder("PC") + for (n in names) File(games, "$n/$n.exe").apply { parentFile!!.mkdirs() }.writeText("game") + SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "") + SessionPrefs.setAddedGamesDirs(app, listOf(games.path)) + return games + } + + private fun session(phase: SessionPhase) { + SessionState.sessionId = "session-test" + SessionState.stopRequested = false + SessionState.phase = phase + SessionState.running = true + } + + private fun until(what: String, check: () -> Boolean) { + val end = System.currentTimeMillis() + 30_000 + while (!check()) { + assertTrue(what, System.currentTimeMillis() < end) + Thread.sleep(20) + } + } + + private fun scanLock(): Any = + AddedGames::class.java.getDeclaredField("scanning").apply { isAccessible = true }.get(null)!! + + private fun refreshes() = Thread.getAllStackTraces().keys.filter { it.name == "added-games-refresh" } + + @Test fun aSessionStartsFromTheLastListingWhileTheLibraryScanHoldsTheLock() { + gamesFolder("Alpha") + val listing = AddedGames.listingFile(app).apply { parentFile!!.mkdirs(); writeText(stale) } + val done = CountDownLatch(1) + var returned: File? = null + var seen = "" + synchronized(scanLock()) { + Thread { + returned = AddedGamesPublisher.sessionListing(app) + seen = listing.readText() + done.countDown() + }.start() + assertTrue("the session start waited for the library scan", done.await(5, TimeUnit.SECONDS)) + } + assertEquals(listing.path, returned!!.path) + assertEquals(stale, seen) + refreshes().forEach { it.join(30_000) } + assertTrue(refreshes().isEmpty()) + val fresh = listing.readText() + assertTrue(fresh.contains("\"Alpha\"")) + assertFalse(fresh.contains("\"Old\"")) + assertFalse(File(listing.parentFile, listing.name + ".part").exists()) + } + + @Test fun aFirstSessionScansBeforeStarting() { + gamesFolder("Alpha") + AddedGamesPublisher.now = false + val listing = AddedGames.listingFile(app) + listing.delete() + assertEquals(listing.path, AddedGamesPublisher.sessionListing(app).path) + assertTrue(listing.readText().contains("\"Alpha\"")) + assertTrue(refreshes().isEmpty()) + assertFalse(File(listing.parentFile, listing.name + ".part").exists()) + } + + @Test fun aListingThatCannotBeReplacedKeepsTheOldOne() { + val listing = AddedGames.listingFile(app).apply { parentFile?.mkdirs() } + listing.writeText("[]") + val blocked = File(listing.parentFile, listing.name + ".part").apply { mkdirs() } + gamesFolder("Alpha") + AddedGames.writeListing(app, AddedGames.scan(app)) + assertEquals("[]", listing.readText()) + assertFalse(blocked.exists()) + } + + @Test fun anUnreadableListingIsRescannedBeforeStarting() { + gamesFolder("Alpha") + AddedGamesPublisher.now = false + val listing = AddedGames.listingFile(app).apply { parentFile!!.mkdirs(); writeText("[{\"name\":") } + AddedGamesPublisher.sessionListing(app) + assertTrue(listing.readText().contains("\"Alpha\"")) + assertTrue(refreshes().isEmpty()) + } + + @Test fun aGameRemovedWhileTheClientStartsIsNotAddedToIt() { + val games = gamesFolder("Alpha", "Beta") + val listing = AddedGames.listingFile(app).apply { parentFile!!.mkdirs(); writeText(stale) } + val delivered = Collections.synchronizedList(ArrayList()) + AddedGamesPublisher.live = { _, found, include -> delivered.addAll(found.filter(include).map { it.name }); true } + session(SessionPhase.STARTING_STEAM) + AddedGamesPublisher.sessionListing(app) + until("the refresh did not write the listing") { listing.readText().contains("\"Beta\"") } + SessionPrefs.setAddedGameRemoved(app, File(games, "Beta").path, true) + SessionState.phase = SessionPhase.READY + refreshes().forEach { it.join(30_000) } + assertTrue(refreshes().isEmpty()) + assertEquals(listOf("Alpha"), delivered.toList()) + } + + @Test fun aDeliveryTheClientRefusesIsRetriedUntilItIsTaken() { + gamesFolder("Alpha") + AddedGames.listingFile(app).apply { parentFile!!.mkdirs(); writeText(stale) } + val attempts = Collections.synchronizedList(ArrayList>()) + AddedGamesPublisher.live = { _, found, include -> attempts.add(found.filter(include).map { it.name }); attempts.size > 1 } + session(SessionPhase.READY) + AddedGamesPublisher.sessionListing(app) + refreshes().forEach { it.join(30_000) } + assertTrue(refreshes().isEmpty()) + assertEquals(listOf(listOf("Alpha"), listOf("Alpha")), attempts.toList()) + } + + @Test fun anEndedSessionStopsTheRetries() { + gamesFolder("Alpha") + AddedGames.listingFile(app).apply { parentFile!!.mkdirs(); writeText(stale) } + val attempts = Collections.synchronizedList(ArrayList()) + AddedGamesPublisher.live = { _, found, _ -> attempts.addAll(found.map { it.name }); SessionState.running = false; false } + session(SessionPhase.READY) + AddedGamesPublisher.sessionListing(app) + refreshes().forEach { it.join(30_000) } + assertTrue(refreshes().isEmpty()) + assertEquals(listOf("Alpha"), attempts.toList()) + } + + @Test fun aDeliveryQueuedForAnEndedSessionIsNotSentToTheNextOne() { + gamesFolder("Alpha") + AddedGames.listingFile(app).apply { parentFile!!.mkdirs(); writeText(stale) } + val delivered = Collections.synchronizedList(ArrayList()) + AddedGamesPublisher.live = { _, found, include -> delivered.addAll(found.filter(include).map { it.name }); true } + session(SessionPhase.READY) + val first = CountDownLatch(1) + val firstHeld = CountDownLatch(1) + val second = CountDownLatch(1) + val secondHeld = CountDownLatch(1) + AddedGamesPublisher.later(app) { firstHeld.countDown(); first.await() } + try { + assertTrue(firstHeld.await(30, TimeUnit.SECONDS)) + AddedGamesPublisher.sessionListing(app) + val refresh = refreshes().single() + until("the refresh did not wait for its scan") { refresh.state == Thread.State.WAITING } + AddedGamesPublisher.later(app) { secondHeld.countDown(); second.await() } + first.countDown() + assertTrue(secondHeld.await(30, TimeUnit.SECONDS)) + until("the refresh did not queue its delivery") { + refresh.state == Thread.State.WAITING && refresh.stackTrace.any { it.methodName == "deliver" } + } + SessionState.sessionId = "session-next" + } finally { + first.countDown() + second.countDown() + } + refreshes().forEach { it.join(30_000) } + assertTrue(refreshes().isEmpty()) + assertTrue(delivered.isEmpty()) + } + + @Test fun theRefreshWaitsForEarlierPublicationsBeforeWriting() { + gamesFolder("Alpha") + val listing = AddedGames.listingFile(app).apply { parentFile!!.mkdirs(); writeText(stale) } + val hold = CountDownLatch(1) + val holding = CountDownLatch(1) + AddedGamesPublisher.later(app) { holding.countDown(); hold.await() } + try { + assertTrue(holding.await(30, TimeUnit.SECONDS)) + AddedGamesPublisher.sessionListing(app) + val refresh = refreshes().single() + until("the refresh neither finished nor waited") { refresh.state == Thread.State.WAITING || !refresh.isAlive } + assertTrue("the refresh wrote while an earlier publication was running", refresh.isAlive) + assertEquals(stale, listing.readText()) + } finally { + hold.countDown() + } + refreshes().forEach { it.join(30_000) } + assertTrue(refreshes().isEmpty()) + assertTrue(listing.readText().contains("\"Alpha\"")) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesStoreScanTest.kt b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesStoreScanTest.kt index 8cbe467864..ab93d40d40 100644 --- a/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesStoreScanTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesStoreScanTest.kt @@ -103,6 +103,23 @@ class AddedGamesStoreScanTest { assertTrue(listing.contains("\"store\":\"${Store.EPIC.id}\"")) } + @Test fun anEaGamesSavedLaunchOptionsReachTheListingAndOtherStoresIgnoreThem() { + val ea = install(Store.EA, "Origin.OFR.1", "Burnout Paradise", "bin/Game.exe", launcher = true) + val gog = install(Store.GOG, "42", "Plain Gog", "Game.exe") + AddedGames.scan(app) + AddedGameEdits.setLaunchOptions(app, ea.path, "-dx11") + AddedGameEdits.setLaunchOptions(app, gog.path, "-ignored") + val games = AddedGames.scan(app) + assertEquals("-dx11", games.single { it.folder.absolutePath == ea.absolutePath }.launchOptions) + assertEquals("", games.single { it.folder.absolutePath == gog.absolutePath }.launchOptions) + assertTrue(AddedGames.writeListing(app, games).readText().contains("\"launch\":\"-dx11\"")) + } + + @Test fun anEaGameWithoutSavedLaunchOptionsHasNone() { + val ea = install(Store.EA, "Origin.OFR.2", "Other EA", "bin/Game.exe", launcher = true) + assertEquals("", AddedGames.scan(app).single { it.folder.absolutePath == ea.absolutePath }.launchOptions) + } + // GOG runs a task from its declared working directory; the install root when it declares none. @Test fun aTaskWorkingDirectoryBecomesTheShortcutsStartIn() { val folder = install(Store.GOG, "1207658924", "Witcher Game", "System/witcher.exe", workdir = "System") diff --git a/app/src/test/java/com/droiddeck/launcher/frontend/GameLaunchIntentTest.kt b/app/src/test/java/com/droiddeck/launcher/frontend/GameLaunchIntentTest.kt index 63b6807c0f..8011f23518 100644 --- a/app/src/test/java/com/droiddeck/launcher/frontend/GameLaunchIntentTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/frontend/GameLaunchIntentTest.kt @@ -20,6 +20,22 @@ class GameLaunchIntentTest { } } + @Test fun aLinkIsReplayedOnlyWhenANewProcessRestoresItOrRecentsReopensIt() { + val link = Intent(Intent.ACTION_VIEW) + assertFalse(GameLaunchIntent.replayed(link, restored = false, savedProcess = null, process = "b")) + assertFalse(GameLaunchIntent.replayed(link, restored = true, savedProcess = "b", process = "b")) + assertTrue(GameLaunchIntent.replayed(link, restored = true, savedProcess = "a", process = "b")) + assertTrue(GameLaunchIntent.replayed(link, restored = true, savedProcess = null, process = "b")) + val fromRecents = Intent(link).addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) + assertTrue(GameLaunchIntent.replayed(fromRecents, restored = false, savedProcess = null, process = "b")) + assertTrue(GameLaunchIntent.replayed(fromRecents, restored = true, savedProcess = "b", process = "b")) + val settings = Intent(Intent.ACTION_VIEW, android.net.Uri.parse("droiddeck://settings/storage")) + .addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) + assertFalse(GameLaunchIntent.replayed(settings, restored = true, savedProcess = "a", process = "b")) + assertTrue(GameLaunchIntent.replayed(Intent(Intent.ACTION_VIEW, android.net.Uri.parse("droiddeck://game/620")), + restored = true, savedProcess = "a", process = "b")) + } + @Test fun longAndStringIdsPreserveUnsignedShortcutIds() { listOf("2147483648", "18446744073709551615").forEach { id -> assertEquals(id, GameLaunchIntent.readExtras(Intent(GameLaunchIntent.ACTION).putExtra("app_id", id))?.id) diff --git a/app/src/test/java/com/droiddeck/launcher/gpu/SocNamesTest.kt b/app/src/test/java/com/droiddeck/launcher/gpu/SocNamesTest.kt index cc530fae49..8715069bd7 100644 --- a/app/src/test/java/com/droiddeck/launcher/gpu/SocNamesTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/gpu/SocNamesTest.kt @@ -16,12 +16,20 @@ class SocNamesTest { @Test fun knownModelsAndPlatformsGetTheirNames() { assertEquals("Snapdragon 8 Gen 2", SocNames.name("QCS8550", "")) - assertEquals("Snapdragon 8 Gen 3 family", SocNames.name("SG8350P", "pineapple")) + assertEquals("Snapdragon G3 Gen 3", SocNames.name("SG8350P", "pineapple")) assertNull(SocNames.name("XYZ123", "nowhere")) assertEquals("Snapdragon 8 Gen 2 (QCS8550)", SocNames.label("QCS8550", "")) - assertEquals("Snapdragon 8 Gen 3 family (SG8350P)", SocNames.label("SG8350P", "pineapple")) + assertEquals("Snapdragon G3 Gen 3 (SG8350P)", SocNames.label("SG8350P", "pineapple")) assertEquals("XYZ123", SocNames.label("XYZ123", "")) } + @Test fun platformFamilyOnlyForPhonePartsOrNoModel() { + assertEquals("Dragonwing Q-7790", SocNames.name("CQ7790S", "sun")) + assertNull(SocNames.name("CQ1234X", "sun")) + assertEquals("Snapdragon 8 Elite family", SocNames.name("SM9999", "sun")) + assertEquals("Snapdragon 8 Elite family", SocNames.name("", "sun")) + assertEquals("Snapdragon 8 Elite Gen 5 family", SocNames.name("", "canoe")) + } + @Test fun qtiPrefixIsNormalizedWithoutGuessingOtherModelVariants() { assertEquals("Snapdragon 8 Elite Extreme Gen 6", SocNames.name("SM8975", "")) assertEquals("Snapdragon 8 Elite Extreme Gen 6", SocNames.name("QTI SM8975", "")) @@ -34,7 +42,8 @@ class SocNamesTest { } @Test fun plainNameNeverGuessesFromThePlatform() { assertEquals("Snapdragon 8 Gen 2 (SM8550)", SocNames.plainName("SM8550", "QTI")) - assertEquals("Moorechip CQ7790S", SocNames.plainName("CQ7790S", "Moorechip")) - assertEquals("CQ7790S", SocNames.plainName("CQ7790S", "")) + assertEquals("Dragonwing Q-7790 (CQ7790S)", SocNames.plainName("CQ7790S", "Moorechip")) + assertEquals("Moorechip CQ1234X", SocNames.plainName("CQ1234X", "Moorechip")) + assertEquals("CQ1234X", SocNames.plainName("CQ1234X", "")) } } diff --git a/app/src/test/java/com/droiddeck/launcher/hud/DroidDeckHudPanelTest.kt b/app/src/test/java/com/droiddeck/launcher/hud/DroidDeckHudPanelTest.kt index f638ea4afe..54d3e5584e 100644 --- a/app/src/test/java/com/droiddeck/launcher/hud/DroidDeckHudPanelTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/hud/DroidDeckHudPanelTest.kt @@ -34,8 +34,8 @@ class DroidDeckHudPanelTest { assertEquals(DroidDeckHudSize.MINIMAL, DroidDeckHudSize.from(DroidDeckHudConfig.DEFAULTS["hudSize"])) } - @Test fun theHudStartsLocked() { - assertEquals("1", DroidDeckHudConfig.DEFAULTS["hudLocked"]) + @Test fun theHudStartsUnlocked() { + assertEquals("0", DroidDeckHudConfig.DEFAULTS["hudLocked"]) } @Test fun aLongPressCollapsesTheHudUnlessTheUserChoseToLockWithIt() { diff --git a/app/src/test/java/com/droiddeck/launcher/input/BackQamInputTest.kt b/app/src/test/java/com/droiddeck/launcher/input/BackQamInputTest.kt index db813c62df..7a36fe01b0 100644 --- a/app/src/test/java/com/droiddeck/launcher/input/BackQamInputTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/input/BackQamInputTest.kt @@ -63,6 +63,46 @@ class BackQamInputTest { } } + @Test fun anAtOnceSingleTapActsOnReleaseAndADoubleTapStillFollows() { + val direct = BackQamInput(changes::add, taps::add, atOnce = { true }) + fun press(action: Int) = direct.onKeyEvent(KeyEvent(action, KeyEvent.KEYCODE_BACK), true) + press(KeyEvent.ACTION_DOWN) + assertTrue(taps.isEmpty()) + press(KeyEvent.ACTION_UP) + assertEquals(listOf(false), taps) + assertTrue(direct.awaitingTap) + advance(300) + press(KeyEvent.ACTION_DOWN) + advance(400) + assertTrue(direct.awaitingTap) + press(KeyEvent.ACTION_UP) + assertEquals(listOf(false, true), taps) + assertFalse(direct.awaitingTap) + assertTrue(changes.isEmpty()) + } + + @Test fun cancellingOnlyTheTapKeepsAPressThatIsAlreadyDown() { + val direct = BackQamInput(changes::add, taps::add, atOnce = { true }) + fun press(action: Int) = direct.onKeyEvent(KeyEvent(action, KeyEvent.KEYCODE_BACK), true) + press(KeyEvent.ACTION_DOWN) + press(KeyEvent.ACTION_UP) + advance(100) + press(KeyEvent.ACTION_DOWN) + direct.cancelTap() + assertFalse(direct.awaitingTap) + press(KeyEvent.ACTION_UP) + assertEquals(listOf(false, false), taps) + } + + @Test fun anAtOnceTapStopsAwaitingWhenTheWindowEnds() { + val direct = BackQamInput(changes::add, taps::add, atOnce = { true }) + direct.onKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK), true) + direct.onKeyEvent(KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK), true) + advance(500) + assertFalse(direct.awaitingTap) + assertEquals(listOf(false), taps) + } + @Test fun aHoldStartsAt700msAndNeverProducesATap() { assertTrue(send(KeyEvent.ACTION_DOWN)) advance(699) @@ -191,6 +231,19 @@ class BackQamInputTest { assertTrue(taps.isEmpty()) } + @Test fun cancellingHeldInputCanKeepThePendingTapForTheDoubleAction() { + val direct = BackQamInput(changes::add, taps::add, atOnce = { true }) + fun press(action: Int) = direct.onKeyEvent(KeyEvent(action, KeyEvent.KEYCODE_BACK), true) + press(KeyEvent.ACTION_DOWN) + press(KeyEvent.ACTION_UP) + direct.cancel(keepTap = true) + assertTrue(direct.awaitingTap) + press(KeyEvent.ACTION_DOWN) + press(KeyEvent.ACTION_UP) + assertEquals(listOf(false, true), taps) + assertFalse(direct.awaitingTap) + } + @Test fun cancellationAlsoDiscardsAPendingSingleTap() { send(KeyEvent.ACTION_DOWN) send(KeyEvent.ACTION_UP) diff --git a/app/src/test/java/com/droiddeck/launcher/input/BackTapsTest.kt b/app/src/test/java/com/droiddeck/launcher/input/BackTapsTest.kt new file mode 100644 index 0000000000..52700c89f4 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/input/BackTapsTest.kt @@ -0,0 +1,133 @@ +package com.droiddeck.launcher.input + +import android.os.Looper +import java.time.Duration +import org.junit.Assert.* +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.Shadows.shadowOf +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [34], manifest = Config.NONE) +class BackTapsTest { + private val seen = mutableListOf() + private var atOnce = true + private var window = 500L + private val taps = BackTaps({ window }, { atOnce }, seen::add) + + @Test fun aSingleTapActsWithoutWaitingForTheWindow() { + taps.tap() + assertEquals(listOf(false), seen) + assertTrue(taps.pending) + advance(500) + assertEquals(listOf(false), seen) + assertFalse(taps.pending) + } + + @Test fun aSecondTapInsideTheWindowAddsTheDoubleAction() { + taps.tap() + advance(499) + taps.tap() + assertEquals(listOf(false, true), seen) + assertFalse(taps.pending) + advance(1000) + assertEquals(listOf(false, true), seen) + } + + @Test fun aTapAfterTheWindowIsANewSingleTap() { + taps.tap() + advance(500) + taps.tap() + assertEquals(listOf(false, false), seen) + } + + @Test fun aDeferredSingleTapWaitsForTheWindow() { + atOnce = false + taps.tap() + advance(499) + assertTrue(seen.isEmpty()) + advance(1) + assertEquals(listOf(false), seen) + } + + @Test fun aDeferredDoubleTapProducesOnlyTheDoubleAction() { + atOnce = false + taps.tap() + advance(100) + taps.tap() + advance(1000) + assertEquals(listOf(true), seen) + } + + @Test fun theConfiguredWindowAppliesInBothModes() { + for (mode in listOf(true, false)) for (ms in listOf(100L, 800L)) { + seen.clear() + atOnce = mode + window = ms + taps.tap() + advance(ms - 1) + taps.tap() + assertEquals(true, seen.last()) + advance(ms) + assertFalse(taps.pending) + } + } + + @Test fun holdKeepsTheWindowOpenUntilTheNextTap() { + taps.tap() + advance(400) + taps.hold() + advance(5000) + assertTrue(taps.pending) + taps.tap() + assertEquals(listOf(false, true), seen) + } + + @Test fun cancelDropsADeferredTapAndClosesTheWindow() { + atOnce = false + taps.tap() + taps.cancel() + advance(1000) + assertTrue(seen.isEmpty()) + assertFalse(taps.pending) + taps.tap() + advance(500) + assertEquals(listOf(false), seen) + } + + @Test fun aDoubleTapWhoseActionMatchesTheImmediateSingleTapIsNotRepeated() { + var same = true + val coalesced = BackTaps({ window }, { atOnce }, seen::add, { same }) + coalesced.tap() + coalesced.tap() + assertEquals(listOf(false), seen) + assertFalse(coalesced.pending) + same = false + coalesced.tap() + coalesced.tap() + assertEquals(listOf(false, false, true), seen) + } + + @Test fun aDeferredDoubleTapStillActsWhenBothActionsMatch() { + atOnce = false + val coalesced = BackTaps({ window }, { atOnce }, seen::add, { true }) + coalesced.tap() + coalesced.tap() + advance(1000) + assertEquals(listOf(true), seen) + } + + @Test fun aHeldTapCancelledBeforeItsReleaseLeavesTheNextTapASingleTap() { + val coalesced = BackTaps({ window }, { atOnce }, seen::add, { true }) + coalesced.tap() + coalesced.hold() + coalesced.cancel() + advance(5000) + coalesced.tap() + assertEquals(listOf(false, false), seen) + } + + private fun advance(ms: Long) = shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(ms)) +} diff --git a/app/src/test/java/com/droiddeck/launcher/input/DirectTouchHoldTest.kt b/app/src/test/java/com/droiddeck/launcher/input/DirectTouchHoldTest.kt index 20c7fe451f..fbfa3ddd76 100644 --- a/app/src/test/java/com/droiddeck/launcher/input/DirectTouchHoldTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/input/DirectTouchHoldTest.kt @@ -201,6 +201,25 @@ class DirectTouchHoldTest { ) } + @Test fun aDragLiftsAtOnce() { + touch(MotionEvent.ACTION_DOWN) + touch(MotionEvent.ACTION_MOVE, 80f) + advance(80) + touches.clear() + touch(MotionEvent.ACTION_UP, 80f) + assertEquals(listOf("up 0 at 80.0,30.0"), touches) + } + + @Test fun aTapStaysPressedLongEnoughToBeSeen() { + touch(MotionEvent.ACTION_DOWN) + advance(10) + touch(MotionEvent.ACTION_UP) + advance(49) + assertEquals(listOf("down 0 at 40.0,30.0"), touches) + advance(1) + assertEquals(listOf("down 0 at 40.0,30.0", "up 0 at 40.0,30.0"), touches) + } + private fun advance(ms: Long) = shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(ms)) private fun touch(action: Int, x: Float = 40f): Boolean { val event = MotionEvent.obtain(0, 0, action, x, 30f, 0) diff --git a/app/src/test/java/com/droiddeck/launcher/input/InputProfilesTest.kt b/app/src/test/java/com/droiddeck/launcher/input/InputProfilesTest.kt index e5fc41f09a..1751c6dd54 100644 --- a/app/src/test/java/com/droiddeck/launcher/input/InputProfilesTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/input/InputProfilesTest.kt @@ -50,6 +50,8 @@ class InputProfilesTest { @Test fun bindingsAndDeviceKeysRoundTripWithoutAffectingOtherProfile() { val game = InputProfile.defaults(InputProfile.GAME) .withBinding(InputRole.SECONDARY, InputControl.A, InputAction.Keys(listOf(29, 30))) + .withBinding(InputRole.PRIMARY, InputControl.Y, InputAction.Command(InputCommand.GAME_ZOOM_IN)) + .withBinding(InputRole.PRIMARY, InputControl.B, InputAction.Command(InputCommand.GAME_ZOOM_OUT)) .copy(keys = listOf(PhysicalInputBinding(PhysicalInputKey("1:2:descriptor", "Thor", 131, 59), InputAction.Command(InputCommand.MENU)))) InputProfiles.save(context, game) assertEquals(game, InputProfiles.read(context, InputProfile.GAME)) diff --git a/app/src/test/java/com/droiddeck/launcher/input/OnScreenLayoutTest.kt b/app/src/test/java/com/droiddeck/launcher/input/OnScreenLayoutTest.kt index 1fa557b6d9..3b02f4db38 100644 --- a/app/src/test/java/com/droiddeck/launcher/input/OnScreenLayoutTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/input/OnScreenLayoutTest.kt @@ -96,6 +96,115 @@ class OnScreenLayoutTest { } } + @Test fun changingControllerSizeRegeneratesAnUneditedBuiltInLandscapeOverlay() { + SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK) + val layout = gamepad() + val w = 1200 + val h = 540 + ControllerPrefs.setSize(context, 100) + val original = OnScreenLayout.elements(context, layout, w, h, Rect()) + ControllerPrefs.setSize(context, 115) + val resized = OnScreenLayout.elements(context, layout, w, h, Rect()) + assertNotEquals(original.single { it.id == "legacy:a" }.width, resized.single { it.id == "legacy:a" }.width, .0001f) + assertNotEquals(original.single { it.id == "legacy:ls" }.height, resized.single { it.id == "legacy:ls" }.height, .0001f) + } + + @Test fun unchangedSizeDoesNotCollapseCoincidentEditedPortraitControls() { + SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK) + val stock = gamepad() + val coincident = stock.elements.map { element -> + if (element.id == "legacy:a" || element.id == "legacy:b") { + element.copy(x = .2f, y = .2f, width = .1f, height = .1f) + } else element + } + val edited = stock.copy(elements = coincident, aspect = .5f) + ControllerPrefs.setSize(context, 100) + val placed = OnScreenLayout.elements( + context, edited, 540, 1080, Rect(), + dock = OnScreenLayout.Dock(true, false), + ) + assertTrue(placed.at(InputControl.A).width > 0f) + assertTrue(placed.at(InputControl.B).width > 0f) + } + + @Test fun changingControllerSizeResizesDefaultDockedControlsWithoutASavedLayout() { + SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK) + val layout = gamepad() + val w = 1200 + val h = 540 + val dock = OnScreenLayout.Dock(false, false) + ControllerPrefs.setSize(context, 100) + val original = OnScreenLayout.elements(context, layout, w, h, Rect(), dock = dock) + ControllerPrefs.setSize(context, 125) + val resized = OnScreenLayout.elements(context, layout, w, h, Rect(), dock = dock) + assertNotEquals(original.at(InputControl.LS).width, resized.at(InputControl.LS).width, .0001f) + assertNotEquals(original.at(InputControl.A).height, resized.at(InputControl.A).height, .0001f) + assertInside(resized, w, h) + } + + @Test fun changingControllerSizeRegeneratesSavedLandscapeBuiltInOverlay() { + SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK) + val layout = gamepad().copy(aspect = 2f) + val w = 1200 + val h = 540 + ControllerPrefs.setSize(context, 100) + val original = OnScreenLayout.elements(context, layout, w, h, Rect()) + ControllerPrefs.setSize(context, 125) + val resized = OnScreenLayout.elements(context, layout, w, h, Rect()) + assertNotEquals(original.at(InputControl.A).width, resized.at(InputControl.A).width, .0001f) + } + + @Test fun enlargedDefaultDockedControlsDoNotOverlapTheActionButtonAndRightStick() { + SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK) + ControllerPrefs.setSize(context, 125) + val placed = OnScreenLayout.elements( + context, gamepad(), 1200, 540, Rect(), + dock = OnScreenLayout.Dock(false, false), + ) + val stick = placed.at(InputControl.RS) + val button = placed.at(InputControl.A) + val overlapX = minOf(stick.x + stick.width, button.x + button.width) - maxOf(stick.x, button.x) + val overlapY = minOf(stick.y + stick.height, button.y + button.height) - maxOf(stick.y, button.y) + assertFalse("RS and A hit rectangles must not overlap", overlapX > 0f && overlapY > 0f) + } + + @Test fun changingControllerSizeResizesDockedControlsWithASavedLayout() { + SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK) + val layout = gamepad() + val w = 1200 + val h = 540 + ControllerPrefs.setLayout(context, w, h, mapOf("ls" to (.12f to .7f))) + val dock = OnScreenLayout.Dock(false, false) + ControllerPrefs.setSize(context, 100) + val original = OnScreenLayout.elements(context, layout, w, h, Rect(), dock = dock) + ControllerPrefs.setSize(context, 120) + val resized = OnScreenLayout.elements(context, layout, w, h, Rect(), dock = dock) + val before = original.single { it.id == "legacy:a" } + val after = resized.single { it.id == "legacy:a" } + assertTrue(after.width > before.width) + assertTrue(after.height > before.height) + assertEquals(before.x + before.width / 2f, after.x + after.width / 2f, .001f) + assertEquals(before.y + before.height / 2f, after.y + after.height / 2f, .001f) + assertEquals(mapOf("ls" to (.12f to .7f)), ControllerPrefs.layout(context, w, h)) + } + + @Test fun enlargedDockedControlsStayInsideSafeAreaAndKeepShoulderGaps() { + SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_DECK) + val w = 1080 + val h = 200 + val safe = Rect(20, 0, 20, 24) + ControllerPrefs.setLayout(context, w, h, mapOf("ls" to (.12f to .7f))) + ControllerPrefs.setSize(context, 125) + val placed = OnScreenLayout.elements(context, gamepad(), w, h, safe, dock = OnScreenLayout.Dock(false, false)) + assertInside(placed, w, h, safe) + for ((left, right) in listOf(InputControl.LT to InputControl.LB, InputControl.RB to InputControl.RT)) { + val a = placed.single { it.control == left } + val b = placed.single { it.control == right } + assertTrue("$left should remain left of $right", a.x + a.width <= b.x) + assertTrue("$left and $right should retain a gap", (b.x - a.x - a.width) * w >= 3.5f) + } + } + @Test @Config(qualifiers = "w745dp-h343dp-land-420dpi") fun aBuiltInGamepadSavedAtTheDisplaySizeRegeneratesForTheMeasuredSurface() { SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_NONE) @@ -227,6 +336,16 @@ class OnScreenLayoutTest { } } + @Test fun dockedControlsStayInsideTheSafeAreaAtTheDefaultSizeWithoutAControllerKit() { + SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_NONE) + ControllerPrefs.setSize(context, 100) + val safe = Rect(40, 0, 60, 24) + for ((w, h) in listOf(1080 to 200, 1200 to 540, 2208 to 800)) { + val placed = OnScreenLayout.elements(context, gamepad(), w, h, safe, dock = OnScreenLayout.Dock(false, false)) + assertInside(placed.filter { it.id.startsWith("legacy:") }, w, h, safe) + } + } + @Test fun anEditedLayoutKeepsItsAspectAndCornersWhenTheScreenRotates() { val corner = InputSurfaceElement(InputControl.A, .85f, .7f, .1f, .2f) val left = InputSurfaceElement(InputControl.LS, .05f, .5f, .2f, .4f) @@ -574,6 +693,12 @@ class OnScreenLayoutTest { val normal = at(1f) for (scale in listOf(.8f, 1.25f)) { val placed = at(scale) + for (control in listOf(InputControl.A, InputControl.B, InputControl.X, InputControl.Y, InputControl.LS, InputControl.RS)) { + val before = normal.at(control) + val after = placed.at(control) + assertEquals("$kit $scale ${control.id} aspect ratio", before.width / before.height, + after.width / after.height, .02f) + } assertEquals("$kit $scale", normal.at(InputControl.A).width * scale, placed.at(InputControl.A).width, .002f) assertEquals("$kit $scale", normal.at(InputControl.LS).height * scale, placed.at(InputControl.LS).height, .002f) if (scale > 1f) for (cluster in listOf(face, dpad)) { @@ -699,4 +824,34 @@ class OnScreenLayoutTest { assertFalse(kit.artwork(layout.elements.first { it.control == InputControl.A }.copy(image = "picture"))) } } + + @Test + fun dockedSizeAppliesWithoutAKitAndToThePortraitCluster() { + SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_NONE) + val stock = gamepad() + val dock = OnScreenLayout.Dock(false, false) + + ControllerPrefs.setSize(context, 100) + val defaultNormal = OnScreenLayout.elements(context, stock, 1200, 540, Rect(), dock = dock) + ControllerPrefs.setSize(context, 125) + val defaultLarge = OnScreenLayout.elements(context, stock, 1200, 540, Rect(), dock = dock) + assertTrue(defaultLarge.at(InputControl.A).width > defaultNormal.at(InputControl.A).width) + + val portraitEdited = stock.copy( + elements = stock.elements.map { + if (it.control == InputControl.A) it.copy(x = it.x + .07f) else it + }, + aspect = .5f, + ) + val portraitDock = OnScreenLayout.Dock(true, false) + ControllerPrefs.setSize(context, 100) + val clusterNormal = OnScreenLayout.elements( + context, portraitEdited, 540, 1200, Rect(), dock = portraitDock, + ) + ControllerPrefs.setSize(context, 125) + val clusterLarge = OnScreenLayout.elements( + context, portraitEdited, 540, 1200, Rect(), dock = portraitDock, + ) + assertTrue(clusterLarge.at(InputControl.A).width > clusterNormal.at(InputControl.A).width) + } } diff --git a/app/src/test/java/com/droiddeck/launcher/input/PadBridgeRoutingTest.kt b/app/src/test/java/com/droiddeck/launcher/input/PadBridgeRoutingTest.kt index ea66f32136..316cf90f90 100644 --- a/app/src/test/java/com/droiddeck/launcher/input/PadBridgeRoutingTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/input/PadBridgeRoutingTest.kt @@ -71,7 +71,7 @@ class PadBridgeRoutingTest { InputDevice.KEYBOARD_TYPE_NONE, id = -1) assertTrue(virtual.isVirtual) assertFalse(PadBridge.isFromController(virtual)) - for (uinputName in listOf("uinput-xiaomi", "uinput-fpc", "uinput_nav")) { + for (uinputName in listOf("uinput-xiaomi", "uinput-fpc", "uinput_nav", "ui-input-xiaomi")) { val phantom = device( InputDevice.SOURCE_GAMEPAD or InputDevice.SOURCE_JOYSTICK, InputDevice.KEYBOARD_TYPE_NONE, diff --git a/app/src/test/java/com/droiddeck/launcher/input/PadPartialAxesTest.kt b/app/src/test/java/com/droiddeck/launcher/input/PadPartialAxesTest.kt index b79e813a9e..0e75de36c0 100644 --- a/app/src/test/java/com/droiddeck/launcher/input/PadPartialAxesTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/input/PadPartialAxesTest.kt @@ -259,7 +259,7 @@ class PadPartialAxesTest { } @Test fun keyTriggerDecision() { - val held = BooleanArray(2) + val held = PadBridge.TriggerKey.slots(1)[0] assertEquals(1f, PadBridge.keyTrigger(0f, true, 0, false, held, 0)) assertEquals(0f, PadBridge.keyTrigger(1f, false, 0, false, held, 0)) assertEquals(0.25f, PadBridge.keyTrigger(0.25f, true, 1, false, held, 0)) @@ -271,6 +271,64 @@ class PadPartialAxesTest { assertEquals(0f, PadBridge.axisTrigger(0f, held, 1)) } + @Test fun keyBeforeAxisOnAFullPullIsOnePress() { + val device = device(MotionEvent.AXIS_GAS) + motion(device) + key(device, KeyEvent.KEYCODE_BUTTON_R2) + assertEquals(1f, pad().rightTrigger) + for (value in listOf(0.1f, 0.3f, 0.6f, 1f, 0.98f)) { + motion(device, MotionEvent.AXIS_GAS to value) + assertEquals(1f, pad().rightTrigger) + } + motion(device, MotionEvent.AXIS_GAS to 0.7f) + assertEquals(0.7f, pad().rightTrigger) + key(device, KeyEvent.KEYCODE_BUTTON_R2, KeyEvent.ACTION_UP) + assertEquals(0.7f, pad().rightTrigger) + motion(device, MotionEvent.AXIS_GAS to 0f) + assertEquals(0f, pad().rightTrigger) + } + + @Test fun releasingDuringTheHandoffFollowsTheAxis() { + val device = device(MotionEvent.AXIS_GAS) + motion(device) + key(device, KeyEvent.KEYCODE_BUTTON_R2) + motion(device, MotionEvent.AXIS_GAS to 0.4f) + assertEquals(1f, pad().rightTrigger) + key(device, KeyEvent.KEYCODE_BUTTON_R2, KeyEvent.ACTION_UP) + assertEquals(0.4f, pad().rightTrigger) + } + + @Test fun movingTriggerAxisStaysAnalogWhenItsKeyFiresFirst() { + val device = device(MotionEvent.AXIS_GAS) + motion(device, MotionEvent.AXIS_GAS to 0.5f) + motion(device, MotionEvent.AXIS_GAS to 0f) + key(device, KeyEvent.KEYCODE_BUTTON_R2) + assertEquals(0f, pad().rightTrigger) + motion(device, MotionEvent.AXIS_GAS to 0.1f) + assertEquals(0.1f, pad().rightTrigger) + motion(device, MotionEvent.AXIS_GAS to 0.35f) + assertEquals(0.35f, pad().rightTrigger) + key(device, KeyEvent.KEYCODE_BUTTON_R2, KeyEvent.ACTION_UP) + motion(device, MotionEvent.AXIS_GAS to 0f) + assertEquals(0f, pad().rightTrigger) + } + + @Test fun triggerSwitchedToDigitalPressesAgainAfterOneSilentPress() { + val device = device(MotionEvent.AXIS_GAS) + motion(device, MotionEvent.AXIS_GAS to 0.5f) + motion(device, MotionEvent.AXIS_GAS to 0f) + key(device, KeyEvent.KEYCODE_BUTTON_R2) + motion(device) + key(device, KeyEvent.KEYCODE_BUTTON_R2, KeyEvent.ACTION_UP) + assertEquals(0f, pad().rightTrigger) + key(device, KeyEvent.KEYCODE_BUTTON_R2) + assertEquals(1f, pad().rightTrigger) + motion(device) + assertEquals(1f, pad().rightTrigger) + key(device, KeyEvent.KEYCODE_BUTTON_R2, KeyEvent.ACTION_UP) + assertEquals(0f, pad().rightTrigger) + } + @Test fun silentTriggerAxesLetTheirKeysPress() { val device = device(MotionEvent.AXIS_LTRIGGER, MotionEvent.AXIS_RTRIGGER) motion(device) @@ -294,11 +352,15 @@ class PadPartialAxesTest { key(device, KeyEvent.KEYCODE_BUTTON_L2) assertEquals(1f, pad().leftTrigger) motion(device, MotionEvent.AXIS_LTRIGGER to 0.4f) - assertEquals(0.4f, pad().leftTrigger) + assertEquals(1f, pad().leftTrigger) motion(device, MotionEvent.AXIS_LTRIGGER to 0f) assertEquals(0f, pad().leftTrigger) key(device, KeyEvent.KEYCODE_BUTTON_L2, KeyEvent.ACTION_UP) assertEquals(0f, pad().leftTrigger) + key(device, KeyEvent.KEYCODE_BUTTON_L2) + assertEquals(0f, pad().leftTrigger) + motion(device, MotionEvent.AXIS_LTRIGGER to 0.4f) + assertEquals(0.4f, pad().leftTrigger) } private fun pad(): PadState = requireNotNull(JoyConPadTest.RecordingWriter.pads[0]) diff --git a/app/src/test/java/com/droiddeck/launcher/input/PointerCaptureTest.kt b/app/src/test/java/com/droiddeck/launcher/input/PointerCaptureTest.kt new file mode 100644 index 0000000000..3d85e8c259 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/input/PointerCaptureTest.kt @@ -0,0 +1,77 @@ +package com.droiddeck.launcher.input + +import android.view.InputDevice +import android.view.MotionEvent +import org.junit.Assert.assertArrayEquals +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [34], manifest = Config.NONE) +class PointerCaptureTest { + @Test fun aCapturedMouseReportsItsPositionAsMovement() { + val event = event(MotionEvent.ACTION_MOVE, InputDevice.SOURCE_MOUSE_RELATIVE, x = 12f, y = -7f) + try { + assertTrue(PointerCapture.accepts(event)) + assertFalse(PointerCapture.isTouchpad(event)) + assertArrayEquals(floatArrayOf(12f, -7f), PointerCapture.delta(event), 0.001f) + } finally { + event.recycle() + } + } + + @Test fun batchedMouseSamplesAddUp() { + val event = event(MotionEvent.ACTION_MOVE, InputDevice.SOURCE_MOUSE_RELATIVE, x = 3f, y = -5f) + try { + event.addBatch(1L, arrayOf(MotionEvent.PointerCoords().apply { x = 2f; y = 4f }), 0) + assertArrayEquals(floatArrayOf(5f, -1f), PointerCapture.delta(event), 0.001f) + } finally { + event.recycle() + } + } + + @Test fun aCapturedTouchpadIsACapturedPointer() { + val event = event(MotionEvent.ACTION_DOWN, InputDevice.SOURCE_TOUCHPAD, x = 800f, y = 400f) + try { + assertTrue(PointerCapture.accepts(event)) + assertTrue(PointerCapture.isTouchpad(event)) + } finally { + event.recycle() + } + } + + @Test fun anUncapturedMouseIsNotACapturedPointer() { + val event = event(MotionEvent.ACTION_HOVER_MOVE, InputDevice.SOURCE_MOUSE, x = 12f, y = -7f) + try { + assertFalse(PointerCapture.accepts(event)) + } finally { + event.recycle() + } + } + + @Test fun touchpadTravelMatchesTheSameDistanceOnScreen() { + assertEquals(0.5f, PointerCapture.touchpadScale(unitsPerMm = 20f, padWidth = 2000f, pixelsPerMm = 10f, screenWidth = 1920), 0.001f) + } + + @Test fun aTouchpadWithoutAResolutionSpansTheScreen() { + assertEquals(1.92f, PointerCapture.touchpadScale(unitsPerMm = 0f, padWidth = 1000f, pixelsPerMm = 10f, screenWidth = 1920), 0.001f) + } + + @Test fun aTouchpadWithoutARangeKeepsItsUnits() { + assertEquals(1f, PointerCapture.touchpadScale(unitsPerMm = 0f, padWidth = 0f, pixelsPerMm = 10f, screenWidth = 1920), 0.001f) + } + + private fun event(action: Int, source: Int, x: Float, y: Float): MotionEvent { + val properties = arrayOf(MotionEvent.PointerProperties().apply { + id = 0 + toolType = MotionEvent.TOOL_TYPE_FINGER + }) + val coords = arrayOf(MotionEvent.PointerCoords().apply { this.x = x; this.y = y }) + return MotionEvent.obtain(0L, 0L, action, 1, properties, coords, 0, 0, 1f, 1f, 0, 0, source, 0) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/input/SecondScreenModeTest.kt b/app/src/test/java/com/droiddeck/launcher/input/SecondScreenModeTest.kt index d49a937e05..dc93a5591a 100644 --- a/app/src/test/java/com/droiddeck/launcher/input/SecondScreenModeTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/input/SecondScreenModeTest.kt @@ -99,6 +99,18 @@ class SecondScreenModeTest { assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("dashboard", deckPad = false)) } + @Test fun steamQuickAccessOpensAgainOnlyInASteamSession() { + assertEquals(SecondScreenMode.STEAM_QAM, SecondScreenMode.opening("steam-qam", deckPad = true, dashboard = true, steam = true)) + assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("steam-qam", deckPad = true, dashboard = true)) + assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("steam-qam", deckPad = true, steam = true)) + } + + @Test fun gameArtOpensAgainOnlyInASteamSession() { + assertEquals(SecondScreenMode.ART, SecondScreenMode.opening("art", deckPad = true, dashboard = true, steam = true)) + assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("art", deckPad = true, dashboard = true)) + assertTrue(SecondScreenMode.ART.sessionPanel) + } + @Test fun theDesktopOpensAgainOnlyWhileItCanRun() { assertEquals(SecondScreenMode.DESKTOP, SecondScreenMode.opening("desktop", deckPad = true, dashboard = true, bottomDesktop = true)) assertEquals(SecondScreenMode.MENU, SecondScreenMode.opening("desktop", deckPad = true, dashboard = true)) diff --git a/app/src/test/java/com/droiddeck/launcher/input/TouchpadGesturesTest.kt b/app/src/test/java/com/droiddeck/launcher/input/TouchpadGesturesTest.kt index c967ce02fd..80df39e48c 100644 --- a/app/src/test/java/com/droiddeck/launcher/input/TouchpadGesturesTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/input/TouchpadGesturesTest.kt @@ -331,6 +331,81 @@ class TouchpadGesturesTest { assertEquals(listOf("left down", "left up", "left down"), events) } + @Test fun aRestingFingerNeverDragsWhenHoldDragsAreOff() { + touchpad = TouchpadGestures(SLOP, listener, holdDrags = false) + touchpad.bounds = RectF(0f, 0f, 1920f, 1080f) + touchpad.place(960f, 540f) + touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f)) + advance(TouchTiming.HOLD_MS + 100) + touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (400f to 300f), 2 to (600f to 300f)) + advance(10) + touch(MotionEvent.ACTION_MOVE, 0, 1 to (400f to 300f), 2 to (620f to 300f)) + advance(10) + touch(MotionEvent.ACTION_MOVE, 0, 1 to (400f to 300f), 2 to (640f to 300f)) + assertFalse(events.any { it.startsWith("left") || it == "long press" }) + } + + @Test fun tapsStillClickWhenHoldDragsAreOff() { + touchpad = TouchpadGestures(SLOP, listener, holdDrags = false) + tap() + assertEquals(listOf("left down"), events) + } + + @Test fun aPhysicalButtonPressIsNotAlsoATap() { + touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f)) + touchpad.buttonPressed() + advance(80) + touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 300f)) + advance(TouchTiming.HOLD_MS + 100) + assertTrue(events.isEmpty()) + } + + @Test fun aPhysicalButtonPressDuringTwoFingersIsNotARightClick() { + touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f)) + advance(10) + touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (400f to 300f), 2 to (600f to 300f)) + touchpad.buttonPressed() + advance(40) + touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (400f to 300f), 2 to (600f to 300f)) + touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 300f)) + assertTrue(events.isEmpty()) + } + + @Test fun aSecondFingerAfterAPhysicalButtonPressIsNotARightClick() { + touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f)) + touchpad.buttonPressed() + advance(10) + touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (400f to 300f), 2 to (600f to 300f)) + advance(40) + touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (400f to 300f), 2 to (600f to 300f)) + touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 300f)) + advance(TouchTiming.HOLD_MS + 100) + assertTrue(events.isEmpty()) + twoFingerTapStillRightClicks() + } + + @Test fun aPhysicalButtonPressReleasesAPendingTapClickFirst() { + tap() + assertEquals(listOf("left down"), events) + touchpad.buttonPressed() + assertEquals(listOf("left down", "left up"), events) + advance(TouchTiming.CLICK_MS + 100) + assertEquals(listOf("left down", "left up"), events) + } + + private fun twoFingerTapStillRightClicks() { + advance(1000) + events.clear() + touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f)) + advance(10) + touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (400f to 300f), 2 to (600f to 300f)) + advance(40) + touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (400f to 300f), 2 to (600f to 300f)) + touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 300f)) + advance(TouchTiming.HOLD_MS + 100) + assertTrue("right down" in events) + } + private fun tap() { touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f)) advance(80) diff --git a/app/src/test/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponentTest.kt b/app/src/test/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponentTest.kt index dea3a46859..c0928c4545 100644 --- a/app/src/test/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponentTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponentTest.kt @@ -188,4 +188,57 @@ class LinuxNetworkLinkComponentTest { ReflectionHelpers.callInstanceMethod(component, "replace", from(java.io.File::class.java, file), from(String::class.java, "nameserver 8.8.8.8\n")) assertEquals("nameserver 8.8.8.8\n", file.readText()) } + + private val telemetryLine = "0.0.0.0 " + LinuxNetworkLinkComponent.UNITY_TELEMETRY_HOSTS.joinToString(" ") + + @Test + fun newHostsFileHasLocalhostAndRefusesUnityTelemetry() { + val text = LinuxNetworkLinkComponent.hostsText(null) + assertTrue(text.startsWith("127.0.0.1 localhost\n::1 localhost\n")) + assertTrue(text.contains("$telemetryLine\n")) + assertTrue("stats.unity3d.com" in LinuxNetworkLinkComponent.UNITY_TELEMETRY_HOSTS) + } + + @Test + fun hostsKeepsTheUsersLinesAndWritesTheBlockOnce() { + val user = "127.0.0.1 localhost\n::1 localhost\n10.0.0.5 nas.lan\n" + val once = LinuxNetworkLinkComponent.hostsText(user) + assertTrue(once.startsWith(user)) + assertEquals(once, LinuxNetworkLinkComponent.hostsText(once)) + assertEquals(1, once.lines().count { it == telemetryLine }) + } + + @Test + fun hostsReplacesAnOlderBlockWithTheCurrentList() { + val old = "127.0.0.1 localhost\n# DroidDeck: Unity telemetry is refused (start)\n0.0.0.0 old.example\n" + + "# DroidDeck: Unity telemetry is refused (end)\n10.0.0.5 nas.lan\n" + val text = LinuxNetworkLinkComponent.hostsText(old) + assertFalse(text.contains("old.example")) + assertTrue(text.contains("10.0.0.5 nas.lan\n")) + assertTrue(text.contains("$telemetryLine\n")) + } + + @Test + fun hostsKeepsTheUsersLinesAfterAStartMarkerWithoutAnEnd() { + val broken = "127.0.0.1 localhost\n# DroidDeck: Unity telemetry is refused (start)\n10.0.0.5 nas.lan\n" + val once = LinuxNetworkLinkComponent.hostsText(broken) + assertTrue(once.contains("10.0.0.5 nas.lan\n")) + assertEquals(1, once.lines().count { it == "# DroidDeck: Unity telemetry is refused (start)" }) + val twice = LinuxNetworkLinkComponent.hostsText(once) + assertTrue(twice.contains("10.0.0.5 nas.lan\n")) + assertEquals(once, twice) + } + + @Test + fun hostsDropsAStrayEndMarker() { + val text = LinuxNetworkLinkComponent.hostsText("127.0.0.1 localhost\n# DroidDeck: Unity telemetry is refused (end)\n10.0.0.5 nas.lan\n") + assertTrue(text.startsWith("127.0.0.1 localhost\n10.0.0.5 nas.lan\n")) + assertEquals(1, text.lines().count { it == "# DroidDeck: Unity telemetry is refused (end)" }) + } + + @Test + fun hostsAddsLocalhostOnlyWhenItIsMissing() { + assertTrue(LinuxNetworkLinkComponent.hostsText("10.0.0.5 nas.lan\n").startsWith("127.0.0.1 localhost\n::1 localhost\n10.0.0.5 nas.lan\n")) + assertEquals(1, LinuxNetworkLinkComponent.hostsText("127.0.0.1 localhost\n").lines().count { "localhost" in it }) + } } diff --git a/app/src/test/java/com/droiddeck/launcher/runtime/LinuxRuntimeRootPrefixTest.kt b/app/src/test/java/com/droiddeck/launcher/runtime/LinuxRuntimeRootPrefixTest.kt index e956781db9..9560641597 100644 --- a/app/src/test/java/com/droiddeck/launcher/runtime/LinuxRuntimeRootPrefixTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/runtime/LinuxRuntimeRootPrefixTest.kt @@ -14,6 +14,8 @@ import org.robolectric.annotation.Config import org.robolectric.annotation.Implementation import org.robolectric.annotation.Implements import java.io.File +import java.nio.file.Files +import java.nio.file.Paths @RunWith(RobolectricTestRunner::class) @Config(sdk = [33], manifest = Config.NONE, application = Application::class, shadows = [LinuxRuntimeRootPrefixTest.Uname::class]) @@ -44,6 +46,82 @@ class LinuxRuntimeRootPrefixTest { assertEquals(LinuxRuntime.prootPrefix(context, root, "/root"), cmd.dropLast(guest.size)) } + @Test fun aLinkProotMadeAfterTheNativeRelinkIsMadeRelativeAtTheNextNativeStart() { + val home = File(root, "root/.steam").apply { mkdirs() } + File(root, "root/.local/share/Steam/logs").mkdirs() + val steam = File(home, "steam").toPath() + val card = File(home, "card").toPath() + Files.createSymbolicLink(card, Paths.get("/storage/emulated/0")) + NativeGuest.relinkAbsoluteSymlinks(context, root) + Files.createSymbolicLink(steam, Paths.get("/root/.local/share/Steam")) + assertEquals(0, NativeGuest.relinkAbsoluteSymlinks(context, root)) + assertTrue(Files.readSymbolicLink(steam).isAbsolute) + + LinuxRuntime.prootPrefix(context, root, "/root") + + assertEquals(1, NativeGuest.relinkAbsoluteSymlinks(context, root)) + assertEquals(Paths.get("../.local/share/Steam"), Files.readSymbolicLink(steam)) + assertTrue(File(home, "steam/logs").isDirectory) + assertEquals(Paths.get("/storage/emulated/0"), Files.readSymbolicLink(card)) + } + + @Test fun linksIntoSharedStorageKeepTheirGuestPath() { + val home = File(root, "root").apply { mkdirs() } + File(home, "Storage/Download").mkdirs() + File(root, "root/.local/share/Steam").mkdirs() + val downloads = File(home, "Downloads").toPath() + val storage = File(home, "Storage").toPath() + val steam = File(home, "steam").toPath() + Files.createSymbolicLink(downloads, Paths.get("/root/Storage/Download")) + Files.createSymbolicLink(File(home, "share").toPath(), Paths.get("/root/Storage")) + Files.createSymbolicLink(steam, Paths.get("/root/.local/share/Steam")) + Files.createSymbolicLink(File(home, "StorageX").toPath(), Paths.get("/root/StorageX")) + + assertEquals(2, NativeGuest.relinkAbsoluteSymlinks(context, root)) + + assertEquals(Paths.get("/root/Storage/Download"), Files.readSymbolicLink(downloads)) + assertEquals(Paths.get("/root/Storage"), Files.readSymbolicLink(File(home, "share").toPath())) + assertEquals(Paths.get(".local/share/Steam"), Files.readSymbolicLink(steam)) + assertEquals(Paths.get("StorageX"), Files.readSymbolicLink(File(home, "StorageX").toPath())) + assertTrue(Files.isDirectory(storage)) + } + + @Test fun aWalkDuringALiveProotRunLeavesTheNextNativeStartToWalkAgain() { + val home = File(root, "root").apply { mkdirs() } + File(root, "root/.local/share/Steam").mkdirs() + val proot = LinuxRuntime.prootBinary(context).path + LinuxRuntime.prootPrefix(context, root, "/root") + NativeGuest.relinkAbsoluteSymlinks(context, root) { sequenceOf(listOf("/system/bin/linker64", proot, "--kill-on-exit")) } + val steam = File(home, "steam").toPath() + Files.createSymbolicLink(steam, Paths.get("/root/.local/share/Steam")) + + assertEquals(1, NativeGuest.relinkAbsoluteSymlinks(context, root) { emptySequence() }) + assertEquals(Paths.get(".local/share/Steam"), Files.readSymbolicLink(steam)) + assertEquals(0, NativeGuest.relinkAbsoluteSymlinks(context, root) { emptySequence() }) + } + + @Test fun onlyTheProotTracerCountsAsALiveProotRun() { + val proot = "/data/app/x/lib/arm64/libproot.so" + assertTrue(NativeGuest.prootRunning(proot, sequenceOf(listOf("/system/bin/linker64", proot, "-r", "/rootfs")))) + assertTrue(NativeGuest.prootRunning(proot, sequenceOf(listOf(proot, "-r", "/rootfs")))) + assertFalse(NativeGuest.prootRunning(proot, sequenceOf(listOf("/usr/bin/bash", "-c", proot)))) + assertFalse(NativeGuest.prootRunning(proot, sequenceOf(listOf("$proot.old"), emptyList()))) + } + + @Test fun packageLinksAFakeRootProotRunMadeAreRelinkedToo() { + val bin = File(root, "usr/bin").apply { mkdirs() } + File(root, "usr/share/tool").mkdirs() + NativeGuest.relinkAbsoluteSymlinks(context, root) + val tool = File(bin, "tool").toPath() + Files.createSymbolicLink(tool, Paths.get("/usr/share/tool")) + + LinuxRuntime.commandWithBinds(context, root, emptyList(), guest, true) + + assertEquals(1, NativeGuest.relinkAbsoluteSymlinks(context, root)) + assertEquals(Paths.get("../share/tool"), Files.readSymbolicLink(tool)) + assertEquals(0, NativeGuest.relinkAbsoluteSymlinks(context, root)) + } + @Implements(Os::class) class Uname { companion object { diff --git a/app/src/test/java/com/droiddeck/launcher/runtime/NativeGuestPrepareTest.kt b/app/src/test/java/com/droiddeck/launcher/runtime/NativeGuestPrepareTest.kt new file mode 100644 index 0000000000..e5bc975892 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/runtime/NativeGuestPrepareTest.kt @@ -0,0 +1,79 @@ +package com.droiddeck.launcher.runtime + +import androidx.test.core.app.ApplicationProvider +import java.io.File +import java.nio.ByteBuffer +import java.nio.ByteOrder +import java.nio.file.Files +import org.junit.After +import org.junit.Assert.assertArrayEquals +import org.junit.Assert.assertEquals +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner + +@RunWith(RobolectricTestRunner::class) +class NativeGuestPrepareTest { + private val svc = 0xd4000001.toInt() + private val rseq = 0xd28024a8.toInt() + private val enosys = 0x928004a0.toInt() + + private fun unpatchedLoader(): ByteArray { + val data = ByteArray(0x200) + val b = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN) + b.put(0, 0x7f); b.put(1, 'E'.code.toByte()); b.put(2, 'L'.code.toByte()); b.put(3, 'F'.code.toByte()) + b.put(4, 2); b.put(5, 1) + b.putShort(18, 183) + b.putLong(32, 64) + b.putShort(54, 56); b.putShort(56, 1) + b.putInt(64, 1); b.putInt(68, 5) + b.putLong(72, 0x100); b.putLong(96, 0x100) + b.putInt(0x100, rseq); b.putInt(0x104, svc) + return data + } + + private fun rootWithUnpatchedLoader(): Pair { + val root = Files.createTempDirectory("native-prepare").toFile() + val loader = File(root, "usr/lib/ld-linux-aarch64.so.1") + loader.parentFile!!.mkdirs() + loader.writeBytes(unpatchedLoader()) + return root to loader + } + + private fun instructionAfterRseq(loader: File): Int = + ByteBuffer.wrap(loader.readBytes()).order(ByteOrder.LITTLE_ENDIAN).getInt(0x104) + + @After + fun endSession() { + NativeGuest.sessionMode = null + } + + @Test + fun aProgramStartedOutsideASessionGetsALoaderThatSurvivesSeccomp() { + val (root, loader) = rootWithUnpatchedLoader() + NativeGuest.sessionMode = null + NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true")) + assertEquals(enosys, instructionAfterRseq(loader)) + } + + @Test + fun aProgramStartedInARunningSessionLeavesTheRootfsAsTheSessionPreparedIt() { + val (root, loader) = rootWithUnpatchedLoader() + val before = loader.readBytes() + NativeGuest.sessionMode = true + NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true")) + assertArrayEquals(before, loader.readBytes()) + } + + @Test + fun anAlreadyPreparedLoaderIsNotRewritten() { + val (root, loader) = rootWithUnpatchedLoader() + NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true")) + val modified = loader.lastModified() + val bytes = loader.readBytes() + loader.setLastModified(modified - 10_000) + NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true")) + assertArrayEquals(bytes, loader.readBytes()) + assertEquals(modified - 10_000, loader.lastModified()) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/session/GameDebugLogsExpiryTest.kt b/app/src/test/java/com/droiddeck/launcher/session/GameDebugLogsExpiryTest.kt new file mode 100644 index 0000000000..9642b27462 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/GameDebugLogsExpiryTest.kt @@ -0,0 +1,88 @@ +package com.droiddeck.launcher.session + +import android.app.Activity +import android.app.Application +import android.content.Context +import android.os.Looper +import android.view.View +import com.droiddeck.launcher.ui.BuildWatermark +import org.junit.After +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.Robolectric +import org.robolectric.RobolectricTestRunner +import org.robolectric.RuntimeEnvironment +import org.robolectric.Shadows.shadowOf +import org.robolectric.annotation.Config +import org.robolectric.annotation.ConscryptMode +import org.robolectric.annotation.GraphicsMode +import java.io.File + +@RunWith(RobolectricTestRunner::class) +@ConscryptMode(ConscryptMode.Mode.OFF) +@GraphicsMode(GraphicsMode.Mode.LEGACY) +@Config(sdk = [34], manifest = Config.NONE, application = Application::class) +class GameDebugLogsExpiryTest { + private val context get() = RuntimeEnvironment.getApplication() + private val prefs get() = context.getSharedPreferences("session", Context.MODE_PRIVATE) + + @Before fun reset() { + SessionPaths.take() + prefs.edit().clear().commit() + listOf("build-watermark", "build-watermark.lock").forEach { File(context.filesDir, it).delete() } + } + + @After fun end() { + SessionPaths.take() + } + + private fun setDebugLogs(on: Boolean) = prefs.edit().putBoolean("gameDebugLogsEnabled", on).commit() + + @Test fun settingTurnsOffWhenTheSessionItStartedWithEnds() { + setDebugLogs(true) + SessionPaths.beginOrCurrent(context, "steam") + assertTrue(SessionPrefs.gameDebugLogsEnabled(context)) + SessionPaths.take() + assertFalse(SessionPrefs.gameDebugLogsEnabled(context)) + } + + @Test fun settingStaysOnForTheSessionRunningWhenItWasEnabled() { + SessionPaths.beginOrCurrent(context, "steam") + setDebugLogs(true) + SessionPaths.take() + assertTrue(SessionPrefs.gameDebugLogsEnabled(context)) + SessionPaths.beginOrCurrent(context, "steam") + SessionPaths.take() + assertFalse(SessionPrefs.gameDebugLogsEnabled(context)) + } + + @Test fun settingThatWasOffStaysOff() { + SessionPaths.beginOrCurrent(context, "steam") + SessionPaths.take() + assertFalse(SessionPrefs.gameDebugLogsEnabled(context)) + } + + @Test fun badgeShowsWhileOnEvenWithTheBuildWatermarkOff() { + BuildWatermark.install(context) + SessionPrefs.setBuildWatermarkEnabled(context, false) + val activity = Robolectric.buildActivity(Activity::class.java).setup() + try { + assertNull(activity.get().window.decorView.findViewWithTag("build-watermark")) + setDebugLogs(true) + BuildWatermarkSetting.notifyChanged(context) + shadowOf(Looper.getMainLooper()).idle() + assertNotNull(activity.get().window.decorView.findViewWithTag("build-watermark")) + SessionPaths.beginOrCurrent(context, "steam") + SessionPaths.take() + shadowOf(Looper.getMainLooper()).idle() + assertNull(activity.get().window.decorView.findViewWithTag("build-watermark")) + } finally { + activity.pause().stop().destroy() + } + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/session/GameEnvironmentStoreTest.kt b/app/src/test/java/com/droiddeck/launcher/session/GameEnvironmentStoreTest.kt index 273d91d1d9..f48d51b1ca 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/GameEnvironmentStoreTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/GameEnvironmentStoreTest.kt @@ -36,7 +36,43 @@ class GameEnvironmentStoreTest { context.getSharedPreferences("session", Context.MODE_PRIVATE).edit() .remove("logs") .remove("gameDebugLogsEnabled") + .remove("gameCpus") .commit() + listOf("game-environment.json.new", "game-cores.new").forEach { File(guest.parentFile, it).delete() } + } + + @Test fun gameCoresChangedInSettingsReachTheGuestAtOnce() { + val live = File(LinuxRuntime.rootDir(context), "root/.config/droiddeck/game-cores") + val all = com.droiddeck.launcher.core.CpuCores.all + + SessionPrefs.setGameCpus(context, all.last().toString()) + assertEquals("${all.last()}\n", live.readText()) + + SessionPrefs.setGameCpus(context, com.droiddeck.launcher.core.CpuCores.format(all.toSet())) + assertEquals("\n", live.readText()) + } + + @Config(sdk = [34]) + @Test fun gameCoresStillReachTheGuestWhenTheRestOfTheEnvironmentCannotBeWritten() { + val dir = File(LinuxRuntime.rootDir(context), "root/.config/droiddeck") + val last = com.droiddeck.launcher.core.CpuCores.all.last() + assertTrue(File(dir, "game-environment.json.new").mkdirs()) + + context.getSharedPreferences("session", Context.MODE_PRIVATE).edit().putString("gameCpus", last.toString()).commit() + + assertTrue(runCatching { GameEnvironmentStore.publish(context) }.isFailure) + assertEquals("$last\n", File(dir, "game-cores").readText()) + } + + @Test fun gameCoresThatCannotBeWrittenLeaveNoOlderValueForTheGuest() { + val dir = File(LinuxRuntime.rootDir(context), "root/.config/droiddeck") + val all = com.droiddeck.launcher.core.CpuCores.all + SessionPrefs.setGameCpus(context, all.last().toString()) + assertTrue(File(dir, "game-cores.new").mkdirs()) + + SessionPrefs.setGameCpus(context, all.first().toString()) + + assertFalse(File(dir, "game-cores").exists()) } @Test fun gameDebugLogsAreOffByDefault() { @@ -166,11 +202,19 @@ class GameEnvironmentStoreTest { assertEquals("false", published.shared["MESA_SHADER_CACHE_DISABLE"]) assertFalse(published.shared.containsKey("VKD3D_FEATURE_LEVEL")) assertFalse(published.shared.containsKey("VKD3D_SHADER_MODEL")) - assertEquals(config.games, published.games) + assertEquals(config.games + GameEnvironment.knownGames, published.games) assertEquals(config.shared["LITERAL"], published.shared["LITERAL"]) assertEquals("", published.shared["EMPTY"]) } + @Test fun aKnownGamesFixReachesTheGuestWithoutBeingSavedAsTheUsersSetting() { + GameEnvironmentStore.save(context, GameEnvironment.Config()) + assertEquals(emptyMap>(), GameEnvironmentStore.read(context).games) + val published = GameEnvironmentStore.decode(JSONObject(guest.readText())) + assertEquals(GameEnvironment.knownGames, published.games) + assertEquals("0", published.entries("12100")["FEX_X87REDUCEDPRECISION"]) + } + @Test fun publishingPreservesExplicitSharedGraphicsCapabilities() { val config = GameEnvironment.Config(shared = mapOf( "VKD3D_FEATURE_LEVEL" to "12_1", "VKD3D_SHADER_MODEL" to "6_6", @@ -230,7 +274,7 @@ class GameEnvironmentStoreTest { assertEquals(original.entries("43"), saved.entries("43")) assertEquals("PERFORMANCE_TSO", SessionPrefs.fexPreset(context)) val published = GameEnvironmentStore.decode(JSONObject(guest.readText())) - assertEquals(saved.games, published.games) + assertEquals(saved.games + GameEnvironment.knownGames, published.games) assertEquals("0", published.shared["FEX_HALFBARRIERTSOENABLED"]) assertEquals("1", published.entries("42")["FEX_HALFBARRIERTSOENABLED"]) } diff --git a/app/src/test/java/com/droiddeck/launcher/session/GameLinksTest.kt b/app/src/test/java/com/droiddeck/launcher/session/GameLinksTest.kt new file mode 100644 index 0000000000..1f7a6cec41 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/GameLinksTest.kt @@ -0,0 +1,129 @@ +package com.droiddeck.launcher.session + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33]) +class GameLinksTest { + private fun row(vararg pairs: Pair) = + pairs.joinToString(",", "{", "}") { (k, v) -> "\"$k\":{\"type\":\"literal\",\"value\":\"$v\"}" } + + @Test + fun mapsWikidataIdsToSiteUrls() { + val json = """{"results":{"bindings":[ + ${row("fandom" to "it.eldenring", "pcgw" to "Elden_Ring", "gamefaqs" to "265984", "ign" to "elden-ring", "hltb" to "68151", "sw" to "Elden Ring")}, + ${row("fandom" to "eldenring", "pcgw" to "Elden_Ring", "gamefaqs" to "323053")} + ]}}""" + val links = GameLinks.parse(json).associate { it.kind to it.url } + assertEquals("https://eldenring.fandom.com/", links[GameLinks.Kind.WIKI]) + assertEquals("https://strategywiki.org/wiki/Elden_Ring", links[GameLinks.Kind.STRATEGYWIKI]) + assertEquals("https://www.pcgamingwiki.com/wiki/Elden_Ring", links[GameLinks.Kind.PCGAMINGWIKI]) + assertEquals("https://gamefaqs.gamespot.com/-/265984-", links[GameLinks.Kind.GAMEFAQS]) + assertEquals("https://www.ign.com/games/elden-ring", links[GameLinks.Kind.IGN]) + assertEquals("https://howlongtobeat.com/game/68151", links[GameLinks.Kind.HOWLONGTOBEAT]) + } + + @Test + fun aLanguageOnlyFandomWikiKeepsItsLanguage() { + val links = GameLinks.parse("""{"results":{"bindings":[${row("fandom" to "de.hollowknight")}]}}""") + assertEquals("https://hollowknight.fandom.com/de/", links.single().url) + } + + @Test + fun noMatchIsNoLinks() { + assertTrue(GameLinks.parse("""{"results":{"bindings":[]}}""").isEmpty()) + } + + @Test + fun protonDbTiers() { + assertEquals("gold", GameLinks.parseTier("""{"bestReportedTier":"platinum","tier":"gold","total":2109}""")) + assertNull(GameLinks.parseTier("""{"tier":"pending"}""")) + } + + @Test + fun searchesStayOnTheSitesAndSkipGameFaqsWhenItHasAPage() { + val youtube = GameLinks.searches("Arcade Paradise", emptyList()).first { it.id == "youtube" }.url + assertEquals("https://m.youtube.com/results?search_query=Arcade+Paradise+walkthrough", youtube) + assertTrue(GameLinks.searches("Bully", emptyList()).none { "duckduckgo" in it.url }) + val faqs = GameLinks.Link(GameLinks.Kind.GAMEFAQS, "https://gamefaqs.gamespot.com/-/1-") + assertEquals(listOf("youtube"), GameLinks.searches("Bully", listOf(faqs)).map { it.id }) + } + + @Test + fun slugsTryTheFullNameThenTheShortOne() { + assertEquals(listOf("bully-scholarship-edition", "bully"), GameLinks.slugs("Bully: Scholarship Edition")) + assertEquals(listOf("sonic-mania"), GameLinks.slugs("Sonic Mania")) + assertEquals(listOf("tom-clancys-the-division-2"), GameLinks.slugs("Tom Clancy’s The Division 2")) + assertEquals(listOf("hotline-miami"), GameLinks.slugs("Hotline Miami™")) + } + + @Test + fun directPagesComeFromTheSitesOwnRoutes() { + val live = setOf("https://mapgenie.io/bully", "https://www.ign.com/wikis/bully", "https://bully.fandom.com/api.php?action=query&meta=siteinfo&format=json") + val found = GameLinks.direct("Bully: Scholarship Edition", + listOf(GameLinks.Link(GameLinks.Kind.IGN, "https://www.ign.com/games/bully-scholarship-edition")), + exists = { it in live }, strategyWiki = { if (it == "Bully") "https://strategywiki.org/wiki/Bully" else null }) + assertEquals(mapOf( + GameLinks.Kind.MAPGENIE to "https://mapgenie.io/bully", + GameLinks.Kind.IGN to "https://www.ign.com/wikis/bully", + GameLinks.Kind.WIKI to "https://bully.fandom.com/", + GameLinks.Kind.STRATEGYWIKI to "https://strategywiki.org/wiki/Bully", + ), found.associate { it.kind to it.url }) + assertTrue(found.none { "duckduckgo" in it.url }) + } + + @Test + fun aMissingSiteLeavesWikidataLinksAlone() { + val ign = GameLinks.Link(GameLinks.Kind.IGN, "https://www.ign.com/games/x") + assertEquals(listOf(ign), GameLinks.direct("X", listOf(ign), exists = { false }, strategyWiki = { null })) + } + + @Test + fun openSearchPicksTheExactTitle() { + val json = """["Bully",["Bully's Sporting Darts","Bully"],["",""],["https://strategywiki.org/wiki/Bully%27s_Sporting_Darts","https://strategywiki.org/wiki/Bully"]]""" + assertEquals("https://strategywiki.org/wiki/Bully", GameLinks.parseOpenSearch(json, "Bully")) + assertNull(GameLinks.parseOpenSearch(json, "Canis Canem Edit")) + } + + @Test + fun cachedDiscoveriesYieldToNewWikidataLinks() { + val fandom = GameLinks.Link(GameLinks.Kind.WIKI, "https://bully.fandom.com/") + val map = GameLinks.Link(GameLinks.Kind.MAPGENIE, "https://mapgenie.io/bully") + val wiki = GameLinks.Link(GameLinks.Kind.WIKI, "https://bully.wiki.gg/") + assertEquals(listOf(wiki, map), GameLinks.merge(listOf(wiki), listOf(fandom, map))) + assertEquals(listOf(fandom, map), GameLinks.merge(emptyList(), listOf(fandom, map))) + } + + @Test + fun cachedLinksRoundTrip() { + val links = listOf(GameLinks.Link(GameLinks.Kind.MAPGENIE, "https://mapgenie.io/bully")) + assertEquals(links, GameLinks.readLinks(GameLinks.writeLinks(links))) + } + + @Test + fun steamGuideTagFilter() { + assertEquals("https://steamcommunity.com/app/620/guides/?browsefilter=toprated&browsesort=toprated&requiredtags%5B%5D=Maps+or+Levels", + SteamGuides.listUrl(620, "Maps or Levels")) + assertEquals("https://steamcommunity.com/app/620/guides/?browsefilter=toprated&browsesort=toprated", SteamGuides.listUrl(620, null)) + } + + @Test + fun guideLanguageFollowsTheDevice() { + assertEquals("english", SteamGuides.language(java.util.Locale.US)) + assertEquals("german", SteamGuides.language(java.util.Locale.GERMANY)) + assertEquals("schinese", SteamGuides.language(java.util.Locale.SIMPLIFIED_CHINESE)) + assertEquals("tchinese", SteamGuides.language(java.util.Locale.TRADITIONAL_CHINESE)) + assertEquals("brazilian", SteamGuides.language(java.util.Locale("pt", "BR"))) + assertEquals("latam", SteamGuides.language(java.util.Locale("es", "MX"))) + assertEquals("spanish", SteamGuides.language(java.util.Locale("es", "ES"))) + assertEquals("english", SteamGuides.language(java.util.Locale("eo"))) + assertEquals("https://steamcommunity.com/app/620/guides/?browsefilter=toprated&browsesort=toprated&requiredtags%5B%5D=Secrets&requiredtags%5B%5D=english", + SteamGuides.listUrl(620, "Secrets", "english")) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/session/GameStorageTest.kt b/app/src/test/java/com/droiddeck/launcher/session/GameStorageTest.kt index a6b50eb1cc..c34cf0c854 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/GameStorageTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/GameStorageTest.kt @@ -114,6 +114,19 @@ class GameStorageTest { assertFalse(GameStorage.disconnected(app)) } + @Test fun aRawCardPathTheProcessCannotUseFallsBackToItsStoragePath() { + val usable = setOf("/storage/A042-9B16/Games") + assertEquals("/storage/A042-9B16/Games", GameStorage.reachable("/mnt/media_rw/A042-9B16/Games") { it.path in usable }) + } + + @Test fun aUsableRawPathAndOtherPathsAreKept() { + assertEquals("/mnt/media_rw/A042-9B16/Games", GameStorage.reachable("/mnt/media_rw/A042-9B16/Games") { true }) + assertEquals("/mnt/media_rw/0000-0000/Games", GameStorage.reachable("/mnt/media_rw/0000-0000/Games") { false }) + assertEquals("/storage/A042-9B16/Games", GameStorage.reachable("/storage/A042-9B16/Games") { false }) + val folder = tmp.newFolder("library").path + assertEquals(folder, GameStorage.reachable(folder) { false }) + } + @Test fun onlyAVfatMountCountsAsFat32() { val mounts = """ /dev/fuse /storage/emulated fuse rw 0 0 diff --git a/app/src/test/java/com/droiddeck/launcher/session/GpuClockPinTest.kt b/app/src/test/java/com/droiddeck/launcher/session/GpuClockPinTest.kt index 3311df0501..fb081fd847 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/GpuClockPinTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/GpuClockPinTest.kt @@ -2,7 +2,9 @@ package com.droiddeck.launcher.session import org.junit.After import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @@ -14,7 +16,21 @@ import org.robolectric.annotation.Config class GpuClockPinTest { private val context = RuntimeEnvironment.getApplication() - @After fun stop() { GpuClockPin.stop(context) } + private val calls = mutableListOf() + private val node = GpuClockPin.supported + private val turbo = GpuClockPin.turbo + + @After fun stop() { + GpuClockPin.stop(context) + GpuClockPin.supported = node + GpuClockPin.turbo = turbo + SessionPrefs.setGpuClockPin(context, false) + } + + private fun fakeGpu() { + GpuClockPin.supported = true + GpuClockPin.turbo = { calls += it } + } @Test fun aToggleOutsideASessionSaysNothing() { SessionPrefs.setGpuClockPin(context, true) @@ -31,4 +47,52 @@ class GpuClockPinTest { SessionPrefs.setGpuClockPin(context, false) assertEquals(started, GpuClockPin.sync(context)) } + + @Test fun aBoostHoldsTheClockOnlyWhileItLasts() { + fakeGpu() + assertEquals("gpu clock: governed", GpuClockPin.start(context)) + assertTrue(GpuClockPin.boost(true)) + assertEquals("gpu clock: held at its top", GpuClockPin.sync(context)) + assertFalse(GpuClockPin.boost(true)) + assertTrue(GpuClockPin.boost(false)) + assertEquals("gpu clock: governed", GpuClockPin.sync(context)) + assertEquals(listOf(true, false), calls) + } + + @Test fun endingABoostKeepsTheHoldTheUserTurnedOn() { + fakeGpu() + SessionPrefs.setGpuClockPin(context, true) + GpuClockPin.start(context) + GpuClockPin.boost(true) + GpuClockPin.sync(context) + GpuClockPin.boost(false) + assertEquals("gpu clock: held at its top", GpuClockPin.sync(context)) + assertFalse(false in calls) + } + + @Test fun aBoostOutsideASessionDoesNothing() { + fakeGpu() + GpuClockPin.boost(true) + assertNull(GpuClockPin.sync(context)) + assertTrue(calls.isEmpty()) + } + + @Test fun aBoostDoesNotOutliveItsSession() { + fakeGpu() + GpuClockPin.start(context) + GpuClockPin.boost(true) + GpuClockPin.sync(context) + GpuClockPin.stop(context) + assertEquals("gpu clock: governed", GpuClockPin.start(context)) + assertEquals(listOf(true, false), calls) + } + + @Test fun aBoostWithoutTheGpuNodeLeavesTheClockGoverned() { + GpuClockPin.supported = false + GpuClockPin.turbo = { calls += it } + GpuClockPin.start(context) + GpuClockPin.boost(true) + assertEquals("gpu clock: no /dev/kgsl-3d0, left governed", GpuClockPin.sync(context)) + assertTrue(calls.isEmpty()) + } } diff --git a/app/src/test/java/com/droiddeck/launcher/session/GuestLeftoversTest.kt b/app/src/test/java/com/droiddeck/launcher/session/GuestLeftoversTest.kt new file mode 100644 index 0000000000..f26a45d789 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/GuestLeftoversTest.kt @@ -0,0 +1,35 @@ +package com.droiddeck.launcher.session + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +class GuestLeftoversTest { + private fun environ(vararg entries: String) = entries.joinToString("\u0000", postfix = "\u0000").toByteArray() + + @Test + fun aProcessOfTheEndedSessionCarriesItsFolder() { + val marker = "DD_DEBUG_DIR=/data/logs/2026-11-28-85-steam" + assertTrue(GuestLeftovers.carries(environ("HOME=/home/deck", marker, "TERM=xterm"), marker)) + assertTrue(GuestLeftovers.carries(environ(marker), marker)) + } + + @Test + fun anotherSessionsFolderOrALongerPathIsNotTheEndedSession() { + val marker = "DD_DEBUG_DIR=/data/logs/2026-11-28-85-steam" + assertFalse(GuestLeftovers.carries(environ("DD_DEBUG_DIR=/data/logs/2026-11-28-86-steam"), marker)) + assertFalse(GuestLeftovers.carries(environ("$marker-2"), marker)) + assertFalse(GuestLeftovers.carries(environ("X$marker"), marker)) + assertFalse(GuestLeftovers.carries(null, marker)) + assertFalse(GuestLeftovers.carries(ByteArray(0), marker)) + } + + @Test + fun whatAMatchedProcessStartedGoesWithIt() { + // 10 was proot's child and now belongs to init; 12 cleared its environment; 20 is unrelated + val parents = mapOf(10 to 1, 11 to 10, 12 to 11, 13 to 12, 20 to 1, 21 to 20) + assertEquals(setOf(10, 11, 12, 13), GuestLeftovers.withDescendants(setOf(10), parents)) + assertEquals(emptySet(), GuestLeftovers.withDescendants(emptySet(), parents)) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/session/LoopbackWebSocketTest.kt b/app/src/test/java/com/droiddeck/launcher/session/LoopbackWebSocketTest.kt new file mode 100644 index 0000000000..34de5505dd --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/LoopbackWebSocketTest.kt @@ -0,0 +1,87 @@ +package com.droiddeck.launcher.session + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertThrows +import org.junit.Test +import java.io.DataInputStream +import java.io.IOException +import java.net.ServerSocket +import kotlin.concurrent.thread + +class LoopbackWebSocketTest { + @Test + fun talksToALoopbackWebSocketServer() { + val server = ServerSocket(0).apply { soTimeout = 5_000 } + var received: String? = null + val worker = thread { + server.accept().use { client -> + client.soTimeout = 5_000 + val input = DataInputStream(client.getInputStream()) + val out = client.getOutputStream() + out.write(upgrade(handshakeKey(input)).toByteArray()) + for (text in listOf("""{"id":1}""", "x".repeat(300))) { + val bytes = text.toByteArray() + out.write(0x81) + if (bytes.size < 126) out.write(bytes.size) else { out.write(126); out.write(bytes.size shr 8); out.write(bytes.size and 0xFF) } + out.write(bytes) + } + out.flush() + val b0 = input.read() + val len = input.read() and 0x7F + val mask = ByteArray(4).also(input::readFully) + val payload = ByteArray(len).also(input::readFully) + for (i in payload.indices) payload[i] = (payload[i].toInt() xor mask[i % 4].toInt()).toByte() + if (b0 == 0x81) received = String(payload) + } + } + try { + LoopbackWebSocket(server.localPort, readTimeoutMs = 5_000).use { ws -> + assertEquals("""{"id":1}""", ws.receive()) + assertEquals(300, ws.receive()!!.length) + ws.send("""{"id":2}""") + } + worker.join(5_000) + } finally { + server.close() + } + assertEquals("""{"id":2}""", received) + } + + @Test + fun rejectsAnUpgradeWithoutTheRightAcceptHeader() { + for (reply in listOf( + "HTTP/1.1 101 Switching Protocols\r\n\r\n", + "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: wrong\r\n\r\n", + "HTTP/1.1 1010 Nope\r\n\r\n", + )) { + val server = ServerSocket(0) + val worker = thread { + server.accept().use { client -> + handshakeKey(DataInputStream(client.getInputStream())) + client.getOutputStream().apply { write(reply.toByteArray()); flush() } + Thread.sleep(200) + } + } + assertThrows(IOException::class.java) { LoopbackWebSocket(server.localPort).close() } + worker.join(5_000) + server.close() + } + } + + private fun upgrade(key: String) = "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n" + + "Sec-WebSocket-Accept: ${LoopbackWebSocket.accept(key)}\r\n\r\n" + + private fun handshakeKey(input: DataInputStream): String = + generateSequence { readLine(input) }.takeWhile { it.isNotEmpty() }.toList() + .first { it.startsWith("Sec-WebSocket-Key:") }.substringAfter(':').trim() + + private fun readLine(input: DataInputStream): String? { + val sb = StringBuilder() + while (true) { + val c = input.read() + if (c < 0) return null + if (c == '\n'.code) return sb.toString().trimEnd('\r') + sb.append(c.toChar()) + } + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/session/MemoryKillTest.kt b/app/src/test/java/com/droiddeck/launcher/session/MemoryKillTest.kt new file mode 100644 index 0000000000..4f0f369af3 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/MemoryKillTest.kt @@ -0,0 +1,18 @@ +package com.droiddeck.launcher.session + +import android.app.ApplicationExitInfo +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +class MemoryKillTest { + @Test + fun recognisesLowMemoryAndTheAndroid17Limiter() { + assertTrue(SessionArtifacts.memoryKill(ApplicationExitInfo.REASON_LOW_MEMORY, null)) + assertTrue(SessionArtifacts.memoryKill(17, "kill")) + assertTrue(SessionArtifacts.memoryKill(ApplicationExitInfo.REASON_OTHER, "MemoryLimiter:AnonSwap")) + assertFalse(SessionArtifacts.memoryKill(ApplicationExitInfo.REASON_OTHER, "unstable content provider")) + assertFalse(SessionArtifacts.memoryKill(ApplicationExitInfo.REASON_OTHER, null)) + assertFalse(SessionArtifacts.memoryKill(ApplicationExitInfo.REASON_USER_REQUESTED, "MemoryLimiter:AnonSwap")) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/session/SecondaryLibraryTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SecondaryLibraryTest.kt index a58e075380..47c55f349d 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/SecondaryLibraryTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/SecondaryLibraryTest.kt @@ -21,6 +21,24 @@ class SecondaryLibraryTest { assertFalse(SecondaryLibrary.privateRoot(files, content).exists()) } + @Test fun aCardReachedThroughItsOtherPathKeepsItsPrivateDirectories() { + val files = tmp.newFolder("files") + val raw = SecondaryLibrary.privateRoot(files, File("/mnt/media_rw/A042-9B16/Games")).apply { mkdirs() } + assertEquals(raw, SecondaryLibrary.privateRoot(files, File("/storage/A042-9B16/Games"))) + val storage = SecondaryLibrary.privateRoot(files, File("/storage/B2BD-BCFC/Games")).apply { mkdirs() } + assertEquals(storage, SecondaryLibrary.privateRoot(files, File("/mnt/media_rw/B2BD-BCFC/Games"))) + } + + @Test fun aLibraryWithItsOwnPrivateDirectoriesKeepsThem() { + val files = tmp.newFolder("files") + val own = SecondaryLibrary.privateRoot(files, File("/storage/A042-9B16/Games")).apply { mkdirs() } + val raw = File(own.parentFile, SecondaryLibrary.privateRoot(tmp.newFolder("other"), File("/mnt/media_rw/A042-9B16/Games")).name) + raw.mkdirs() + assertEquals(own, SecondaryLibrary.privateRoot(files, File("/storage/A042-9B16/Games"))) + assertEquals(raw, SecondaryLibrary.privateRoot(files, File("/mnt/media_rw/A042-9B16/Games"))) + assertFalse(SecondaryLibrary.privateRoot(files, File("/storage/emulated/0/Games")).exists()) + } + @Test fun aWritableAliasIsSelectedAndItsProbeIsRemoved() { val library = tmp.newFolder("shared") val candidate = File(tmp.root, "direct") diff --git a/app/src/test/java/com/droiddeck/launcher/session/SteamGameProcessTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SteamGameProcessTest.kt index 5e68b5fee9..fd08a5c513 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/SteamGameProcessTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/SteamGameProcessTest.kt @@ -1,6 +1,8 @@ package com.droiddeck.launcher.session +import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse +import org.junit.Assert.assertNull import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test @@ -89,6 +91,20 @@ class SteamGameProcessTest { assertTrue(SteamGameProcess.running("351710", proc)) } + @Test fun aKnownGameProcessIsCheckedBeforeEveryOtherProcess() { + val proc = tmp.newFolder("proc") + fun process(pid: String, vararg args: String) = File(proc, pid).apply { mkdirs() }.resolve("cmdline").writeBytes(cmdline(*args)) + process("100", "reaper", "SteamLaunch", "AppId=1") + process("200", "reaper", "SteamLaunch", "AppId=1") + assertEquals("200", SteamGameProcess.runningPid("1", "200", proc)) + File(proc, "200/cmdline").writeBytes(cmdline("bash")) + assertEquals("100", SteamGameProcess.runningPid("1", "200", proc)) + assertEquals("100", SteamGameProcess.runningPid("1", "999", proc)) + File(proc, "100").deleteRecursively() + assertNull(SteamGameProcess.runningPid("1", "100", proc)) + assertNull(SteamGameProcess.runningPid("2", null, proc)) + } + @Test fun onlyTheRunningCurrentGameCountsAsAlreadyRunning() { val proc = tmp.newFolder("proc-relaunch") File(proc, "200").apply { mkdirs() }.resolve("cmdline") diff --git a/app/src/test/java/com/droiddeck/launcher/session/SteamGuidesTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SteamGuidesTest.kt new file mode 100644 index 0000000000..416a8b9b5c --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/SteamGuidesTest.kt @@ -0,0 +1,73 @@ +package com.droiddeck.launcher.session + +import androidx.test.core.app.ApplicationProvider +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33]) +class SteamGuidesTest { + private val page = """ +
+ +
+ +
+
+
+ """.trimIndent() + + @Test + fun parsesGuideCards() { + val guides = SteamGuides.parse(page) + assertEquals(1, guides.size) + val g = guides.single() + assertEquals("1848481525", g.id) + assertEquals("Stardew & You", g.title) + assertEquals("Farmer", g.author) + assertEquals("Everything about the valley...", g.summary) + assertEquals("https://images.steamusercontent.com/ugc/1/A/?imw=200&imh=200", g.preview) + assertEquals(5, g.stars) + assertEquals("https://steamcommunity.com/sharedfiles/filedetails/?id=1848481525", g.url) + } + + @Test + fun remembersOnlyGuidePagesPerGame() { + val context = ApplicationProvider.getApplicationContext() + assertNull(SteamGuides.place(context, "413150")) + SteamGuides.savePlace(context, "413150", "https://example.com/", 0.5f) + assertNull(SteamGuides.place(context, "413150")) + SteamGuides.savePlace(context, "413150", "https://steamcommunity.com/sharedfiles/filedetails/?id=1#Section", 0.4f) + assertEquals(0.4f, SteamGuides.place(context, "413150")!!.scroll, 0.001f) + assertNull(SteamGuides.place(context, "620")) + SteamGuides.clear(context, "413150") + assertNull(SteamGuides.place(context, "413150")) + } + + @Test + fun guideUrls() { + assertTrue(SteamGuides.isGuide("https://steamcommunity.com/sharedfiles/filedetails/?id=123")) + assertFalse(SteamGuides.isGuide("https://steamcommunity.com.evil/sharedfiles/filedetails/?id=123")) + assertFalse(SteamGuides.isGuide("http://steamcommunity.com/sharedfiles/filedetails/?id=123")) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/session/SteamLocalConfigTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SteamLocalConfigTest.kt new file mode 100644 index 0000000000..6470aaf3a5 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/SteamLocalConfigTest.kt @@ -0,0 +1,59 @@ +package com.droiddeck.launcher.session + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Test + +class SteamLocalConfigTest { + private val config = """ + "UserLocalConfigStore" + { + "Software" + { + "Valve" + { + "Steam" + { + "apps" + { + "620" + { + "cloud" + { + "last_sync_state" "synchronized" + } + "LastPlayed" "1764000000" + "Playtime" "754" + } + "1145360" + { + "LastPlayed" "1764100000" + } + } + } + } + } + "1145360" { "Playtime" "9999" } + } + """.trimIndent() + + @Test + fun readsPlaytimeAndLastPlayedPastNestedBlocks() { + val stats = SteamLocalConfig.appStats(config, 620)!! + assertEquals(754L, stats.playtimeMinutes) + assertEquals(1764000000L, stats.lastPlayed) + } + + @Test + fun onlyReadsTheAppsBlock() { + val stats = SteamLocalConfig.appStats(config, 1145360)!! + assertEquals(0L, stats.playtimeMinutes) + assertEquals(1764100000L, stats.lastPlayed) + } + + @Test + fun unknownAppIsNull() { + assertNull(SteamLocalConfig.appStats(config, 413150)) + assertNull(SteamLocalConfig.appStats("not vdf", 620)) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/session/SteamQamTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SteamQamTest.kt new file mode 100644 index 0000000000..5e16af444f --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/SteamQamTest.kt @@ -0,0 +1,154 @@ +package com.droiddeck.launcher.session + +import com.droiddeck.launcher.ui.QamFit +import com.droiddeck.launcher.ui.QamLayout +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner + +@RunWith(RobolectricTestRunner::class) +class SteamQamTest { + @Test fun findsTheQuickAccessPageAndKeepsOnlyItsPath() { + val json = """[ + {"title":"SP BPM_uid0","webSocketDebuggerUrl":"ws://127.0.0.1:8080/devtools/page/AAA"}, + {"title":"QuickAccess_uid2","webSocketDebuggerUrl":"ws://127.0.0.1:8080/devtools/page/0F3A-b9"} + ]""" + assertEquals(SteamQam.Target(4321, "/devtools/page/0F3A-b9"), SteamQam.parseTarget(4321, json)) + } + + @Test fun readsTheTargetListByContentLengthWithoutWaitingForClose() { + val stream = object : java.io.InputStream() { + val bytes = "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: 4\r\n\r\n[{}]".toByteArray() + var at = 0 + override fun read(): Int = if (at < bytes.size) bytes[at++].toInt() and 0xff else error("read past the response") + } + assertEquals("[{}]", SteamQam.httpBody(stream)) + } + + @Test fun ignoresMissingOrForeignDebuggerUrls() { + assertNull(SteamQam.parseTarget(1, """[{"title":"SP BPM_uid0","webSocketDebuggerUrl":"ws://127.0.0.1:1/devtools/page/A"}]""")) + assertNull(SteamQam.parseTarget(1, """[{"title":"QuickAccess_uid2"}]""")) + assertNull(SteamQam.parseTarget(1, """[{"title":"QuickAccess_uid2","webSocketDebuggerUrl":"ws://x/devtools/page/A?b=1"}]""")) + } + + @Test fun holdingIsALeaseAndReleasingEndsIt() { + assertTrue(SteamQam.script(true, owner = 7).contains(SteamQam.leaseScript(true, 7))) + assertTrue(SteamQam.script(false, owner = 7).contains(SteamQam.leaseScript(false, 7))) + assertTrue(SteamQam.newOwner() < SteamQam.newOwner()) + } + + /** Runs the lease steps in Node, in order, and returns which owner holds a live lease afterwards (0 for none). */ + private fun leaseAfter(vararg steps: Pair): Long? = runLease(steps.toList(), "g.__ddQamUntil > Date.now() ? g.__ddQamOwner : 0")?.toLongOrNull() + + /** Runs lease steps (on, owner, aspect) in Node and returns [result], a JS expression over `g`. */ + private fun runLease(steps: List, result: String): String? { + val node = runCatching { ProcessBuilder("node", "--version").start().waitFor() == 0 }.getOrDefault(false) + org.junit.Assume.assumeTrue("node is not installed", node) + val program = "const g = {};\n" + steps.joinToString("\n") { step -> + when (step) { + is Triple<*, *, *> -> SteamQam.leaseScript(step.first as Boolean, step.second as Long, step.third as Float) + is Pair<*, *> -> if (step.second == EXPIRE) "g.__ddQamUntil = Date.now() - 1;" else SteamQam.leaseScript(step.first as Boolean, step.second as Long) + else -> error("unknown step $step") + } + } + + "\nprocess.stdout.write(String($result));" + val p = ProcessBuilder("node", "-e", program).redirectErrorStream(true).start() + val out = p.inputStream.bufferedReader().readText().trim() + assertEquals(out, 0, p.waitFor()) + return out + } + + @Test fun aLateRequestFromAnOldPanelLeavesItsReplacementsLease() { + // The replacement takes the lease, then the old panel's in-flight hold lands, then its release. + assertEquals(2L, leaseAfter(true to 2L, true to 1L, false to 1L)) + // The old panel's release alone does not end the replacement's lease either. + assertEquals(2L, leaseAfter(true to 1L, true to 2L, false to 1L)) + // A panel releases its own lease. + assertEquals(0L, leaseAfter(true to 2L, false to 2L)) + // With no live lease, any panel can take it: after a release, or once a newer panel's lease has run out. + assertEquals(1L, leaseAfter(true to 2L, false to 2L, true to 1L)) + assertEquals(1L, leaseAfter(true to 2L, false to EXPIRE, true to 1L)) + // A rejected hold from an older panel leaves the newer panel's layout alone. + assertEquals("1.5", runLease(listOf(Triple(true, 2L, 1.5f), Triple(true, 1L, 0.75f)), "g.__ddQamAspect")) + assertEquals("0.75", runLease(listOf(Triple(true, 2L, 1.5f), Triple(false, 2L, 0f), Triple(true, 1L, 0.75f)), "g.__ddQamAspect")) + } + + @Test fun readsWhetherTheMenuIsShownOnTheTopScreen() { + assertEquals(SteamQam.Hold(2, false), SteamQam.parseHold("[2,0]")) + assertEquals(SteamQam.Hold(2, true), SteamQam.parseHold("[2,1]")) + assertNull(SteamQam.parseHold("2")) + } + + @Test fun theQuickAccessButtonTogglesTheTopScreenAndTheWideLayoutFollows() { + val script = SteamQam.script(true) + assertTrue(script.contains("const ours = () => held() && m.m_eOpenSideMenu === QAM && !g.__ddQamTop;")) + assertTrue(script.contains("if (press !== g.__ddQamPress) {")) + assertTrue(QamLayout.contentScript(true).contains("max-width: none !important")) + assertFalse(QamLayout.contentScript(false).contains("max-width: none")) + } + + @Test fun theMenuIsLaidOutAtThePanelsShapeOnlyWhileHeld() { + assertTrue(SteamQam.script(true, 1.5f, owner = 3).contains("g.__ddQamOwner = 3; g.__ddQamUntil = Date.now() + ${SteamQam.LEASE_MS}; g.__ddQamAspect = 1.5; }")) + assertFalse(SteamQam.script(true).contains("g.__ddQamAspect =")) + assertFalse(SteamQam.script(false, 1.5f).contains("g.__ddQamAspect =")) + } + + @Test fun aSteamDialogOverTheGameGetsTheInput() { + val script = SteamQam.script(true) + assertTrue(script.contains("t.m_ID?.startsWith(\"ModalDialogOverlay\") && t.m_Root?.m_element?.isConnected")) + assertTrue(script.contains("if (dialog && !g.__ddQamTop) {")) + assertTrue(script.indexOf("if (dialog && !g.__ddQamTop)") < script.indexOf("g.__ddQamDecky = decky;")) + } + + @Test fun theRelayAnswersWithItsPortAndSecret() { + assertEquals(41234 to "0123456789abcdef0123456789abcdef", SteamQam.parseRelay("41234 0123456789abcdef0123456789abcdef\n")) + assertNull(SteamQam.parseRelay("41234")) + assertNull(SteamQam.parseRelay("41234 not-a-secret")) + assertNull(SteamQam.parseRelay(null)) + } + + @Test fun whileHeldTheMenuStaysOffTheTopScreenAndOutOfTheGamesWay() { + val script = SteamQam.script(true) + assertTrue(script.contains("return without >= 2 ? v : 1;")) + assertTrue(script.contains("if (w > 0 && ours()) { x = popup.m_popup.innerWidth + 64; w = width(h) || w; }")) + assertTrue(script.contains("nav.m_LastActiveNavTree?.m_ID?.startsWith(\"QuickAccess\")")) + assertTrue(script.contains("if (m.m_eOpenSideMenu === QAM) m.CloseSideMenus();")) + } + + @Test fun theMenuFillsTheHeightAndCentresAndTouchesMapBack() { + val (scale, left) = QamLayout.fit(1280f, 832f, 400f, 640f) + assertEquals(1.3f, scale, 0.001f) + assertEquals((1280f - 520f) / 2f, left, 0.001f) + val (x, y) = QamLayout.toCss(left + 130f, 260f, scale, left) + assertEquals(100f, x, 0.001f) + assertEquals(200f, y, 0.001f) + } + + @Test fun aNarrowMenuCanSitLeftOrRight() { + assertEquals(0f, QamLayout.fit(1280f, 832f, 400f, 640f, -1).second, 0.001f) + assertEquals(1280f - 520f, QamLayout.fit(1280f, 832f, 400f, 640f, 1).second, 0.001f) + assertEquals(0f, QamLayout.fit(1280f, 832f, 1280f, 640f, 1).second, 0.001f) + } + + @Test fun theLayoutButtonCyclesFullLeftCenterRight() { + assertEquals(listOf(QamFit.LEFT, QamFit.CENTER, QamFit.RIGHT, QamFit.FULL), QamFit.entries.map { it.next }) + assertEquals(QamFit.FULL, QamFit.from(null)) + assertEquals(QamFit.RIGHT, QamFit.from("right")) + assertEquals(QamFit.FULL, QamFit.from("sideways")) + } + + @Test fun aWideMenuFitsTheWidth() { + val (scale, left) = QamLayout.fit(1280f, 832f, 1280f, 640f) + assertEquals(1f, scale, 0.001f) + assertEquals(0f, left, 0.001f) + } + + private companion object { + /** A lease step that lets the current lease run out. */ + const val EXPIRE = -1L + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/session/StoresTabOrderTest.kt b/app/src/test/java/com/droiddeck/launcher/session/StoresTabOrderTest.kt index fb1fb71a5d..4137f0a81b 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/StoresTabOrderTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/StoresTabOrderTest.kt @@ -15,7 +15,7 @@ import org.robolectric.annotation.Config @Config(sdk = [33]) class StoresTabOrderTest { private val app get() = RuntimeEnvironment.getApplication() - private val defaults = Store.entries.map { it.id } + private val defaults = Store.tabbed.map { it.id } private fun shown() = arrangeStoreTabs(SessionPrefs.storesTabOrder(app), emptySet()).map { it.store.id } @Test diff --git a/app/src/test/java/com/droiddeck/launcher/session/WinComponentsSupportTest.kt b/app/src/test/java/com/droiddeck/launcher/session/WinComponentsSupportTest.kt index 8311736999..4d70c02022 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/WinComponentsSupportTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/WinComponentsSupportTest.kt @@ -3,6 +3,7 @@ package com.droiddeck.launcher.session import com.droiddeck.launcher.session.WinComponents.Support import org.json.JSONObject import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @@ -31,12 +32,13 @@ class WinComponentsSupportTest { step("install_msi", "url" to "$base/ps-x86.msi"), step("install_msi", "url" to "$base/ps-x64.msi")))) } - @Test fun builtInArm64RuntimeIsRegistryOnlyInBothViews() { + @Test fun builtInArm64RuntimeInstallsTheRedistributable() { val c = WinComponents.builtInArm64Runtime() assertEquals(Support.READY, support(c)) - assertEquals(12, c.steps.count { it.action == "set_register_key" }) - assertEquals(setOf("HKLM\\Software\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\arm64", - "HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\arm64"), c.steps.map { it.str("key") }.toSet()) + assertEquals(listOf("install_exe"), c.steps.map { it.action }) + assertEquals("VC_redist.arm64.exe", c.steps.single().str("file_name")) + assertEquals(0, c.steps.count { it.action == "set_register_key" }) + assertTrue(c.revision > 0) } @Test fun installerWrappersInstallHere() { diff --git a/app/src/test/java/com/droiddeck/launcher/stores/SteamAchievementsTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/SteamAchievementsTest.kt new file mode 100644 index 0000000000..23bf252cca --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/stores/SteamAchievementsTest.kt @@ -0,0 +1,41 @@ +package com.droiddeck.launcher.stores + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33]) +class SteamAchievementsTest { + @Test + fun parsesTheClientsAchievementList() { + val json = """{"result":1,"data":{"rgAchievements":[ + {"strID":"ACH_WIN","strName":"Winner","strDescription":"Win once","bAchieved":true,"rtUnlocked":1764000000, + "strImage":"https://cdn.example/apps/620/abc.jpg","bHidden":false}, + {"strID":"ACH_SECRET","strName":"Secret","strDescription":"","bAchieved":false,"rtUnlocked":1764000000, + "strImage":"def.jpg","bHidden":true}]}}""" + val list = (SteamAchievements.parse(620, json) as StoreAchievements.Result.Found).list + assertEquals(2, list.size) + assertEquals("Winner", list[0].name) + assertTrue(list[0].unlocked) + assertEquals(1764000000L, list[0].unlockedAt) + assertEquals("https://cdn.example/apps/620/abc.jpg", list[0].icon) + assertTrue(list[1].hidden) + assertEquals(0L, list[1].unlockedAt) + assertEquals("https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/apps/620/def.jpg", list[1].icon) + } + + @Test + fun gamesWithoutStatsHaveNoAchievementsAndGarbageIsUnreachable() { + assertEquals(0, (SteamAchievements.parse(12200, """{"result":2,"message":"Failed to retrieve user stats"}""") as StoreAchievements.Result.Found).list.size) + assertTrue(SteamAchievements.parse(620, "nope") is StoreAchievements.Result.Failed) + } + + @Test + fun noListIsNoAchievements() { + assertEquals(0, (SteamAchievements.parse(620, """{"result":1,"data":{}}""") as StoreAchievements.Result.Found).list.size) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/stores/SteamLiveShortcutsSyncTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/SteamLiveShortcutsSyncTest.kt new file mode 100644 index 0000000000..11d9b1b982 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/stores/SteamLiveShortcutsSyncTest.kt @@ -0,0 +1,27 @@ +package com.droiddeck.launcher.stores + +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33]) +class SteamLiveShortcutsSyncTest { + @Test fun everyGameKnownOrAddedIsDelivered() { + assertTrue(SteamLiveShortcuts.synced("""{"added":2,"missed":0}""")) + assertTrue(SteamLiveShortcuts.synced("""{"added":0,"missed":0}""")) + } + + @Test fun aGameTheClientRefusedIsNotDelivered() { + assertFalse(SteamLiveShortcuts.synced("""{"added":1,"missed":1}""")) + assertFalse(SteamLiveShortcuts.synced("""{"added":0,"missed":3}""")) + } + + @Test fun noAnswerIsNotDelivered() { + assertFalse(SteamLiveShortcuts.synced(null)) + assertFalse(SteamLiveShortcuts.synced("1")) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/stores/battlenet/BattleNetLibraryTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/battlenet/BattleNetLibraryTest.kt new file mode 100644 index 0000000000..39f6d59448 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/stores/battlenet/BattleNetLibraryTest.kt @@ -0,0 +1,34 @@ +package com.droiddeck.launcher.stores.battlenet + +import com.droiddeck.launcher.session.SessionPrefs +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.RuntimeEnvironment +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33]) +class BattleNetLibraryTest { + private val app get() = RuntimeEnvironment.getApplication() + @get:Rule val tmp = TemporaryFolder() + + @Test fun aMissingLibraryLeavesBattleNetsInstallFolderAlone() { + SessionPrefs.setGameStorage(app, "/storage/0000-0000/Games", "SD card") + assertTrue(BattleNetClient.library(app).isEmpty()) + } + + @Test fun anAttachedLibraryIsHandedToBattleNet() { + SessionPrefs.setGameStorage(app, tmp.newFolder("card").path, "SD card") + assertEquals("--library", BattleNetClient.library(app).firstOrNull()) + } + + @Test fun internalStorageIsHandedToBattleNetWhenItIsTheChoice() { + SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "") + assertEquals("--library", BattleNetClient.library(app).firstOrNull()) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/stores/download/DownloadQueueRemovalTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/download/DownloadQueueRemovalTest.kt index 5ad355f8ec..c8e36953e6 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/download/DownloadQueueRemovalTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/download/DownloadQueueRemovalTest.kt @@ -188,6 +188,34 @@ class DownloadQueueRemovalTest { assertFalse(folder.exists()) } + @Test fun uninstallStopsARunningDownloadThenRemovesTheGame() { + val running = CountDownLatch(1) + val cancels = AtomicInteger() + val entry = DownloadEntry(Store.GOG, "uninstall-while-running", "Running") + DownloadQueue.enqueue(app, entry) { + object : DownloadQueue.DownloadJob { + override fun run(handle: DownloadQueue.JobHandle): String? { + running.countDown() + val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(10) + while (!handle.isCancelled && System.nanoTime() < until) Thread.sleep(10) + return null + } + override fun cancel(deleteFiles: Boolean) { cancels.incrementAndGet() } + } + } + assertTrue(running.await(5, TimeUnit.SECONDS)) + val folder = File(app.filesDir, "uninstall-while-running").apply { mkdirs() } + File(folder, "game.bin").writeText("x") + val game = InstalledStoreGame(StoreGameSidecar(Store.GOG, "uninstall-while-running", "Running", exe = "game.bin"), folder) + assertEquals(entry.key, game.key) + val done = CountDownLatch(1) + StoresState.uninstall(app, game) { done.countDown() } + assertTrue(idleUntil { done.count == 0L }) + assertEquals(1, cancels.get()) + assertTrue(DownloadQueue.entry(entry.key)?.state.let { it == null || it == DownloadState.CANCELLED }) + assertFalse(folder.exists()) + } + private fun blockDiscards(): CountDownLatch { val release = CountDownLatch(1) StoreInstalls.beforeDiscard = { release.await(5, TimeUnit.SECONDS) } diff --git a/app/src/test/java/com/droiddeck/launcher/stores/ea/EaTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/ea/EaTest.kt index 2a3ed5ce63..84500376ca 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/ea/EaTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/ea/EaTest.kt @@ -302,7 +302,7 @@ class EaTest { val text = StoreLaunch.launcherText(StoreGameSidecar(Store.EA, "Origin.OFR.1", "Game", exe = "bin/Game.exe", args = listOf("-dx12"))) assertTrue(text.contains("for /f \"usebackq tokens=1,* delims==\" %%a in (\"%~dp0.droiddeck-ea-env\") do set \"%%a=%%b\"")) assertTrue(text.contains("del \"%~dp0.droiddeck-ea-env\"")) - assertTrue(text.contains("start \"\" \"${StoreLaunch.EA_ORIGIN}\"\r\n\"%~dp0bin\\Game.exe\" -dx12\r\n")) + assertTrue(text.contains("start \"\" \"${StoreLaunch.EA_ORIGIN}\"\r\n\"%~dp0bin\\Game.exe\" -dx12 %*\r\n")) assertTrue(text.trimEnd().endsWith("taskkill /f /im Origin.exe >nul 2>&1")) } diff --git a/app/src/test/java/com/droiddeck/launcher/stores/steam/SteamLibraryFoldersTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/steam/SteamLibraryFoldersTest.kt new file mode 100644 index 0000000000..5eadd93b3b --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/stores/steam/SteamLibraryFoldersTest.kt @@ -0,0 +1,278 @@ +package com.droiddeck.launcher.stores.steam + +import com.droiddeck.launcher.stores.download.DownloadStage +import java.io.File +import java.nio.file.Files +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test + +class SteamLibraryFoldersTest { + private val rootfs = File("/data/user/0/com.droiddeck.launcher/files/rootfs") + private val card = File("/storage/1A2B-3C4D/Android/data/com.droiddeck.launcher/files/steam") + private val lib = File("/storage/1A2B-3C4D/SteamLibrary") + private val games = File("/storage/1A2B-3C4D/Games") + private val armRoot = File(rootfs, "root/.local/share/Steam") + private val x64Root = File(rootfs, "root/.droiddeck-x64/.local/share/Steam") + private val armAliases = listOf("/root/.local/share/Steam", "/root/.steam/steam", "/root/.steam/root") + private val mounts = listOf( + SteamLibraryFolders.Mount("/mnt/droiddeck-sd", card), + SteamLibraryFolders.Mount("/mnt/droiddeck-lib/1", lib), + SteamLibraryFolders.Mount("/root/Games/Card/", games), + SteamLibraryFolders.Mount("/root/Storage", File("/storage/emulated/0")), + ) + + private val vdf = """ + "libraryfolders" + { + "contentstatsid" "-4785" + "0" + { + "path" "/root/.local/share/Steam" + "label" "Internal Storage" + "contentid" "123" + "totalsize" "0" + "apps" + { + "228980" "0" + } + } + "1" + { + "path" "/mnt/droiddeck-sd" + "label" "SD card" + "apps" + { + "291550" "1500000000" + } + } + "2" + { + "path" "/mnt/droiddeck-lib/1" + "label" "Steam \"Lib\"" + } + "3" + { + "path" "/root/Games/Card" + "label" "" + } + "4" + { + "path" "/root/.droiddeck-x64/shared/x86-64" + "label" "x86-64 client games" + } + "5" + { + "path" "/mnt/droiddeck-lib/9" + "label" "Removed" + } + "6" + { + "path" "/root/Games/Gone" + "label" "Gone" + } + } + """.trimIndent() + + @Test fun readsEveryFolderWithItsLabel() { + val folders = SteamLibraryFolders.parse(vdf) + assertEquals( + listOf("/root/.local/share/Steam", "/mnt/droiddeck-sd", "/mnt/droiddeck-lib/1", "/root/Games/Card", + "/root/.droiddeck-x64/shared/x86-64", "/mnt/droiddeck-lib/9", "/root/Games/Gone"), + folders.map { it.path }, + ) + assertEquals("Internal Storage", folders[0].label) + assertEquals("Steam \"Lib\"", folders[2].label) + assertEquals("", folders[3].label) + } + + @Test fun readsTheOldFormatAndEscapedPaths() { + val old = """ + "LibraryFolders" + { + "TimeNextStatsReport" "1700000000" + "ContentStatsID" "-1" + "1" "/mnt/droiddeck-sd" + "2" "/root/odd\\name" + } + """.trimIndent() + assertEquals( + listOf(SteamLibraryFolders.Folder("/mnt/droiddeck-sd", ""), SteamLibraryFolders.Folder("/root/odd\\name", "")), + SteamLibraryFolders.parse(old), + ) + assertTrue(SteamLibraryFolders.parse("").isEmpty()) + } + + @Test fun arm64LibrariesMapFromGuestToHost() { + val libraries = SteamLibraryFolders.resolve( + SteamLibraryFolders.parse(vdf), "/root/.local/share/Steam", armAliases, armRoot, mounts, rootfs, + ) + assertEquals( + listOf(armRoot, card, lib, games, File(rootfs, "root/.droiddeck-x64/shared/x86-64")), + libraries.map { it.host }, + ) + assertEquals(listOf(true, false, false, false, false), libraries.map { it.main }) + assertEquals("/mnt/droiddeck-sd", libraries[1].guest) + assertEquals("SD card", libraries[1].label) + } + + @Test fun x64LibrariesSitInsideTheCardAndAddedLibraries() { + val text = """ + "libraryfolders" + { + "0" { "path" "/root/.droiddeck-x64/.local/share/Steam" "label" "Internal Storage" } + "1" { "path" "/mnt/droiddeck-sd/x86-64" "label" "SD card" } + "2" { "path" "/mnt/droiddeck-lib/1/x86-64/" "label" "Lib" } + "3" { "path" "/root/.droiddeck-x64/shared/arm64" "label" "ARM64 client games" } + } + """.trimIndent() + val libraries = SteamLibraryFolders.resolve( + SteamLibraryFolders.parse(text), "/root/.droiddeck-x64/.local/share/Steam", + listOf("/root/.droiddeck-x64/.local/share/Steam", "/root/.droiddeck-x64/.steam/steam"), x64Root, mounts, rootfs, + ) + assertEquals( + listOf(x64Root, File(card, "x86-64"), File(lib, "x86-64"), File(rootfs, "root/.droiddeck-x64/shared/arm64")), + libraries.map { it.host }, + ) + assertEquals("/mnt/droiddeck-lib/1/x86-64", libraries[2].guest) + } + + @Test fun aGuestPathWithoutItsBindIsNotAnInstallTarget() { + assertNull(SteamLibraryFolders.hostFor("/mnt/droiddeck-sd", emptyList(), rootfs)) + assertNull(SteamLibraryFolders.hostFor("/root/Games/Gone", mounts, rootfs)) + assertNull(SteamLibraryFolders.hostFor("/root/Storage/Steam", emptyList(), rootfs)) + assertNull(SteamLibraryFolders.hostFor("/opt/steam", mounts, rootfs)) + assertNull(SteamLibraryFolders.hostFor("/root/../etc", mounts, rootfs)) + assertNull(SteamLibraryFolders.hostFor("relative/path", mounts, rootfs)) + assertEquals(File("/storage/emulated/0/Steam"), SteamLibraryFolders.hostFor("/root/Storage/Steam", mounts, rootfs)) + assertEquals(File(card, "x86-64"), SteamLibraryFolders.hostFor("/mnt/droiddeck-sd//x86-64/", mounts, rootfs)) + } + + @Test fun aliasesAreTheMainLibraryAndAMissingMainIsAddedFirst() { + val aliased = SteamLibraryFolders.resolve( + listOf(SteamLibraryFolders.Folder("/root/.steam/steam", "Internal Storage"), SteamLibraryFolders.Folder("/mnt/droiddeck-sd", "SD card")), + "/root/.local/share/Steam", armAliases, armRoot, mounts, rootfs, + ) + assertEquals(listOf(armRoot, card), aliased.map { it.host }) + assertEquals("/root/.steam/steam", aliased[0].guest) + + val missing = SteamLibraryFolders.resolve( + listOf(SteamLibraryFolders.Folder("/mnt/droiddeck-sd", "SD card"), SteamLibraryFolders.Folder("/mnt/droiddeck-sd/", "Again")), + "/root/.local/share/Steam", armAliases, armRoot, mounts, rootfs, + ) + assertEquals(listOf(armRoot, card), missing.map { it.host }) + assertEquals("/root/.local/share/Steam", missing[0].guest) + assertEquals("", missing[0].label) + } + + private fun acf(library: File, appId: Int, name: String, flags: Int, dir: String = name, size: Long = 0L) { + val apps = File(library, "steamapps").apply { mkdirs() } + File(apps, "appmanifest_$appId.acf").writeText( + """ + "AppState" + { + "appid" "$appId" + "name" "$name" + "StateFlags" "$flags" + "installdir" "$dir" + "SizeOnDisk" "$size" + } + """.trimIndent(), + ) + } + + @Test fun onlyFullyInstalledGamesCountAsInstalled() { + val base = Files.createTempDirectory("steam-libs").toFile() + try { + val first = SteamLibraryFolders.Library("/root/.local/share/Steam", File(base, "internal"), "Internal Storage", true) + val second = SteamLibraryFolders.Library("/mnt/droiddeck-sd", File(base, "card"), "SD card", false) + val missing = SteamLibraryFolders.Library("/mnt/droiddeck-lib/1", File(base, "gone"), "Gone", false) + acf(first.host, 291550, "Brawlhalla", 4, size = 1_500_000_000L) + acf(first.host, 620, "Portal 2", 1026) + acf(first.host, 1628350, "Steam Linux Runtime 3.0 (sniper)", 4, dir = "SteamLinuxRuntime_sniper") + acf(second.host, 291550, "Brawlhalla copy", 4) + acf(second.host, 413150, "Stardew Valley", 6) + File(second.host, "steamapps/appmanifest_400.acf.tmp").writeText("\"AppState\" { \"appid\" \"400\" \"StateFlags\" \"4\" }") + File(second.host, "steamapps/libraryfolder.vdf").writeText("\"libraryfolder\" { }") + + val found = SteamLibraryFolders.installed(listOf(first, second, missing)) + assertEquals(setOf(291550, 413150), found.keys) + assertEquals("Brawlhalla", found.getValue(291550).name) + assertEquals(first, found.getValue(291550).library) + assertEquals(1_500_000_000L, found.getValue(291550).sizeOnDisk) + assertEquals(second, found.getValue(413150).library) + assertEquals("Stardew Valley", found.getValue(413150).installDir) + } finally { + base.deleteRecursively() + } + } + + @Test fun theClientsRememberedAccountIsTheSavedSignIn() { + val users = """ + "users" + { + "76561190000000001" + { + "AccountName" "old" + "PersonaName" "Old One" + "RememberPassword" "1" + "MostRecent" "0" + "Timestamp" "1600000000" + } + "76561190000000002" + { + "AccountName" "player" + "PersonaName" "Player" + "RememberPassword" "1" + "MostRecent" "1" + "Timestamp" "1700000000" + } + } + """.trimIndent() + assertEquals("Player", SteamLibraryFolders.savedAccount(users)) + assertEquals(SteamLibraryFolders.SavedAccount("76561190000000002", "Player"), SteamLibraryFolders.savedLogin(users)) + assertEquals("Old One", SteamLibraryFolders.savedAccount(users.replace("\"MostRecent\"\t\t\"1\"", "\"MostRecent\"\t\t\"0\"").replace("\"1700000000\"", "\"1500000000\""))) + assertEquals("player", SteamLibraryFolders.savedAccount(users.replace("\"PersonaName\"\t\t\"Player\"", "\"PersonaName\"\t\t\"\"").replace("\"Old One\"", "\"\"").replace("\"1600000000\"", "\"1\""))) + assertNull(SteamLibraryFolders.savedAccount(users.replace("\"RememberPassword\"\t\t\"1\"", "\"RememberPassword\"\t\t\"0\""))) + assertNull(SteamLibraryFolders.savedAccount("")) + val registry = "\"Registry\"\n{\n\t\"HKCU\"\n\t{\n\t\t\"Software\"\n\t\t{\n\t\t\t\"Valve\"\n\t\t\t{\n\t\t\t\t\"Steam\"\n\t\t\t\t{\n\t\t\t\t\t\"AutoLoginUser\"\t\t\"OLD\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n" + assertEquals(SteamLibraryFolders.SavedAccount("76561190000000001", "Old One"), SteamLibraryFolders.savedLogin(users, registry)) + assertNull(SteamLibraryFolders.savedLogin(users.replace("\"RememberPassword\"\t\t\"1\"\n\t\t\"MostRecent\"\t\t\"0\"", "\"RememberPassword\"\t\t\"0\"\n\t\t\"MostRecent\"\t\t\"0\""), registry)) + } + + @Test fun theClientLanguageComesFromTheRegistry() { + val registry = """ + "Registry" + { + "HKCU" + { + "Software" + { + "Valve" + { + "Steam" + { + "AutoLoginUser" "player" + "language" "german" + } + } + } + } + } + """.trimIndent() + assertEquals("german", SteamLibraryFolders.language(registry)) + assertNull(SteamLibraryFolders.language("\"Registry\" { \"HKCU\" { } }")) + } + + @Test fun enginePhasesShowAsDownloadStages() { + assertEquals(DownloadStage.DOWNLOAD, SteamLibraryFolders.stageOf("download")) + assertEquals(DownloadStage.DOWNLOAD, SteamLibraryFolders.stageOf("Downloading")) + assertEquals(DownloadStage.DOWNLOAD, SteamLibraryFolders.stageOf("")) + assertEquals(DownloadStage.VERIFY, SteamLibraryFolders.stageOf("verify")) + assertEquals(DownloadStage.MANIFEST, SteamLibraryFolders.stageOf("manifests")) + assertEquals(DownloadStage.MANIFEST, SteamLibraryFolders.stageOf("cleanup")) + assertEquals(DownloadStage.INSTALL, SteamLibraryFolders.stageOf("register")) + assertEquals(DownloadStage.INSTALL, SteamLibraryFolders.stageOf("finalize")) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/stores/steam/SteamPickingSnapshotTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/steam/SteamPickingSnapshotTest.kt new file mode 100644 index 0000000000..6193a037bf --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/stores/steam/SteamPickingSnapshotTest.kt @@ -0,0 +1,37 @@ +package com.droiddeck.launcher.stores.steam + +import androidx.compose.runtime.State +import androidx.compose.runtime.snapshots.Snapshot +import androidx.compose.runtime.snapshots.StateObject +import com.droiddeck.launcher.stores.StoresState +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config +import kotlin.concurrent.thread + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33], manifest = Config.NONE) +class SteamPickingSnapshotTest { + @Test + fun theInstallPickerIsReadableInASnapshotOpenedBeforeTheSteamEngineStarts() { + StoresState.steamPicking = null + val snapshot = Snapshot.takeMutableSnapshot() + try { + thread { SteamStore.hashCode() }.join() + assertNull(snapshot.enter { StoresState.steamPicking }) + } finally { + snapshot.dispose() + } + } + + @Test + fun theSteamEngineHoldsNoComposeState() { + val stateFields = SteamStore::class.java.declaredFields.filter { + StateObject::class.java.isAssignableFrom(it.type) || State::class.java.isAssignableFrom(it.type) + } + assertTrue(stateFields.joinToString { it.name }, stateFields.isEmpty()) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxCatalogTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxCatalogTest.kt index c2106a9bf9..810c2f8642 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxCatalogTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxCatalogTest.kt @@ -208,4 +208,53 @@ class XboxCatalogTest { val merged = mergeEditions(listOf(pc, console)).single() assertEquals(game, merged.id); assertTrue(merged.xboxPc); assertTrue(merged.xboxCloud); assertEquals(parent, merged.xboxCloudId) } + + @Test fun anOwnedCloudEditionMakesTheGamePassPcCardOwned() { + val cloud = XboxCloudCatalog(gamePass = setOf(game), all = setOf(game, parent)) + val pc = XboxCatalog.product(product(game, "Windows.Desktop"), mapOf(game to "gamepass"), cloud)!! + val console = XboxCatalog.product(product(parent, "Xbox.One"), mapOf(parent to "owned"), cloud)!! + val merged = mergeEditions(listOf(pc, console)).single() + assertEquals(game, merged.id); assertTrue(merged.owned); assertFalse(merged.subscription); assertEquals("owned", merged.extra["access"]) + assertTrue(merged.xboxCloud); assertEquals(game, merged.xboxCloudId) + } + + @Test fun launchArtIsHeroArtThenScreenshotsFromStoreImagesOnly() { + fun img(purpose: String, uri: String) = JSONObject().put("ImagePurpose", purpose).put("Uri", uri) + val json = JSONObject().put("LocalizedProperties", JSONArray().put(JSONObject().put("Images", JSONArray() + .put(img("Screenshot", "//store-images.s-microsoft.com/image/shot1")) + .put(img("BoxArt", "https://store-images.s-microsoft.com/image/box")) + .put(img("SuperHeroArt", "https://store-images.s-microsoft.com/image/hero")) + .put(img("Screenshot", "https://evil.example/shot2")) + .put(img("Screenshot", "https://store-images.s-microsoft.com/image/shot1"))))) + assertEquals(listOf("https://store-images.s-microsoft.com/image/hero", "https://store-images.s-microsoft.com/image/shot1"), + XboxCatalog.launchArtUrls(json)) + assertEquals(emptyList(), XboxCatalog.launchArtUrls(JSONObject())) + } + + @Test fun cloudOnlyEditionsWithTheSameTitleBecomeOneOwnedCard() { + val third = "9CCCCCCCCCCC" + val cloud = XboxCloudCatalog(gamePass = setOf(game), all = setOf(game, third)) + val pass = XboxCatalog.product(product(game, "Xbox.One"), mapOf(game to "gamepass"), cloud)!! + val owned = XboxCatalog.product(product(third, "Xbox.One"), mapOf(third to "owned"), cloud)!! + val merged = mergeEditions(listOf(pass, owned)).single() + assertEquals(third, merged.id); assertTrue(merged.owned) + } + + @Test fun nonLatinTitlesStaySeparateEditions() { + val third = "9CCCCCCCCCCC" + val cloud = XboxCloudCatalog(gamePass = setOf(game, parent, third), all = setOf(game, parent, third)) + val first = XboxCatalog.product(product(game, "Xbox.One"), mapOf(game to "gamepass"), cloud)!!.copy(title = "原神") + val second = XboxCatalog.product(product(parent, "Xbox.One"), mapOf(parent to "gamepass"), cloud)!!.copy(title = "逆転裁判") + val pc = XboxCatalog.product(product(third, "Windows.Desktop"), mapOf(third to "gamepass"), cloud)!!.copy(title = "鉄拳") + val merged = mergeEditions(listOf(first, second, pc)) + assertEquals(setOf(game, parent, third), merged.map { it.id }.toSet()) + assertFalse(merged.single { it.id == third }.extra["cloudId"] in setOf(game, parent)) + } + + @Test fun supplementaryPlaneLettersKeepEditionsApart() { + val cloud = XboxCloudCatalog(gamePass = setOf(game, parent), all = setOf(game, parent)) + val first = XboxCatalog.product(product(game, "Xbox.One"), mapOf(game to "gamepass"), cloud)!!.copy(title = "\uD840\uDC00 2") + val second = XboxCatalog.product(product(parent, "Xbox.One"), mapOf(parent to "gamepass"), cloud)!!.copy(title = "\uD840\uDC01 2") + assertEquals(2, mergeEditions(listOf(first, second)).size) + } } diff --git a/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxCloudTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxCloudTest.kt index bbe2e11f90..36e774a446 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxCloudTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxCloudTest.kt @@ -46,4 +46,11 @@ class XboxCloudTest { @Test fun cloudLaunchUrlUsesTheStreamingEdition() { assertEquals("https://www.xbox.com/play/launch/ball-x-pit/9BBBBBBBBBBB", XboxCatalog.cloudUrl("9AAAAAAAAAAA", "BALL x PIT", "9BBBBBBBBBBB")) } + + @Test fun titleNameKeyDropsEditionWords() { + assertEquals("FORZAHORIZON6", XboxCloudSession.nameKey("Forza Horizon 6 Standard Edition")) + assertEquals("FORTNITE", XboxCloudSession.nameKey("Fortnite")) + assertEquals("HALOINFINITE", XboxCloudSession.nameKey("Halo Infinite (Xbox Series X|S)")) + assertEquals("STARFIELD", XboxCloudSession.nameKey("Starfield Premium Edition for Windows")) + } } diff --git a/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxManifestTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxManifestTest.kt index cb0a7bf0cc..5c3cd5c637 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxManifestTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxManifestTest.kt @@ -16,6 +16,34 @@ class XboxManifestTest { java.io.File(root, "MicrosoftGame.Config").writeText("") assertEquals("Bin/Game.exe", XboxInstaller.executable(root)) } + @Test fun aListedExecutableThePackageDoesNotShipFallsThroughToTheNextOne() { + val root = temporary.newFolder() + java.io.File(root, "bin/x64_dx12").mkdirs() + java.io.File(root, "bin/x64_dx12/game.exe").writeText("encrypted") + java.io.File(root, "MicrosoftGame.config").writeText("" + + "" + + "" + + "") + assertEquals("bin/x64_dx12/game.exe", XboxInstaller.executable(root)) + } + @Test fun anAmbiguouslyCasedExecutableFallsThroughToTheNextOne() { + val root = temporary.newFolder() + java.io.File(root, "Game.exe").writeText("one") + java.io.File(root, "GAME.exe").writeText("two") + java.io.File(root, "Other.exe").writeText("three") + org.junit.Assume.assumeTrue(root.listFiles().orEmpty().count { it.name.equals("game.exe", true) } == 2) + java.io.File(root, "MicrosoftGame.config").writeText("" + + "") + assertEquals("Other.exe", XboxInstaller.executable(root)) + } + @Test fun aPackageWithNoneOfItsListedExecutablesStillFails() { + val root = temporary.newFolder() + java.io.File(root, "Unlisted.exe").writeText("encrypted") + java.io.File(root, "MicrosoftGame.config").writeText("" + + "") + val failure = assertThrows(IllegalArgumentException::class.java) { XboxInstaller.executable(root) } + assertEquals("Missing or ambiguous Xbox launch path.", failure.message) + } @Test fun aLauncherMenuIsSkippedForTheProgramItNames() { val root = temporary.newFolder() java.io.File(root, "EmuMenu").mkdir() diff --git a/app/src/test/java/com/droiddeck/launcher/stores/xbox/XodusDiagnosticsTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/xbox/XodusDiagnosticsTest.kt index 3e2310be5c..6b9ecb4918 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/xbox/XodusDiagnosticsTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/xbox/XodusDiagnosticsTest.kt @@ -9,6 +9,25 @@ import org.junit.Test class XodusDiagnosticsTest { private val rejected = Regex(Xodus.SIGN_IN_REJECTED) + @Test fun aDeviceLimitReachesTheInstallerWithoutBecomingASignInFailure() { + val line = "NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-device-limit 200" + val tail = listOf(line).filter { it.matches(Xodus.reportable) } + assertEquals(listOf(line), tail) + assertFalse(line.matches(rejected)) + assertEquals(com.droiddeck.launcher.R.string.stores_xbox_device_group_full, XboxInstaller.licenseRefusal(tail)) + } + + @Test fun aLaterLicenseSuccessClearsTheDeviceLimitThroughTheDiagnosticFilter() { + val stderr = listOf( + "NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-device-limit 200", + "NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-parsed 200", + "NEXUS_EXTRACT_DIAGNOSTIC_V1 extract-failed" + ) + val tail = stderr.filter { it.matches(Xodus.reportable) } + assertEquals(stderr, tail) + assertNull(XboxInstaller.licenseRefusal(tail)) + } + @Test fun aContentLicenseRejectionIsRecognised() { assertTrue("Microsoft content licensing rejected sign-in (HTTP 401). Sign in again in Settings.".matches(rejected)) } diff --git a/app/src/test/java/com/droiddeck/launcher/ui/BottomBrightnessTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/BottomBrightnessTest.kt new file mode 100644 index 0000000000..99fae40305 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/ui/BottomBrightnessTest.kt @@ -0,0 +1,47 @@ +package com.droiddeck.launcher.ui + +import androidx.test.core.app.ApplicationProvider +import android.content.Context +import com.droiddeck.launcher.session.SessionPrefs +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner + +@RunWith(RobolectricTestRunner::class) +class BottomBrightnessTest { + private val context = ApplicationProvider.getApplicationContext() + + @Test fun followsTheSystemUntilTheUserPicksALevel() { + assertNull(BottomBrightness.level(context)) + SessionPrefs.setBottomBrightness(context, 40) + assertEquals(0.4f, BottomBrightness.level(context)!!, 0.001f) + } + + @Test fun theSliderNeverReachesZero() { + assertEquals(BottomBrightness.MIN, BottomBrightness.clamp(0)) + assertEquals(BottomBrightness.MIN, BottomBrightness.clamp(-20)) + assertEquals(100, BottomBrightness.clamp(150)) + SessionPrefs.setBottomBrightness(context, 0) + assertEquals(BottomBrightness.MIN / 100f, BottomBrightness.level(context)!!, 0.001f) + } + + @Test fun autoDimNeverBrightensADarkerChoice() { + assertEquals(0.05f, BottomBrightness.dimmed(context, 0.05f), 0.001f) + SessionPrefs.setBottomBrightness(context, 5) + assertEquals(0.05f, BottomBrightness.dimmed(context, 0.2f), 0.001f) + SessionPrefs.setBottomBrightness(context, 80) + assertEquals(0.05f, BottomBrightness.dimmed(context, 0.05f), 0.001f) + } + + @Test fun autoDimFollowsADarkerManualSystemLevelWhenNothingIsSaved() { + val resolver = context.contentResolver + android.provider.Settings.System.putInt(resolver, android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE, + android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL) + android.provider.Settings.System.putInt(resolver, android.provider.Settings.System.SCREEN_BRIGHTNESS, 3) + assertEquals(3 / 255f, BottomBrightness.dimmed(context, 0.05f), 0.001f) + android.provider.Settings.System.putInt(resolver, android.provider.Settings.System.SCREEN_BRIGHTNESS, 200) + assertEquals(0.05f, BottomBrightness.dimmed(context, 0.05f), 0.001f) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/ui/BottomChromeTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/BottomChromeTest.kt new file mode 100644 index 0000000000..26d51288fa --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/ui/BottomChromeTest.kt @@ -0,0 +1,36 @@ +package com.droiddeck.launcher.ui + +import org.junit.After +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +class BottomChromeTest { + @After fun clear() { + BottomChrome.reset() + } + + @Test fun aFullScreenPanelHidesTheBarAndThePullTabBringsItBack() { + assertTrue(BottomChrome.barShown) + BottomChrome.request(true) + assertFalse(BottomChrome.barShown) + BottomChrome.show(true) + assertTrue(BottomChrome.barShown) + BottomChrome.request(false) + assertTrue(BottomChrome.barShown) + } + + @Test fun hidingByHandLastsUntilAPanelChangesItsRequest() { + BottomChrome.show(false) + assertFalse(BottomChrome.barShown) + BottomChrome.request(true) + BottomChrome.request(false) + assertTrue(BottomChrome.barShown) + } + + @Test fun moreReleasesThanRequestsNeverHideTheBarForGood() { + BottomChrome.request(false) + BottomChrome.request(false) + assertTrue(BottomChrome.barShown) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/ui/BottomDashboardTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/BottomDashboardTest.kt index 4598643681..cba37de693 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/BottomDashboardTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/BottomDashboardTest.kt @@ -28,6 +28,11 @@ class BottomDashboardTest { assertEquals("telemetry", pageForGameStart(listOf("telemetry", "downloads", "chat"))) assertNull(pageForGameStart(listOf("downloads", "chat"))) } + + @Test fun aGameStartShowsThePageLastPickedForThatGame() { + assertEquals("chat", pageForGameStart(listOf("telemetry", "downloads", "chat"), "chat")) + assertEquals("telemetry", pageForGameStart(listOf("telemetry", "downloads"), "chat")) + } } class BottomDownloadsRateTest { diff --git a/app/src/test/java/com/droiddeck/launcher/ui/BottomGuidesPageTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/BottomGuidesPageTest.kt new file mode 100644 index 0000000000..89d6482898 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/ui/BottomGuidesPageTest.kt @@ -0,0 +1,54 @@ +package com.droiddeck.launcher.ui + +import android.net.Uri +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33]) +class BottomGuidesPageTest { + @Test + fun theReaderStaysOnTheSiteUnlessTheUserFollowsALink() { + val start = "https://eldenring.fandom.com/" + assertTrue(readerAllows(start, Uri.parse("https://eldenring.fandom.com/wiki/Margit"), false)) + assertTrue(readerAllows(start, Uri.parse("https://community.fandom.com/"), false)) + assertFalse(readerAllows(start, Uri.parse("https://ads.example.com/landing"), false)) + assertTrue(readerAllows(start, Uri.parse("https://mapgenie.io/elden-ring"), true)) + assertTrue(readerAllows(start, Uri.parse("https://steamcommunity.com/app/1"), false)) + assertFalse(readerAllows(start, Uri.parse("intent://scan/#Intent;end"), true)) + assertFalse(readerAllows(start, Uri.parse("javascript:alert(1)"), true)) + } + + @Test + fun adHostsAreBlockedBySuffix() { + assertTrue(ReaderAds.blocks("securepubads.g.doubleclick.net")) + assertTrue(ReaderAds.blocks("c.amazon-adsystem.com")) + assertFalse(ReaderAds.blocks("strategywiki.org")) + assertFalse(ReaderAds.blocks("static.wikia.nocookie.net")) + assertFalse(ReaderAds.blocks("net")) + assertFalse(ReaderAds.blocks(null)) + } + + @Test + fun bigMapsAreDecodedAtAManageableSize() { + assertEquals(1, MapMarkers.sampleSize(4000, 3000, 4096)) + assertEquals(1, MapMarkers.sampleSize(4096, 2000, 4096)) + assertEquals(2, MapMarkers.sampleSize(6000, 6000, 4096)) + assertEquals(2, MapMarkers.sampleSize(8192, 8192, 4096)) + assertEquals(4, MapMarkers.sampleSize(9000, 6000, 4096)) + assertEquals(8, MapMarkers.sampleSize(20000, 12000, 4096)) + } + + @Test + fun mirrorHideCyclesAndDefaultsToShown() { + assertEquals(MirrorHide.OFF, MirrorHide.from(null)) + assertEquals(MirrorHide.DIM, MirrorHide.from("dim")) + assertEquals(MirrorHide.BLACK, MirrorHide.OFF.next()) + assertEquals(MirrorHide.OFF, MirrorHide.DIM.next()) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/ui/BottomIdleHomeTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/BottomIdleHomeTest.kt new file mode 100644 index 0000000000..97aeff6ae9 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/ui/BottomIdleHomeTest.kt @@ -0,0 +1,51 @@ +package com.droiddeck.launcher.ui + +import com.droiddeck.launcher.frontend.Library +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33]) +class BottomIdleHomeTest { + private val games = listOf( + Library.SteamGame(620, "Portal 2", null, "", lastPlayed = 100), + Library.SteamGame(1145360, "Hades", null, "", lastPlayed = 300), + Library.SteamGame(504230, "Celeste", null, ""), + ) + + @Test + fun prefersTheGameSelectedInSteam() { + val (game, highlighted) = IdleHome.pick(games, 504230)!! + assertEquals(504230, game.appId) + assertEquals(true, highlighted) + } + + @Test + fun fallsBackToTheMostRecentGame() { + val (game, highlighted) = IdleHome.pick(games, 999)!! + assertEquals(1145360, game.appId) + assertEquals(false, highlighted) + assertEquals(1145360, IdleHome.pick(games, null)!!.first.appId) + } + + @Test + fun nothingPlayedAndNothingSelected() { + assertNull(IdleHome.pick(listOf(Library.SteamGame(1, "A", null, "")), null)) + } + + @Test + fun readsSteamsOverviewOfTheHighlightedGame() { + val o = IdleHome.parseOverview("""{"name":"Sonic Mania","minutes":864,"last":1764000000}""")!! + assertEquals("Sonic Mania", o.name) + assertEquals(864L, o.minutes) + assertEquals(1764000000L, o.lastPlayed) + assertNull(IdleHome.parseOverview(null)) + assertNull(IdleHome.parseOverview("""{"name":""}""")) + assertNull(IdleHome.parseOverview("nope")) + assertEquals(true, IdleHome.overviewExpression(584400).contains("GetAppOverviewByAppID?.(584400)")) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/ui/BottomMirrorPageTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/BottomMirrorPageTest.kt new file mode 100644 index 0000000000..7eccd488f4 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/ui/BottomMirrorPageTest.kt @@ -0,0 +1,43 @@ +package com.droiddeck.launcher.ui + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33]) +class BottomMirrorPageTest { + @Test + fun regionsRoundTripAndNormalize() { + val r = MirrorRegion.normalize(0.9f, 0.3f, 0.75f, 0.05f)!! + assertEquals(0.75f, r.left, 0.0001f) + assertEquals(0.05f, r.top, 0.0001f) + assertEquals(0.9f, r.right, 0.0001f) + assertEquals(0.3f, r.bottom, 0.0001f) + val back = MirrorRegion.parse(MirrorRegion.format(r))!! + assertEquals(r.left, back.left, 0.0001f) + assertEquals(r.bottom, back.bottom, 0.0001f) + assertEquals(1f, MirrorRegion.normalize(-1f, -1f, 2f, 2f)!!.right, 0f) + } + + @Test + fun tinyOrBrokenRegionsAreRejected() { + assertNull(MirrorRegion.normalize(0.5f, 0.5f, 0.505f, 0.9f)) + assertNull(MirrorRegion.parse("0.1,0.2,0.3")) + assertNull(MirrorRegion.parse(null)) + assertNull(MirrorRegion.parse("a,b,c,d")) + } + + @Test + fun outputKeepsTheRegionsAspect() { + val minimap = MirrorRegion.normalize(0.8f, 0.0f, 1.0f, 0.3555f)!! + val (w, h) = MirrorRegion.outputSize(minimap, 16f / 9f, 720) + assertEquals(720, w) + assertEquals(720, h) + val bar = MirrorRegion.normalize(0.3f, 0.9f, 0.7f, 1.0f)!! + assertEquals(720 to 101, MirrorRegion.outputSize(bar, 16f / 9f, 720)) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/ui/CurseLinkTabTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/CurseLinkTabTest.kt index a64e56383f..b16a03071b 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/CurseLinkTabTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/CurseLinkTabTest.kt @@ -1,8 +1,12 @@ package com.droiddeck.launcher.ui import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.test.assertCountEquals +import androidx.compose.ui.test.assertIsNotEnabled +import androidx.compose.ui.test.onAllNodesWithText +import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onAllNodesWithContentDescription import com.droiddeck.launcher.R import com.droiddeck.launcher.runtime.AppImageManager @@ -302,12 +306,19 @@ class CurseLinkTabTest { onSetPhantomProcessLimit = { _, _ -> }, ) - private fun row(update: Boolean?, wowi: Boolean) { + private fun row(update: Boolean?, wowi: Boolean, progress: MutableMap = mutableMapOf()) { val target = WowAddons.Target("_retail_", temp.newFolder("AddOns")) val item = WowAddons.Installed("Leatrix_Maps", "1.60.35", null) val newer = WowAddonCatalog.Addon("1", "Leatrix Maps", "Leatrix", "1.60.36", 0, 0, null).takeIf { wowi } val curse = update?.let { CurseForgeApp.Project("298842", "m", listOf("Leatrix_Maps"), it) to CurseLink(app) } - compose.setContent { DroidDeckTheme { AddonRow(item, newer, target, actions, curse) } } + compose.setContent { DroidDeckTheme { AddonRow(item, newer, target, actions, progress, curse) } } + } + + @Test + fun aRowUpdatedByUpdateAllShowsItsProgressAndCannotStartASecondUpdate() { + row(update = true, wowi = false, progress = mutableStateMapOf("Leatrix_Maps" to 0)) + compose.onAllNodesWithText(RuntimeEnvironment.getApplication().getString(R.string.ctrl_percent, 0)).assertCountEquals(1) + compose.onNodeWithContentDescription(text(R.string.common_update)).assertIsNotEnabled() } @Test diff --git a/app/src/test/java/com/droiddeck/launcher/ui/IdleFramesTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/IdleFramesTest.kt new file mode 100644 index 0000000000..860fcc9665 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/ui/IdleFramesTest.kt @@ -0,0 +1,19 @@ +package com.droiddeck.launcher.ui + +import org.junit.Assert.assertEquals +import org.junit.Test + +class IdleFramesTest { + @Test + fun idleLoopsDrawThirtyFramesASecondAndShareEachOne() { + val start = 5_000_000_000L + val frame = 8_333_333L + val drawn = (0 until 120).count { IdleFrames.due(start + it * frame) } + assertEquals(30, drawn) + + val later = start + 1_000_000_000L + assertEquals(listOf(true, true, true), List(3) { IdleFrames.due(later) }) + assertEquals(listOf(false, false), List(2) { IdleFrames.due(later + frame) }) + assertEquals(listOf(true, true), List(2) { IdleFrames.due(later + 4 * frame) }) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/ui/LibraryEntriesTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/LibraryEntriesTest.kt index b168587e09..a47bc8aa9b 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/LibraryEntriesTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/LibraryEntriesTest.kt @@ -27,6 +27,17 @@ class LibraryEntriesTest { assertNull(entries[2].game) } + @Test fun ownedSteamGamesJoinTheSteamTabAndAnInstalledOneShowsOnce() { + val games = listOf(Library.SteamGame(440, "Team Fortress 2", null, "Steam library")) + val library = mapOf(Store.STEAM to listOf(owned(Store.STEAM, "440", "Team Fortress 2"), owned(Store.STEAM, "620", "Portal 2"))) + val entries = libraryEntries(games, library, emptySet()) + assertEquals(listOf("app:440", "app:steamstore:620"), entries.map { it.key }) + assertEquals(listOf(Library.SOURCE_STEAM, Library.SOURCE_STEAM), entries.map { it.source }) + assertFalse(entries[1].installed) + assertEquals("app:620", entries[1].favoriteKey) + assertEquals(listOf("steam"), librarySources(entries, listOf(Store.STEAM.id, "epic"))) + } + @Test fun theEpicLauncherIsNotAGame() { val launcher = Library.SteamGame(0, Library.EPIC_LAUNCHER_NAME, null, Library.EPIC_LAUNCHER) assertEquals(emptyList(), libraryEntries(listOf(launcher), emptyMap(), emptySet()).map { it.key }) @@ -111,6 +122,19 @@ class LibraryEntriesTest { assertEquals(listOf("steam", "xbox", "itch", "gamejolt"), librarySources(entries, listOf("xbox", "itch", "gamejolt"), setOf("itch", "gamejolt"))) } + @Test fun everySignedInStoreKeepsItsTabWhenItsLibraryIsEmptyOrFailedToLoad() { + val entries = listOf(LibraryEntry("epic:1", "epic", "Game", null, null, true)) + val order = listOf("epic", Store.ROCKSTAR.id, "gog") + val always = alwaysLibraryTabs(listOf(Store.STEAM, Store.ROCKSTAR), stores = true, soundMode = false) + assertEquals(listOf("steam", "epic", "rockstar", "battlenet", "added"), librarySources(entries, order, always)) + } + + @Test fun signedOutStoresAndSoundtrackModeDoNotGainEmptyTabs() { + assertEquals(setOf("added", "battlenet"), alwaysLibraryTabs(emptyList(), stores = true, soundMode = false)) + assertEquals(setOf("added", "battlenet"), alwaysLibraryTabs(listOf(Store.STEAM, Store.ROCKSTAR), stores = true, soundMode = true)) + assertEquals(emptySet(), alwaysLibraryTabs(emptyList(), stores = false, soundMode = false)) + } + @Test fun gameKeysNameEitherAnAppOrAStoreProduct() { GameRef.parse("app:440").let { assertEquals(440, it.appId); assertNull(it.store) } GameRef.parse("app:-12").let { assertEquals(-12, it.appId) } diff --git a/app/src/test/java/com/droiddeck/launcher/ui/LibraryVisibilityTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/LibraryVisibilityTest.kt index 4123ac826c..87e1d0bbb3 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/LibraryVisibilityTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/LibraryVisibilityTest.kt @@ -11,6 +11,7 @@ import androidx.compose.runtime.snapshots.Snapshot import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertCountEquals import androidx.compose.ui.test.onAllNodesWithText import androidx.compose.ui.test.onNodeWithContentDescription @@ -195,13 +196,32 @@ class LibraryVisibilityTest { compose.onNodeWithText("Uninstalled GOG").assertExists() } - private fun show() { + @Test fun battleNetHasAnOpenClientActionEvenWithoutInstalledGames() { + var opened = 0 + show(actions(onBattleNet = { opened++ })) + compose.onNodeWithTag("library-battlenet-open").assertDoesNotExist() + compose.onNodeWithTag("library-source-battlenet").performClick() + compose.mainClock.advanceTimeBy(1_000) + compose.onNodeWithTag("library-battlenet-open").assertIsDisplayed().performClick() + assertEquals(1, opened) + compose.onNodeWithTag("library-source-steam").performClick() + compose.mainClock.advanceTimeBy(1_000) + compose.onNodeWithTag("library-battlenet-open").assertDoesNotExist() + } + + @Test fun battleNetOpenIsDisabledWhileBusy() { + LibraryView.source = Store.BATTLENET.id + show(frontState = state(busy = true)) + compose.onNodeWithTag("library-battlenet-open").assertIsNotEnabled() + } + + private fun show(frontActions: FrontEndActions = actions(), frontState: FrontEndState = state()) { compose.mainClock.autoAdvance = false compose.setContent { key(generation) { DroidDeckTheme { CompositionLocalProvider(LocalFrontFocus provides FrontFocus()) { FocusGlideHost { Box(Modifier.fillMaxSize()) { - LibraryPage(state(), actions(), "games", {}, Modifier.fillMaxSize()) + LibraryPage(frontState, frontActions, "games", {}, Modifier.fillMaxSize()) StepsLayer(Offset.Zero) } } } @@ -216,15 +236,16 @@ class LibraryVisibilityTest { assertEquals(show, SessionPrefs.libraryShowUninstalled(ctx)) } - private fun state(games: List = listOf(Library.SteamGame(440, "Installed Steam game", null, "internal"))) = FrontEndState( - installed = "r9", ready = true, available = null, busy = false, stage = "", percent = -1, + private fun state(games: List = listOf(Library.SteamGame(440, "Installed Steam game", null, "internal")), busy: Boolean = false) = FrontEndState( + installed = "r9", ready = true, available = null, busy = busy, stage = "", percent = -1, desktopInstalled = true, offlineAccount = null, offline = false, frameGenLabel = "", romsDir = null, logsEnabled = false, steamGames = games, emulators = emptyList(), running = null, ) - private fun actions() = FrontEndActions( + private fun actions(onBattleNet: () -> Unit = {}) = FrontEndActions( + onBattleNet = onBattleNet, onPlay = {}, onPlayDesktopUi = {}, onSteamGame = {}, onDesktop = {}, onEmulator = {}, onRom = {}, onResume = {}, onSteamSettings = {}, onDesktopSettings = {}, onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {}, diff --git a/app/src/test/java/com/droiddeck/launcher/ui/NavTabsTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/NavTabsTest.kt index a04579033c..72546927c7 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/NavTabsTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/NavTabsTest.kt @@ -40,8 +40,8 @@ class NavTabsTest { } @Test fun aFreshInstallShowsTheDefaultBarMoreAndHiddenTabs() { - assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", NavTabs.MORE), navigationKeys(state())) - assertEquals(listOf("soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state())) + assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", NavTabs.MORE), navigationKeys(state())) + assertEquals(listOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state())) assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "android-apps")) assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "agent")) assertFalse(com.droiddeck.launcher.agent.AgentTab.shown) @@ -66,13 +66,13 @@ class NavTabsTest { @Test fun showingMusicOnceKeepsItShownAfterReload() { place("soundtracks", TabPlace.BAR) NavTabs.load(ctx) - assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", NavTabs.MORE), navigationKeys(state())) + assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "soundtracks", NavTabs.MORE), navigationKeys(state())) } @Test fun shelvedTabsLeaveTheBarAndAddMoreAtTheEnd() { place("desktop", TabPlace.MORE) val s = state() - assertEquals(listOf("desktop", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(s)) + assertEquals(listOf("desktop", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(s)) assertEquals(NavTabs.MORE, navigationKeys(s).last()) assertFalse("desktop" in navigationKeys(s)) } @@ -85,14 +85,14 @@ class NavTabsTest { } @Test fun resettingPutsBackTheDefaultLayout() { - place("stores", TabPlace.MORE) + place("stores", TabPlace.BAR) place("updates", TabPlace.HIDDEN) moveTab("downloads", -1) assertFalse(NavTabs.isDefault()) NavTabs.reset(ctx) NavTabs.load(ctx) assertTrue(NavTabs.isDefault()) - assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", NavTabs.MORE), navigationKeys(state())) + assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", NavTabs.MORE), navigationKeys(state())) } @Test fun anOldLayoutKeepsWhatItsSwitchesShowed() { diff --git a/app/src/test/java/com/droiddeck/launcher/ui/SecondScreenBarTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/SecondScreenBarTest.kt index a2e7f61c31..2239382b37 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/SecondScreenBarTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/SecondScreenBarTest.kt @@ -2,6 +2,7 @@ package com.droiddeck.launcher.ui import android.hardware.display.DisplayManager import android.view.Display +import android.view.MotionEvent import android.view.View import android.view.ViewGroup import androidx.compose.runtime.MutableState @@ -76,6 +77,27 @@ class SecondScreenBarTest { return (0 until root.childCount).map { root.getChildAt(it) } } + @Test fun theTouchThatWakesTheScreenDoesNotReachThePanel() { + SessionState.mode = SessionService.MODE_STEAM + val panel = presentation() + try { + panel.show() + panel.showMode(SecondScreenMode.KEYBOARD_TRACKPAD) + val root: ViewGroup = ReflectionHelpers.getField(panel, "root") + val seen = mutableListOf() + root.setOnTouchListener { _, e -> seen += e.actionMasked; true } + fun touch(action: Int) = MotionEvent.obtain(0, 0, action, 10f, 10f, 0).also { panel.dispatchTouchEvent(it); it.recycle() } + panel.screenOff() + touch(MotionEvent.ACTION_DOWN) + touch(MotionEvent.ACTION_UP) + assertTrue(seen.isEmpty()) + assertEquals(BottomScreenLight.ON, ReflectionHelpers.getField(panel, "screen")) + assertEquals(false, ReflectionHelpers.getField(panel, "waking")) + } finally { + panel.dismiss() + } + } + @Test fun trackpadPanelHasTheBarWithTheKeyboardToggleStateAndSwap() { SessionState.mode = SessionService.MODE_STEAM var swaps = 0 @@ -90,13 +112,13 @@ class SecondScreenBarTest { assertEquals(context.getString(R.string.second_mode_keyboard_trackpad), bar.title) assertNotNull(bar.onClose); assertNotNull(bar.onMenu); assertNotNull(bar.onSteam); assertNotNull(bar.onQam) assertNull(bar.tabs) - assertEquals(listOf("bottom-keyboard", "bottom-swap"), bar.extras.map { it.tag }) + assertEquals(listOf("bottom-keyboard", "bottom-swap", "bottom-brightness-toggle", "bottom-bar-hide"), bar.extras.map { it.tag }) val keyboard = bar.extras.first() assertEquals(context.getString(R.string.second_show_keyboard), keyboard.description) assertFalse(keyboard.active) - bar.extras.last().onClick() + bar.extras.first { it.tag == "bottom-swap" }.onClick() assertEquals(1, swaps) - assertEquals(listOf("bottom-keyboard", "bottom-swap"), panel.barModel(SecondScreenMode.TERMINAL)!!.extras.map { it.tag }) + assertEquals(listOf("bottom-keyboard", "bottom-swap", "bottom-brightness-toggle", "bottom-bar-hide"), panel.barModel(SecondScreenMode.TERMINAL)!!.extras.map { it.tag }) ReflectionHelpers.getField>(panel, "keyboardShown").value = true val shown = panel.barModel(SecondScreenMode.KEYBOARD_TRACKPAD)!!.extras.first() assertEquals(context.getString(R.string.second_hide_keyboard), shown.description) @@ -115,17 +137,17 @@ class SecondScreenBarTest { assertTrue(rootChildren(panel)[0] is ComposeView) val bar = panel.barModel(SecondScreenMode.DECK_CONTROLS)!! assertEquals(context.getString(R.string.second_mode_deck_controls), bar.title) - assertEquals(listOf(context.getString(R.string.swap_screens)), bar.extras.map { it.description }) - bar.extras.single().onClick() + assertEquals(listOf(context.getString(R.string.swap_screens), context.getString(R.string.bottom_brightness), context.getString(R.string.bottom_bar_hide)), bar.extras.map { it.description }) + bar.extras.first { it.tag == "bottom-swap" }.onClick() assertEquals(1, swaps) assertEquals(DeckPanel.entries.map { context.getString(it.label) }, bar.tabs!!.labels) assertEquals(DeckPanel.BOTH.ordinal, bar.tabs!!.selected) panel.showMode(SecondScreenMode.CUSTOM_CONTROLS) val profile = panel.barModel(SecondScreenMode.CUSTOM_CONTROLS)!! assertEquals(context.getString(R.string.input_profile_controls_mode), profile.title) - assertEquals(listOf(context.getString(R.string.swap_screens)), profile.extras.map { it.description }) + assertEquals(listOf(context.getString(R.string.swap_screens), context.getString(R.string.bottom_brightness), context.getString(R.string.bottom_bar_hide)), profile.extras.map { it.description }) assertNotNull(profile.onClose); assertNotNull(profile.onMenu) - profile.extras.single().onClick() + profile.extras.first { it.tag == "bottom-swap" }.onClick() assertEquals(2, swaps) assertTrue(rootChildren(panel)[0] is ComposeView) assertTrue(rootChildren(panel)[1] is InputSurfaceView) @@ -134,9 +156,9 @@ class SecondScreenBarTest { try { noSwap.show() noSwap.showMode(SecondScreenMode.DECK_CONTROLS) - assertTrue(noSwap.barModel(SecondScreenMode.DECK_CONTROLS)!!.extras.isEmpty()) - assertEquals(listOf("bottom-keyboard"), noSwap.barModel(SecondScreenMode.TERMINAL)!!.extras.map { it.tag }) - assertEquals(listOf("bottom-keyboard"), noSwap.barModel(SecondScreenMode.KEYBOARD_TRACKPAD)!!.extras.map { it.tag }) + assertEquals(listOf("bottom-brightness-toggle", "bottom-bar-hide"), noSwap.barModel(SecondScreenMode.DECK_CONTROLS)!!.extras.map { it.tag }) + assertEquals(listOf("bottom-keyboard", "bottom-brightness-toggle", "bottom-bar-hide"), noSwap.barModel(SecondScreenMode.TERMINAL)!!.extras.map { it.tag }) + assertEquals(listOf("bottom-keyboard", "bottom-brightness-toggle", "bottom-bar-hide"), noSwap.barModel(SecondScreenMode.KEYBOARD_TRACKPAD)!!.extras.map { it.tag }) } finally { noSwap.closeControls() } } diff --git a/docs/development/bottom-screen-guides.md b/docs/development/bottom-screen-guides.md new file mode 100644 index 0000000000..6f13941a21 --- /dev/null +++ b/docs/development/bottom-screen-guides.md @@ -0,0 +1,118 @@ +# Bottom screen: guides tab + +Part of the [bottom screen research](bottom-screen.md). Researched 2026-11-26 against `main` at `d788afc12`. Milestones 1 and 4 are built (Steam guides with tag and language filters, the Wikidata crosswalk with wiki, fixes and the ProtonDB tier, pinned maps with markers, and saved pages); see the status in the overview. Milestones 2 (achievement checklist with spoiler blur), 3 (native section reader and controller mode) and 5 (progress-aware help) are not started. + +A dashboard tab that follows the running game and shows its guides, achievements, maps and fixes, reopens where the user left off, and saves pages for offline use. + +## Use cases + +- Stuck on a puzzle or boss: the walkthrough for this game is already open on the bottom screen at the last section read. +- Achievement hunting: a checklist of locked achievements with missable ones flagged, spoilers blurred until tapped. +- Collectibles: a map image pinned with pan and zoom, markers saved per map. +- Fixes: PCGamingWiki and ProtonDB notes for the game when it misbehaves. +- Offline play on a plane with guides saved earlier. + +## Prior art + +| Project | Matching | Offline | Reader and extras | Complaints and requests | +| --- | --- | --- | --- | --- | +| [Game Twin](https://github.com/alpha-minus/game-twin) (GPL-3, 157★) | Bundled catalogs (GameFAQs, StrategyWiki, VGMaps, Steam guides) rebuilt offline; Jaccard title match at 0.6 with a sequel guard (numbers must match); hand-mapped series sites (Zelda Dungeon, Bulbapedia); site search URLs for the rest | `WebView.saveWebArchive` after forcing lazy images to load; MHT split into HTML and assets served via `shouldInterceptRequest`; scripts stripped; OkHttp with WebView cookies for side downloads. Also imports PDF, TXT, EPUB | Reading mode with per-host cleanup, auto table of contents, find, bookmarks. Resume by the text at the top of the viewport plus its occurrence, so it survives reflow. Maps with markers, checklists, RetroAchievements and Steam achievements, folder sync, optional Gemini with a screenshot | Battery and fan noise from live pages left running ([#12](https://github.com/alpha-minus/game-twin/issues/12), [#24](https://github.com/alpha-minus/game-twin/issues/24)); saved guides unreadable in dark mode ([#9](https://github.com/alpha-minus/game-twin/issues/9)); cookie banners ([#2](https://github.com/alpha-minus/game-twin/issues/2)); requests for notes ([#28](https://github.com/alpha-minus/game-twin/issues/28)) and a visible capture indicator for AI ([#22](https://github.com/alpha-minus/game-twin/issues/22)) | +| [Pixel Guide](https://github.com/rexmont/Pixel-Guide-Android) (closed source) | Manual | TXT, single-file HTML, multi-page Neoseeker | ASCII reflow with auto table of contents, per-guide font, resume, find, controller scrolling, 14 themes, manuals, translation, AI | Ads in saved pages ([#46](https://github.com/rexmont/Pixel-Guide-Android/issues/46)), very large guides fail ([#58](https://github.com/rexmont/Pixel-Guide-Android/issues/58)); requests for stick scrolling ([#35](https://github.com/rexmont/Pixel-Guide-Android/issues/35)), prev/next ([#27](https://github.com/rexmont/Pixel-Guide-Android/issues/27)), checklists ([#44](https://github.com/rexmont/Pixel-Guide-Android/issues/44)), remembering the game association ([#20](https://github.com/rexmont/Pixel-Guide-Android/issues/20)) | +| [WalkThor](https://github.com/nerf-herder-29/WalkThor) (MIT) | Fuzzy match of ROM name to local files | Local PDF and TXT only | Position stored as a character offset; 80-column pages for ASCII tables; L1/R1 page turns. Bottom window is non-focusable while a game runs because taking focus "can halve its frame rate" | n/a | +| Steam Deck overlay Guides (SteamOS 3.3) | Exact app id | No | Favourites and popular guides; later fixes for oversized images and spoiler tags. Gone from the desktop overlay, where the 2023 overlay instead added pinned windows and Game Notes ([PC Gamer](https://pcgamer.com/new-steam-feature-lets-you-pin-windows-over-games-including-guides-notes-and-web-pages)) | n/a | + +DroidDeck's advantage: we know the exact Steam app id of the focused game, so we need no title matching for Steam games. + +## Sources + +| Source | Access | Terms | Use | +| --- | --- | --- | --- | +| **Steam Community guides** | Listing: `steamcommunity.com/app//guides/?browsefilter=toprated\|trend&requiredtags[]=Walkthroughs`. API: `IPublishedFileService/QueryFiles` with `filetype=11` needs a key or the signed-in user's token. Guide pages (`sharedfiles/filedetails/?id=`) are server-rendered; sections are `div.subSection` with numeric ids | Authors own their guides under the Steam Subscriber Agreement. Cache per user, never redistribute | First source. Native section reader with stable anchors for chapter jumps and resume | +| **Steam achievements** | `IPlayerService/GetGameAchievements/v1/?appid=&language=` needs no key and returns names, icons, the hidden flag, global unlock percentage, and descriptions even for hidden achievements (checked on Elden Ring, Hollow Knight, Baldur's Gate 3). It is undocumented. `GetGlobalAchievementPercentagesForApp` also needs no key. The player's unlocks should come from the local client (`SteamClient.Apps` through CDP, or the client's stats cache); not yet tested | Valve | Achievement checklist with spoiler blur and difficulty from unlock % | +| **Wikidata** | SPARQL by Steam app id (P1733), or Epic (P6278) or GOG (P2725) id, returns the Fandom wiki (P4073), PCGamingWiki (P6337), GameFAQs (P4769), IGN (P5385), HowLongToBeat (P2816) and speedrun.com ids | CC0 | Crosswalk from the running game to every other site, including non-Steam games | +| **StrategyWiki** | MediaWiki API | CC BY-SA 4.0 | Full offline caching allowed | +| **Fandom wikis** | MediaWiki `api.php` per wiki | CC BY-SA (media excluded) | Per-game wiki pages, found through Wikidata | +| **PCGamingWiki** | `pcgamingwiki.com/api/appid.php?appid=` redirects to the page; MediaWiki API (anonymous Cargo queries are refused now) | CC BY-NC-SA 3.0 | Fixes and settings, in a "Fixes" section | +| **ProtonDB** | `protondb.com/api/v1/reports/summaries/.json`, no key | ProtonDB | A tier badge next to fixes | +| **GameFAQs, Neoseeker, IGN** | No API. GameFAQs terms forbid unauthorized scraping; its robots signals allow reference use but not AI training | Authors' copyright; Ziff Davis bans automated retrieval including AI use without permission | Browse in a WebView; save a page only when the user asks; never prefetch or send to AI | +| **VGMaps, Map Genie** | Images; Map Genie is an interactive site (Ziff Davis) | Maps belong to the games' owners; Map Genie bans automated retrieval | Save VGMaps images on request into the map viewer; Map Genie only as a live WebView | +| **YouTube** | Search URL (free) or Data API (100 quota units per search) | YouTube | Search link and embedded player, no downloads | +| **HowLongToBeat, TrueSteamAchievements** | No stable API ([unofficial library breaks often](https://github.com/ScrappyCocco/HowLongToBeat-PythonAPI/issues)) | Ziff Davis / site owners | Links only | + +Recommended order for the tab: Steam guides → achievements → StrategyWiki or the game's Fandom wiki (via Wikidata) → PCGamingWiki and ProtonDB → curated series sites → GameFAQs, Neoseeker and IGN in a WebView → maps → YouTube. + +## What DroidDeck already has + +Paths are under [`app/src/main/java/com/droiddeck/launcher/`](../../app/src/main/java/com/droiddeck/launcher/). + +- **Game identity.** Bottom pages receive `gestureGame` as `runningGame`. In Steam mode it is the gamescope-focused app id (ignoring the Steam client, 769); in direct-run mode it is `program:`, which is not a Steam app id, so Steam lookups must not use it. `AgentGuest.activeSteamAppId` reads the focused Steam app directly and is the source for Steam lookups. Non-Steam store games are Steam shortcuts; `resolveAchievementsInFront` already maps the focused id to the store and store id through the library cache. +- **WebView base.** [`ui/BottomChatPage.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/BottomChatPage.kt) loads Steam Community with a host allow-list, desktop user agent, fit-to-screen CSS and crash recovery. [`session/SteamWebLogin.kt`](../../app/src/main/java/com/droiddeck/launcher/session/SteamWebLogin.kt) imports the Steam client's own `steamcommunity.com` cookies, so guides load signed in without another login. +- **Achievements.** [`stores/StoreAchievements.kt`](../../app/src/main/java/com/droiddeck/launcher/stores/StoreAchievements.kt) is a provider base with a per-game cache; GOG and Epic implement it. [`ui/StoreAchievementsUi.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/StoreAchievementsUi.kt) has the rows, tab and session panel. A Steam provider plugs in as source `steam`. +- **Per-game storage.** `SessionPrefs` already keys settings by game (for example `fpsLimit.game.`); the guide workspace fits the same pattern. +- **Game frame without MediaProjection.** `SessionActivity.copyGameFrame` and `AgentAttachments.gameFrame` capture the game image directly, which an optional AI helper could use with no capture permission. +- **Controller.** The dashboard forwards controller input to the game and has no D-pad focus today. The docked session menu has focus handling (`SecondScreenPresentation.dispatchMenuKey`, the `dockedMenuController` setting) and is the pattern to follow. + +## Design + +**Workspace per game.** One workspace per Steam app id (or store key): open guide, section, text anchor, recent searches, pinned maps, checklist ticks. Restored when the game gains focus. Cleared with the game profile. + +**Home of the tab** for the running game: + +1. Continue: the last guide at the last section. +2. Steam guides, top rated and trending, filterable by tag (Walkthroughs, Achievements, Secrets, Maps). +3. Achievements: locked first, missable flagged, hidden descriptions blurred. +4. Wiki: StrategyWiki or Fandom, from Wikidata. +5. Fixes: PCGamingWiki and the ProtonDB tier. +6. Saved: offline pages and maps for this game. +7. Search the web: GameFAQs, Neoseeker, IGN and YouTube with the game name prefilled. + +**Reader.** + +- Steam guides and MediaWiki pages are rendered natively from their HTML (sections, images, spoilers), not as a full web page: smaller, dark by default, and reflowed for the panel. +- Other sites open in a WebView with cleanup CSS, forced dark mode and a cookie-banner dismiss. +- Resume by text anchor (Game Twin's approach), falling back to scroll ratio. +- Table of contents from Steam section ids or the MediaWiki outline; find in page. +- Spoiler-safe by default: Steam `[spoiler]` spans and hidden achievements blurred until tapped. + +**Offline.** + +- Steam guides and wiki pages: save the parsed HTML and images per user. +- Other sites: MHT saved on request, with scripts stripped. +- Saved pages are listed per game and work without network. + +**Controller.** + +- The guide never takes focus or priority from the game (WalkThor's lesson). +- A dedicated chord or the docked-menu controller mode gives it the pad: right stick scrolls, L1/R1 change section, D-pad moves through links and the contents, B returns the pad to the game. +- Touch always works. + +**Battery.** Pause or destroy WebViews when the tab is not visible; the top complaint about Game Twin is a live page draining the battery behind the game. + +## Progress-aware help (later) + +Signals we can use without reading game memory: + +- Steam achievement unlocks with timestamps, matched to guide section titles. +- Steam rich presence (`steam_display`) and, for games that report it, [Steam Timeline](https://partner.steamgames.com/doc/api/ISteamTimeline) game phases and tooltips. Whether the client exposes these to CDP needs checking. + +An optional AI helper ("Where am I, what next?") would send the game frame plus those signals. Rules from Game Twin's feedback and the criticism of Xbox Gaming Copilot ([Tom's Hardware](https://www.tomshardware.com/video-games/pc-gaming/microsoft-says-gaming-copilot-uses-screenshots-to-understand-in-game-events-not-for-training-ai-models-optional-feature-can-be-turned-off-but-not-easily-uninstalled)): + +- opt-in, user's own key; +- one frame per question, with a visible indicator; +- crop out notifications and overlays; +- never send cached text from sources that forbid AI use. + +## Open questions + +- The most reliable way to read the player's Steam unlocks locally (CDP versus the client's stats cache). +- Whether Steam guide listings load reliably without the web API key, using the signed-in cookies. +- How much of a Steam guide's formatting (tables, embedded video) the native reader must support. +- Where the tab lives in swapped mode (it follows the panel to the top screen). + +## Milestones + +1. Steam guides list and WebView reader for the running app id, with a per-game last page. +2. Steam achievements provider and checklist with spoiler blur. +3. Native section reader, offline saving and the controller mode. +4. Wikidata crosswalk, wiki and fixes sections, maps viewer. +5. Progress-aware suggestions and the optional AI helper. diff --git a/docs/development/bottom-screen-region-mirror.md b/docs/development/bottom-screen-region-mirror.md new file mode 100644 index 0000000000..b0479e1bce --- /dev/null +++ b/docs/development/bottom-screen-region-mirror.md @@ -0,0 +1,107 @@ +# Bottom screen: region mirror + +Part of the [bottom screen research](bottom-screen.md). Researched 2026-11-26 against `main` at `d788afc12`. Milestone 1 (the PixelCopy prototype) is built: a Mirror tab with a drag-to-pick editor on a still frame, a live view at about 15 fps with sharp or smooth scaling, and one region per game stored as fractions of the output. PixelCopy sees nothing while the zero-copy path puts the game on a child layer, so the tab turns zero-copy off while it is shown (HDR still forces it on). Checked on a Retroid Pocket Duo Lite Plus. Hide on top (milestone 3 in part) is built as a view over the game surface while the tab is shown: shown, black or dimmed per game. App views sit above the SurfaceView, so the mask hides the region on screen while PixelCopy still reads the real pixels. Blur and the compositor output are not done. + +Show live crops of the game image (minimap, HUD, ability bar, dialogue box) scaled up on the bottom screen, and optionally remove them from the top screen. Regions are saved per game. + +## Use cases + +- **Minimaps** in open-world and action games (GTA, Monster Hunter, The Witcher, Elden Ring's compass): bigger on the bottom, gone from the top. +- **MMO and ARPG bars**: ability, health and buff bars moved off a crowded 6" screen. Megingiard users asked for 90° rotation for a Guild Wars 2 ability bar and for very thin crops for visual-novel text. +- **Racing**: rear-view mirror or track map on the bottom while the top shows only the road. +- **Strategy**: the minimap of an RTS or a city builder, where it is the main navigation tool. +- **Clean top screen**: hide every HUD element on top and keep them all on the bottom. + +## Prior art + +| Project | Capture | Notes | +| --- | --- | --- | +| [Megingiard](https://github.com/stormpanda/megingiard) (Thor) | A privileged shell helper creates a mirror display (hidden `SurfaceControl.createDisplay` on API 33; `AUTO_MIRROR` virtual display through `mirrorSurface` on API 34+), then SurfaceTexture → GLES → TextureView. Falls back to MediaProjection with a consent prompt on every start | Up to 10 cutouts. Crop box edited on the top screen, placement on the bottom. Edge handles, 1 px gamepad steps, snap guides, aspect lock (free, source-locked, destination-locked), rotation and flips, pinch zoom, circle shape, edge blending, temporal smoothing. Variance masks cut moving background out of HUD art. "Visual anchors" (a 256-point colour signature checked at 60 Hz) switch layout or freeze cutouts when a menu covers the HUD. FPS cap 10–120. Complaints: black mirror, consent prompts, helper pairing, DRM blanking ([docs](https://github.com/stormpanda/megingiard/tree/main/docs/features/mirror)) | +| [Heimdall](https://github.com/mastercook777/Heimdall-AYN-Thor-Assistant) (Thor) | MediaProjection into one virtual display, fanned out on the GPU: one EGL surface per "Portal", crop in the texture matrix | Two Portals. Per-Portal zoom, shape, fps, and an "Interactive" mode that sends one-finger touch back to the region. Curated [community profiles](https://github.com/mastercook777/heimdall-community-profiles) keyed by app, checked by SHA-256 | +| [WalkThor](https://github.com/nerf-herder-29/WalkThor) (Thor) | MediaProjection at half resolution into an `ImageReader`, drawn with Compose | Four regions per game stored as fractions of the screen and keyed by game title. Pick box keeps the bottom screen's aspect by default. About 30 fps. Its bottom window is non-focusable so the game keeps top-app priority | +| [OnTopReplica](https://github.com/LorenzCK/OnTopReplica) (Windows) | DWM thumbnails (`DwmRegisterThumbnail` with source and destination rectangles): a crop done by the compositor, with no copy | The usual way to put an MMO minimap on a second monitor. SteamDeckHQ's [AYANEO Flip DS review](https://steamdeckhq.com/news/ayaneo-flip-ds-review/) used it for a Monster Hunter: World minimap on the bottom screen | +| [wl-mirror](https://github.com/Ferdi265/wl-mirror) (Linux) | wlr-screencopy or dmabuf export with `--region` | Scaling modes fit, cover, exact, linear and nearest, plus freeze | +| gamescope PipeWire stream | An extra composite pass of the whole output, used by Steam for recording | Full output only, no regions. Still a precedent for a second output rendered inside the compositor | + +None of the Android tools can hide the region on the top screen: they capture the final display output, so any mask they drew would be captured too. Each also adds at least one composition cycle of latency and needs MediaProjection or a privileged helper. + +## Why DroidDeck can do better + +The game is composited by our own Wayland compositor in the app process. We have the game image as a Vulkan image before it reaches the display, so we can: + +- crop without screen capture, a consent prompt or a privileged helper; +- avoid the extra SurfaceFlinger round trip; +- mask the region on the top screen in the same pass; +- know the game's own resolution and our letterbox or stretch transform, so regions can be stored in game coordinates. + +## Current pipeline + +Paths are under [`app/src/main/cpp/waylandcomp/src/`](../../app/src/main/cpp/waylandcomp/src/). + +- gamescope runs nested in our compositor with its Wayland backend (`tools/linuxfs/overlay/usr/local/bin/droiddeck-session`). Client buffers arrive as dma-bufs or AHardwareBuffers and are imported as `VkImage`s ([`vk_present.c`](../../app/src/main/cpp/waylandcomp/src/vk_present.c)). +- `render_scene()` in [`compositor.c`](../../app/src/main/cpp/waylandcomp/src/compositor.c) builds a draw list; `vkp_render()` composites it, runs the effects chain ([`effects_chain.c`](../../app/src/main/cpp/waylandcomp/src/effects_chain.c): FSR, NIS, SGSR, CAS, CRT and others) and blits into one swapchain on one `ANativeWindow`. +- There is exactly one output window. Swapping the game to the bottom screen ([`BottomGameScreen.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/BottomGameScreen.kt), `SessionActivity.putGameOnBottom`) re-targets that window to the Presentation's `SurfaceView`; it does not feed two surfaces. +- A gated zero-copy path ([`sc_layer.c`](../../app/src/main/cpp/waylandcomp/src/sc_layer.c), [`ZERO_COPY_SPIKE.md`](../../app/src/main/cpp/waylandcomp/ZERO_COPY_SPIKE.md)) posts the game's AHardwareBuffer straight to an `ASurfaceControl` child layer, with no composited image. +- `update_map()` holds the scene-to-output transform for each scale mode (letterbox, fit, stretch, fill, integer); `vkp_output_to_scene` and `vkp_scene_to_output` convert between them. `vkp_blit_image()` already blits into AHB-backed images. +- Screenshots use `PixelCopy` on the active `SurfaceView` (`SessionActivity.copyGameFrame`). +- The bottom-screen Presentation ([`SecondScreenPresentation.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt)) lives in the same process as the compositor, so a new JNI call can hand it a surface. The bottom KDE desktop runs a second compositor in another process and cannot share images without AHB IPC. + +## Technical options + +### A. Second output from the compositor (recommended first) + +Add a second, optional output to `vk_present`: its own `ANativeWindow` and swapchain, fed by a `nativeSetMirrorSurface` JNI call from a `SurfaceView` in the bottom Presentation. + +- After compositing the top frame, blit each region's source rectangle from the scene image into the mirror swapchain image with `vkCmdBlitImage` (or a small shader pass), and present it. +- The copy is small: a 1240×1080 target at 60 Hz is about 0.3 GB/s against roughly 60 GB/s of memory bandwidth on the Thor's SoC (an estimate, not measured). The real costs are an extra queue submit competing with a GPU-bound game, and pacing a second display. +- A shader pass makes nearest or integer scaling (pixel-art HUDs), masks, circles, rounded corners and colour keys possible. An existing upscaler (FSR EASU or SGSR) could scale a small minimap cleanly. +- The mirror runs at its own rate (default 30 fps, options 15 and 60) and skips frames when the bottom panel is behind. +- The top pass can fill, blur or dim the same rectangles to hide them. + +### B. Zero-copy layers + +Composite the top frame into compositor-owned AHardwareBuffers, then attach the same buffer to one `ASurfaceControl` child per region under the bottom `SurfaceView`, with `setCrop`, `setPosition`, `setScale` and `setBufferTransform`. + +- The NDK documents that each layer holding a buffer counts as its own reference, and that all of them must be released before the buffer is reused ([`surface_control.h`](https://cs.android.com/android/platform/superproject/main/+/main:frameworks/native/include/android/surface_control.h)). +- On API 33 (the Thor) the NDK `setBuffer` has no per-buffer release callback; release comes as a per-surface fence in the completion callback. All region fences must be merged before reuse, and the pool needs one or two extra buffers because the 60 Hz bottom panel holds buffers longer than the 120 Hz top panel. +- Avoid the Java `Transaction.setBuffer` release callback here: callbacks are keyed by buffer and per-layer frame number, so two layers showing the same buffer can collide. This is inferred from AOSP source, not tested. +- `ASurfaceControl_fromJava` needs API 34; on API 33 parent through `ASurfaceControl_createFromWindow` on the bottom `SurfaceView`'s window. +- Scaling is done by the display hardware with a fixed vendor filter (no nearest neighbour), and the number of hardware planes is limited. If they run out, SurfaceFlinger composites on the GPU instead, which still works. +- This only makes sense once the top screen itself is presented through AHB layers. Option A first. + +### C. PixelCopy prototype + +Crop a `PixelCopy` of the top `SurfaceView` at 5–10 fps into a bitmap. Useful for testing the editor UX and region presets quickly, but too slow for a real minimap, and it probably returns nothing when the zero-copy path puts the game on a child layer. + +## Coordinates and presets + +- Store rectangles in game-surface coordinates (gamescope's output, `DD_WIDTH`×`DD_HEIGHT`), not display pixels, so they survive changes to scale mode, FSR and output size. The compositor converts them each frame. +- Fractions of the screen alone break when the aspect ratio changes, because engines anchor HUD widgets to corners and scale by height or DPI ([Unreal anchors](https://dev.epicgames.com/documentation/en-us/unreal-engine/umg-anchors-in-unreal-engine-ui)). Store an anchor (one of nine corners, edges or centre), an offset and a size in units of the game's height. +- Key presets by Steam app id, aspect bucket (16:9, 16:10, 4:3, other) and an optional UI-scale tag set by the user. +- Later: a community preset catalog keyed by app id, curated and hashed like Heimdall's, offered as "Suggested regions" for the running game. + +## UX + +- **Editing on both screens.** The top screen shows the frozen frame with a crop box: edge and corner handles, D-pad nudge by 1 px and shoulder buttons by 10. The bottom screen shows placement with snap guides, aspect lock, rotation, flip, filter (smooth or sharp) and shape. +- **Limits.** Up to four regions per game. Long-press freezes a region; tap opens its options. +- **Hide on top.** Per region: off, fill, blur or dim. +- **Auto-hide.** Later, Megingiard-style colour anchors that hide or freeze regions when a menu covers the HUD. +- **Place in the panel system.** A new "Mirror" bottom-screen mode next to the dashboard and control modes, remembered per game (see per-game panel memory in the overview). Regions can also be shown in a corner of the dashboard. +- **Swapped mode.** With the game on the bottom screen, the mirror output goes to the top screen. +- Reuse DroidDeck's own settings components; no generic dialogs. + +## Open questions + +- Pacing and fencing of a second swapchain on a different display without stalling the top present. +- Interaction with glasses output, which already re-targets the single window. +- Whether regions apply before or after effects (a CRT shader on a minimap is probably unwanted). +- Battery and thermal cost, measured on the Thor and Duo with a GPU-bound game. +- Touch forwarding into a region (Heimdall's "Interactive"), mapped back to game coordinates. + +## Milestones + +1. PixelCopy prototype of the editor and per-game storage. +2. Second output in `vk_present` with one region and smooth scaling. +3. Multiple regions, shader filters, hide on top. +4. Presets keyed by aspect, suggested regions, anchors. +5. Zero-copy layers once the top screen uses AHB presentation. diff --git a/docs/development/bottom-screen.md b/docs/development/bottom-screen.md new file mode 100644 index 0000000000..ba0ce9d065 --- /dev/null +++ b/docs/development/bottom-screen.md @@ -0,0 +1,209 @@ +# Bottom screen: research and proposals + +Researched 2026-11-26 against `main` at `d788afc12` (0.7.11). This document records what other dual-screen Android projects put on the second screen, how they get their data, where DroidDeck stood at that commit, and the features we want to build. "DroidDeck today" is that researched baseline; each proposal's **Status** line says what has been built since, and proposals without one are not scheduled. Two proposals have their own documents: [region mirror](bottom-screen-region-mirror.md) and [guides tab](bottom-screen-guides.md). + +The starting point was WULFF DEN's survey video [Dual screen Android apps are getting crazy](https://youtu.be/dAiuG2A-wkc) (2026-11-26). It covers the AYN Thor and Retroid Pocket Duo, and most of its apps come from the [GAFT list](https://andreyvelsk.github.io/GAFT) of Thor apps. + +## DroidDeck in the video + +DroidDeck appears from 17:47 to 18:30 on a Thor: the Steam gamepad UI on top, our bottom panel below. + +- Shown: the mode picker (DroidDeck menu, Keyboard + trackpad, Terminal, Deck grips + trackpads, Profile controls, Dashboard), the controller page of the docked menu, and the Dashboard's In-game stats card with FPS, 1%/0.1%/0.01% lows and a frame-time graph while Ball x Pit runs. +- Verdict: it fills the bottom screen "with useful things like a keyboard and a trackpad" or game information, and makes the device feel "a lot more like having a dual screen Steam Deck". +- Problem: it "froze on install a handful of times" and needed three device restarts. The build was probably 0.7.1 or earlier. Two first-run hang fixes landed later: #3070 (FEX/AppImage extraction deadlock in the clock-pause preload) and #3212 (first-run setup crashing in the background). Whether they cover this report is unconfirmed; slow exFAT preallocation on the Thor's SD card ([thor-sd-storage-investigation.md](thor-sd-storage-investigation.md)) can also look like a freeze. +- Problem: with no game running, the stats card reads "59.6 fps · Steam Client ARM". It measures the Steam client itself, which tells the user nothing. + +## What other projects do + +### System companions and utilities + +| Project | Bottom screen | Data source | +| --- | --- | --- | +| [ArmadaLive](https://github.com/FabianZettl/armadalive) (Armada OS, SteamOS-like Linux on the Thor) | Follows the top screen: logo, background, info, PDF manual, cheats and play time of the current game. Launcher with user and smart folders (recent, favourites, per system), random pick, Add to Steam. System page with FPS and a 60/120 Hz switch, rearrangeable quick-setting tiles (power profile, fan curve, stick LEDs, per-screen brightness, screen off), gauges. Rules (power profile, FPS limit, emulator resolution per game, per system, idle, or base). Tuning (governor, GPU limits, fan curve editor) that reverts after 15 s unless kept. Graphs, task manager, play-time history, trackpads, back buttons as a second controller. Dims after 10 s; hold Start+Select to close a game; AYN button shows or hides it, hold turns the screen off. 55 themes, first-run permission walkthrough, health check, verified self-update | ES-DE custom event scripts writing a state file, emulator process scan matched to ROMs, gamescope focus and stats pipe, the Big Picture selection read over Steam's CEF debug port, ES-DE scraped media and Steam's library cache | +| [Armada OS](https://github.com/armada-os/armada) | Little in game mode: the bottom screen sleeps with the top. An experimental Plasma Mobile session, and `armada-run-bottom -- ` to run single apps on a second gamescope on the bottom panel | n/a | +| [Thor Command Panel](https://github.com/BrianJr03/command-panel) | Replaces the stock dual-screen assistant: screen modes with real blanking, per-screen brightness and volume, 60/120 Hz with FPS, tiles, telemetry, themes, drag-to-arrange cards, replay buffer of either or both screens, full gamepad navigation | System APIs | +| [Better Dual Screen Assistant](https://github.com/stormpanda/better-dual-screen-assistant) (Thor and Duo) | One-tap swap of the foreground apps between screens, linked brightness and volume, FPS from real frame delivery, paged tiles switched with L1/R1, recording, touch lock, mouse mode, key mapper, works before unlock | System APIs | +| [Wayfinder](https://github.com/Thor-Wayfinder/thor-wayfinder) | Move or swap live apps between screens, button combos with a cheat sheet, per-app profiles (screen, performance, fan, refresh rate, lights, controls), keyboard and trackpad on the other screen | System APIs | +| [Megingiard](https://github.com/stormpanda/megingiard) | Mirrors up to 10 cropped regions of the top screen (minimap, HUD) with pinch zoom; per-app macro pads; split keyboard on text focus; trackpad | Screen capture | +| [WalkThor](https://github.com/nerf-herder-29/WalkThor) | Now Playing art, the guide at your last page, up to 4 mirrored top-screen regions remembered per game, console-style face-button labels, FPS graph, learned per-game battery runtime, offline captions of game audio. Hands focus back to the game | Cocoon and ES-DE log files, screen capture | +| [Heimdall](https://github.com/mastercook777/Heimdall-AYN-Thor-Assistant) | Per-game module grid, macros, precision aim, virtual mouse and stick, "portals" (live top-screen regions), OCR translation | Screen capture | +| [ThorSport](https://github.com/CHINW3/ThorSport) | Live scoreboards for 15 leagues, bottom-only mode so a game can run on top, spoiler delay synced to a stream | Sports APIs | +| AYANEO Flip DS (Windows, AYASpace) | Performance stats, quick settings, app shortcuts, moving any window between screens | Windows | + +### Guides + +| Project | Bottom screen | Data source | +| --- | --- | --- | +| [Game Twin](https://github.com/alpha-minus/game-twin) | Per-game vault of guides (GameFAQs, StrategyWiki, IGN) saved offline, VGMaps maps with markers, RetroAchievements and Steam achievements including missables, checklists. Switches workspace with the game and reopens where you left off. Optional Gemini help with a screenshot of the top screen | Polls Cocoon `launch_debug.log`, ES-DE `es_log.txt`, RetroArch `content_history.lpl`, and the Steam Web API for recently played | +| [Pixel Guide](https://github.com/rexmont/Pixel-Guide-Android) | Offline guides, maps, manuals, RetroAchievements, AI help | Games are added by hand | + +### Game companions + +| Project | Bottom screen | How it gets live state | +| --- | --- | --- | +| [Eden Duo](https://github.com/igawa6/eden-duo) (Switch) | Interactive per-game pages (Stats, Map, Tasks); can use items and change equipment | Per-game `.dsmod.zip` packages from a [catalog repo](https://github.com/igawa6/eden-duo-companions): `package.json` with build IDs and per-ABI native modules, a declarative UI manifest (pages, widgets, actions, `poll_hz`, art loaded from the game's own romfs), and pointer chains per build. A small C ABI gives modules `read_memory`/`write_memory`/`publish_*`. Unity IL2CPP members are resolved by name. Unknown builds show a "needs version X" page | +| [GBA DS](https://github.com/kyannon/gba-ds) | Map or HUD for 77 GBA games. Per-game screen sizing, placement, generated overlays and per-screen brightness | A second silent emulator instance receives the live state, opens the map and captures it, confirmed by RAM flags and pixel probes. Some games render twice, with and without the HUD | +| [WiiDS](https://github.com/Maddex712/WiiDS) | Course maps, standings, a rotating Galaxy planet with a touch cursor | Native recompilations, so state is in-process | +| [Silksong Android](https://github.com/jakobkhansen/SilksongAndroid) | Interactive map, inventory and pause menu that look like part of the game | C# patches compiled on-device against the game's assemblies, drawn by a Unity camera on `Display.displays[1]`. Downloads the Linux depot with JavaSteam and syncs Steam Cloud saves | +| [AYN Thor dual-screen mods](https://github.com/JoeCorrell/AYN-Thor-Dualscreen-Mods) (Stardew Valley) | Today, Map, Farm, Journal, Bundles, Calendar; touch actions | A SMAPI mod inside a Steam container serves a WebSocket on `127.0.0.1:7786`; a separate APK draws the pages. A [second client](https://github.com/project-barry/stardew-dual-screen) speaks the same protocol | +| [ShulkDS](https://github.com/NaiSenshin/ShulkDS) (Minecraft Java) | Minimap, touch inventory, options | Its own client reimplementation | +| [TotK Native](https://github.com/AurelioB/totk-android) | Touch equip and eat actions | Guarded reads of native memory into a JSON snapshot polled by a Java UI | +| [Kanto Gear](https://github.com/AverageConsumer/kanto-gear) ([Gen 1 recomp](https://github.com/bryanthaboi/gen1recomp)) | Companion panel, as a combined window, a separate process, or a phone/browser over Wi-Fi | In-process; [KantoGearBottom](https://github.com/venatrix-ritz/KantoGearBottom) puts the separate window on Armada's bottom gamescope | +| [EmuLnk](https://github.com/EmuLnk/emulnk) | HTML/JS dashboards per game that can also write memory or run macros | Emulator forks send memory over UDP; profiles are JSON memory points from a [content repo](https://github.com/EmuLnk/emulnk-repo) | + +Other GAFT companions: Thor Pip-Boy, FNVDS, Grand Theft Companion, FFXII, Terraria, ZomboidDS, Skyrim, Delphis (live Dolphin button guide), PokeMMO Companion, Thor-SpeedrunSplits, DrillPod. + +### Patterns that recur + +- The bottom screen follows the game on top without the user telling it which game. +- Everything is remembered per game: panel, guide page, mirrored regions, power and FPS rules, control profiles. +- One hardware button shows or hides the panel; holding it switches the bottom screen fully off, not just black. +- Per-screen brightness, a 60/120 Hz switch and an honest FPS readout. +- Live crops of the minimap or HUD. +- Auto-dim of an idle OLED panel. +- The panel never takes focus or priority from the game. + +## DroidDeck today + +As of `d788afc12`, before the work in the Status lines below. + +Paths are under [`app/src/main/java/com/droiddeck/launcher/`](../../app/src/main/java/com/droiddeck/launcher/). + +**Panels.** [`input/SecondScreenMode.kt`](../../app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt) lists the modes: menu, keyboard + trackpad, terminal, Deck grips + trackpads, profile controls, dashboard and the KDE desktop. [`ui/SecondScreenPresentation.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt) hosts them in a `Presentation`, with the bar in [`ui/BottomScreenBar.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/BottomScreenBar.kt). The last mode is remembered once for game sessions and once for desktop sessions (`SessionPrefs.secondScreenPanel`), not per game. Outside a session the launcher shows [`ui/DualScreenPanel.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/DualScreenPanel.kt). + +**Dashboard.** [`ui/BottomDashboard.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/BottomDashboard.kt) has In-game stats, Downloads, Screenshots and Chat & voice. The tab is remembered per session and jumps to stats when a game starts. A strip of metrics ([`ui/BottomStrip.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/BottomStrip.kt)) can sit on the other tabs. + +**Displays.** [`input/DualScreen.kt`](../../app/src/main/java/com/droiddeck/launcher/input/DualScreen.kt) finds built-in presentation displays with their own touch panel. Sessions support Auto, On, Swapped (game on the bottom, [`ui/BottomGameScreen.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/BottomGameScreen.kt)) and Off. The game is rendered by our compositor into a `SurfaceView` we own, not by a separate activity. [`input/BottomScreenGuests.kt`](../../app/src/main/java/com/droiddeck/launcher/input/BottomScreenGuests.kt) yields the screen when another app takes it. + +**Data already available.** + +- Frame times from gamescope's ring buffer ([`hud/GameFrames.kt`](../../app/src/main/java/com/droiddeck/launcher/hud/GameFrames.kt)), with lows, graph, focused app and refresh rate. +- Device metrics ([`hud/HudMetrics.java`](../../app/src/main/java/com/droiddeck/launcher/hud/HudMetrics.java)): CPU/GPU load, clocks and temperatures, RAM, VRAM, network, battery with a runtime estimate, fan. +- Game telemetry ([`session/GameTelemetry.kt`](../../app/src/main/java/com/droiddeck/launcher/session/GameTelemetry.kt)): racing UDP, War Thunder over local HTTP, Elite Dangerous status file. +- Steam downloads from app manifests and `content_log.txt`, screenshots from DroidDeck and Steam, Steam chat in a WebView with the web-login cookies. +- `AgentGuest.steamEval` runs `SteamClient.*` in Steam's UI. Only offline mode and live shortcuts use it today. +- Per-game profiles ([`session/SelectedGameProfile.kt`](../../app/src/main/java/com/droiddeck/launcher/session/SelectedGameProfile.kt)) that follow the game Steam has focused (`GameProfileFollowState`). + +**Gaps.** + +- The panel does not follow the game: no per-game mode, tab or control layout. +- With no game running, the stats card measures the Steam client. +- No Steam achievements, friends or notifications on the bottom screen. Achievements exist only for Epic, GOG and EA. The 0.7.0 notes mention a notifications page that no longer exists. +- No way to switch the bottom panel fully off or dim it when idle. +- [`settings-map.md`](../settings-map.md) lists only "Dual screen launcher". Dual screen sessions, Show the game on, Bottom screen controls in games, Bottom screen HUD, Strip on every tab and Physical controls can use bottom screen are missing. + +DroidDeck already has more on the bottom screen than any other project that runs PC games. What it lacks is context: it does not react to what is on top. + +## Proposals + +Ordered by value for effort. Each is independent unless noted. + +### 1. Idle home page + +**Status:** built as its own panel, Game art (Steam sessions), after a first version as a row on the dashboard was removed. The bottom screen shows the hero art of the running game, or the one selected in Big Picture, or the most recently played, with a slow pan and zoom, its logo, and play time; it cross-fades when the selection changes and starts with the bar hidden. Checked on a Retroid Pocket Duo Lite Plus. Code: [`ui/BottomArtPanel.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/BottomArtPanel.kt), selection in [`ui/BottomIdleHome.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/BottomIdleHome.kt). + +![Game art panel: a game's hero art with its logo and play time](evidence/bottom-screen-art-2026-11-27.png) + +When no game is focused, replace the Steam-client FPS card with a page about the game highlighted in Steam: art, play time, last played, achievement progress, and Play / Stream buttons. Add downloads in progress and friends online. + +- Source: the Big Picture selection and app details through `steamEval`, as ArmadaLive does over the CEF port. Art from the existing `SteamGameArt`. +- Open question: which `SteamClient` call or store gives the focused library item most reliably across client updates. ArmadaLive lists this as fragile; we need a fallback to the most recent game. + +### 2. Per-game panel memory + +**Status:** built. Picking a bottom mode or a dashboard tab while a game is focused saves it for that game (`secondScreenPanel.app.`, `bottomPage.app.`); focusing the game restores it, and returning to Steam restores the global choice. Resetting the game profile clears both. Control layouts already follow the game through input profiles. Not yet checked on hardware: launching a game on the test device would have signed out another session on the same Steam account. + +Remember the bottom mode, dashboard tab and control layout per Steam app id, and restore them when that game gains focus. Fall back to today's global choice. + +- Source: the focus already tracked for `GameProfileFollowState`. Store next to the game profile so Reset clears it. +- Applies to swapped mode too, where the panel is on the top screen. + +### 3. Steam achievements and notifications + +**Status:** achievements built, as a section of the Guides panel rather than a dashboard tab. They are read from `SteamClient.Apps.GetMyAchievementsForApp` into the shared `StoreAchievements` model (same list and hidden-achievement handling as Epic and GOG); games without Steam stats show the empty state. Notifications are not started. + +An achievements page for the running game (progress, recent unlocks, locked list with hidden descriptions behind a tap) and a notifications page (friends, invites, downloads finished). + +- Source: `steamEval` against Steam's UI stores, which keep the last synced achievements while the device is offline. The Steam Web API is a fallback only when the device has a network but the Steam client is offline; with no network, the page shows the cached list or says achievements are unavailable. +- Matches the existing Epic, GOG and EA achievement readers so all stores look the same. + +### 4. Quick tiles and per-game rules + +**Status:** not built. A first tile page was tried and removed: the in-game menu already has these controls, and a second copy on the dashboard did not fit the panel's style. + +Rearrangeable tiles on the dashboard: FPS limit, 60/120 Hz, per-screen brightness, frame generation, screen effects, screenshot, swap screens, bottom screen off. A "Keep for this game" action saves the value into the game profile; settings that can make the device unusable revert after 15 s unless confirmed. + +- Most of these are already per-game somewhere (frame generation, screen effects, FPS limit for non-Steam games). This exposes them where the user is looking during play. + +### 5. Bottom screen off and auto-dim + +**Status:** built and checked on a Retroid Pocket Duo Lite Plus, where the window brightness override is per display: screen off sets the bottom display to 0.0 and auto-dim to 0.05 (`mBrightnessReason=override(com.droiddeck.launcher)`), while the top display stays at the user's manual level. Every panel's bar has a sun button that drops down a brightness slider for the bottom screen only (5–100 %, saved; it never reaches 0) with the screen-off button at its end: the panel goes black and asks for the lowest window brightness (`BRIGHTNESS_OVERRIDE_OFF`); a touch wakes it to the chosen level, and the waking touch does not reach the panel. Auto-dim never brightens a level set below it. The dashboard dims after 60 s without touch (pref `bottomAutoDim`, on by default); trackpad and keyboard panels never dim. Hardware buttons are not claimed. + +- A real off state for the bottom panel during a game (the backlight off, not a black Presentation), toggled from the bar or a button hold. +- Dim after a period without touch, wake on touch. Off by default for the trackpad and keyboard modes. +- Investigate which hardware buttons we can claim on the Thor and Duo without fighting the stock assistant. + +**Bar:** every panel's bar can be hidden with its chevron button; a pull tab at the top edge brings it back by a tap or a pull down. Game art, a page open in the Guides reader and a pinned map hide it on their own, and leaving them shows it again. + +| Brightness | Bar hidden | +| --- | --- | +| ![Brightness slider dropped down under the bottom bar, with the screen-off button at its end](evidence/bottom-screen-brightness-2026-11-27.png) | ![Bottom bar hidden, with the pull tab at the top edge](evidence/bottom-screen-bar-hidden-2026-11-27.png) | + +### 6. Region mirror from our compositor + +**Status:** milestone 1 built as its own bottom-screen panel (Mirror in the panel picker): the live region fills the panel, and Region, Top screen (shown, hidden or dimmed) and Scaling open as a card from the bar's options button. Checked on a Retroid Pocket Duo Lite Plus; see the region mirror doc. + +Crop rectangles of the game image (minimap, HUD, ability bars) onto the bottom screen, saved per game, optionally hidden on the top screen. Other Thor tools need MediaProjection or a privileged helper and cannot hide the original; our compositor has the game image before display, so it can do both with no permission prompt. Recommended path: a second output in `vk_present` that blits region sub-rectangles, with zero-copy layers later. + +Details: [bottom-screen-region-mirror.md](bottom-screen-region-mirror.md). + +### 7. Guides panel + +**Status:** milestones 1 and 4 built as their own bottom-screen panel (Guides in the panel picker), checked on a Retroid Pocket Duo Lite Plus. Five sections, switched with the app's tab strip and LB/RB, for the running game or the one selected in Steam: Guides (top-rated Steam guides in the device's language with a category choice and Continue reading), Achievements, Wiki & fixes (ProtonDB tier, and the wiki, StrategyWiki, PCGamingWiki, GameFAQs, IGN and HowLongToBeat through Wikidata; what Wikidata lacks is found from each site's own routes, such as Map Genie and IGN wiki slugs, Fandom's API and StrategyWiki's search API, so every row opens the page itself rather than a web search; only YouTube walkthroughs stay a search), Maps (images pinned by long-press, with zoom and markers per map, and the game's Map Genie page) and Saved (web archives for offline reading). The reader never takes focus, blocks common ad hosts and stays on the opened site unless the user follows a link. Code: [`session/SteamGuides.kt`](../../app/src/main/java/com/droiddeck/launcher/session/SteamGuides.kt), [`session/GameLinks.kt`](../../app/src/main/java/com/droiddeck/launcher/session/GameLinks.kt), [`ui/BottomGuidesPage.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/BottomGuidesPage.kt). + +A per-game tab with Steam Community guides for the exact app id, Steam achievements as a spoiler-safe checklist, the game's wiki and fixes (found through Wikidata), saved pages for offline use, and a workspace that reopens at the last section. It must never take focus from the game, and pauses pages it is not showing. + +Details: [bottom-screen-guides.md](bottom-screen-guides.md). + +### 8. Companion API for PC games + +**Status:** not built here; the first adapters (Stardew Valley, Skyrim SE, Fallout 4) follow in their own change. + +Let mods running in Proton drive native bottom-screen pages over loopback. Thor Pip-Boy (Fallout 4) and Grand Theft Companion (GTA) already run against DroidDeck as separate apps, and the Stardew, Skyrim and RimWorld ecosystems have servers we can adapt to. Plan: adapters for those first, then DroidDeck's own token-authenticated protocol with declarative pages and normalized state keys, then "run on bottom", then memory profiles only if needed. The existing racing, War Thunder and Elite Dangerous telemetry is the first set of built-in adapters. + +### 9. Steam's Quick Access menu on the bottom screen + +**Status:** built as its own panel (Quick Access in the panel picker, Steam sessions only) and checked on a Retroid Pocket Duo Lite Plus in Big Picture and in a game. The bottom screen shows Steam's real Quick Access menu: notifications, friends and chat, quick settings, performance, soundtracks and help, plus Decky Loader's tab and its plugins when Decky is enabled. Taps, drags and scrolling go to it; the controller stays on the top screen, so the d-pad drives the library or the game while the menu stays open. Code: [`session/SteamQam.kt`](../../app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt), [`ui/BottomSteamQamPanel.kt`](../../app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt), [`droiddeck-qam-relay`](../../tools/linuxfs/overlay/usr/local/bin/droiddeck-qam-relay). + +Plugin loaders expose Steam's CEF DevTools so the menu can be viewed in a desktop browser, but it renders only while it is open on the main screen. The panel keeps it open without covering the top screen: + +- Steam's UI is told to open the menu and keep it open: its composition request is capped at "notification" while the menu is ours, so gamescope keeps focus on the game, and losing focus no longer closes it. Gamepad focus moves from the menu back to the main UI only when the menu took it, so Steam's own popups keep the controller. The blurred backdrop is hidden. +- The menu's browser view is placed just outside the Big Picture window through its own `SetBounds`, so it keeps rendering but never shows on top, including while Steam slides it wider for Friends and chat. The view is also given the panel's shape (about 712 × 463 instead of Steam's 856 × 463), so every tab shows at one scale. In Full width, a style on the menu page also lifts Steam's 300 px cap on each tab, so every tab fills the panel and Friends shows its list and chat side by side. +- A timer inside Steam keeps this state every 250 ms, so the menu comes back, on the tab it was showing, as soon as Steam's main menu or a full-screen page such as Decky's store closes. It runs on a 5 s lease that the panel renews each second: if the app stops, Steam returns to normal by itself. +- The hold starts only once the session is ready: holding the menu before Steam's first frame kept gamescope from presenting anything. +- `droiddeck-qam-relay` relays the app to the DevTools port, which only answers clients inside the guest. The panel streams the menu with `Page.startScreencast`, scales its content to the panel and fills the rest with the menu's own background, and forwards touches on the menu with `Input.dispatchTouchEvent`. A layout button in the panel's bar cycles Full width (every tab stretched to the panel), Left, Center and Right (Steam's own narrow tabs, placed on that side); the choice is kept. Returning to the panel shows the last frame at once while the stream reconnects, and the first frame after a cold start takes about 1.4 s. +- The Quick Access button still shows the menu on the top screen, in Steam's own layout and with the controller; closing it there (B or the button again) returns it to the bottom screen on the same tab. +- Leaving the panel closes the menu and turns the patches off; the Steam button and the normal Quick Access button then work as before. Opening Steam's main menu replaces the Quick Access menu for as long as it is open, as on a Deck. + +Checked with Decky Loader 3.3.1 enabled: its tab renders and takes touch, and its store opens full screen on top with the controller, then returns to the Decky tab below. Decky hooks the menu after Steam starts, so the panel reopens it once when that happens. + +Limits: it relies on Steam's minified UI stores and method names, so a client update can break it; the panel then shows that the menu is not available. + +| Big Picture, friends | In game, performance | In game, quick settings | +| --- | --- | --- | +| ![Quick Access Friends tab on the bottom screen](evidence/bottom-screen-qam-friends-2026-11-27.png) | ![Quick Access Performance tab on the bottom screen during a game](evidence/bottom-screen-qam-performance-ingame-2026-11-27.png) | ![Quick Access Quick Settings tab on the bottom screen](evidence/bottom-screen-qam-settings-2026-11-27.png) | + +| Decky | Performance | +| --- | --- | +| ![Decky Loader's tab in Quick Access on the bottom screen](evidence/bottom-screen-qam-decky-2026-11-27.png) | ![Quick Access Performance tab in the full-width layout](evidence/bottom-screen-qam-performance-2026-11-27.png) | + +| Layout: Center | Layout: Right | +| --- | --- | +| ![Quick Access in the centred layout](evidence/bottom-screen-qam-center-2026-11-27.png) | ![Quick Access in the right-aligned layout](evidence/bottom-screen-qam-right-2026-11-27.png) | + +The top screen during that game, with the menu open on the bottom: ![Top screen during the game, with nothing drawn over it](evidence/bottom-screen-qam-top-ingame-2026-11-27.png) + +## Related fixes + +- Add the missing dual-screen settings to `SettingsIndex` and regenerate [`settings-map.md`](../settings-map.md). +- Reproduce a first install on a Thor from a clean state, including with Steam on the SD card, against 0.7.11 to confirm the reported freeze is gone. diff --git a/docs/development/dd-fg.md b/docs/development/dd-fg.md index 81cb43a9ea..1275b18758 100644 --- a/docs/development/dd-fg.md +++ b/docs/development/dd-fg.md @@ -27,6 +27,28 @@ bytes for dimensions at least four pixels: These are pixel payloads, not driver allocation sizes or measured FPS gains. +## Scratch ownership and rebuilds + +Each `FrameGen` instance owns its scratch buffers, mappings and descriptor sets. +A size or live-preset rebuild first confirms GPU completion and resets that +instance's descriptor pool, then releases the old scratch and image resources. +Motion/history validity is reset with the rebuilt images. Repeated preparation +at the same size and ordinary frame recording do not add device-idle waits. + +Healthy destruction releases the descriptor pool, mapped scratch buffers and +images. The native engine releases its input ring only after the chain confirms +completion, so an input image is not destroyed before the wait. + +If `vkDeviceWaitIdle` fails with an error other than +`VK_ERROR_DEVICE_LOST`, the affected instance becomes unusable: further +recording and rebuilding stop, and its Vulkan resources and input ring are +intentionally retained because GPU completion is unknown. Device loss follows +a separate teardown path: `FrameGen::destroy()` releases its owned resources +without another wait and returns true, allowing the Engine to release the +input ring. This is local DD-FG containment, not compositor-wide GPU recovery. +A descriptor-pool reset failure also stops that resize without releasing the +resources, but healthy teardown can still release them. + ## Validation Run `python3 -m unittest discover -s tools/tests -p 'test_ddfg_flow_levels.py'`. @@ -35,4 +57,10 @@ selected through the usual SDK/NDK environment variables. It compiles the actual DD-FG chain against a mock Vulkan dispatch table and checks resource counts, dispatch order and sizes, valid descriptor bindings, both models, every preset, 2x/3x/4x generation, small/odd extents, resize and live preset changes. +The same harness enforces descriptor-pool capacity, accounts for all live +resources, and models pending GPU work to reject early cleanup. Lifecycle cases +cover repeated rebuilds, same-size restarts, two simultaneous instances, +automatic/idempotent destruction, partial resize allocation, failed GPU waits, +and failed descriptor-pool resets. The actual native `Engine` is included to +check the input-ring destruction order. It does not execute shaders on a GPU or replace on-device validation. diff --git a/docs/development/ea-store.md b/docs/development/ea-store.md index 89a345c80f..bbfe00b9a5 100644 --- a/docs/development/ea-store.md +++ b/docs/development/ea-store.md @@ -13,6 +13,7 @@ EA games install, update and start without the EA app. The research behind it is | Downloads | Rust `src/ea/` in `libdroiddeckstores.so`, `EaInstaller.kt` | A build is one ZIP on EA's CDN. The engine reads its central directory with ranged reads, keeps files whose size and CRC match, and streams every other entry through inflate into place. `.droiddeck-ea-files` records what it placed, so a resume or update does not re-hash those files; files a new build drops are removed. | | Updates | `EaUpdates` in `EaBackend.kt` | The game page compares the installed version with the offer's live `gameVersion` (every 30 minutes at most). Update runs the same install, which only fetches changed files. | | Launch, guest | `droiddeck-store-launch` (`prepare_ea`) | Creates the prefix, reads the machine as Wine reports it (`wmic`, `vol`, `hostname`; cached in `pfx/.droiddeck-ea-hw.json`), writes EA app presence keys and the game's `Install Dir` keys in both registry views, runs the build's Touchup once per installed build, then asks the app for the session and writes any licence files. | +| Launch, Steam copy | `prepare_steam_ea` in `droiddeck-store-launch`, the Proton wrapper | Steam starts its EA titles with `steam2ea://`, which only the EA app handles, and the EA app does not install here. When the prefix has no EA app, the hook reads the game's `__Installer/installerdata.xml` and its offers (`__Installer/LOC/Origin.OFR.*.dat`), runs `prepare_ea` with a `steam` request (the app answers with the launch environment instead of a sidecar file), and writes `droiddeck-ea-steam.bat` in the game's compatdata. The wrapper runs that launcher in place of the link. Writing the EA app presence keys also satisfies the install script, so Steam stops running the EA app installer. | | Launch, app | `EaLaunch.kt`, `EaOoa.kt`, `EaLsx.kt` | Answers `ea-prepare`: starts the LSX endpoint on `127.0.0.1:3216`, mints the short-lived opaque token, writes `.droiddeck-ea-env` (read once and deleted by the launcher `.bat`), and for games with a `Core` folder requests an online-activation licence for the machine hash. | | LSX | `EaLsx.kt` | The local endpoint EA's SDK talks to instead of the EA app: challenge, AES session key, config, profile, settings, game info, auth codes for the game's own client ids, licences with Denuvo tokens, entitlements. Friends, presence and the overlay answer empty. | @@ -26,6 +27,5 @@ WMI does not expose, so those use `00000000` unless the probe learns it. ## Not done yet - Cloud saves (`cloudsync.juno.ea.com`). -- Steam copies of EA games still install the EA app (#2036). - Pre-DiP games (no `installerdata.xml`) fall back to the exe picker. - Javelin anti-cheat games do not run under Proton. diff --git a/docs/development/evidence/bottom-screen-art-2026-11-27.png b/docs/development/evidence/bottom-screen-art-2026-11-27.png new file mode 100644 index 0000000000..32e8572364 Binary files /dev/null and b/docs/development/evidence/bottom-screen-art-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-bar-hidden-2026-11-27.png b/docs/development/evidence/bottom-screen-bar-hidden-2026-11-27.png new file mode 100644 index 0000000000..55f04e1779 Binary files /dev/null and b/docs/development/evidence/bottom-screen-bar-hidden-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-brightness-2026-11-27.png b/docs/development/evidence/bottom-screen-brightness-2026-11-27.png new file mode 100644 index 0000000000..7cd71288e4 Binary files /dev/null and b/docs/development/evidence/bottom-screen-brightness-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-guides-achievements-bottom-2026-11-27.png b/docs/development/evidence/bottom-screen-guides-achievements-bottom-2026-11-27.png new file mode 100644 index 0000000000..92608d5df5 Binary files /dev/null and b/docs/development/evidence/bottom-screen-guides-achievements-bottom-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-guides-bottom-2026-11-27.png b/docs/development/evidence/bottom-screen-guides-bottom-2026-11-27.png new file mode 100644 index 0000000000..8d056b9acd Binary files /dev/null and b/docs/development/evidence/bottom-screen-guides-bottom-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-guides-maps-bottom-2026-11-27.png b/docs/development/evidence/bottom-screen-guides-maps-bottom-2026-11-27.png new file mode 100644 index 0000000000..8af6fc61ae Binary files /dev/null and b/docs/development/evidence/bottom-screen-guides-maps-bottom-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-guides-reader-bottom-2026-11-27.png b/docs/development/evidence/bottom-screen-guides-reader-bottom-2026-11-27.png new file mode 100644 index 0000000000..735e76d01f Binary files /dev/null and b/docs/development/evidence/bottom-screen-guides-reader-bottom-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-guides-saved-bottom-2026-11-27.png b/docs/development/evidence/bottom-screen-guides-saved-bottom-2026-11-27.png new file mode 100644 index 0000000000..59d311303e Binary files /dev/null and b/docs/development/evidence/bottom-screen-guides-saved-bottom-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-guides-wiki-bottom-2026-11-27.png b/docs/development/evidence/bottom-screen-guides-wiki-bottom-2026-11-27.png new file mode 100644 index 0000000000..3af7744ca2 Binary files /dev/null and b/docs/development/evidence/bottom-screen-guides-wiki-bottom-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-mirror-bottom-2026-11-27.png b/docs/development/evidence/bottom-screen-mirror-bottom-2026-11-27.png new file mode 100644 index 0000000000..d75281879c Binary files /dev/null and b/docs/development/evidence/bottom-screen-mirror-bottom-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-mirror-options-2026-11-27.png b/docs/development/evidence/bottom-screen-mirror-options-2026-11-27.png new file mode 100644 index 0000000000..4a05ca4380 Binary files /dev/null and b/docs/development/evidence/bottom-screen-mirror-options-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-mirror-top-2026-11-27.jpg b/docs/development/evidence/bottom-screen-mirror-top-2026-11-27.jpg new file mode 100644 index 0000000000..bbfe6291ec Binary files /dev/null and b/docs/development/evidence/bottom-screen-mirror-top-2026-11-27.jpg differ diff --git a/docs/development/evidence/bottom-screen-picker-bottom-2026-11-27.png b/docs/development/evidence/bottom-screen-picker-bottom-2026-11-27.png new file mode 100644 index 0000000000..95747ea8ad Binary files /dev/null and b/docs/development/evidence/bottom-screen-picker-bottom-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-qam-center-2026-11-27.png b/docs/development/evidence/bottom-screen-qam-center-2026-11-27.png new file mode 100644 index 0000000000..f511b716ac Binary files /dev/null and b/docs/development/evidence/bottom-screen-qam-center-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-qam-decky-2026-11-27.png b/docs/development/evidence/bottom-screen-qam-decky-2026-11-27.png new file mode 100644 index 0000000000..5b837b7eb5 Binary files /dev/null and b/docs/development/evidence/bottom-screen-qam-decky-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-qam-friends-2026-11-27.png b/docs/development/evidence/bottom-screen-qam-friends-2026-11-27.png new file mode 100644 index 0000000000..6bc726fd3c Binary files /dev/null and b/docs/development/evidence/bottom-screen-qam-friends-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-qam-performance-2026-11-27.png b/docs/development/evidence/bottom-screen-qam-performance-2026-11-27.png new file mode 100644 index 0000000000..94ceb551c5 Binary files /dev/null and b/docs/development/evidence/bottom-screen-qam-performance-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-qam-performance-ingame-2026-11-27.png b/docs/development/evidence/bottom-screen-qam-performance-ingame-2026-11-27.png new file mode 100644 index 0000000000..4d93a28f40 Binary files /dev/null and b/docs/development/evidence/bottom-screen-qam-performance-ingame-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-qam-right-2026-11-27.png b/docs/development/evidence/bottom-screen-qam-right-2026-11-27.png new file mode 100644 index 0000000000..858308fc97 Binary files /dev/null and b/docs/development/evidence/bottom-screen-qam-right-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-qam-settings-2026-11-27.png b/docs/development/evidence/bottom-screen-qam-settings-2026-11-27.png new file mode 100644 index 0000000000..31f298e77a Binary files /dev/null and b/docs/development/evidence/bottom-screen-qam-settings-2026-11-27.png differ diff --git a/docs/development/evidence/bottom-screen-qam-top-ingame-2026-11-27.png b/docs/development/evidence/bottom-screen-qam-top-ingame-2026-11-27.png new file mode 100644 index 0000000000..01869fe49d Binary files /dev/null and b/docs/development/evidence/bottom-screen-qam-top-ingame-2026-11-27.png differ diff --git a/docs/development/framegen-post-upscale.md b/docs/development/framegen-post-upscale.md new file mode 100644 index 0000000000..084040d96d --- /dev/null +++ b/docs/development/framegen-post-upscale.md @@ -0,0 +1,68 @@ +# Experimental spatial upscaling after frame generation + +The compositor limits effects output to the logical scene size while frame +generation is active. This avoids running interpolation over the full phone +panel, but can make FSR/GSR/NIS see equal input and output sizes and skip their +spatial pass. Version 0.5.0 instead upscaled before interpolation, which made +the interpolation workload scale with panel resolution. + +This experiment keeps the existing source-resolution selection and runs frame +generation at the effects input size. Each generated frame and the final real +frame then uses the selected spatial filter at the mapped display size. +It introduces no extra frame queue or CPU fence wait. Performance and latency +improvements are hypotheses, not measured results. + +## Scope and activation + +Use an SDR game with a real input buffer smaller than the mapped output. +Enable frame generation and select AMD FSR 1, FSR Fit, Snapdragon GSR/GSR HQ, +or NIS in the scaling filter setting. Keep additional effects (CAS, color, +FXAA, CRT, etc.) off for this experiment. Sharpen-only, linear, nearest, +frame-generation-off, HDR and cardboard paths retain their existing behavior. +Combining a spatial filter with additional effects also retains the old path; +this experiment does not claim to fix that combination. + +Source selection remains conservative. A game already rendering a native-size +backbuffer cannot recover its lower internal rendering resolution here. +Overlays included in the low-resolution input are interpolated/upscaled with +that input; this is not a separate native-resolution HUD reconstruction. + +GPU targets and source descriptors are separate for each presentation slot so +recording one generated frame cannot replace another frame's bindings. +Source views are released after the existing frame-completion fence; targets +are cached and destroyed with the effects device. This increases GPU memory +use with interpolation multiplier and panel resolution. Allocation failures +retain the input-sized image and the existing screen blit fallback. + +## Applying and reverting + +Install the test APK produced for this PR. Check its signing/package identity +before replacing an installed release: an Actions test-key APK is not a +release-signed update. An official signed test build requires the repository's +normal publication authorization. Back up session logs and record the exact +APK commit, GPU driver, engine and game settings for comparisons. + +No setting migration is required. Disable frame generation or select Linear +to return to the previous presentation path. Do not mix this test with Vulkan +feature-level or game compatibility changes. + +## Device validation required before merge + +- Compare the same scene on baseline main and this branch: FG off/on, Linear, + FSR, GSR, GSR HQ, NIS, FSR Fit, sharpen-only and nearest. +- Test each supported interpolation multiplier, both engines, warm-up/no + generated frames, 720p-to-1080p and 1080p-to-panel scaling, and no upscale. +- Check real and generated frames for consistent sharpness, halos, ghosting, + text/cursor artifacts, black bars, stretching and frame-order errors. +- Change resolution/filter/engine/multiplier live; open Steam/QAM, rotate, + suspend/resume and stop/restart. Verify no stale image, GPU loss or crash. +- Confirm HDR, cardboard, FG-off and additional-effects fallback behavior. +- Compare sustained frame pacing, generated vs real FPS, GPU load, memory, + temperature and battery use after warm-up; do not treat output FPS alone as + lower input latency. Measure input-to-display latency if equipment permits. +- Test memory pressure and allocation failure fallback; inspect Vulkan + validation for descriptor lifetime, image layouts and synchronization. + +Host harnesses exercise resolution routing, generated/real frame counts, +filter gates, fallback and source descriptor lifetime. They do not validate +shader output, mobile-driver behavior, performance or physical input latency. diff --git a/docs/development/game-environment.md b/docs/development/game-environment.md index 916fa30dc6..6036cc3a7a 100644 --- a/docs/development/game-environment.md +++ b/docs/development/game-environment.md @@ -134,6 +134,11 @@ spaces, quotes, or shell characters stay literal. Existing arguments and settings on the next launch. It does not change Steam probes or native Linux programs, whose ordinary output remains in the session log. +Proton's log is held to its first 64 MiB, whichever setting turned it on: a +watcher checks `steam-.log` and `steam-proton.log` every second while the game runs and +cuts them back, and later output continues after the cut. A game stuck in an exception loop +otherwise writes gigabytes per run. + After reproducing once, stop the session and use **Latest session logs > Share logs**. The archive includes the generated Wine/Proton and graphics logs. Debug logging can reduce performance and consume storage; disable it after collecting @@ -188,6 +193,15 @@ A Unity game under FEX (`UnityPlayer.dll` for Windows builds under Proton, turns it off: without TSO such games can deadlock or crash (seen with Megabonk and Crab Game). A FEX preset chosen for the game itself still applies. +An Inno Setup installer added as a game runs with the Stability preset's FEX +settings (full TSO, full x87 precision, no multiblock). Under the default +Performance + TSO preset the 32-bit setup stub corrupts its own paths and stops +with Wine's "Path not fpund." dialog (#1277, #3067). The stub is found by the +setup loader's offset-table ID in its resources, or by the `Inno` marker that +loaders older than 5.1.5 keep at offset 0x30. GOG installs avoid the stub by +extracting natively. A FEX preset chosen for the installer's own entry still +applies. + Games launched through Proton get `vblank_mode=0`, so OpenGL does not wait for each screen refresh. Wine asks for a swap interval of 1 on every OpenGL window, and WineD3D's front-buffer drawing (DirectDraw, Direct3D 1–7) never lowers it, so those games ran at the diff --git a/docs/development/low-memory.md b/docs/development/low-memory.md index 50e78363ef..a0fbb9f274 100644 --- a/docs/development/low-memory.md +++ b/docs/development/low-memory.md @@ -105,7 +105,11 @@ is left, so a process that is not paging out has no thread the preload added. Pr check they are single-threaded before they fork or call `unshare(CLONE_NEWUSER)`, such as Chromium's zygote, keep working. The worker is a bare `clone` with the flags of a normal thread, on a stack the preload maps itself, and makes only raw system calls, so starting it -from the signal handler is safe and seccomp filters that only allow thread clones accept it. A +from the signal handler is safe and seccomp filters that only allow thread clones accept it. +Because those calls bypass the native userland hook (Run without proot), which maps guest paths +only inside libc, the preload adds `DDNATV_ROOT` to `/tmp/.dd-zram` and its hold, trim and ack files +once at startup. Without it, no process of a native session installed the handler and every +request was ignored. A process that has a single thread, or whose signalled thread added a seccomp filter after the process started, as browser sandboxes do, gets no worker. When there is no worker, the process trims inline in steps of at most 32 MiB per request and looks at no more than 512 MiB of its address space each time. The page-out for a suspend and the read-back diff --git a/docs/development/mali-venus.md b/docs/development/mali-venus.md index 5cdc4ab39f..34f97d48b6 100644 --- a/docs/development/mali-venus.md +++ b/docs/development/mali-venus.md @@ -150,6 +150,19 @@ The SPIR-V version the driver gets: - This is what Dawn ("Disable SPIR-V 1.4 on Android ARM"), ANGLE (`supportsSPIRV14`) and naga (`AVOID_SPIRV_COPY_LOGICAL`) do for a proprietary compiler they cannot trust. +Geometry shaders: +- The Mali-G610's driver (r38p1) crashes compiling Zink's geometry shaders, always at the same + place (SIGSEGV at 0x40 in `cmpbe_v2_compile_multiple_shaders`): its shader for `GL_QUADS`, and + a GLSL geometry shader that only passes triangles on. +- A geometry shader that only passes triangles on, from a plain Vulkan program, does not crash it + but draws nothing, in SPIR-V 1.0, 1.3 and 1.6, with and without the layer. +- Zink writes them in SPIR-V 1.6 with the Vulkan memory model, which the version cap leaves alone. + Lowering them would not help, since the plain shader draws nothing at 1.0 and 1.3 either. +- On ARM GPUs the layer reports no `geometryShader` to Zink (engine name `mesa zink`). Mesa then + splits quads into triangles itself, and Zink still offers OpenGL 3.2. DXVK keeps the feature: it + needs it for D3D10 and 11. +- `DROIDDECK_MALI_COMPAT_NO_GS=0` keeps the feature for Zink, `=1` hides it from every application. + Files: - `layer.c`: loader plumbing, feature and limit reporting, device creation, the hook table. - `pipeline.c`: pipelines, shader modules, viewports. diff --git a/docs/development/screen-effects.md b/docs/development/screen-effects.md new file mode 100644 index 0000000000..2551c65a38 --- /dev/null +++ b/docs/development/screen-effects.md @@ -0,0 +1,28 @@ +# Screen-effect pipeline creation + +The screen-effect chain creates its shared render passes, sampler, descriptor +layout/pool and pipeline layout when first used. Graphics pipelines are created +only when the frame's settings require them, then reused until output-format +reset or explicit chain teardown. Source-image and size changes keep the cache. + +Pipeline preparation happens before any effect draw is recorded. If a required +pipeline fails to initialize, the chain follows its existing whole-chain +fallback and returns the unprocessed scene; it does not record a partial stack. +Settings are snapshotted at frame entry, so changes during recording apply to +the next invocation. + +Spatial upscalers are prepared only when their dispatch path is active. FSR +creates EASU and creates RCAS only when sharpening is enabled; sharpen-only +mode creates RCAS. SMAA prepares its three passes only when selected, while +keeping FXAA available for the existing SMAA scratch-allocation fallback. +Half-precision shaders remain selected by the existing debug property. The +optional fast NIS path and its coefficient resources are deferred until NIS is +actually used; the existing fragment-shader fallback is retained. + +This reduces unused pipeline creation and first-use setup work. It does not +reduce the shader work performed each frame, and first use of a newly selected +effect may still compile its pipelines. No background precompilation is added. +Pipeline-count reductions are not measurements of startup latency or FPS. + +Validation still requires the native effect-chain tests and on-device visual +testing. Static source checks alone do not establish Vulkan runtime correctness. diff --git a/docs/settings-map.md b/docs/settings-map.md index bcef3a25c3..122ab30945 100644 --- a/docs/settings-map.md +++ b/docs/settings-map.md @@ -64,6 +64,7 @@ Links of the form `droiddeck://settings/
` open a Settings section direc | Setting | Where | Also matches | | --- | --- | --- | | Storage | Tabs › Storage | sd card, space, uninstall, disk | +| Phone storage in Linux | Tabs › Storage | sdcard, mount, privacy, files | | Syncthing | Tabs › Syncthing | syncthing, saves | | Decky | Tabs › Decky | plugins, plugin store, homebrew, loader | | Boot movies | Tabs › Boot movies | startup movie, boot video, animation, steamdeckrepo | diff --git a/tools/bionic-runtime/build.sh b/tools/bionic-runtime/build.sh index bca9ddbd70..9837fbfd3f 100755 --- a/tools/bionic-runtime/build.sh +++ b/tools/bionic-runtime/build.sh @@ -35,10 +35,11 @@ GAMESCOPE_COMMIT=8f212644c46460549035971ab914421180f61a7c GAMESCOPE_PATCHES="0117-wsi-cache-present-bypass-check.patch 0119-wsi-default-images-under-limiter.patch" VULKAN_HEADERS_TAG=v1.4.341 # The bionic DroidDeck-Proton layer the pack is made for: linked against (libwayland-client) and checked against, not packed. -# Layer v16 (067c719d) plus the ARM64EC code-map fix for 39-bit hosts (d4c9ffa7, run 44291095238). -LAYER_URL=https://github.com/The412Banner/proton-wine/releases/download/build-bionic-layers-20261118-v16-unwind/DroidDeck-Proton-11.0-12.8-arm64ec.wcp -LAYER_SHA256=3cc74b877bc8707d75aa2cc22e335373b6a6c0b6b1937c7b3c2cd98e55de2e89 # proton-wine d48e30a1 (a188791d + fecf7376 on d4c9ffa7) -LAYER_VERSION=12.8 +# Layer v18: DroidDeck-Proton 11-14.1 (Valve Wine a47c73f52fd7, as GE-Proton11-14), the build Bannerlator ships; it +# carries the ARM64EC code-map and unwind fixes the 12.8 layer had (5ebfaa6f, 2515a989, e88fab40). +LAYER_URL=https://github.com/The412Banner/proton-wine/releases/download/build-bionic-layers-20261124-v18/DroidDeck-proton-11.0-14.1-arm64ec.wcp +LAYER_SHA256=bf94176180e96584185835f9e80b168666f9fa752aa9583cfedb8fe493134ff6 # proton-wine 1a5735e7 (run 45926928349) +LAYER_VERSION=14.1 # Packed into the DroidDeck-Bionic tool next to the layer: FEX with Android-built unix libraries, and default # DXVK / VKD3D-Proton (DroidDeck components can swap these in files/lib/wine/{dxvk,vkd3d-proton} later). FEX_URL=https://github.com/The412Banner/Nightlies/releases/download/FEXCore-2611.1/FEXCore-2611.1-unix.wcp diff --git a/tools/bionic-runtime/gst-plugins.txt b/tools/bionic-runtime/gst-plugins.txt index cb8941a5ae..8d814116a0 100644 --- a/tools/bionic-runtime/gst-plugins.txt +++ b/tools/bionic-runtime/gst-plugins.txt @@ -1,6 +1,7 @@ # GStreamer plugins packed for winegstreamer (game video/audio), from the imagefs's lib/gstreamer-1.0 by name # (libgst.so): Proton's usual set as far as this imagefs has it (no vpx; videoconvert+videoscale are videoconvertscale). coreelements +debug app audioconvert audiorate diff --git a/tools/bionic-runtime/tool/launch.sh b/tools/bionic-runtime/tool/launch.sh index 9ea92668a3..8e52a857da 100644 --- a/tools/bionic-runtime/tool/launch.sh +++ b/tools/bionic-runtime/tool/launch.sh @@ -29,6 +29,11 @@ echo "$(date +%H:%M:%S) $verb $EXE ($VERSION, uid $(id -u), DISPLAY ${DISPLAY:-u # Keep Steam's game identity, DroidDeck's input/display/driver/sync settings and its game environment (the names # ../proton lists in DROIDDECK_BIONIC_KEEP); drop the rest of the glibc guest's environment. KEEP=" ${DROIDDECK_BIONIC_KEEP:-} " +# The built-in DirectAudio driver reads DroidDeck's AUDIO_DIRECT_* settings (the microphone switch among them) under +# the BANNER_ names droiddeck-proton gives them for Proton. +for v in $(env | sed -n 's/^\(AUDIO_DIRECT_[A-Za-z0-9_]*\)=.*/\1/p'); do + eval "export BANNER_$v=\"\$$v\"" +done for v in $(env | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p'); do case "$KEEP" in *" $v "*) continue ;; esac case "$v" in @@ -36,7 +41,7 @@ for v in $(env | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p'); do ANDROID_*|BOOTCLASSPATH|DEX2OATBOOTCLASSPATH|SYSTEMSERVERCLASSPATH|EXTERNAL_STORAGE|ASEC_MOUNTPOINT) ;; FAKE_*|SDL_*|DD_WIDTH|DD_HEIGHT|DD_VK_DRIVER|WINEDLLOVERRIDES) ;; DISPLAY|GAMESCOPE_WAYLAND_DISPLAY|FEX_*) ;; - TU_DEBUG|MESA_NO_ERROR|DXVK_CONFIG|DXVK_HUD|DROIDDECK_FORCE_SSBS) ;; + TU_DEBUG|MESA_NO_ERROR|DXVK_CONFIG|DXVK_HUD|DROIDDECK_FORCE_SSBS|BANNER_AUDIO_DIRECT_*) ;; mesa_glthread|vblank_mode|ZINK_*|GALLIUM_HUD|GALLIUM_THREAD) ;; DD_SYNC|DD_FSYNC_FIRST|DD_SYNC_FALLBACK|PROTON_NO_ESYNC|PROTON_NO_FSYNC|PROTON_NO_NTSYNC|WINEESYNC) ;; PROTON_USE_D7VK) ;; @@ -104,6 +109,9 @@ export NTSYNC_SHM=$COMPAT/ntsync-shm # DroidDeck's Force SSBS (its glibc libssbs.so preload) is bionic Wine's own WINE_FORCE_SSBS on "${DROIDDECK_FORCE_SSBS:-}" && export WINE_FORCE_SSBS=1 export HODLL=libwow64fex.dll WINEDEBUG=err+all,fixme-all +# The network adapter list (GetAdaptersAddresses) from the layer's getifaddrs code: its default if_nameindex code never +# answered here, and the Paradox Launcher (Europa Universalis IV) waited on it forever. +export WINE_NEW_NDIS=${WINE_NEW_NDIS:-1} export XENVIRONMENT=$TOOL/bionic/Xdefaults # The adapter's Wayland swapchain gets its buffers back from gamescope later than DroidDeck-Proton's Turnip does; # with gamescope's default three images the game waits for one about a fifth of the time at high frame rates. @@ -301,6 +309,21 @@ if [ "$verb" != runinprefix ] && prefix_busy; then fi prefix_busy || rm -f "$NTSYNC_SHM".v* +# Steam's running client, as a game's steam_api checks it: Proton names its steam.exe (the prefix's first program, +# alive while the game runs), which this tool does not start. Here the first program is the one Steam started, so a +# launcher that starts the game and quits (EU4's dowser.exe) left a game that reported "Steam not detected". The +# PID is the one this tool's own prefixes carry. +steam_pid() { + R=$COMPAT/pfx/user.reg + [ -f "$R" ] || return 0 + awk '/^\[/ { on = index($0, "[Software\\\\Valve\\\\Steam\\\\ActiveProcess]") == 1 } + on && /^"PID"=dword:/ && $0 != "\"PID\"=dword:0000fffe" { found = 1 } END { exit !found }' "$R" || return 0 + awk '/^\[/ { on = index($0, "[Software\\\\Valve\\\\Steam\\\\ActiveProcess]") == 1 } + on && /^"PID"=dword:/ { print "\"PID\"=dword:0000fffe"; next } { print }' "$R" > "$R.dd-new.$$" && mv -f "$R.dd-new.$$" "$R" && + echo "$(date +%H:%M:%S) Steam's process ID in the registry set to this tool's" +} +prefix_busy || steam_pid + # Links into a tool that is gone (an older DroidDeck-Bionic, a deleted DroidDeck-Proton) or to a file it no longer has. # Wine's update cannot write over them, so drivers (network, controller) and other files stay missing. Drop them and # clear both stamps: prepare_prefix relinks this tool's files and Wine's update puts its own back. diff --git a/tools/bionic-runtime/tool/proton b/tools/bionic-runtime/tool/proton index ef957b1bca..a054905b2f 100644 --- a/tools/bionic-runtime/tool/proton +++ b/tools/bionic-runtime/tool/proton @@ -36,6 +36,21 @@ zpath() { esac } +# Drive links of the prefix in compatdata folder $1 that name guest paths (DroidDeck-Proton's s: for the Steam library) +# -> their Android paths, which this Wine follows. A game's mods on S: were missing otherwise. A session's start +# gives them their guest paths back (NativeGuest.relinkPrefixDrives); z: is launch.sh's. +android_drives() { + local d t a + for d in "$1"/pfx/dosdevices/[a-y]:; do + [ -L "$d" ] || continue + t=$(readlink "$d") + case "$t" in /*) ;; *) continue ;; esac + a=$(real "$t") + [ "$a" = "$t" ] && continue + ln -sfn "$a" "$d.dd-new.$$" && mv -fT "$d.dd-new.$$" "$d" && echo "drive ${d##*/} -> $a" + done +} + # Where a game launch's log goes in DroidDeck's session folder (Share logs takes that folder): the game's log folder # when Detailed graphics logs made one (droiddeck-game-env), else a folder of its own; nothing for other verbs session_logs() { @@ -109,6 +124,7 @@ print(" ".join(sorted(n for n in names if re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*" PY ) export DROIDDECK_BIONIC_KEEP + [ -n "${STEAM_COMPAT_DATA_PATH:-}" ] && android_drives "$STEAM_COMPAT_DATA_PATH" >&2 exec /system/bin/sh "$tool/bionic/launch.sh" "$verb" "$compat" "$exe" ${args[@]+"${args[@]}"} ;; getcompatpath) p=$(real "${1:-}") diff --git a/tools/ci/install-ubuntu-packages.sh b/tools/ci/install-ubuntu-packages.sh index d1bd5e698a..4f6c61d882 100644 --- a/tools/ci/install-ubuntu-packages.sh +++ b/tools/ci/install-ubuntu-packages.sh @@ -10,13 +10,13 @@ if [ "${#missing[@]}" = 0 ]; then echo "Ubuntu build dependencies are already installed." exit 0 fi -options=() +source_options=() # Runners without the deb822 Ubuntu sources file keep their own apt configuration. ubuntu_sources=${UBUNTU_SOURCES_FILE:-/etc/apt/sources.list.d/ubuntu.sources} if [ -f "$ubuntu_sources" ]; then - options+=(-o "Dir::Etc::sourcelist=$ubuntu_sources" -o Dir::Etc::sourceparts=-) + source_options=(-o "Dir::Etc::sourcelist=$ubuntu_sources" -o Dir::Etc::sourceparts=-) fi -options+=( +apt_options=( -o Acquire::Retries=1 -o Acquire::http::Timeout=15 -o Acquire::https::Timeout=15 @@ -24,14 +24,23 @@ options+=( ) install_packages() { echo "Updating Ubuntu package indexes." - sudo timeout --kill-after=10s 60s apt-get "${options[@]}" -o APT::Update::Error-Mode=any update -q || return $? + sudo timeout --kill-after=10s 60s apt-get "${source_options[@]}" "${apt_options[@]}" -o APT::Update::Error-Mode=any update -q || return $? echo "Installing: ${missing[*]}" - sudo timeout --kill-after=10s 120s env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get "${options[@]}" install -y -q --no-install-recommends "${missing[@]}" + sudo timeout --kill-after=10s 120s env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get "${source_options[@]}" "${apt_options[@]}" install -y -q --no-install-recommends "${missing[@]}" } if install_packages; then exit 0 fi -[ -f "$ubuntu_sources" ] || exit 1 +if [ -f "$ubuntu_sources" ]; then + template=$(cat "$ubuntu_sources") +else + codename=$(. "${OS_RELEASE_FILE:-/etc/os-release}" && echo "${UBUNTU_CODENAME:-${VERSION_CODENAME:-}}") + [ -n "$codename" ] || exit 1 + template="Types: deb +URIs: - +Suites: $codename $codename-updates $codename-security +Components: main restricted universe multiverse" +fi sources=$(mktemp --suffix=.sources) trap 'rm -f "$sources"' EXIT # The last mirror of each list is outside Canonical's network, so it still answers when runners cannot reach Canonical. @@ -39,12 +48,12 @@ mirrors=(https://archive.ubuntu.com/ubuntu https://mirrors.edge.kernel.org/ubunt case "$(dpkg --print-architecture)" in arm64) mirrors=(https://ports.ubuntu.com/ubuntu-ports https://mirrors.ocf.berkeley.edu/ubuntu-ports) ;; esac +source_options=(-o "Dir::Etc::sourcelist=$sources" -o Dir::Etc::sourceparts=-) status=1 for mirror in "${mirrors[@]}"; do echo "::warning::Ubuntu mirror failed or timed out; retrying with $mirror." - sed -E "s@^URIs:.*@URIs: $mirror@" "$ubuntu_sources" > "$sources" + printf '%s\n' "$template" | sed -E "s@^URIs:.*@URIs: $mirror@" > "$sources" chmod 644 "$sources" - options[1]="Dir::Etc::sourcelist=$sources" status=0 install_packages || status=$? [ "$status" = 0 ] && exit 0 diff --git a/tools/ddfg_compare/of3_flowreg_opt.comp b/tools/ddfg_compare/of3_flowreg_opt.comp new file mode 100644 index 0000000000..37392039e3 --- /dev/null +++ b/tools/ddfg_compare/of3_flowreg_opt.comp @@ -0,0 +1,138 @@ +#version 450 +// ───────────────────────────────────────────────────────────────────────────── +// win-fg C2 — FLOW REGULARIZATION (TV-L1 smoothness prior), one iteration. +// +// CLEAN-ROOM STATEMENT +// Written from first principles for win-fg. NO code from LSFG, Max's wnfg_XX +// blobs, GameScope, or any NC-licensed source — equations only, from published +// papers. win-fg is MIT. +// +// WHAT THIS DOES +// C1 (of3_gm_prewarp) removes the CAMERA motion before the dense SAD search, so +// the flow field this shader receives (flowLvl_[kFlowFinest], 1/4-res) is the +// OBJECT-only residual. That residual still carries incoherent / spurious +// per-block vectors on low-texture or ambiguous blocks. C2 applies a variational +// smoothness prior that suppresses those spurious vectors while PRESERVING true +// motion discontinuities at object edges (that is the whole point of using an L1 +// / Total-Variation prior instead of an L2 / Horn-Schunck one — L2 rounds the +// silhouettes off, which is exactly the smear we are trying to remove). +// +// ENERGY (TV-L1 optical-flow denoising of a fixed observation f0): +// min_u Σ g(x)·|∇u(x)| + λ·|u(x) − f0(x)| +// where u is the regularized flow, f0 is the raw SAD flow (the fixed data term), +// |∇u| is the Total-Variation (L1-of-gradient) regularizer, and g(x)∈(0,1] is an +// edge-aware weight from the luma gradient (small across an object silhouette so +// the prior does NOT smooth flow across it). References: +// * Zach, Pock & Bischof 2007, "A Duality Based Approach for Realtime TV-L1 +// Optical Flow" (DAGM) — the TV-L1 energy + the L1 data soft-threshold step. +// * Chambolle & Pock 2011, "A First-Order Primal-Dual Algorithm ..." (JMIV) — +// primal-dual TV framework. +// * Rudin, Osher & Fatemi 1992 — Total Variation regularization (ROF). +// * Vogel & Oman 1996; Chan, Golub & Mulet 1999 — the lagged-diffusivity / +// semi-implicit solver actually used here (see SCHEME note). +// * Perona & Malik 1990; Weickert 1998; Nagel & Enkelmann 1986 — the +// edge-aware (image-gradient) weighting of the smoothness term. +// * Horn & Schunck 1981 — the L2 baseline this L1 variant deliberately replaces. +// +// SCHEME (why not textbook Chambolle-Pock primal-dual): +// The canonical TV-L1 solver keeps a persistent dual field p (2 components per +// flow channel = 8 floats/px) and alternates a dual-ascent + primal-descent with +// step sizes (σ,τ) that must satisfy στL²≤1 or it DIVERGES. That is exactly the +// kind of tuning-sensitive instability we do not want on Turnip, and it breaks +// the one-shader / ping-pong-two-flow-images contract (it needs extra dual +// images). Instead we solve the SAME energy with a lagged-diffusivity +// semi-implicit (Jacobi) step: the TV term is linearized as a divergence of the +// edge-weighted, TV-normalized gradient (dual re-derived in closed form each +// iteration as p = g·∇u/|∇u|_ε, which is exactly the optimal TV dual and has +// |p|≤1 by construction), then a Jacobi update that is UNCONDITIONALLY STABLE for +// any dt>0 (the primal is a convex combination of the centre and its neighbours, +// so it can never blow up or NaN), followed by the exact L1 data-term +// soft-threshold. State carried between iterations is only u itself → ping-pong +// two rgba16f flow images, N iterations. Identity behaviour: with 0 iterations +// the field is untouched (byte-identical to pre-C2). +// +// COMPOSES WITH: +// * quality-tier2's 5-tap median: that median stays in of3_expand(_m4) and runs +// AFTER C2, as a final speckle scrub on the already-coherent field (harmless — +// L1 is already outlier-robust). C2 does not touch expand. +// * C1 global-motion add-back: C2 cleans the residual IN PLACE at +// flowLvl_[kFlowFinest]; of3_expand then medians + confidence-gates + adds the +// global affine back exactly as before, now on the cleaned residual. The +// end-to-end composed flow stays correct; identity affine ⇒ pre-C1 path. +// ───────────────────────────────────────────────────────────────────────────── +layout(local_size_x = 16, local_size_y = 16) in; + +layout(binding = 0) uniform U { + // x = dt : semi-implicit smoothing step (larger ⇒ more smoothing) + // y = lambda : L1 data-fidelity weight (larger ⇒ trust the SAD flow more) + // z = edgeAlpha : luma-gradient edge sensitivity for g (larger ⇒ sharper stop) + // w = epsTV : Charbonnier epsilon for the TV diffusivity (px; larger ⇒ softer) + vec4 params; +}; + +layout(binding = 32) uniform sampler2D uFlowIn; // current iterate u (.xy fwd, .zw bwd), full-res px +layout(binding = 33) uniform sampler2D uFlowObs; // fixed observation f0 (the raw SAD flow) +layout(binding = 34) uniform sampler2D uLuma; // prev luma at this flow level (R32F, Rec.709 [0,1]) +layout(binding = 48, rgba16f) uniform writeonly image2D uFlowOut; + +vec4 fetchU(ivec2 p, ivec2 dim) { + return texelFetch(uFlowIn, clamp(p, ivec2(0), dim - 1), 0); +} +float fetchL(ivec2 p, ivec2 dim) { + return texelFetch(uLuma, clamp(p, ivec2(0), dim - 1), 0).r; +} + +void main() { + ivec2 gid = ivec2(gl_GlobalInvocationID.xy); + ivec2 dim = textureSize(uFlowIn, 0); + if (gid.x >= dim.x || gid.y >= dim.y) return; + + float dt = params.x; + float lambda = params.y; + float edgeAlpha = params.z; + float epsTV = params.w; + + // 4-connected neighbourhood of the current iterate (all 4 flow channels). + vec4 uC = texelFetch(uFlowIn, gid, 0); + vec4 uL = fetchU(gid + ivec2(-1, 0), dim); + vec4 uR = fetchU(gid + ivec2( 1, 0), dim); + vec4 uU = fetchU(gid + ivec2( 0, -1), dim); + vec4 uD = fetchU(gid + ivec2( 0, 1), dim); + + // ── Edge-aware weight g from the luma gradient (Perona-Malik / Weickert) ──── + // Luma level res == flow level res (both at kFlowFinest), so index 1:1. + float lL = fetchL(gid + ivec2(-1, 0), dim); + float lR = fetchL(gid + ivec2( 1, 0), dim); + float lU = fetchL(gid + ivec2( 0,-1), dim); + float lD = fetchL(gid + ivec2( 0, 1), dim); + float gmag = 0.5 * length(vec2(lR - lL, lD - lU)); // |∇I|, central diff + float g = clamp(exp(-edgeAlpha * gmag), 0.05, 1.0); // small across silhouettes + + // ── TV diffusivity per face: w = g / sqrt(|Δu|² + ε²) ─────────────────────── + // |Δu| is the full 4-vector flow difference (vectorial-TV coupling: fwd & bwd + // share the same motion discontinuities). Large across a flow edge ⇒ small w ⇒ + // the edge is preserved; ~0 in flat regions ⇒ large w ⇒ strong smoothing. + vec4 dL = uL - uC, dR = uR - uC, dU = uU - uC, dD = uD - uC; + float e2 = epsTV * epsTV; + float qL = inversesqrt(dot(dL, dL) + e2); + float qR = inversesqrt(dot(dR, dR) + e2); + float qU = inversesqrt(dot(dU, dU) + e2); + float qD = inversesqrt(dot(dD, dD) + e2); + + float sumW = g * (qL + qR + qU + qD); + vec4 sumWU = g * (qL * uL + qR * uR + qU * uU + qD * uD); + + // Semi-implicit (Jacobi) TV step: a convex combination of uC and the + // edge/TV-weighted neighbour mean ⇒ unconditionally stable, always finite. + vec4 uDiff = (uC + dt * sumWU) / (1.0 + dt * sumW); + + // ── L1 data term (exact TV-L1 soft-threshold toward the fixed observation) ── + // r>θ ⇒ u=uDiff−θ , r<−θ ⇒ u=uDiff+θ , |r|≤θ ⇒ u=f0 , with θ = dt·λ. + // The branchless form u = uDiff − clamp(r,−θ,θ) is identical per component. + vec4 f0 = texelFetch(uFlowObs, gid, 0); + float theta = dt * lambda; + vec4 r = uDiff - f0; + vec4 uNew = uDiff - clamp(r, vec4(-theta), vec4(theta)); + + imageStore(uFlowOut, gid, uNew); +} diff --git a/tools/desktop-kde/overlay/usr/share/applications/droiddeck-return-gaming.desktop b/tools/desktop-kde/overlay/usr/share/applications/droiddeck-return-gaming.desktop deleted file mode 100644 index 67f1d7f218..0000000000 --- a/tools/desktop-kde/overlay/usr/share/applications/droiddeck-return-gaming.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=Return to Gaming Mode -Comment=Log out of the desktop and go back to Steam -Exec=dbus-send --session --type=method_call --dest=org.kde.Shutdown /Shutdown org.kde.Shutdown.logout -Icon=steamdeck-gaming-return -Terminal=false -Type=Application -StartupNotify=false -NoDisplay=true diff --git a/tools/gamescope/PATCHES.md b/tools/gamescope/PATCHES.md index 8ddddcca22..f322c5f38b 100644 --- a/tools/gamescope/PATCHES.md +++ b/tools/gamescope/PATCHES.md @@ -21,9 +21,10 @@ library list, before anything is published. trip to Xwayland on the paint thread; with no image, wlserver's position is used as upstream does. - `0101-nested-wayland-cursor-routing.patch` - this app: `gamescope_cursor_composite=2` lets the nested Wayland session paint its cursor in the output using the real X pointer position; client - cursor surfaces are cleared to prevent a duplicate at the host pointer, while Gamescope's original - default host-cursor fallback is preserved when its no-keyboard-focus policy selects it. Empty - client cursor images and Gamescope's hidden flag still suppress the painted cursor. + cursor surfaces are cleared to prevent a duplicate at the host pointer, and so is Gamescope's + default host-cursor fallback, which would otherwise show a second arrow until Gamescope gets + keyboard focus. Empty client cursor images and Gamescope's hidden flag still suppress the + painted cursor. - `0110-wayland-backend-touch.patch` - this app: the nested Wayland backend bound only the host's pointer and keyboard, so a finger on the phone's screen never reached Steam. It now binds `wl_touch` too and hands each finger to wlserver's touch path (`wlserver_touchdown` / `motion` / @@ -444,3 +445,54 @@ starts there as before, but no motion is sent for it. The fake pointer position With the patch, the Duo starts with only the bottom bar under the parked pointer hovered and controller focus on the first tile (4 of 4 starts), and returns from a game the same way (3 of 3). Making 0100 ignore the X server's initial pointer instead was tried and rejected: the centre motion still arrived, and the header or search bar ended up hovered. + +## 0143 wlserver: only the first finger drives the emulated mouse + +In the Hover, Left, Right, Middle and Trackpad touch click modes every finger warped the X pointer and any finger lifting +released the click. With a second finger down the pointer jumped between both fingers on every frame while the button +stayed held, so a dragged item followed whichever finger moved last, and lifting the second finger dropped it under the +first. The first finger of a gesture now owns the emulated mouse: only it moves the pointer and only its lift releases the +click. Fingers that land while it is down are ignored, and so are the others once it lifts, until every finger is up. +Touches the click modes never claimed (Passthrough, Disabled, no focused surface) still release a held click when they +lift, and the nested pointer (`bAlwaysWarpCursor`) moves the pointer as before. `tools/tests/test_gamescope_touch_click_owner.py` +compiles the rule from this patch. + +## 0144 steamcompmgr: motion into the screen edge does not decide the pointer hold + +0133 compares the motion gamescope sends with how the X pointer moves. At the edge of the X screen the pointer cannot move +further, so a drawn-cursor game whose pointer sat at an edge while touch or mouse motion pushed outward counted as +holding the pointer: the hold stayed on, every such frame restarted the 30 frames needed to release it, and touch drags +kept turning into relative motion with no button held. The sent motion is now clamped to what the pointer can reach +inside the X screen before it is compared, so motion into an edge counts as no motion. A recentring game is detected as +before, since its pointer stays away from the edges. `tools/tests/test_gamescope_pointer_hold_edge.py` compiles the rule +from this patch with the 0133 rule. + +## 0145 steamcompmgr: touch-down warps do not decide the pointer hold + +In click mode every touch-down warps the X pointer to the finger. 0133 read that jump as the pointer not following the +sent motion, so each new stroke on a drawn-cursor game restarted the 30 following frames needed to release the hold. +Short strokes never released it, and taps kept landing at the relative pointer instead of under the finger. wlserver now +counts its touch-down warps, and a frame that contains one is left out of the hold decision. Touch drags, mouse motion +and mouse warps still count, so a drag on a game that follows the pointer releases the hold and a recentring game is +still held. `tools/tests/test_gamescope_pointer_hold_touch_down.py` compiles the rule with the 0133 rule. + +## 0146 rendervulkan: composite only into output images the display has finished scanning out + +The host compositor now releases a zero-copy display buffer as soon as the display latches the next one, and attaches +the display's release fence to the buffer's dma-buf instead of waiting for it on the CPU. That wait had held every +release back by about one refresh, so a chain of three buffers ran at two thirds of the refresh rate. KGSL Turnip does +not wait on fences attached to a dma-buf, so the composite now checks each output image's dma-buf with `poll(POLLOUT)`. +It picks the next image that is neither held by the host nor still being scanned out. Only when every free image is +still on the display does it wait for one, up to 100 ms. On kernels that cannot attach the fence, the host keeps +waiting itself and nothing changes. `tools/gamescope/tests/nested-swapchain.cpp` covers the choice and the busy check. + +## 0147 Wayland backend: a forwarded client buffer goes back to its client only after scanout + +When no composite is needed, gamescope hands a client's own buffer to the host compositor as a plane. The host now +releases a buffer as soon as the display latches the next one and leaves its release fence on the buffer's dma-buf. +gamescope returned the buffer to the client on that release, and a client whose Vulkan driver does not wait on +fences attached to a dma-buf then drew into it while the display was still scanning it out, which showed as black +tiles in compressed buffers. A forwarded client buffer now stays held until `poll(POLLOUT)` on its dma-buf reports +that the display has finished with it, on a waiter thread so nothing else blocks. A release that arrives after the +buffer was shown again is dropped, so the later release decides. Composite output images keep the 0146 path, and a +host that waits for the fence itself releases buffers that are already idle, so nothing changes there. diff --git a/tools/gamescope/patches/0101-nested-wayland-cursor-routing.patch b/tools/gamescope/patches/0101-nested-wayland-cursor-routing.patch index f59201e672..0a4805a839 100644 --- a/tools/gamescope/patches/0101-nested-wayland-cursor-routing.patch +++ b/tools/gamescope/patches/0101-nested-wayland-cursor-routing.patch @@ -74,7 +74,7 @@ index 0000000..d7c21da + + constexpr bool CursorShouldBeForwardedToHost( int cursorCompositeMode, bool useHostCursorFallback ) + { -+ return cursorCompositeMode != 2 || useHostCursorFallback; ++ return cursorCompositeMode != 2; + } + + constexpr bool CursorImageShouldBePainted( bool imageEmpty, bool cursorHidden ) @@ -176,10 +176,10 @@ index 0000000..9c622db + REQUIRE( CursorShouldBeComposited( 2, false, false, true, false ) ); +} + -+TEST_CASE("manual composition retains only the no-focus default cursor fallback", "[cursor_routing]") ++TEST_CASE("manual composition never forwards a cursor to the host", "[cursor_routing]") +{ + REQUIRE_FALSE( CursorShouldBeForwardedToHost( 2, false ) ); -+ REQUIRE( CursorShouldBeForwardedToHost( 2, true ) ); ++ REQUIRE_FALSE( CursorShouldBeForwardedToHost( 2, true ) ); + REQUIRE( CursorShouldBeForwardedToHost( 1, false ) ); + REQUIRE( CursorShouldBeForwardedToHost( 0, false ) ); +} diff --git a/tools/gamescope/patches/0143-touch-click-first-finger-drives.patch b/tools/gamescope/patches/0143-touch-click-first-finger-drives.patch new file mode 100644 index 0000000000..2eb9e66487 --- /dev/null +++ b/tools/gamescope/patches/0143-touch-click-first-finger-drives.patch @@ -0,0 +1,75 @@ +diff --git a/src/wlserver.cpp b/src/wlserver.cpp +index 9740875..cb72051 100644 +--- a/src/wlserver.cpp ++++ b/src/wlserver.cpp +@@ -3283,6 +3283,38 @@ static void apply_touchscreen_orientation(GamescopePanelOrientation orientation, + *y = ty; + } + ++struct TouchClickState ++{ ++ std::set ids; ++ int nOwner = -1; ++}; ++ ++static TouchClickState s_TouchClick; ++ ++static bool touch_click_claim( TouchClickState &state, int nTouchId ) ++{ ++ if ( state.ids.empty() ) ++ state.nOwner = nTouchId; ++ state.ids.insert( nTouchId ); ++ return state.nOwner == nTouchId; ++} ++ ++static bool touch_click_drives( const TouchClickState &state, int nTouchId ) ++{ ++ return state.nOwner == nTouchId; ++} ++ ++static bool touch_click_lift( TouchClickState &state, int nTouchId ) ++{ ++ const bool bTracked = state.ids.erase( nTouchId ) > 0; ++ if ( state.nOwner == nTouchId ) ++ { ++ state.nOwner = -1; ++ return true; ++ } ++ return !bTracked && state.nOwner < 0; ++} ++ + void wlserver_touchmotion( double x, double y, int touch_id, uint32_t time, bool bAlwaysWarpCursor, gamescope::IBackendConnector* connector ) + { + assert( wlserver_is_lock_held() ); +@@ -3333,9 +3365,10 @@ void wlserver_touchmotion( double x, double y, int touch_id, uint32_t time, bool + } + else if ( eMode == gamescope::TouchClickModes::Trackpad ) + { +- wlserver_mousemotion( trackpad_dx, trackpad_dy, time ); ++ if ( touch_click_drives( s_TouchClick, touch_id ) ) ++ wlserver_mousemotion( trackpad_dx, trackpad_dy, time ); + } +- else ++ else if ( bAlwaysWarpCursor || touch_click_drives( s_TouchClick, touch_id ) ) + { + g_bPendingTouchMovement = true; + +@@ -3389,7 +3422,7 @@ void wlserver_touchdown( double x, double y, int touch_id, uint32_t time, gamesc + { + return; + } +- else ++ else if ( touch_click_claim( s_TouchClick, touch_id ) ) + { + g_bPendingTouchMovement = true; + +@@ -3417,7 +3450,8 @@ void wlserver_touchup( int touch_id, uint32_t time ) + + // Release whatever the touch pressed even if its surface is gone, or the seat keeps the button down. + bool bReleasedAny = false; +- for ( int i = 0; i < WLSERVER_BUTTON_COUNT; i++ ) ++ const bool bClickTouch = touch_click_lift( s_TouchClick, touch_id ); ++ for ( int i = 0; bClickTouch && i < WLSERVER_BUTTON_COUNT; i++ ) + { + if ( wlserver.button_held[ i ] == true ) + { diff --git a/tools/gamescope/patches/0144-pointer-hold-ignores-motion-into-the-edge.patch b/tools/gamescope/patches/0144-pointer-hold-ignores-motion-into-the-edge.patch new file mode 100644 index 0000000000..a7db8bacd0 --- /dev/null +++ b/tools/gamescope/patches/0144-pointer-hold-ignores-motion-into-the-edge.patch @@ -0,0 +1,28 @@ +diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp +index e98d320..85af598 100644 +--- a/src/steamcompmgr.cpp ++++ b/src/steamcompmgr.cpp +@@ -3245,6 +3245,11 @@ static bool pointer_hold_step( PointerHold &state, bool bConstrained, double flS + return state.bHeld; + } + ++static double pointer_reach( int nFrom, double flDelta, int nSize ) ++{ ++ return std::clamp( nFrom + flDelta, 0.0, double( std::max( nSize - 1, 0 ) ) ) - nFrom; ++} ++ + static bool s_bPointerHeld = false; + + static void update_pointer_hold( global_focus_t *pFocus, bool bConstrained, bool bHinted ) +@@ -3311,7 +3316,10 @@ static void update_pointer_hold( global_focus_t *pFocus, bool bConstrained, bool + + if ( s_bTracking ) + { +- s_bPointerHeld = pointer_hold_step( s_Hold, true, flDX, flDY, nRootX - s_nRootX, nRootY - s_nRootY, get_time_in_nanos() ); ++ const xwayland_ctx_t *pCtx = pFocus->cursor->getCtx(); ++ const double flReachX = pointer_reach( s_nRootX, flDX, pCtx->root_width ); ++ const double flReachY = pointer_reach( s_nRootY, flDY, pCtx->root_height ); ++ s_bPointerHeld = pointer_hold_step( s_Hold, true, flReachX, flReachY, nRootX - s_nRootX, nRootY - s_nRootY, get_time_in_nanos() ); + } + else + { diff --git a/tools/gamescope/patches/0145-pointer-hold-skips-touch-down-warps.patch b/tools/gamescope/patches/0145-pointer-hold-skips-touch-down-warps.patch new file mode 100644 index 0000000000..3a71f219dd --- /dev/null +++ b/tools/gamescope/patches/0145-pointer-hold-skips-touch-down-warps.patch @@ -0,0 +1,73 @@ +diff --git a/src/wlserver.hpp b/src/wlserver.hpp +--- a/src/wlserver.hpp ++++ b/src/wlserver.hpp +@@ -173,6 +173,7 @@ + double flFollowDY = 0.0; + double flSentDX = 0.0; + double flSentDY = 0.0; ++ uint64_t ulTouchDownWarps = 0; + + bool button_held[ WLSERVER_BUTTON_COUNT ]; + std::set touch_down_ids; +diff --git a/src/wlserver.cpp b/src/wlserver.cpp +--- a/src/wlserver.cpp ++++ b/src/wlserver.cpp +@@ -3429,6 +3429,7 @@ + if ( eMode != gamescope::TouchClickModes::Trackpad ) + { + wlserver_mousewarp( tx, ty, time, false, true ); ++ wlserver.ulTouchDownWarps++; + } + + uint32_t button = TouchClickModeToLinuxButton( eMode ); +diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp +--- a/src/steamcompmgr.cpp ++++ b/src/steamcompmgr.cpp +@@ -3263,6 +3263,7 @@ + static bool s_bHinted = false; + static const steamcompmgr_win_t *s_pWindow = nullptr; + static const struct wlr_pointer_constraint_v1 *s_pConstraint = nullptr; ++ static uint64_t s_ulTouchDownWarps = 0; + + wlserver_lock(); + const double flX = wlserver.mouse_surface_cursorx; +@@ -3272,8 +3273,12 @@ + const struct wlr_pointer_constraint_v1 *pConstraint = wlserver.GetCursorConstraint(); + wlserver.flSentDX = 0.0; + wlserver.flSentDY = 0.0; ++ const uint64_t ulTouchDownWarps = wlserver.ulTouchDownWarps; + wlserver_unlock(); + ++ const bool bTouchDown = ulTouchDownWarps != s_ulTouchDownWarps; ++ s_ulTouchDownWarps = ulTouchDownWarps; ++ + if ( !bConstrained || !pFocus->cursor ) + { + s_bTracking = false; +@@ -3314,19 +3319,19 @@ + int nRootY = 0; + pFocus->cursor->QueryRootPosition( &nRootX, &nRootY ); + +- if ( s_bTracking ) ++ if ( !s_bTracking ) ++ { ++ s_Hold = PointerHold{}; ++ s_Hold.bHeld = bHinted; ++ s_bPointerHeld = bHinted; ++ } ++ else if ( !bTouchDown ) + { + const xwayland_ctx_t *pCtx = pFocus->cursor->getCtx(); + const double flReachX = pointer_reach( s_nRootX, flDX, pCtx->root_width ); + const double flReachY = pointer_reach( s_nRootY, flDY, pCtx->root_height ); + s_bPointerHeld = pointer_hold_step( s_Hold, true, flReachX, flReachY, nRootX - s_nRootX, nRootY - s_nRootY, get_time_in_nanos() ); + } +- else +- { +- s_Hold = PointerHold{}; +- s_Hold.bHeld = bHinted; +- s_bPointerHeld = bHinted; +- } + + s_bTracking = true; + s_flSeatX = flX; diff --git a/tools/gamescope/patches/0146-composite-waits-for-scanout.patch b/tools/gamescope/patches/0146-composite-waits-for-scanout.patch new file mode 100644 index 0000000000..db90cc5ca7 --- /dev/null +++ b/tools/gamescope/patches/0146-composite-waits-for-scanout.patch @@ -0,0 +1,106 @@ +diff --git a/src/output_image_pick.hpp b/src/output_image_pick.hpp +new file mode 100644 +index 0000000..193d9de +--- /dev/null ++++ b/src/output_image_pick.hpp +@@ -0,0 +1,50 @@ ++#pragma once ++#include ++#include ++ ++namespace gamescope ++{ ++struct OutputImagePick ++{ ++ uint32_t image; ++ bool scanoutPending; ++}; ++ ++template ++inline OutputImagePick PickOutputImage( uint32_t count, uint32_t first, uint32_t last, uint32_t deferred, ++ Held &&held, Busy &&busy ) ++{ ++ for ( int pass = 0; pass < 2; pass++ ) ++ { ++ for ( uint32_t i = 0; i < count; i++ ) ++ { ++ const uint32_t image = ( first + i ) % count; ++ if ( count > 3 && ( image == last || image == deferred ) ) ++ continue; ++ if ( held( image ) ) ++ continue; ++ const bool pending = busy( image ); ++ if ( pass == 0 && pending ) ++ continue; ++ return { image, pending }; ++ } ++ } ++ return { first, busy( first ) }; ++} ++ ++inline bool DmabufScanoutPending( int fd ) ++{ ++ if ( fd < 0 ) ++ return false; ++ pollfd p = { .fd = fd, .events = POLLOUT, .revents = 0 }; ++ return poll( &p, 1, 0 ) == 0; ++} ++ ++inline void WaitDmabufScanout( int fd, int timeoutMs ) ++{ ++ if ( fd < 0 ) ++ return; ++ pollfd p = { .fd = fd, .events = POLLOUT, .revents = 0 }; ++ poll( &p, 1, timeoutMs ); ++} ++} +diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp +index 1d3a80c..3668a10 100644 +--- a/src/rendervulkan.cpp ++++ b/src/rendervulkan.cpp +@@ -37,6 +37,7 @@ + #include "steamcompmgr.hpp" + #include "log.hpp" + #include "Utils/Process.h" ++#include "output_image_pick.hpp" + + #include "cs_composite_blit.h" + #include "cs_composite_blur.h" +@@ -4297,18 +4298,29 @@ static bool vulkan_output_image_held( uint32_t nImage ) + return false; + } + ++static bool vulkan_output_image_scanout_pending( uint32_t nImage ) ++{ ++ for ( const auto &pImage : { g_output.outputImages[ nImage ], g_output.outputImagesPartialOverlay[ nImage ] } ) ++ { ++ if ( pImage != nullptr && pImage->GetBackendFb() != nullptr && gamescope::DmabufScanoutPending( pImage->dmabuf().fd[0] ) ) ++ return true; ++ } ++ return false; ++} ++ + static uint32_t vulkan_free_output_image( uint32_t nFirst ) + { +- const uint32_t uCount = g_output.outputImages.size(); +- for ( uint32_t i = 0; i < uCount; i++ ) ++ const gamescope::OutputImagePick pick = gamescope::PickOutputImage( g_output.outputImages.size(), nFirst, ++ g_output.nLastOutImage, g_output.nDeferredOutImage, vulkan_output_image_held, vulkan_output_image_scanout_pending ); ++ if ( pick.scanoutPending ) + { +- const uint32_t nImage = ( nFirst + i ) % uCount; +- if ( uCount > 3 && ( nImage == g_output.nLastOutImage || nImage == g_output.nDeferredOutImage ) ) +- continue; +- if ( !vulkan_output_image_held( nImage ) ) +- return nImage; ++ for ( const auto &pImage : { g_output.outputImages[ pick.image ], g_output.outputImagesPartialOverlay[ pick.image ] } ) ++ { ++ if ( pImage != nullptr && pImage->GetBackendFb() != nullptr ) ++ gamescope::WaitDmabufScanout( pImage->dmabuf().fd[0], 100 ); ++ } + } +- return nFirst; ++ return pick.image; + } + + std::optional vulkan_composite( struct FrameInfo_t *frameInfo, gamescope::Rc pPipewireTexture, bool partial, gamescope::Rc pOutputOverride, bool increment, std::unique_ptr pInCommandBuffer ) diff --git a/tools/gamescope/patches/0147-forwarded-buffers-wait-for-scanout.patch b/tools/gamescope/patches/0147-forwarded-buffers-wait-for-scanout.patch new file mode 100644 index 0000000000..928f1ba9b0 --- /dev/null +++ b/tools/gamescope/patches/0147-forwarded-buffers-wait-for-scanout.patch @@ -0,0 +1,351 @@ +diff --git a/src/Backends/WaylandBackend.cpp b/src/Backends/WaylandBackend.cpp +index 12f0f50..a0fedd4 100644 +--- a/src/Backends/WaylandBackend.cpp ++++ b/src/Backends/WaylandBackend.cpp +@@ -3,24 +3,28 @@ + #include "wlserver.hpp" + #include "vblankmanager.hpp" + #include "steamcompmgr.hpp" + #include "edid.h" + #include "Utils/Defer.h" + #include "Utils/Algorithm.h" + #include "convar.h" + #include "refresh_rate.h" + #include "waitable.h" + #include "Utils/TempFiles.h" + #include "Utils/CursorRouting.h" + #include "Utils/WaylandScaling.h" ++#include "output_image_pick.hpp" ++ ++#include ++#include + + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #include "wlr_begin.hpp" +@@ -485,44 +489,82 @@ namespace gamescope + + // One backing plane plus every layer steamcompmgr can hand us. + CWaylandPlane m_Planes[k_nMaxLayers + 1]; + bool m_bVisible = true; + std::atomic m_bDesiredFullscreenState = { false }; + + bool m_bHostCompositorIsCurrentlyVRR = false; + }; + + class CWaylandFb final : public CBaseBackendFb + { + public: +- CWaylandFb( CWaylandBackend *pBackend, wl_buffer *pHostBuffer ); ++ CWaylandFb( CWaylandBackend *pBackend, wl_buffer *pHostBuffer, int nDmabufFd = -1 ); + ~CWaylandFb(); + + void OnCompositorAcquire(); + void OnCompositorRelease(); ++ void OnScanoutDone( uint64_t ulAcquireSerial ); + + wl_buffer *GetHostBuffer() const { return m_pHostBuffer; } + wlr_buffer *GetClientBuffer() const { return m_pClientBuffer; } + + bool HeldByHost() const override { return m_bCompositorAcquired; } + + void Wayland_Buffer_Release( wl_buffer *pBuffer ); + static const wl_buffer_listener s_BufferListener; + + private: + CWaylandBackend *m_pBackend = nullptr; + wl_buffer *m_pHostBuffer = nullptr; + wlr_buffer *m_pClientBuffer = nullptr; ++ int m_nDmabufFd = -1; ++ std::mutex m_AcquireMutex; ++ uint64_t m_ulAcquireSerial = 0; + bool m_bCompositorAcquired = false; + }; ++ ++ class CWaylandScanoutRelease final : public IWaitable ++ { ++ public: ++ CWaylandScanoutRelease( CWaylandFb *pFb, int nFd, uint64_t ulAcquireSerial ) ++ : m_pFb{ pFb } ++ , m_nFd{ nFd } ++ , m_ulAcquireSerial{ ulAcquireSerial } ++ { ++ } ++ ++ int GetFD() override { return m_nFd; } ++ void OnPollOut() override { Finish(); } ++ void OnPollHangUp() override { Finish(); } ++ ++ static CAsyncWaiter<> &Waiter() ++ { ++ static CAsyncWaiter<> s_Waiter{ "gamescope-scanout" }; ++ return s_Waiter; ++ } ++ ++ private: ++ void Finish() ++ { ++ Waiter().RemoveWaitable( this ); ++ m_pFb->OnScanoutDone( m_ulAcquireSerial ); ++ close( m_nFd ); ++ delete this; ++ } ++ ++ CWaylandFb *m_pFb; ++ int m_nFd; ++ uint64_t m_ulAcquireSerial; ++ }; + const wl_buffer_listener CWaylandFb::s_BufferListener = + { + .release = WAYLAND_USERDATA_TO_THIS( CWaylandFb, Wayland_Buffer_Release ), + }; + + class CWaylandInputThread + { + public: + CWaylandInputThread(); + ~CWaylandInputThread(); + + bool Init( CWaylandBackend *pBackend ); +@@ -969,73 +1011,108 @@ namespace gamescope + .action = WAYLAND_NULL(), + }; + const zwp_primary_selection_source_v1_listener CWaylandBackend::s_PrimarySelectionSourceListener = + { + .send = WAYLAND_USERDATA_TO_THIS( CWaylandBackend, Wayland_PrimarySelectionSource_Send ), + .cancelled = WAYLAND_USERDATA_TO_THIS( CWaylandBackend, Wayland_PrimarySelectionSource_Cancelled ), + }; + + ////////////////// + // CWaylandFb + ////////////////// + +- CWaylandFb::CWaylandFb( CWaylandBackend *pBackend, wl_buffer *pHostBuffer ) ++ CWaylandFb::CWaylandFb( CWaylandBackend *pBackend, wl_buffer *pHostBuffer, int nDmabufFd ) + : CBaseBackendFb() + , m_pBackend { pBackend } + , m_pHostBuffer { pHostBuffer } ++ , m_nDmabufFd { nDmabufFd } + { + wl_buffer_add_listener( pHostBuffer, &s_BufferListener, this ); + } + + CWaylandFb::~CWaylandFb() + { + // I own the pHostBuffer. + wl_buffer_destroy( m_pHostBuffer ); + m_pHostBuffer = nullptr; ++ if ( m_nDmabufFd >= 0 ) ++ close( m_nDmabufFd ); + } + + void CWaylandFb::OnCompositorAcquire() + { +- // If the compositor has acquired us, track that +- // and increment the ref count. +- if ( !m_bCompositorAcquired ) ++ bool bTakeRef = false; + { ++ std::scoped_lock lock( m_AcquireMutex ); ++ m_ulAcquireSerial++; ++ bTakeRef = !m_bCompositorAcquired; + m_bCompositorAcquired = true; +- IncRef(); + } ++ ++ if ( bTakeRef ) ++ IncRef(); + } + + void CWaylandFb::OnCompositorRelease() + { +- // Compositor has released us, decrement rc. +- //assert( m_bCompositorAcquired ); ++ uint64_t ulSerial; ++ { ++ std::scoped_lock lock( m_AcquireMutex ); ++ ulSerial = m_ulAcquireSerial; ++ } ++ OnScanoutDone( ulSerial ); ++ } + +- if ( m_bCompositorAcquired ) ++ void CWaylandFb::OnScanoutDone( uint64_t ulAcquireSerial ) ++ { ++ bool bDropRef = false; + { ++ std::scoped_lock lock( m_AcquireMutex ); ++ if ( ulAcquireSerial != m_ulAcquireSerial ) ++ return; ++ bDropRef = m_bCompositorAcquired; + m_bCompositorAcquired = false; +- DecRef(); + } ++ ++ if ( bDropRef ) ++ DecRef(); + else +- { + xdg_log.errorf( "Compositor released us but we were not acquired. Oh no." ); +- } + } + + void CWaylandFb::Wayland_Buffer_Release( wl_buffer *pBuffer ) + { + assert( m_pHostBuffer ); + assert( m_pHostBuffer == pBuffer ); + + xdg_log.debugf( "buffer_release: %p", pBuffer ); + ++ if ( ShowsClientBuffer() && gamescope::DmabufScanoutPending( m_nDmabufFd ) ) ++ { ++ int nFd = fcntl( m_nDmabufFd, F_DUPFD_CLOEXEC, 0 ); ++ if ( nFd >= 0 ) ++ { ++ uint64_t ulSerial; ++ { ++ std::scoped_lock lock( m_AcquireMutex ); ++ ulSerial = m_ulAcquireSerial; ++ } ++ auto *pWait = new CWaylandScanoutRelease( this, nFd, ulSerial ); ++ if ( CWaylandScanoutRelease::Waiter().AddWaitable( pWait, EPOLLOUT | EPOLLHUP | EPOLLONESHOT ) ) ++ return; ++ delete pWait; ++ close( nFd ); ++ } ++ } ++ + OnCompositorRelease(); + } + + ////////////////// + // CWaylandConnector + ////////////////// + + CWaylandConnector::CWaylandConnector( CWaylandBackend *pBackend, uint64_t ulVirtualConnectorKey ) + : CBaseBackendConnector{ ulVirtualConnectorKey } + , m_pBackend( pBackend ) + , m_Planes{ this, this, this, this, this, this, this, this, this } + { +@@ -2349,25 +2426,26 @@ namespace gamescope + pDmaBuf->format, + 0u ); + + if ( !pImportedBuffer ) + { + xdg_log.errorf( "Failed to import dmabuf" ); + zwp_linux_buffer_params_v1_destroy( pBufferParams ); + return nullptr; + } + + zwp_linux_buffer_params_v1_destroy( pBufferParams ); + +- return new CWaylandFb{ this, pImportedBuffer }; ++ int nDmabufFd = pDmaBuf->n_planes > 0 ? fcntl( pDmaBuf->fd[0], F_DUPFD_CLOEXEC, 0 ) : -1; ++ return new CWaylandFb{ this, pImportedBuffer, nDmabufFd }; + } + + bool CWaylandBackend::UsesModifiers() const + { + if ( !cv_wayland_use_modifiers ) + return false; + + return m_bCanUseModifiers; + } + std::span CWaylandBackend::GetSupportedModifiers( uint32_t uDrmFormat ) const + { + auto iter = m_FormatModifiers.find( uDrmFormat ); +diff --git a/src/backend.cpp b/src/backend.cpp +index cc91853..ec59c8b 100644 +--- a/src/backend.cpp ++++ b/src/backend.cpp +@@ -109,41 +109,47 @@ namespace gamescope + wlserver_unlock(); + } + + // Potentially release now! + DecRefPrivate(); + } + + return uRefCount; + } + + void CBaseBackendFb::SetBuffer( wlr_buffer *pClientBuffer ) + { ++ if ( pClientBuffer ) ++ m_bShowsClientBuffer = true; ++ + if ( m_pClientBuffer == pClientBuffer ) + return; + + assert( m_pClientBuffer == nullptr ); + m_pClientBuffer = pClientBuffer; + if ( GetRefCount() ) + { + wlserver_lock(); + wlr_buffer_lock( m_pClientBuffer ); + wlserver_unlock( false ); + } + + m_pReleasePoint = nullptr; + } + + void CBaseBackendFb::SetReleasePoint( std::shared_ptr pReleasePoint ) + { ++ if ( pReleasePoint ) ++ m_bShowsClientBuffer = true; ++ + if ( m_pReleasePoint == pReleasePoint ) + return; + + m_pReleasePoint = pReleasePoint; + + if ( m_pClientBuffer && GetRefCount() ) + { + wlserver_lock(); + wlr_buffer_unlock( m_pClientBuffer ); + wlserver_unlock(); + m_pClientBuffer = nullptr; + } +diff --git a/src/backend.h b/src/backend.h +index 30b42ca..9a27711 100644 +--- a/src/backend.h ++++ b/src/backend.h +@@ -303,26 +303,29 @@ namespace gamescope + public: + CBaseBackendFb(); + virtual ~CBaseBackendFb(); + + uint32_t IncRef() override; + uint32_t DecRef() override; + + void SetBuffer( wlr_buffer *pClientBuffer ) override; + void SetReleasePoint( std::shared_ptr pReleasePoint ) override; + + virtual IBackendFb *EnsureImported() override { return this; }; + ++ bool ShowsClientBuffer() const { return m_bShowsClientBuffer; } ++ + private: + wlr_buffer *m_pClientBuffer = nullptr; ++ std::atomic m_bShowsClientBuffer = { false }; + std::shared_ptr m_pReleasePoint; + }; + + class IBackend + { + public: + virtual ~IBackend() {} + + virtual bool Init() = 0; + virtual bool PostInit() = 0; + virtual std::span GetInstanceExtensions() const = 0; + virtual std::span GetDeviceExtensions( VkPhysicalDevice pVkPhysicalDevice ) const = 0; diff --git a/tools/gamescope/release.env b/tools/gamescope/release.env index 52d5d20e44..f32967c4f2 100644 --- a/tools/gamescope/release.env +++ b/tools/gamescope/release.env @@ -1,3 +1,3 @@ GAMESCOPE_REPO=Droid-Deck/DroidDeck-Components -GAMESCOPE_TAG=gamescope-3.16.29-1a29c65d -GAMESCOPE_SHA256=18620dfedb65860da00003e965cc09784a650ef6ecc9a17056405fe0a1392a02 +GAMESCOPE_TAG=gamescope-3.16.29-cb9c4861 +GAMESCOPE_SHA256=89a3d70124a13bb5de0b4c67ff75d748a5d7ba6f29590194621754e3550b1f31 diff --git a/tools/gamescope/tests/nested-swapchain.cpp b/tools/gamescope/tests/nested-swapchain.cpp index a2054aa746..62f4b6a140 100644 --- a/tools/gamescope/tests/nested-swapchain.cpp +++ b/tools/gamescope/tests/nested-swapchain.cpp @@ -2,6 +2,9 @@ #include "nested_surface_format.hpp" #include "dmabuf_import.hpp" #include "sdl_refresh.hpp" +#include "output_image_pick.hpp" +#include +#include #include #include @@ -152,5 +155,43 @@ int main() assert(DmabufMemoryType(memory, 7, 0, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) == UINT32_MAX); assert(DmabufMemoryType(memory, 7, 4, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) == UINT32_MAX); + + using gamescope::PickOutputImage; + auto none = [](uint32_t) { return false; }; + auto pick = PickOutputImage(5, 2, 1, 0, none, none); + assert(pick.image == 2 && !pick.scanoutPending); + auto heldTwo = [](uint32_t i) { return i == 2; }; + pick = PickOutputImage(5, 2, 1, 0, heldTwo, none); + assert(pick.image == 3 && !pick.scanoutPending); + auto scanningTwo = [](uint32_t i) { return i == 2; }; + pick = PickOutputImage(5, 2, 1, 0, none, scanningTwo); + assert(pick.image == 3 && !pick.scanoutPending); + auto scanningAll = [](uint32_t) { return true; }; + pick = PickOutputImage(5, 2, 1, 0, heldTwo, scanningAll); + assert(pick.image == 3 && pick.scanoutPending); + auto heldAll = [](uint32_t) { return true; }; + auto scanningOne = [](uint32_t i) { return i == 1; }; + pick = PickOutputImage(5, 2, 1, 0, heldAll, none); + assert(pick.image == 2 && !pick.scanoutPending); + pick = PickOutputImage(5, 1, 0, 1, heldAll, scanningOne); + assert(pick.image == 1 && pick.scanoutPending); + pick = PickOutputImage(3, 1, 0, 2, none, none); + assert(pick.image == 1 && !pick.scanoutPending); + pick = PickOutputImage(3, 1, 0, 2, none, scanningOne); + assert(pick.image == 2 && !pick.scanoutPending); + + int fds[2]; + assert(pipe(fds) == 0); + assert(!gamescope::DmabufScanoutPending(fds[1])); + assert(!gamescope::DmabufScanoutPending(-1)); + fcntl(fds[1], F_SETFL, O_NONBLOCK); + char block[4096] = {}; + while (write(fds[1], block, sizeof(block)) > 0) {} + assert(gamescope::DmabufScanoutPending(fds[1])); + gamescope::WaitDmabufScanout(fds[1], 1); + while (read(fds[0], block, sizeof(block)) == sizeof(block) && gamescope::DmabufScanoutPending(fds[1])) {} + assert(!gamescope::DmabufScanoutPending(fds[1])); + close(fds[0]); + close(fds[1]); std::puts("Gamescope presentation and DMA-BUF import tests passed"); } diff --git a/tools/linuxfs/desktop/droiddeck-desktop b/tools/linuxfs/desktop/droiddeck-desktop index fa860dac91..01840825af 100644 --- a/tools/linuxfs/desktop/droiddeck-desktop +++ b/tools/linuxfs/desktop/droiddeck-desktop @@ -10,6 +10,7 @@ export SHELL=/bin/bash export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1 export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1 export MOZ_SHM_NO_SEALS=1 +export QTWEBENGINE_DISABLE_SANDBOX=1 export KWIN_COMPOSE=Q QT_QUICK_BACKEND=software LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe export KWIN_USE_OVERLAYS=0 [ -e /etc/mpv/mpv.conf ] || { mkdir -p /etc/mpv && echo gpu-sw=yes >/etc/mpv/mpv.conf; } 2>/dev/null @@ -228,12 +229,16 @@ fi if ! /usr/local/bin/droiddeck-pipewire start; then echo "== pipewire: not running; screen capture has no picture" fi +return_gaming=/run/droiddeck/return-gaming +mkdir -p /run/droiddeck +rm -f "$return_gaming" echo "== droiddeck-desktop: Plasma on $WAYLAND_DISPLAY" dbus-run-session -- startplasma-wayland rc=$? /usr/local/bin/droiddeck-pipewire stop echo "== droiddeck-desktop: Plasma ended ($rc)" -if [ "$rc" -eq 0 ] && [ -z "${DD_BOTTOM_DESKTOP:-}" ]; then +if [ "$rc" -eq 0 ] && [ -z "${DD_BOTTOM_DESKTOP:-}" ] && [ -e "$return_gaming" ]; then + rm -f "$return_gaming" /usr/local/bin/droiddeck-steam-launch bigpicture sleep 30 fi diff --git a/tools/linuxfs/desktop/droiddeck-return-gaming.desktop b/tools/linuxfs/desktop/droiddeck-return-gaming.desktop new file mode 100644 index 0000000000..a4dd347002 --- /dev/null +++ b/tools/linuxfs/desktop/droiddeck-return-gaming.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Return to Gaming Mode +Comment=Log out of the desktop and go back to Steam +Exec=sh -c ": > /run/droiddeck/return-gaming; dbus-send --session --print-reply --type=method_call --dest=org.kde.Shutdown /Shutdown org.kde.Shutdown.logout >/dev/null || rm -f /run/droiddeck/return-gaming" +Icon=steamdeck-gaming-return +Terminal=false +Type=Application +StartupNotify=false +NoDisplay=true diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-agent b/tools/linuxfs/overlay/usr/local/bin/droiddeck-agent index df0f4cedf1..449c90ac93 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-agent +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-agent @@ -1,6 +1,7 @@ #!/usr/bin/python3 import base64 +import ctypes import json import math import re @@ -19,6 +20,7 @@ import urllib.parse from pathlib import Path VERSION = 1 +PR_SET_CHILD_SUBREAPER = 36 OUTPUT_CAP = 256 * 1024 REQUEST_CAP = 256 * 1024 RESPONSE_CAP = 1024 * 1024 @@ -1238,7 +1240,17 @@ def answer(agent_dir, path): write_json(agent_dir / "resp" / (rid + ".json"), result) +def stop_adopting_orphans(): + # libddsession makes every session process a child subreaper. The agent never reaps adopted orphans, so + # SteamVR left zombies that its helper's stop counted as still running. The session shell above reaps them. + try: + ctypes.CDLL(None, use_errno=True).prctl(PR_SET_CHILD_SUBREAPER, 0, 0, 0, 0) + except (OSError, AttributeError): + pass + + def serve(agent_dir, focus=True, poll=0.1): + stop_adopting_orphans() (agent_dir / "req").mkdir(parents=True, exist_ok=True) (agent_dir / "resp").mkdir(parents=True, exist_ok=True) can_focus = focus and bool(os.environ.get("DISPLAY")) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-appimage-run b/tools/linuxfs/overlay/usr/local/bin/droiddeck-appimage-run index d0d33c595e..daf6a4ae87 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-appimage-run +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-appimage-run @@ -12,6 +12,7 @@ fi export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1 export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1 export MOZ_SHM_NO_SEALS=1 +export QTWEBENGINE_DISABLE_SANDBOX=1 if [ -s /etc/ld.so.preload ]; then preload=$(tr -s '\n' ':' < /etc/ld.so.preload) export LD_PRELOAD="${preload%:}${LD_PRELOAD:+:$LD_PRELOAD}" SHARUN_ALLOW_LD_PRELOAD=1 diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet b/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet index 0f426d9029..150013822d 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet @@ -350,6 +350,17 @@ def keeps_open(root): return isinstance(client, dict) and LAUNCH_BEHAVIOR[0] in client and client[LAUNCH_BEHAVIOR[0]] != LAUNCH_BEHAVIOR[1] +def chosen_folder(root, current, library): + current = current.strip() + folder = windows_path(root, current) if current else None + if not folder or rootfs_drive(root, current) or not os.path.isdir(folder): + return False + try: + return volume_root(os.path.realpath(folder)) == volume_root(os.path.realpath(library)) + except OSError: + return False + + def write_config(root, library=None): path = os.path.join(drive_c(root), *CONFIG) key, value = LAUNCH_BEHAVIOR @@ -374,6 +385,7 @@ def write_config(root, library=None): client["HardwareAcceleration"] = "false" changes.append("acceleration") if library and isinstance(client.setdefault("Install", {}), dict) \ + and not chosen_folder(root, str(client["Install"].get("DefaultInstallPath", "")), library) \ and str(client["Install"].get("DefaultInstallPath", "")).rstrip("/\\") != install_path(root, library).rstrip("\\"): client["Install"]["DefaultInstallPath"] = install_path(root, library) changes.append("library") diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex index 5585f68a87..0b432bb5d3 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex @@ -682,6 +682,10 @@ def guest_environment(fex, env): if "aarch64" in result.get("GCONV_PATH", ""): result["GCONV_PATH"] = "" result.setdefault("GC_DISABLE_INCREMENTAL", "1") + if not result.get("COMPlus_INTERNAL_ThreadSuspendInjection"): + if not result.get("DOTNET_INTERNAL_ThreadSuspendInjection"): + result["DOTNET_INTERNAL_ThreadSuspendInjection"] = "0" + result["COMPlus_INTERNAL_ThreadSuspendInjection"] = result["DOTNET_INTERNAL_ThreadSuspendInjection"] if fex["portable"]: result["FEX_PORTABLE"] = "1" else: diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-debug b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-debug index 9cf741bf87..24147636b7 100644 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-debug +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-debug @@ -3,6 +3,7 @@ import contextlib import json import os import re +import subprocess import sys import tempfile import threading @@ -74,6 +75,50 @@ def apply_game_debug_logs(env, config=None, debug_dir=None): return result +# Proton appends its log through one inherited descriptor and never limits it; a game that loops on an +# exception wrote 3 GB per run. Truncating keeps the first part and frees the rest, and Proton's +# appends continue from the new end. +PROTON_LOG_CAP = 64 * 1024 * 1024 +PROTON_LOG_CHECK_S = 1 +CAP_WATCH = r""" +import os, stat, sys, time +pid, limit, every, paths = int(sys.argv[1]), int(sys.argv[2]), float(sys.argv[3]), sys.argv[4:] +while os.path.isdir("/proc/%d" % pid): + for path in paths: + try: + info = os.lstat(path) + if stat.S_ISREG(info.st_mode) and info.st_size > limit: + os.truncate(path, limit) + except OSError: + pass + time.sleep(every) +""" + + +def proton_log_paths(env): + if env.get("PROTON_LOG", "0") in ("", "0"): + return [] + folder = env.get("PROTON_LOG_DIR") or env.get("HOME") or os.environ.get("HOME") or "/root" + paths = [os.path.join(folder, "steam-proton.log")] + if env.get("SteamGameId"): + paths.insert(0, os.path.join(folder, "steam-%s.log" % env["SteamGameId"])) + return paths + + +def cap_proton_log(env, pid=None, limit=PROTON_LOG_CAP, every=PROTON_LOG_CHECK_S, popen=subprocess.Popen): + """Keep Proton's log under `limit` bytes while process `pid` (this launcher, which becomes Proton) runs.""" + paths = proton_log_paths(env) + if not paths: + return None + try: + return popen([sys.executable, "-c", CAP_WATCH, str(pid or os.getpid()), str(limit), str(every)] + paths, + stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, + start_new_session=True) + except OSError as error: + print("droiddeck-game-env: Proton log size limit unavailable (%s)" % error, file=sys.stderr) + return None + + def capped_log(path, limit, mirror=False): os.makedirs(os.path.dirname(path), exist_ok=True) handle = open(path, "wb") diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index d309e8e7f0..1e02ad4be2 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -66,6 +66,69 @@ DOTNET_FEX = { "FEX_HALFBARRIERTSOENABLED": "1", "FEX_X87REDUCEDPRECISION": "0", } +STABILITY_FEX = dict(DOTNET_FEX, FEX_MULTIBLOCK="0") +# Setup loader offset-table IDs, as innoextract's known_setup_loader_versions lists them. Loaders +# from 5.1.5 keep the table in a resource; older ones also put "Inno" at file offset 0x30. +INNO_LOADER_IDS = (b"rDlPtS", b"nS5W7dT\x83\xaa\x1b\x0fj") +INNO_RESOURCE_LIMIT = 4 << 20 + + +def is_inno_setup(path): + try: + with open(path, "rb") as exe: + head = exe.read(4096) + if head[:2] != b"MZ": + return False + if head[0x30:0x34] == b"Inno": + return True + pe = int.from_bytes(head[0x3C:0x40], "little") + if head[pe:pe + 4] != b"PE\0\0" or int.from_bytes(head[pe + 4:pe + 6], "little") != 0x14C: + return False + count = int.from_bytes(head[pe + 6:pe + 8], "little") + table = pe + 24 + int.from_bytes(head[pe + 20:pe + 22], "little") + for entry in range(table, table + 40 * count, 40): + if head[entry:entry + 8].rstrip(b"\0") == b".rsrc": + exe.seek(int.from_bytes(head[entry + 20:entry + 24], "little")) + size = int.from_bytes(head[entry + 16:entry + 20], "little") + resources = exe.read(min(size, INNO_RESOURCE_LIMIT)) + return any(marker in resources for marker in INNO_LOADER_IDS) + except OSError: + pass + return False + + +STORE_LAUNCHER = ".droiddeck-launch.bat" +STORE_SIDECAR = ".droiddeck-store.json" + + +def store_game_exe(exe): + if os.path.basename(exe).lower() != STORE_LAUNCHER: + return exe + folder = os.path.dirname(exe) + try: + with open(os.path.join(folder, STORE_SIDECAR), encoding="utf-8") as source: + sidecar = json.load(source) + except (OSError, ValueError): + return exe + target = sidecar.get("exe") if isinstance(sidecar, dict) else None + if not isinstance(target, str) or not target.strip() or "\0" in target: + return exe + normalized = target.replace("\\", "/") + if ":" in normalized or normalized.startswith("/") or ".." in normalized.split("/"): + return exe + relative = os.path.normpath(normalized) + if os.path.isabs(relative) or relative in (".", "..") or relative.startswith(".." + os.sep): + return exe + candidate = os.path.join(folder, relative) + if not os.path.isfile(candidate): + return exe + root = os.path.realpath(folder) + try: + if os.path.commonpath((root, os.path.realpath(candidate))) != root: + return exe + except ValueError: + return exe + return candidate def game_files(exe): @@ -89,6 +152,7 @@ def game_files(exe): class Game: def __init__(self, exe, args, app_id=""): + exe = store_game_exe(exe) self.exe = exe self.args = args self.app_id = app_id @@ -191,6 +255,12 @@ def split_second_x87_fip(game): return {"FEX_JITFEATURES": "enablex87fip"}, [], "Split/Second: FEX x87 FIP emulation on (its SecuROM stops with error 8016 without it)" +@fix +def inno_setup_stability(game): + if is_inno_setup(game.exe): + return STABILITY_FEX, [], "Inno Setup installer: FEX Stability settings (under Performance + TSO the 32-bit setup stub corrupts its own paths)" + + @fix def doom_2016_swapchain_images(game): if "doomx64vk.exe" in game.files and game.stem in ("doomx64", "doomx64vk"): @@ -273,7 +343,7 @@ def with_system_settings(text, settings): # The game ignores -ini: overrides and deletes a writable Engine.ini after reading it, so this runs at every launch. def dragon_quest_monsters_4_mesh_detail(exe, env): - project = Path(exe).stem.split("-", 1)[0] + project = Path(store_game_exe(exe)).stem.split("-", 1)[0] if not project.lower().startswith("dragonquestmonsters4"): return prefix = Path(env.get("STEAM_COMPAT_DATA_PATH", "/nonexistent")) / "pfx" @@ -398,7 +468,7 @@ def zomboid_rewrite(node): def project_zomboid_jvm(command): if len(command) <= 2: return - exe = Path(command[2]) + exe = Path(store_game_exe(command[2])) if not exe.stem.lower().startswith("projectzomboid"): return settings = exe.with_suffix(".json") @@ -721,12 +791,15 @@ def apply_config(env, config, app_id, fixes=None): def render_path_defaults(command, env): - if len(command) < 3 or command[1] != "waitforexitandrun" or Path(command[2]).name.lower() != "spintires.exe": + if len(command) < 3 or command[1] != "waitforexitandrun": + return None + exe = Path(store_game_exe(command[2])) + if exe.name.lower() != "spintires.exe": return None own = env.get("DXVK_CONFIG", "") if re.search(r"(?:^|;)\s*dxvk\.tilerMode\s*=", own) or env.get("DXVK_CONFIG_FILE"): return None - if Path("dxvk.conf").is_file() or Path(command[2]).with_name("dxvk.conf").is_file(): + if Path("dxvk.conf").is_file() or exe.with_name("dxvk.conf").is_file(): return None driver = env.get("VK_DRIVER_FILES", env.get("VK_ICD_FILENAMES", "")) if Path(driver).parent.name != "DD-Turnip_v0.4.0": @@ -1290,7 +1363,7 @@ def dirt_ws2_wanted(command, env): prefix = env.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/") if len(command) < 3 or not prefix or not os.path.isfile(DIRT_WS2): return None - game = DIRT_GAMES.get(os.path.splitext(os.path.basename(command[2]))[0].lower()) + game = DIRT_GAMES.get(os.path.splitext(os.path.basename(store_game_exe(command[2])))[0].lower()) if not game or not dirt_telemetry_on(prefix, game) or proton_has_dirt_fix(command[0]): return None return prefix if os.path.lexists(prefix_ws2(prefix)) else None @@ -1347,7 +1420,7 @@ def ego_core_plan(command, env): count = windows_core_count(env) if not count or len(command) < 3: return None - folder = Path(command[2]).parent + folder = Path(store_game_exe(command[2])).parent path = folder / EGO_RESTRICTIONS try: raw = path.read_bytes() @@ -1676,14 +1749,26 @@ def main(): if note: print("droiddeck-game-env: " + note, file=sys.stderr) else: + # An installer started with the run verb gets the same Stability settings as one started with + # waitforexitandrun; explicit game settings still win over them in apply_config. + installer = {} + if len(command) > 2 and command[1] == "run" and is_inno_setup(command[2]): + installer = dict(STABILITY_FEX) + print("droiddeck-game-env: Inno Setup installer: FEX Stability settings", file=sys.stderr) path = Path.home() / ".config/droiddeck/game-environment.json" try: with path.open(encoding="utf-8") as source: config = json.load(source) - env = apply_config(env, sync_config(config, app_id), app_id) + synced = sync_config(config, app_id) + if installer: + # A FEX preset chosen for the game itself still wins, as on every other launch path. + game = config.get("games", {}).get(app_id, {}) + synced["games"][app_id].update({k: v for k, v in game.items() if k in STABILITY_FEX}) + env = apply_config(env, synced, app_id, installer) except FileNotFoundError: - pass + env = dict(env, **installer) except (OSError, ValueError, TypeError, AttributeError): + env = dict(env, **installer) print("droiddeck-game-env: invalid configuration; using inherited environment", file=sys.stderr) if waiting: before_debug = env @@ -1748,6 +1833,8 @@ def main(): except OSError as undo: print("droiddeck-game-env: DiRT telemetry fix: prefix ws2_32 not put back (%s); Wine uses its own copy " "and the next launch puts the file back" % undo, file=sys.stderr) + if len(command) > 1 and command[1] == "waitforexitandrun": + GAME_DEBUG["cap_proton_log"](env) sync = load_sync() launch, launch_env = select_sync(command, env, sync) if launch[0] != command[0]: diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-msi-install b/tools/linuxfs/overlay/usr/local/bin/droiddeck-msi-install index 681cf4031b..0066f85577 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-msi-install +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-msi-install @@ -51,6 +51,11 @@ SYSTEM_PROPERTIES = { "UILevel": "2", "INSTALLLEVEL": "1", "ProgramFilesFolder": None, "VersionMsi": "5.00", } +NATIVE_ARCHITECTURE = {"intel": "x86", "x64": "AMD64", "amd64": "AMD64", "arm64": "ARM64"} +ARCHITECTURE_VALUE = ("system\\currentcontrolset\\control\\session manager\\environment", "processor_architecture") +REG_LOCATOR_RAW = 2 +REG_ROOT_LOCAL_MACHINE = 2 + COMPONENT_64BIT = 0x100 FILE_NONCOMPRESSED = 0x2000 SET_PROPERTY, SET_DIRECTORY, ERROR_ACTION = 51, 35, 19 @@ -410,6 +415,18 @@ class Installer: return text + def run_app_search(self): + locators = {row["Signature_"]: row for row in self.pkg.table("RegLocator")} + architecture = NATIVE_ARCHITECTURE.get(self.platform) + for row in self.pkg.table("AppSearch"): + locator = locators.get(row["Signature_"]) + if locator is None or architecture is None: + continue + if to_int(locator.get("Root")) != REG_ROOT_LOCAL_MACHINE or to_int(locator.get("Type")) & 0xF != REG_LOCATOR_RAW: + continue + if (locator.get("Key", "").rstrip("\\").casefold(), locator.get("Name", "").casefold()) == ARCHITECTURE_VALUE: + self.props[row["Property"]] = architecture + def run_set_actions(self): actions = {row["Action"]: row for row in self.pkg.table("CustomAction")} sequence = {} @@ -704,6 +721,7 @@ class Installer: def install(self): self.span.report(0.0, "reading %s" % (self.pkg.summary.get("subject") or Path(self.pkg.path).name)) + self.run_app_search() self.run_set_actions() self.select() with tempfile.TemporaryDirectory(dir=str(self.out.parent), prefix=".msi-") as work: @@ -865,13 +883,9 @@ def choose_packages(found, root): names = [entry.name.lower() for entry in top] if any("full" in name for name in names) and any("_core" in name or "_extended" in name for name in names): top = [entry for entry in top if not ("_core" in entry.name.lower() or "_extended" in entry.name.lower())] - chosen = [] - for entry in top: - template = Package(entry).summary.get("template", "").split(";")[0].strip().lower() - if template in SKIP_PLATFORMS: - continue - chosen.append(entry) - return chosen + platforms = [(entry, Package(entry).summary.get("template", "").split(";")[0].strip().lower()) for entry in top] + native = [entry for entry, template in platforms if template not in SKIP_PLATFORMS] + return native or top def install_wrapper(path, out): @@ -901,6 +915,8 @@ def install_wrapper(path, out): for note in result["notes"]: if note not in total["notes"]: total["notes"].append(note) + if not total["packages"]: + raise MsiError("%s installs nothing here" % path.name) total["how"] = how return total diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-qam-relay b/tools/linuxfs/overlay/usr/local/bin/droiddeck-qam-relay new file mode 100755 index 0000000000..2ce47e214f --- /dev/null +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-qam-relay @@ -0,0 +1,195 @@ +#!/usr/bin/python3 +# Relays the app to Steam's DevTools port, which only answers clients inside the guest, while the bottom screen +# shows Steam's quick access menu. Only requests carrying the secret printed at start reach DevTools, and only for +# the target list and page sockets, so other local apps cannot use the relay to reach Steam. +# droiddeck-qam-relay start prints the relay port and its secret +# droiddeck-qam-relay stop [] stops the relay, or only the one on that port + +import contextlib +import hmac +import os +import re +import secrets +import socket +import sys +import threading +import time + +try: + import fcntl +except ImportError: + fcntl = None + +FLAG = "/tmp/.dd-qam-relay" +INTERVAL = 0.5 +MAX_SECONDS = 6 * 3600 +IDLE_SECONDS = 30 +HEAD_SECONDS = 3 +UNVERIFIED = threading.BoundedSemaphore(8) +ALLOWED = re.compile(r"^/(json|json/list|devtools/page/[A-Za-z0-9-]+)$") + + +class Activity: + def __init__(self): + self.lock = threading.Lock() + self.open = 0 + self.last = time.monotonic() + + def change(self, delta): + with self.lock: + self.open += delta + self.last = time.monotonic() + + def idle(self): + with self.lock: + return self.open == 0 and time.monotonic() - self.last > IDLE_SECONDS + + +@contextlib.contextmanager +def flag_lock(): + """Serializes reading, removing and publishing the owner record, so a stop cannot remove a newer relay's record.""" + if fcntl is None: + yield + return + fd = os.open(FLAG + ".lock", os.O_CREAT | os.O_RDWR, 0o600) + try: + fcntl.flock(fd, fcntl.LOCK_EX) + yield + finally: + os.close(fd) + + +def owner(): + try: + with open(FLAG) as f: + return f.read().split() + except OSError: + return [] + + +def pipe(src, dst): + try: + while True: + data = src.recv(65536) + if not data: + break + dst.sendall(data) + except OSError: + pass + for s in (src, dst): + try: + s.shutdown(socket.SHUT_RDWR) + except OSError: + pass + + +def rewrite(head, token): + """Returns the request with the secret removed from its path, or None when it is not an allowed request.""" + line, sep, rest = head.partition(b"\r\n") + parts = line.split(b" ") + if not sep or len(parts) != 3 or parts[0] != b"GET" or not parts[2].startswith(b"HTTP/1."): + return None + prefix = b"/" + token.encode() + path = parts[1] + if not hmac.compare_digest(path[:len(prefix)], prefix) or not ALLOWED.match(path[len(prefix):].decode("ascii", "replace")): + return None + return b"GET " + path[len(prefix):] + b" " + parts[2] + sep + rest + + +def handle(client, devtools_port, token, activity): + activity.change(1) + verifying = True + try: + deadline = time.monotonic() + HEAD_SECONDS + head = b"" + while b"\r\n" not in head and len(head) < 4096: + left = deadline - time.monotonic() + if left <= 0: + return + client.settimeout(left) + data = client.recv(4096) + if not data: + break + head += data + request = rewrite(head, token) + UNVERIFIED.release() + verifying = False + if request is None: + client.sendall(b"HTTP/1.1 403 Forbidden\r\nContent-Length: 0\r\nConnection: close\r\n\r\n") + return + client.settimeout(None) + upstream = socket.create_connection(("127.0.0.1", devtools_port), 3) + # The connect deadline must not end a quiet DevTools socket. + upstream.settimeout(None) + upstream.sendall(request) + back = threading.Thread(target=pipe, args=(upstream, client), daemon=True) + back.start() + pipe(client, upstream) + back.join() + except OSError: + pass + finally: + if verifying: + UNVERIFIED.release() + client.close() + activity.change(-1) + + +def relay(server, devtools_port, token, activity): + while True: + try: + client, _ = server.accept() + except OSError: + return + # Connections that have not shown the secret yet are capped, so they cannot use up threads. + if not UNVERIFIED.acquire(blocking=False): + client.close() + continue + threading.Thread(target=handle, args=(client, devtools_port, token, activity), daemon=True).start() + + +def serve(server, devtools_port, me, token): + activity = Activity() + threading.Thread(target=relay, args=(server, devtools_port, token, activity), daemon=True).start() + started = time.monotonic() + while owner()[:1] == [me] and time.monotonic() - started < MAX_SECONDS and not activity.idle(): + time.sleep(INTERVAL) + server.close() + + +def main(): + command = sys.argv[1] if len(sys.argv) > 1 else "" + if command == "stop" and len(sys.argv) in (2, 3): + with flag_lock(): + if len(sys.argv) == 3 and owner()[1:] != [sys.argv[2]]: + return 0 + try: + os.unlink(FLAG) + except FileNotFoundError: + pass + return 0 + if command != "start" or len(sys.argv) != 3: + print("usage: droiddeck-qam-relay start | stop []", file=sys.stderr) + return 2 + devtools_port = int(sys.argv[2]) + server = socket.socket() + server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + server.bind(("127.0.0.1", 0)) + server.listen(4) + token = secrets.token_hex(16) + print(server.getsockname()[1], token, flush=True) + if os.fork(): + return 0 + os.setsid() + me = str(os.getpid()) + with flag_lock(), open(FLAG, "w") as f: + f.write("%s %d" % (me, server.getsockname()[1])) + devnull = os.open(os.devnull, os.O_RDWR) + for fd in (0, 1, 2): + os.dup2(devnull, fd) + serve(server, devtools_port, me, token) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session index 23c22edfa2..c30c3098ec 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session @@ -224,15 +224,23 @@ if [ -n "${DD_VK_DRIVER:-}" ]; then unset dd_icd_lib fi dd_webhelper_layout() { + local layout if [ -n "${DD_VKBRIDGE_WEBHELPER_ARGS:-}" ]; then printf '%s\n' "$DD_VKBRIDGE_WEBHELPER_ARGS" - elif [ -z "${DD_VKBRIDGE_CEF_ANGLE:-}" ]; then - echo stock - elif [ "$DD_VKBRIDGE_CEF_ANGLE" = vulkan ] && [ "${DD_VKBRIDGE_CEF_VULKAN:-1}" != 0 ]; then - echo "--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan" - else - echo "--use-gl=angle --use-angle=$DD_VKBRIDGE_CEF_ANGLE" + return fi + if [ -z "${DD_VKBRIDGE_CEF_ANGLE:-}" ]; then + echo stock + return + fi + # ANGLE switches must not replace the helper's stable single-process layout. + layout="--no-zygote --in-process-gpu -AudioServiceOutOfProcess" + if [ "$DD_VKBRIDGE_CEF_ANGLE" = vulkan ] && [ "${DD_VKBRIDGE_CEF_VULKAN:-1}" != 0 ]; then + layout="$layout --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan" + else + layout="$layout --use-gl=angle --use-angle=$DD_VKBRIDGE_CEF_ANGLE" + fi + printf '%s\n' "$layout" } dd_now_ms() { if [ -n "${EPOCHREALTIME:-}" ]; then @@ -778,7 +786,7 @@ case $mode in for _d in /proc/[0-9]*; do [ "${_d##*/}" != "$BASHPID" ] || continue _args=() - while IFS= read -r -d '' _c; do _args+=("$_c"); done 2>/dev/null < "$_d/cmdline" || true + mapfile -d '' -t _args 2>/dev/null < "$_d/cmdline" || true [ "${#_args[@]}" -gt 0 ] || continue _name=${_args[0]} _fex=0 if [ "${#_args[@]}" -gt 1 ]; then @@ -1141,6 +1149,7 @@ case $mode in droiddeck-steam-library "$steam_root" || true step "setting up the ARM64 Proton compatibility tool" steam-compatibility "$steam_root" || true + steam-compatibility "$steam_root" --seed-arm64-tools || true if [ -z "${DD_DESKTOP:-}" ] && [ "${DD_STEAM_UI:-}" != desktop ]; then droiddeck-steam-ui-scale "$steam_root" "${DD_WIDTH:-1280}" "${DD_HEIGHT:-720}" || true fi diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr index 176f92aad3..8abe106a7f 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr @@ -14,7 +14,16 @@ chmod 700 "$state" PKG_URL=https://steamdeck-packages.steamos.cloud/archlinux-deckard-hotfixes/release/0.3.x/deckard-steamvr-rel-r25358740%2B28b72a4f-1-aarch64.pkg.tar.zst PKG_SHA256=90a600775eb3e8856dc475f83166a93a290a0b1f3b4e82a69c8e2a8f06b9ddc9 -running() { pgrep -x vrserver >/dev/null 2>&1; } +alive() { + for p in $(pgrep -x "$1"); do + case "$(awk '/^State:/ { print $2 }' "/proc/$p/status" 2>/dev/null)" in + Z|'') ;; + *) return 0 ;; + esac + done + return 1 +} +running() { alive vrserver; } installed() { [ -x "$steamvr/bin/linuxarm64/vrstartup" ]; } quest_settings() { backup=$HOME/.local/share/droiddeck/steamvr-quest-settings.json @@ -40,6 +49,19 @@ configure_graphics() { esac } +# On the guest's three cores Steam's web helpers took CPU time from vrcompositor's frames, so while the Quest view +# shows SteamVR they run at a lower priority. +steam_ui_priority() { + status=0 + for p in $(pgrep -x steamwebhelper); do + for t in /proc/"$p"/task/*; do + renice -n "$1" -p "${t##*/}" >/dev/null 2>&1 || [ ! -e "$t" ] || status=1 + done + done + [ "$status" = 0 ] || echo "could not set every Steam web helper thread to priority $1" >&2 + return "$status" +} + unregister() { if grep -qF "\"$steamvr\"" "$HOME/.config/openvr/openvrpaths.vrpath" 2>/dev/null; then rm -f "$HOME/.config/openvr/openvrpaths.vrpath" @@ -50,7 +72,7 @@ unregister() { } idle() { - [ ! -f "$state/active" ] && ! running && ! pgrep -x vrstartup >/dev/null 2>&1 && + [ ! -f "$state/active" ] && ! running && ! alive vrstartup && ( flock -n 9 ) 9>"$state/start.lock" } @@ -61,7 +83,7 @@ stop() { done for p in $(pgrep -f "$steamvr/bin/linuxarm64/vrcompositor-launcher"); do kill "$p" 2>/dev/null; done attempts=0 - while pgrep -x 'vrserver|vrcompositor' >/dev/null 2>&1; do + while alive 'vrserver|vrcompositor'; do attempts=$((attempts + 1)) if [ "$attempts" = 10 ]; then for p in $(pgrep -x 'vrserver|vrcompositor'); do kill -KILL "$p" 2>/dev/null; done @@ -69,8 +91,12 @@ stop() { [ "$attempts" -lt 20 ] || { echo 'SteamVR did not stop; preferences remain backed up' >&2; return 1; } sleep 0.1 done + # A SteamVR process killed while holding the IPC mutex in this file leaves it locked, and the next vrserver + # gives up on it ("failed to acquire SysMgrMutex"), so the headset shows an empty void. + alive 'vrserver|vrcompositor|vrstartup|vrdashboard|vrwebhelper' || rm -f /dev/shm/u*-ValveIPCSharedObj-SteamVR unregister quest_settings restore + steam_ui_priority 0 || : } case "${1:-status}" in @@ -81,6 +107,11 @@ launch) "$0" install || exit $? while [ -f "$state/installing" ]; do sleep 1; done fi + if [ -f "$state/quest-immersive" ]; then + : > "$state/xr-request" + echo "asked DroidDeck to open the Quest's immersive view, which starts SteamVR" + exit 0 + fi "$0" start ;; status) @@ -122,7 +153,7 @@ start) flock -n 9 || { echo "SteamVR start already in progress"; exit 0; } installed || { echo "SteamVR is not installed (droiddeck-steamvr install)"; exit 1; } [ -f "$driver/bin/linuxarm64/driver_droiddeck.so" ] || { echo "the Cardboard driver is missing from $driver"; exit 1; } - if [ -f "$state/active" ] && { running || pgrep -x vrstartup >/dev/null 2>&1; }; then + if [ -f "$state/active" ] && { running || alive vrstartup; }; then echo "DroidDeck SteamVR is already running" exit 0 fi @@ -215,8 +246,9 @@ JSON export LD_PRELOAD="$layer/libdroiddeck_vr_scheduling.so${LD_PRELOAD:+:$LD_PRELOAD}" if [ "${DROIDDECK_VR_PRESENT:-}" = questwsi ]; then quest_settings apply || exit 1 + steam_ui_priority 10 || : startup_handed_off=0 - trap '[ "$startup_handed_off" = 1 ] || quest_settings restore' EXIT + trap '[ "$startup_handed_off" = 1 ] || { quest_settings restore; steam_ui_priority 0 || :; }' EXIT cvp=$steamvr/drivers/cv/bin/linuxarm64/libArcturusPerception.so if [ -f "$cvp" ]; then disabled=$cvp.droiddeck-disabled diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr-settings b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr-settings index 723a2b6d5b..b7a4ef457a 100644 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr-settings +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steamvr-settings @@ -4,7 +4,14 @@ import os from pathlib import Path import sys -OVERRIDES = {'enableLinuxVulkanAsync': True, 'motionSmoothing': False} +# SteamVR's arm64 build throttles the compositor to save power and skipped refreshes it had time for. +OVERRIDES = {'enableLinuxVulkanAsync': True, 'motionSmoothing': False, 'framesToThrottle': 0, 'powersaveFramesToThrottle': 0} +# Backups written before the throttle overrides existed do not record them. +ADDED_LATER = {'framesToThrottle', 'powersaveFramesToThrottle'} + + +def saved_entry(section, key): + return [key in section, section.get(key)] def read(path): @@ -33,6 +40,8 @@ def saved_preferences(path): if not isinstance(backup.get('section'), bool) or not isinstance(backup.get('values'), dict): raise ValueError('invalid backup object') for key in OVERRIDES: + if key not in backup['values'] and key in ADDED_LATER: + continue entry = backup['values'].get(key) if not isinstance(entry, list) or len(entry) != 2 or not isinstance(entry[0], bool): raise ValueError('invalid saved preference: ' + key) @@ -45,12 +54,16 @@ def saved_preferences(path): def update(operation, settings_path, backup_path): settings = read(settings_path) if operation == 'apply': + section = settings.get('steamvr', {}) if backup_path.exists(): - saved_preferences(backup_path) + backup = saved_preferences(backup_path) + missing = [key for key in OVERRIDES if key not in backup['values']] + if missing: + backup['values'].update({key: saved_entry(section, key) for key in missing}) + write(backup_path, backup) else: - section = settings.get('steamvr', {}) write(backup_path, {'section': 'steamvr' in settings, - 'values': {key: [key in section, section.get(key)] for key in OVERRIDES}}) + 'values': {key: saved_entry(section, key) for key in OVERRIDES}}) settings.setdefault('steamvr', {}).update(OVERRIDES) write(settings_path, settings) elif operation == 'restore': @@ -59,6 +72,8 @@ def update(operation, settings_path, backup_path): backup = saved_preferences(backup_path) section = settings.setdefault('steamvr', {}) for key in OVERRIDES: + if key not in backup['values']: + continue present, value = backup['values'][key] if present: section[key] = value diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch b/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch index 6c63785dff..9f266048ec 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch @@ -324,6 +324,16 @@ def cloud_on(sidecar): def exited(argv, code=0): found = find_store_game(argv) launch_dir = os.environ.get("DD_LAUNCH_DIR", "") + compat_data = os.environ.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/") + if found is None and launch_dir and compat_data and steam_ea_link(argv): + try: + game = str(json.loads((Path(compat_data) / STEAM_EA_STATE).read_text()).get("id") or "") + except (OSError, ValueError, AttributeError): + game = "" + if game: + ask(Path(launch_dir) / "stores", {"op": "ea-exited", "store": "ea", "id": game}, timeout=1.0) + log("steam ea %s exited" % game) + return 0 if found is not None and launch_dir and str(found[1].get("store")) == "rockstar": ask(Path(launch_dir) / "stores", {"op": "rockstar-exited", "store": "rockstar", "id": str(found[1].get("id"))}, timeout=1.0) compat_data = os.environ.get("STEAM_COMPAT_DATA_PATH") @@ -1552,7 +1562,7 @@ def write_licenses(compat_data, licenses): return written -def prepare_ea(folder, sidecar, compat_data, launch_dir): +def prepare_ea(folder, sidecar, compat_data, launch_dir, steam=None): game = str(sidecar.get("id")) proton = os.environ.get("DD_STORE_PROTON", "") made = create_prefix(compat_data, proton) @@ -1561,16 +1571,149 @@ def prepare_ea(folder, sidecar, compat_data, launch_dir): hardware, probe = ea_hardware(compat_data, proton) if ready else ({}, "no-prefix") answer = None if launch_dir: - answer = ask(Path(launch_dir) / "stores", {"op": "ea-prepare", "store": "ea", "id": game, "hardware": hardware}, timeout=40.0) + request = {"op": "ea-prepare", "store": "ea", "id": game, "hardware": hardware} + if steam is not None: + request["steam"] = steam + answer = ask(Path(launch_dir) / "stores", request, timeout=40.0) sidecar = sidecar_at(Path(folder)) or sidecar log("ea %s prefix=%s stub=%s hardware=%s registry=%s touchup=%s" % ( game, made, stub, probe, ea_registry(folder, sidecar, compat_data, proton), ea_touchup(folder, sidecar, compat_data, proton))) if answer is None: log("ea %s session=no reason=%s" % (game, "timeout" if launch_dir else "no-channel")) - return + return None written = write_licenses(compat_data, answer.get("licenses")) log("ea %s session=%s reason=%s lsx=%s licence=%s files=%d" % ( game, "yes" if answer.get("ok") else "no", answer.get("reason", ""), answer.get("lsx"), answer.get("license", ""), written)) + return answer + + +STEAM_EA_LINK = re.compile(r"(?i)^steam2ea://launchgame/([0-9]+)") +STEAM_EA_LAUNCHER = "droiddeck-ea-steam.bat" +STEAM_EA_ENV = ".droiddeck-ea-steam-env" +STEAM_EA_STATE = ".droiddeck-ea-steam.json" +STEAM_EA_CLIENT = "drive_c/Program Files/Electronic Arts/EA Desktop/EA Desktop/EADesktop.exe" +STEAM_EA_OFFER = re.compile(r"^(Origin\.OFR\.[0-9]+\.[0-9]+)\.dat$", re.IGNORECASE) +REPLACED = 13 + + +def steam_ea_link(argv): + for raw in argv: + if STEAM_EA_LINK.match(raw.strip().strip('"')): + return raw + return None + + +def ea_manifest(folder): + path = find_case(folder, "__Installer/installerdata.xml") + if path is None or not path.is_file(): + return None + import xml.etree.ElementTree as ET + try: + text = decode_output(path.read_bytes()).lstrip("\ufeff") + root = ET.fromstring(re.sub(r"^\s*<\?xml[^>]*\?>", "", text)) + except (OSError, ET.ParseError): + return None + contents = [e.text.strip() for e in root.iter("contentID") if e.text and e.text.strip()] + launchers = [] + for runtime in root.iter("runtime"): + for launcher in runtime.iter("launcher"): + path_text = (launcher.findtext("filePath") or "").strip() + if path_text: + launchers.append((path_text, (launcher.findtext("parameters") or "").strip(), (launcher.findtext("trial") or "0").strip() == "1")) + launcher = next((l for l in launchers if not l[2]), launchers[0] if launchers else None) + version = root.find("buildMetaData/gameVersion") + titles = {e.get("locale"): (e.text or "").strip() for e in root.iter("gameTitle") if e.get("locale")} + exe = None + if launcher is not None: + relative = re.sub(r"^\[[^\]]*\]", "", launcher[0]).replace("{installLocation}", "").lstrip("\\/") + exe = find_case(folder, relative) + return { + "contentIds": contents, + "exe": exe if exe is not None and exe.is_file() else None, + "parameters": launcher[1] if launcher else "", + "version": version.get("version", "") if version is not None else "", + "title": titles.get("en_US") or next(iter(titles.values()), "") or Path(folder).name, + } + + +def steam_ea_offers(folder): + loc = find_case(folder, "__Installer/LOC") + try: + names = sorted(p.name for p in loc.iterdir()) if loc is not None and loc.is_dir() else [] + except OSError: + names = [] + return [m.group(1) for m in map(STEAM_EA_OFFER.match, names) if m] + + +def batch_text(value): + return value.replace("%", "%%").replace('"', "") + + +def batch_arguments(value): + return re.sub(r"[\x00-\x1f]+", " ", value).replace("%", "%%") + + +def steam_ea_launcher(folder, exe, parameters, compat_data): + env = windows_path(str(Path(compat_data) / STEAM_EA_ENV)) + lines = [ + "@echo off", + "setlocal", + "rem Written by DroidDeck: starts Steam's copy of an EA game without the EA app.", + 'cd /d "%s"' % batch_text(windows_path(str(exe.parent))), + 'if not exist "%s" goto run' % batch_text(env), + 'for /f "usebackq tokens=1,* delims==" %%%%a in ("%s") do set "%%%%a=%%%%b"' % batch_text(env), + 'del "%s"' % batch_text(env), + ":run", + 'if exist "%s" start "" "%s"' % (EA_STUB, EA_STUB), + '"%s"%s %%*' % (batch_text(windows_path(str(exe))), " " + batch_arguments(parameters) if parameters else ""), + 'set "DD_RC=%errorlevel%"', + "taskkill /f /im Origin.exe >nul 2>&1", + "exit /b %DD_RC%", + ] + return "\r\n".join(lines) + "\r\n" + + +def prepare_steam_ea(argv, compat_data, launch_dir): + """Steam's copies of EA games start through the EA app, which does not install here: start the game itself.""" + folder = Path(os.environ.get("STEAM_COMPAT_INSTALL_PATH") or os.getcwd()) + if not compat_data: + log("steam ea: no prefix, left to the EA app") + return 0 + if (Path(compat_data) / "pfx" / STEAM_EA_CLIENT).is_file(): + log("steam ea: the EA app is installed in this prefix, left to it") + return 0 + manifest = ea_manifest(folder) + offers = steam_ea_offers(folder) + if manifest is None or manifest["exe"] is None or not manifest["contentIds"] or not offers: + log("steam ea: %s has no EA manifest, launcher or offer, left to the EA app" % folder) + return 0 + if not launch_dir: + log("steam ea: no channel to DroidDeck, left to the EA app") + return 0 + exe = manifest["exe"] + sidecar = {"store": "ea", "id": offers[0], "title": manifest["title"], + "extra": {"contentIds": ",".join(manifest["contentIds"]), "displayName": manifest["title"], "locale": "en_US"}} + steam = {"folder": str(folder), "offers": offers, "contentIds": manifest["contentIds"], "title": manifest["title"], + "version": manifest["version"], "locale": "en_US", "exe": str(exe.relative_to(folder))} + answer = prepare_ea(folder, sidecar, compat_data, launch_dir, steam) + env = answer.get("env") if answer and answer.get("ok") else None + if not isinstance(env, dict): + log("steam ea: no EA session (%s), left to the EA app" % ((answer or {}).get("reason") or "no answer")) + return 0 + data = Path(compat_data) + try: + secret = data / (STEAM_EA_ENV + ".tmp") + secret.write_bytes("".join("%s=%s\r\n" % (k, v) for k, v in env.items() + if re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", str(k)) and "\n" not in str(v)).encode()) + os.chmod(secret, 0o600) + os.replace(secret, data / STEAM_EA_ENV) + (data / STEAM_EA_LAUNCHER).write_bytes(steam_ea_launcher(folder, exe, manifest["parameters"], compat_data).encode()) + (data / STEAM_EA_STATE).write_text(json.dumps({"id": str(answer.get("id") or offers[0])})) + except OSError as error: + log("steam ea: launcher not written (%s), left to the EA app" % type(error).__name__) + return 0 + log("steam ea: %s starts %s directly as %s" % (manifest["title"], exe.name, answer.get("id") or offers[0])) + return REPLACED def gog_support_actions(folder): @@ -1705,6 +1848,8 @@ def main(argv): return RAN if subprocess.call(command) == 0 else RAN_FAILED found = find_store_game(argv) if found is None: + if steam_ea_link(argv): + return prepare_steam_ea(argv, os.environ.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/"), os.environ.get("DD_LAUNCH_DIR", "")) return 0 folder, sidecar = found store, game = str(sidecar.get("store")), str(sidecar.get("id")) diff --git a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility index 3662eab545..4eb7ba26f7 100755 --- a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility +++ b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility @@ -5,6 +5,7 @@ import re import runpy import shutil import sys +import tempfile TOOL = "droiddeck-proton-arm64" TOOL_11 = "droiddeck-proton-11-arm64" @@ -26,6 +27,8 @@ SNIPER_APPID = "1628350" SLR4_APPID = "4183110" FEX_DEPENDENCIES = (FEX_APPID, SNIPER_APPID, SLR4_APPID) REQUIRED_TOOLS = (PROTON_ARM64_APPID,) + FEX_DEPENDENCIES +ARM64_TOOL_DEPENDENCIES = (("1826330", "Proton EasyAntiCheat Runtime"), + ("1070560", "Steam Linux Runtime 1.0 (scout)")) # "0" = the app's "Valve Proton only when needed": Valve's ARM64 Proton is fetched only for a title or # default set to a tool built from it, or while no own Proton build is installed. VALVE_PROTON_ENV = "DD_VALVE_PROTON" @@ -79,6 +82,10 @@ dd_store_launch() { /usr/local/bin/droiddeck-store-launch "$@" rc=$? [ $rc -eq 10 ] && DD_STORE_EXIT=1 + if [ $rc -eq 13 ]; then + DD_STORE_EXIT=1 + DD_STORE_REPLACE="${STEAM_COMPAT_DATA_PATH%/}/droiddeck-ea-steam.bat" + fi [ $rc -eq 11 ] && exit 0 [ $rc -eq 12 ] && exit 1 return 0 @@ -88,6 +95,13 @@ dd_run() { if [ -x /usr/local/bin/droiddeck-steamvr-flat ] && /usr/local/bin/droiddeck-steamvr-flat "${verb:-}"; then set -- /usr/local/bin/droiddeck-steamvr-game "$@" fi + if [ -n "${DD_STORE_REPLACE:-}" ]; then + local arg replaced=() + for arg in "$@"; do + case ${arg,,} in steam2ea://*) replaced+=("$DD_STORE_REPLACE") ;; *) replaced+=("$arg") ;; esac + done + set -- "${replaced[@]}" + fi if [ -n "${DD_STORE_EXIT:-}" ]; then trap : INT TERM HUP "$@" @@ -227,6 +241,14 @@ dd_components() { DD_GAME_CPUS_SETUP = """ dd_game_cpus() { + local live=/root/.config/droiddeck/game-cores cpus rest= + if [ -f "$live" ] && { IFS= read -r cpus && ! IFS= read -r rest; } <"$live" 2>/dev/null && [ -z "$rest" ] && [ "$(wc -c <"$live" 2>/dev/null)" = "$((${#cpus} + 1))" ]; then + [[ -z $cpus || $cpus =~ ^[0-9]+(-[0-9]+)?(,[0-9]+(-[0-9]+)?)*$ ]] || cpus=${DD_GAME_CPUS:-} + if [ -z "$cpus" ] && [ -n "${DD_CLIENT_CPUS:-}" ]; then + cpus=$(nproc --all 2>/dev/null) && cpus=0-$((cpus - 1)) || cpus= + fi + if [ -n "$cpus" ]; then export DD_GAME_CPUS=$cpus; else unset DD_GAME_CPUS; fi + fi [ -n "${DD_GAME_CPUS:-}" ] || return 0 command -v taskset >/dev/null 2>&1 || return 0 DD_TASKSET="taskset -c $DD_GAME_CPUS" @@ -993,10 +1015,15 @@ def manifest_text(appid, name, installdir, bare=False): return text[:-2] + ' "AutoUpdateBehavior" "1"\n}\n' if bare else text -def app_manifest(steam_root, app): +def manifest_paths(steam_root, app): for library in libraries(steam_root): + yield os.path.join(library, "steamapps", "appmanifest_%s.acf" % app) + + +def app_manifest(steam_root, app): + for path in manifest_paths(steam_root, app): try: - with open(os.path.join(library, "steamapps", "appmanifest_%s.acf" % app), encoding="utf-8", errors="replace") as f: + with open(path, encoding="utf-8", errors="replace") as f: return tokenize(f.read()) except OSError: continue @@ -1011,6 +1038,57 @@ def manifest_flags(tokens): return 0 +def installed_manifest(path): + try: + with open(path, encoding="utf-8", errors="replace") as f: + return bool(manifest_flags(tokenize(f.read())) & FULLY_INSTALLED) + except OSError: + return False + + +def seed_unavailable_arm64_tools(steam_root): + entries = appinfo_entries(os.path.join(steam_root, "appcache", "appinfo.vdf"), + [app for app, _ in ARM64_TOOL_DEPENDENCIES]) + steamapps = os.path.join(steam_root, "steamapps") + os.makedirs(steamapps, exist_ok=True) + seeded = [] + for app, display in ARM64_TOOL_DEPENDENCIES: + entry = entries.get(app) + if entry is not None: + if entry["type"] not in ("", "tool"): + continue + if "arm64" in entry["osarch"] or "aarch64" in entry["osarch"]: + continue + existing = [p for p in manifest_paths(steam_root, app) if os.path.isfile(p)] + if any(installed_manifest(p) for p in existing): + continue + name = (entry or {}).get("name") or display + installdir = (entry or {}).get("installdir") or name + path = existing[0] if existing else os.path.join(steamapps, "appmanifest_%s.acf" % app) + temporary = None + try: + with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8", + dir=os.path.dirname(path), + prefix=".appmanifest_", delete=False) as f: + temporary = f.name + f.write(manifest_text(app, name, installdir, True)) + if existing: + os.replace(temporary, path) + else: + os.link(temporary, path) + except OSError as e: + print("steam-compatibility: could not mark %s installed (%s)" % (app, e)) + continue + finally: + if temporary is not None: + try: + os.unlink(temporary) + except OSError: + pass + seeded.append(app) + return seeded + + def valve_proton_on_demand(): return os.environ.get(VALVE_PROTON_ENV) == "0" @@ -1782,6 +1860,11 @@ def main(): steam_root = sys.argv[1] if "--valve-proton-needed" in sys.argv[2:]: sys.exit(0 if valve_proton_needed(steam_root) else 1) + if "--seed-arm64-tools" in sys.argv[2:]: + seeded = seed_unavailable_arm64_tools(steam_root) + if seeded: + print("steam-compatibility: marked unavailable ARM64 tool(s) installed: %s" % ", ".join(seeded)) + return if "--x64" in sys.argv[2:]: x64_repoint(steam_root, os.environ.get("DD_COMPAT_TOOL"), "--live" in sys.argv[2:]) return diff --git a/tools/linuxfs/preload/inputudev.c b/tools/linuxfs/preload/inputudev.c index 346541c347..77152b105d 100644 --- a/tools/linuxfs/preload/inputudev.c +++ b/tools/linuxfs/preload/inputudev.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -15,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +36,9 @@ "NAME=\"Xbox 360 Controller (%d)\"\n" \ "PHYS=\"usb-fakeinput/input%d\"\n" +#define STEAM_VIRTUAL_VENDOR 0x28de +#define STEAM_VIRTUAL_PRODUCT 0x11ff + #define PARENT_NAME "droiddeck-input" #define PARENT_SYSPATH_FORMAT "/sys/devices/droiddeck%d/" PARENT_NAME "%d" #define EVENT_SYSPATH_FORMAT PARENT_SYSPATH_FORMAT "/event%d" @@ -49,6 +54,8 @@ struct pad { int live; }; +static const char *ring_uevent_format(void); + static struct pad pads[PAD_MAX]; static struct pad parents[PAD_MAX]; static int pad_count; @@ -89,7 +96,7 @@ static void discover_pads(void) { snprintf(pad->syspath, sizeof(pad->syspath), EVENT_SYSPATH_FORMAT, (int)slot, (int)slot, (int)slot); snprintf(pad->devnode, sizeof(pad->devnode), "/dev/input/event%ld", slot); - snprintf(pad->uevent, sizeof(pad->uevent), PAD_UEVENT_FORMAT, (int)slot, (int)slot); + snprintf(pad->uevent, sizeof(pad->uevent), ring_uevent_format(), (int)slot, (int)slot); pad->devnum = makedev(13, EVENT_MINOR_BASE + (unsigned int)slot); pad->node = (int)slot; pad->live = 1; @@ -137,6 +144,10 @@ static int any_virtual_pad(void) { return 0; } +static const char *ring_uevent_format(void) { + return uinput_enabled() && any_virtual_pad() ? PAD_PHYSICAL_UEVENT_FORMAT : PAD_UEVENT_FORMAT; +} + static void refresh_locked(int node) { struct pad *pad = &pads[node]; @@ -167,9 +178,7 @@ static void refresh_locked(int node) { } else { snprintf(pad->devnode, sizeof(pad->devnode), "/dev/input/event%d", node); pad->live = 1; - if (uinput_enabled()) - snprintf(pad->uevent, sizeof(pad->uevent), - any_virtual_pad() ? PAD_PHYSICAL_UEVENT_FORMAT : PAD_UEVENT_FORMAT, node, node); + snprintf(pad->uevent, sizeof(pad->uevent), ring_uevent_format(), node, node); } } sync_parent(node); @@ -441,11 +450,102 @@ static void *next_symbol(const char *name) { char *dd_cached_realpath(const char *path, char *resolved, char *(*real)(const char *, char *)) __attribute__((visibility("hidden"))); -static int caller_is_winebus(void *caller) { +static int caller_in_library(void *caller, const char *library) { Dl_info info; if (dladdr(caller, &info) == 0 || info.dli_fname == NULL) return 0; - return strstr(info.dli_fname, "winebus.so") != NULL; + return strstr(info.dli_fname, library) != NULL; +} + +static int caller_is_winebus(void *caller) { return caller_in_library(caller, "winebus.so"); } + +static int note_winebus(struct dl_phdr_info *info, size_t size, void *data) { + (void)size; + if (info->dlpi_name == NULL || strstr(info->dlpi_name, "winebus.so") == NULL) return 0; + *(int *)data = 1; + return 1; +} + +static int winebus_reads_udev(void) { + const char *x360 = getenv("FAKE_EVDEV_STEAM_PAD_AS_X360"); + int loaded = 0; + + if (x360 != NULL && atoi(x360) != 0) return 0; + dl_iterate_phdr(note_winebus, &loaded); + return loaded; +} + +static int ring_pad_fd(int fd) { + const char *spec = getenv("FAKE_EVDEV_MEMFD_PATHS"); + const char *entry; + struct stat opened; + struct stat ring; + char path[PATH_MAX]; + + if (spec == NULL || fstat(fd, &opened) != 0) return 0; + for (entry = spec; *entry != '\0';) { + char *end; + long slot = strtol(entry, &end, 10); + const char *next = strchr(entry, ';'); + size_t length; + + if (end != entry && *end == '=' && slot >= 0 && slot < RING_MAX) { + length = next != NULL ? (size_t)(next - end - 1) : strlen(end + 1); + if (length < sizeof(path)) { + memcpy(path, end + 1, length); + path[length] = '\0'; + if (stat(path, &ring) == 0 && ring.st_dev == opened.st_dev && ring.st_ino == opened.st_ino) return 1; + } + } + if (next == NULL) break; + entry = next + 1; + } + return 0; +} + +__attribute__((visibility("hidden"))) void dd_ring_pad_sdl_id(int fd, unsigned long request, void *arg, + void *caller, int rc) { + struct input_id *id = arg; + + if (rc != 0 || request != EVIOCGID || id == NULL) return; + if (!caller_in_library(caller, "libSDL") || !winebus_reads_udev() || !ring_pad_fd(fd)) return; + id->vendor = STEAM_VIRTUAL_VENDOR; + id->product = STEAM_VIRTUAL_PRODUCT; +} + +typedef int (*sdl_rumble_fn)(void *, uint16_t, uint16_t, uint32_t); +static _Atomic(sdl_rumble_fn) real_sdl_rumble; +static __thread int winebus_sdl_call; + +static int winebus_sdl_rumble(void *joystick, uint16_t low, uint16_t high, uint32_t duration) { + sdl_rumble_fn real = atomic_load_explicit(&real_sdl_rumble, memory_order_acquire); + int result; + + if (!caller_is_winebus(__builtin_return_address(0))) return real(joystick, low, high, duration); + if (low != 0 || high != 0) duration = 0; + winebus_sdl_call = 1; + result = real(joystick, low, high, duration); + winebus_sdl_call = 0; + return result; +} + +static void *winebus_sdl_rumble_dlsym(void *handle, const char *name) { + (void)handle; + (void)name; + return (void *)winebus_sdl_rumble; +} + +static void *sdl_rumble_target(void *handle, void *(*forward)(void *, const char *)) { + sdl_rumble_fn expected = NULL; + sdl_rumble_fn found; + + if (handle == RTLD_NEXT || handle == RTLD_DEFAULT) return NULL; + found = (sdl_rumble_fn)forward(handle, "SDL_JoystickRumble"); + if (found == NULL) return NULL; + atomic_compare_exchange_strong_explicit(&real_sdl_rumble, &expected, found, memory_order_acq_rel, + memory_order_acquire); + if (atomic_load_explicit(&real_sdl_rumble, memory_order_acquire) != found) return NULL; + return (void *)winebus_sdl_rumble_dlsym; } __attribute__((visibility("hidden"))) int dd_winebus_rumble_ioctl(int (*real)(int, unsigned long, void *), int fd, @@ -454,7 +554,8 @@ __attribute__((visibility("hidden"))) int dd_winebus_rumble_ioctl(int (*real)(in struct ff_effect *effect = arg; __u16 length; - if (request != EVIOCSFF || effect == NULL || effect->type != FF_RUMBLE || !caller_is_winebus(caller)) return 0; + if (request != EVIOCSFF || effect == NULL || effect->type != FF_RUMBLE) return 0; + if (!caller_is_winebus(caller) && !(winebus_sdl_call && caller_in_library(caller, "libSDL"))) return 0; length = effect->replay.length; effect->replay.length = 0; *rc = real(fd, request, arg); @@ -1195,7 +1296,10 @@ static void *own_dlsym(void *handle, const char *name) { __attribute__((visibility("hidden"), used)) void *inputudev_dlsym_target(void *handle, const char *name) { void *forward = real_dlsym(); - (void)handle; + if (forward != NULL && name != NULL && strcmp(name, "SDL_JoystickRumble") == 0) { + void *rumble = sdl_rumble_target(handle, forward); + if (rumble != NULL) return rumble; + } if (name != NULL && strncmp(name, "udev_", 5) == 0 && own_udev_symbol(name) != NULL && !steam_client_process()) return (void *)own_dlsym; diff --git a/tools/linuxfs/preload/netif.c b/tools/linuxfs/preload/netif.c index 38453ba5ab..6cd296b3d6 100644 --- a/tools/linuxfs/preload/netif.c +++ b/tools/linuxfs/preload/netif.c @@ -424,6 +424,8 @@ int dd_venc_ioctl(int fd, unsigned long request, void *arg, int *rc) __attribute int dd_vdec_ioctl(int fd, unsigned long request, void *arg, int *rc) __attribute__((visibility("hidden"))); int dd_winebus_rumble_ioctl(int (*real)(int, unsigned long, void *), int fd, unsigned long request, void *arg, void *caller, int *rc) __attribute__((visibility("hidden"))); +void dd_ring_pad_sdl_id(int fd, unsigned long request, void *arg, void *caller, int rc) + __attribute__((visibility("hidden"))); int dd_writewatch_ioctl(int (*real)(int, unsigned long, void *), int fd, unsigned long request, void *arg, int *rc) __attribute__((visibility("hidden"))); @@ -444,6 +446,7 @@ int ioctl(int fd, unsigned long request, ...) { if (dd_winebus_rumble_ioctl(real, fd, request, arg, __builtin_return_address(0), &rc)) return rc; if (dd_writewatch_ioctl(real, fd, request, arg, &rc)) return rc; if (!dd_kgsl_poll(real, fd, request, arg, &rc)) rc = quest_kgsl_ioctl(real, fd, request, arg); + dd_ring_pad_sdl_id(fd, request, arg, __builtin_return_address(0), rc); dd_kgsl_track(real, fd, request, arg, &rc); dd_kgsl_chip_id_fixup(request, arg, rc); if (arg == NULL || !is_link_query(request)) return rc; diff --git a/tools/linuxfs/preload/zram.c b/tools/linuxfs/preload/zram.c index ad13d8258b..7fc21d0cab 100644 --- a/tools/linuxfs/preload/zram.c +++ b/tools/linuxfs/preload/zram.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,7 @@ #ifndef ZR_CTL #define ZR_CTL "/tmp/.dd-zram" #endif +#define ZR_PATH 256 #define ZR_SWAPPED (1ULL << 62) #define ZR_PRESENT (1ULL << 63) #define ZR_BATCH 512 @@ -213,6 +215,9 @@ static char *zr_find(char *text, char c, size_t n) { return NULL; } +static char zr_ctl[ZR_PATH] = ZR_CTL; +static char zr_hold[ZR_PATH + sizeof(".hold")]; + static int zr_open(const char *path) { return (int)zr_sys(SYS_openat, AT_FDCWD, path, O_RDONLY | O_CLOEXEC, 0); } @@ -220,13 +225,13 @@ static int zr_open(const char *path) { static int zr_mode(unsigned long *want) { char text[24]; long n = 0; - int fd = zr_open(ZR_CTL ".hold"); + int fd = zr_open(zr_hold); if (fd >= 0) { n = zr_sys(SYS_read, fd, text, sizeof(text)); zr_sys(SYS_close, fd); } if (n < 1) { - fd = zr_open(ZR_CTL); + fd = zr_open(zr_ctl); if (fd < 0) return -1; n = zr_sys(SYS_read, fd, text, sizeof(text)); zr_sys(SYS_close, fd); @@ -413,10 +418,10 @@ static unsigned long zr_walk(int mode, unsigned long want, unsigned long lo, uns static void zr_ack(long value, int trim) { const char *suffix = trim ? ".trim." : ".ack."; - char path[sizeof(ZR_CTL) + sizeof(".trim.") + 20]; + char path[sizeof(zr_ctl) + sizeof(".trim.") + 20]; char digits[20]; size_t n = 0, d = 0; - for (const char *p = ZR_CTL; *p; p++) path[n++] = *p; + for (const char *p = zr_ctl; *p; p++) path[n++] = *p; for (const char *p = suffix; *p; p++) path[n++] = *p; long pid = zr_sys(SYS_getpid); do digits[d++] = (char)('0' + pid % 10); while ((pid /= 10) > 0); @@ -547,8 +552,23 @@ static void zr_child(void) { __atomic_store_n(&zr_stack_busy, 0, __ATOMIC_RELEASE); } +// The native userland hook maps guest paths in libc only; these raw calls see the host's paths. +static void zr_paths(void) { + const char *root = getenv("DDNATV_ROOT"); + size_t r = root && root[0] == '/' ? strlen(root) : 0, c = sizeof(ZR_CTL) - 1; + while (r > 1 && root[r - 1] == '/') r--; + if (r > 1 && ZR_CTL[0] == '/' && r + c < sizeof(zr_ctl)) { + memcpy(zr_ctl, root, r); + memcpy(zr_ctl + r, ZR_CTL, c + 1); + } + size_t n = strlen(zr_ctl); + memcpy(zr_hold, zr_ctl, n); + memcpy(zr_hold + n, ".hold", sizeof(".hold")); +} + __attribute__((constructor)) static void zr_init(void) { - int fd = zr_open(ZR_CTL); + zr_paths(); + int fd = zr_open(zr_ctl); if (fd < 0) return; zr_sys(SYS_close, fd); long page = sysconf(_SC_PAGESIZE); diff --git a/tools/nativeguest/hook/env.c b/tools/nativeguest/hook/env.c index fd6824d3b7..7c9a1ac77e 100644 --- a/tools/nativeguest/hook/env.c +++ b/tools/nativeguest/hook/env.c @@ -93,6 +93,7 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe, const // are compared (this was 13 strncmp() calls for each of the 30 or so variables) int has_nt = 0; int has_binds = 0; + int has_binds_kernel = 0; int has_hostname = 0; int has_link_root = 0; int has_exec_loader = 0; @@ -121,6 +122,7 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe, const if (strncmp(e, "DDNATV_ROOT=", 12) == 0) has_root = 1; else if (strncmp(e, "DDNATV_NT=", 10) == 0) has_nt = 1; else if (strncmp(e, "DDNATV_BINDS=", 13) == 0) has_binds = 1; + else if (strncmp(e, "DDNATV_BINDS_KERNEL=", 20) == 0) has_binds_kernel = 1; else if (strncmp(e, "DDNATV_PRELOAD=", 15) == 0) has_preload_list = 1; else if (strncmp(e, "DDNATV_HOSTNAME=", 16) == 0) has_hostname = 1; else if (strncmp(e, "DDNATV_LINK_ROOT=", 17) == 0) has_link_root = 1; @@ -255,6 +257,15 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe, const new_env[dst++] = str; } } + if (!has_binds_kernel && g_binds_kernel) { + size_t kernel_len = strlen(g_binds_kernel); + char *kernel = malloc(20 + kernel_len + 1); + if (kernel) { + memcpy(kernel, "DDNATV_BINDS_KERNEL=", 20); + memcpy(kernel + 20, g_binds_kernel, kernel_len + 1); + new_env[dst++] = kernel; + } + } // This process looked for the ARM translator's files and found none: the programs it starts // need not look again (it takes a look at /proc/self/fd in each of them, see privileged.c) if (!has_nt && g_no_translator) { diff --git a/tools/nativeguest/hook/exec.c b/tools/nativeguest/hook/exec.c index b4249eb06c..546531c6dd 100644 --- a/tools/nativeguest/hook/exec.c +++ b/tools/nativeguest/hook/exec.c @@ -452,7 +452,8 @@ static int ddnatv_execve(const char *filename, char *const argv[], char *const e char resolved_target[PATH_MAX]; // Only intercept binaries/scripts within DDNATV_ROOT - if ((g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(filename)) { + if ((g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(filename) || + is_bound_guest_program(target)) { struct exec_probe probe; const char *elf_target = select_exec_target(target, resolved_target, sizeof(resolved_target), &probe); if (probe.is_elf && !probe.is_dynamic) static_elf = elf_target; @@ -969,7 +970,8 @@ static int ddnatv_posix_spawn(pid_t *pid, const char *path, } char *const *orig_ep = envp ? envp : environ; - int in_root = (g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(path); + int in_root = (g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(path) || + is_bound_guest_program(target); struct exec_probe probe; char resolved_target[PATH_MAX]; @@ -1161,6 +1163,7 @@ int system(const char *command) { int status = -1; pid_t pid = start_shell(command, -1, -1, &old, &intr, &quit, 0); + if (pid < 0) status = 127 << 8; // as glibc's system() when the shell could not be started if (pid > 0) { while (waitpid(pid, &status, 0) < 0) { if (errno != EINTR) { @@ -1192,28 +1195,52 @@ static pthread_mutex_t g_popen_lock = PTHREAD_MUTEX_INITIALIZER; static pid_t start_shell(const char *command, int child_fd, int target_fd, const sigset_t *mask, const struct sigaction *intr, const struct sigaction *quit, int close_popen_streams) { - pid_t pid = fork(); - if (pid != 0) return pid; - if (intr) sigaction(SIGINT, intr, NULL); - if (quit) sigaction(SIGQUIT, quit, NULL); - if (mask) sigprocmask(SIG_SETMASK, mask, NULL); + // Through posix_spawn(), as glibc does: its child only makes system calls. A forked child running + // the exec code here would take locks that another thread of a multithreaded caller may have held + // at fork(), and wait for them forever (Steam's popen()s did, and its main loop stalled). + posix_spawn_file_actions_t actions; + posix_spawnattr_t attr; + if (posix_spawn_file_actions_init(&actions) != 0) return -1; + if (posix_spawnattr_init(&attr) != 0) { + posix_spawn_file_actions_destroy(&actions); + return -1; + } + int err = 0; if (child_fd >= 0) { - if (child_fd == target_fd) { - fcntl(target_fd, F_SETFD, 0); - } else if (dup2(child_fd, target_fd) < 0) { - _exit(127); - } + // dup2 onto itself clears FD_CLOEXEC in the child (glibc 2.29 and later) + err = posix_spawn_file_actions_adddup2(&actions, child_fd, target_fd); } // POSIX: the streams of earlier popen() calls are not open in the new shell - if (close_popen_streams) { - for (struct ddnatv_popen *p = g_popen_streams; p; p = p->next) { - int fd = fileno(p->fp); - if (fd >= 0 && fd != target_fd) close(fd); - } + for (struct ddnatv_popen *p = g_popen_streams; !err && close_popen_streams && p; p = p->next) { + int fd = fileno(p->fp); + if (fd >= 0 && fd != target_fd) err = posix_spawn_file_actions_addclose(&actions, fd); } + short flags = 0; + if (!err && mask) { + posix_spawnattr_setsigmask(&attr, mask); + flags |= POSIX_SPAWN_SETSIGMASK; + } + // SIGINT and SIGQUIT as they were before system() ignored them: an exec keeps an ignored signal + // ignored and puts a handled one back to the default + sigset_t defaults; + sigemptyset(&defaults); + if (intr && intr->sa_handler != SIG_IGN) sigaddset(&defaults, SIGINT); + if (quit && quit->sa_handler != SIG_IGN) sigaddset(&defaults, SIGQUIT); + if (!err && (intr || quit)) { + posix_spawnattr_setsigdefault(&attr, &defaults); + flags |= POSIX_SPAWN_SETSIGDEF; + } + if (!err) err = posix_spawnattr_setflags(&attr, flags); + pid_t pid = -1; char *const argv[] = { (char *)"sh", (char *)"-c", (char *)command, NULL }; - ddnatv_execve("/bin/sh", argv, environ, 0); - _exit(127); + if (!err) err = posix_spawn(&pid, "/bin/sh", &actions, &attr, argv, environ); + posix_spawn_file_actions_destroy(&actions); + posix_spawnattr_destroy(&attr); + if (err) { + errno = err; + return -1; + } + return pid; } FILE *popen(const char *command, const char *type) { diff --git a/tools/nativeguest/hook/exec_probe.c b/tools/nativeguest/hook/exec_probe.c index be708e9158..32dabeb982 100644 --- a/tools/nativeguest/hook/exec_probe.c +++ b/tools/nativeguest/hook/exec_probe.c @@ -983,6 +983,14 @@ static int is_host_interpreter(const char *interp, const char *rewritten) { return probe.android_interp; } +static int is_bound_guest_program(const char *path) { + if (g_ddnatv_root[0] == '\0' || !is_identity_bound_path(path)) return 0; + struct exec_probe probe; + probe_exec_file(path, &probe); + if (probe.is_elf) return probe.is_dynamic && !probe.android_interp; + return probe.n >= 2 && probe.hdr[0] == '#' && probe.hdr[1] == '!'; +} + // argv for running `script` with its interpreter: interp [arg] script args... (the script's own // argv[0] is dropped, as the kernel does). free() the result. static char **build_script_argv(const char *interp, const char *interp_arg, const char *script, char *const argv[]) { diff --git a/tools/nativeguest/hook/fileops.c b/tools/nativeguest/hook/fileops.c index 840812fe69..a515e6a248 100644 --- a/tools/nativeguest/hook/fileops.c +++ b/tools/nativeguest/hook/fileops.c @@ -739,10 +739,8 @@ char *getcwd(char *buf, size_t size) { static char *(*orig_getcwd)(char *, size_t) = NULL; if (!orig_getcwd) orig_getcwd = (char *(*)(char *, size_t))dlsym(RTLD_NEXT, "getcwd"); char *res = orig_getcwd ? orig_getcwd(buf, size) : NULL; - if (res) { - size_t len = strlen(res); - guest_path_of_mount_source(res, len, buf ? size : len + 1, NULL); - } + if (res && !buf) return guest_path_of_allocated_mount_source(res); + if (res) guest_path_of_mount_source(res, strlen(res), size, NULL); return res; } @@ -790,7 +788,8 @@ char *realpath(const char *path, char *resolved_path) { } } } - if (res) guest_path_of_mount_source(res, strlen(res), resolved_path ? PATH_MAX : strlen(res) + 1, NULL); + if (res && !resolved_path) return guest_path_of_allocated_mount_source(res); + if (res) guest_path_of_mount_source(res, strlen(res), PATH_MAX, NULL); return res; } diff --git a/tools/nativeguest/hook/paths.c b/tools/nativeguest/hook/paths.c index 18f933afa8..74983a7552 100644 --- a/tools/nativeguest/hook/paths.c +++ b/tools/nativeguest/hook/paths.c @@ -14,15 +14,36 @@ static size_t g_ddnatv_root_len = 0; // The path the kernel reports for [path] (/proc/self/fd, getcwd(), realpath()): for a targetSdk 30+ // app, Android's own /data/user/0 is a link to /data/data, so the app's paths are not what the kernel // gives back for them. Into out, or path itself when it cannot be resolved; returns out's length. -static size_t ddnatv_kernel_path(const char *path, size_t len, char *out, size_t outsz) { - static char *(*libc_realpath)(const char *, char *) = NULL; +static char *(*libc_realpath)(const char *, char *) = NULL; +static long (*libc_syscall)(long, ...) = NULL; + +static void ddnatv_resolve_libc(void) { if (!libc_realpath) libc_realpath = (char *(*)(const char *, char *))dlsym(RTLD_NEXT, "realpath"); + if (!libc_syscall) libc_syscall = (long (*)(long, ...))dlsym(RTLD_NEXT, "syscall"); +} + +static size_t ddnatv_resolve_path(const char *path, size_t len, char *out, size_t outsz, int *found) { + ddnatv_resolve_libc(); char given[PATH_MAX]; if (len >= sizeof(given)) len = sizeof(given) - 1; memcpy(given, path, len); given[len] = '\0'; char resolved[PATH_MAX]; - const char *use = (libc_realpath && libc_realpath(given, resolved)) ? resolved : given; + const char *use = given; + int fd = libc_syscall && given[0] == '/' && strncmp(given, "/proc/", 6) != 0 + ? (int)libc_syscall(SYS_openat, AT_FDCWD, given, O_PATH | O_CLOEXEC) : -1; + if (fd >= 0) { + char link[32]; + snprintf(link, sizeof(link), "/proc/self/fd/%d", fd); + ssize_t n = libc_syscall(SYS_readlinkat, AT_FDCWD, link, resolved, sizeof(resolved) - 1); + libc_syscall(SYS_close, fd); + if (n > 0 && resolved[0] == '/') { + resolved[n] = '\0'; + use = resolved; + } + } + if (use == given && libc_realpath && libc_realpath(given, resolved)) use = resolved; + if (found) *found = use != given; size_t n = strlen(use); if (n >= outsz) n = outsz - 1; memcpy(out, use, n); @@ -30,6 +51,10 @@ static size_t ddnatv_kernel_path(const char *path, size_t len, char *out, size_t return n; } +static size_t ddnatv_kernel_path(const char *path, size_t len, char *out, size_t outsz) { + return ddnatv_resolve_path(path, len, out, outsz, NULL); +} + static void ddnatv_set_root(const char *root, size_t len) { if (!root) len = 0; if (len > 0) len = ddnatv_kernel_path(root, len, g_ddnatv_root, sizeof(g_ddnatv_root)); @@ -45,12 +70,14 @@ struct ddnatv_bind { size_t src_len, dst_len; int identity; int links; + int resolved; int order; // position in DDNATV_BINDS: the earlier of two mounts of one folder is its guest path }; // as many as the session has: a fixed table dropped what came after its 128th entry static struct ddnatv_bind *g_binds = NULL; static int g_nbinds = 0; static char *g_binds_raw = NULL; +static char *g_binds_kernel = NULL; // The session's host name (DDNATV_HOSTNAME), what proot put in uname(): Android's kernel says "localhost" static char g_hostname[65]; // A Flatpak sandbox's: the session's rootfs (DDNATV_LINK_ROOT), whose hook stored absolute guest @@ -64,7 +91,18 @@ static int ddnatv_bind_longer_first(const void *a, const void *b) { return (y->dst_len > x->dst_len) - (y->dst_len < x->dst_len); } -static void ddnatv_load_binds(const char *spec) { +static size_t ddnatv_append(char *out, size_t outsz, size_t used, const char *s, size_t len); + +static uint64_t ddnatv_hash(const char *s) { + uint64_t h = 1469598103934665603ULL; + for (; *s; s++) { + h ^= (unsigned char)*s; + h *= 1099511628211ULL; + } + return h; +} + +static void ddnatv_load_binds(const char *spec, const char *known) { if (!spec || !spec[0]) return; char *raw = strdup(spec); char *copy = strdup(spec); @@ -73,18 +111,47 @@ static void ddnatv_load_binds(const char *spec) { size_t count = 1; for (const char *c = spec; *c; c++) count += *c == '|'; g_binds = calloc(count, sizeof(*g_binds)); - if (!g_binds) { free(raw); free(copy); return; } + const char **given = calloc(count, sizeof(*given)); + if (!g_binds || !given) { free(g_binds); g_binds = NULL; free(given); free(raw); free(copy); return; } + char hash[17]; + snprintf(hash, sizeof(hash), "%016llx", (unsigned long long)ddnatv_hash(spec)); + char *cache = known && strncmp(known, hash, 16) == 0 && known[16] == '|' ? strdup(known + 17) : NULL; + char *next = cache; for (char *entry = strtok_r(copy, "|", &save); entry && (size_t)g_nbinds < count; entry = strtok_r(NULL, "|", &save)) { char *colon = strchr(entry, ':'); const char *src = entry; const char *dst = colon ? colon + 1 : entry; if (colon) *colon = '\0'; if (src[0] != '/' || dst[0] != '/' || strcmp(dst, "/") == 0) continue; - struct ddnatv_bind *b = &g_binds[g_nbinds++]; + char *cached = next; + if (next) { + char *bar = strchr(next, '|'); + if (bar) *bar = '\0'; + next = bar ? bar + 1 : NULL; + } + int index = g_nbinds++; + struct ddnatv_bind *b = &g_binds[index]; + given[index] = src; char kernel_src[PATH_MAX]; if (strcmp(src, dst) != 0) { - ddnatv_kernel_path(src, strlen(src), kernel_src, sizeof(kernel_src)); - if (strncmp(kernel_src, "/proc/", 6) != 0 || kernel_src[6] < '0' || kernel_src[6] > '9') src = kernel_src; + if (cached && cached[0] == '/') { + src = cached; + b->resolved = 1; + } else { + for (int j = 0; j < index && !b->resolved; j++) { + if (g_binds[j].resolved && strcmp(given[j], src) == 0) { + src = g_binds[j].src; + b->resolved = 1; + } + } + if (!b->resolved) { + ddnatv_resolve_path(src, strlen(src), kernel_src, sizeof(kernel_src), &b->resolved); + const char *lead = src; + while (lead[0] == '/' && lead[1] == '/') lead++; + if (strncmp(lead, "/proc/", 6) == 0 || strchr(kernel_src, '|')) b->resolved = 0; + if (strncmp(kernel_src, "/proc/", 6) != 0 || kernel_src[6] < '0' || kernel_src[6] > '9') src = kernel_src; + } + } } b->src = strdup(src); b->dst = strdup(dst); @@ -93,8 +160,23 @@ static void ddnatv_load_binds(const char *spec) { while (b->dst_len > 1 && b->dst[b->dst_len - 1] == '/') b->dst[--b->dst_len] = '\0'; while (b->src_len > 1 && b->src[b->src_len - 1] == '/') b->src[--b->src_len] = '\0'; b->identity = strcmp(b->src, b->dst) == 0; - b->order = g_nbinds - 1; + b->order = index; } + size_t size = 17; + for (int i = 0; i < g_nbinds; i++) size += 1 + (g_binds[i].resolved ? g_binds[i].src_len : 0); + long page = sysconf(_SC_PAGESIZE); + char *table = size + 21 <= (size_t)(page > 0 ? page : 4096) * 32 ? malloc(size + 1) : NULL; + if (table) { + size_t used = ddnatv_append(table, size + 1, 0, hash, 16); + for (int i = 0; i < g_nbinds; i++) { + used = ddnatv_append(table, size + 1, used, "|", 1); + if (g_binds[i].resolved) used = ddnatv_append(table, size + 1, used, g_binds[i].src, g_binds[i].src_len); + } + if (!known || strcmp(known, table) != 0) setenv("DDNATV_BINDS_KERNEL", table, 1); + g_binds_kernel = table; + } + free(cache); + free(given); free(copy); qsort(g_binds, (size_t)g_nbinds, sizeof(g_binds[0]), ddnatv_bind_longer_first); g_binds_raw = raw; @@ -152,6 +234,13 @@ static int is_mapped_guest_path(const char *path) { return 0; } +static int is_identity_bound_path(const char *path) { + if (!path || path[0] != '/') return 0; + for (int i = 0; i < g_nbinds; i++) + if (g_binds[i].identity && is_path_prefix(path, g_binds[i].dst, g_binds[i].dst_len)) return 1; + return 0; +} + // Android's own mounts and files, which must never be redirected into the rootfs. // `path` starts with '/'; a prefix can only match when its second character does. static int is_android_host_path(const char *path) { @@ -886,6 +975,20 @@ static size_t guest_path_of_mount_source(char *buf, size_t len, size_t cap, int return best->dst_len + rest; } +static char *guest_path_of_allocated_mount_source(char *res) { + size_t len = strlen(res); + char tmp[PATH_MAX]; + if (len >= sizeof(tmp)) return res; + memcpy(tmp, res, len + 1); + int converted = 0; + size_t n = guest_path_of_mount_source(tmp, len, sizeof(tmp), &converted); + if (!converted) return res; + char *grown = realloc(res, n + 1); + if (!grown) return res; + memcpy(grown, tmp, n + 1); + return grown; +} + static ssize_t postprocess_readlink(const char *linkpath, char *buf, ssize_t ret, size_t bufsiz) { if (ret <= 0) return ret; if ((size_t)ret < bufsiz) { diff --git a/tools/nativeguest/hook/setup.c b/tools/nativeguest/hook/setup.c index 599bccb142..f44604f9c8 100644 --- a/tools/nativeguest/hook/setup.c +++ b/tools/nativeguest/hook/setup.c @@ -36,7 +36,7 @@ static void init_ddnatv_hook(void) { } } } - ddnatv_load_binds(getenv("DDNATV_BINDS")); + ddnatv_load_binds(getenv("DDNATV_BINDS"), getenv("DDNATV_BINDS_KERNEL")); const char *mount_table = getenv("DDNATV_MOUNTINFO"); if (mount_table && mount_table[0] == '/' && strlen(mount_table) < sizeof(g_mount_table)) ddnatv_copy_cstr(g_mount_table, sizeof(g_mount_table), mount_table); @@ -228,6 +228,7 @@ static void adopt_forwarded_fds(void) { __attribute__((constructor(103))) static void init_ddnatv_hook_early(int argc, char **argv) { adopt_forwarded_fds(); + ddnatv_resolve_libc(); init_ddnatv_hook(); compact_loader_args(argc, argv); // The kernel names the process after what it executed, the rootfs ld.so: process monitors, and diff --git a/tools/release/check_session_assets.py b/tools/release/check_session_assets.py index dc0828bec0..8d2eb0b75a 100644 --- a/tools/release/check_session_assets.py +++ b/tools/release/check_session_assets.py @@ -32,6 +32,7 @@ def source_assets(overlay=OVERLAY): result[desktop / name] = 'assets/linuxfs/usr/local/bin/' + name result[desktop / 'firefox-droiddeck.js'] = 'assets/linuxfs/usr/lib/firefox/defaults/pref/droiddeck.js' result[desktop / 'droiddeck-clipboard.desktop'] = 'assets/linuxfs/etc/xdg/autostart/droiddeck-clipboard.desktop' + result[desktop / 'droiddeck-return-gaming.desktop'] = 'assets/linuxfs/usr/share/applications/droiddeck-return-gaming.desktop' result[desktop / 'fastfetch.jsonc'] = 'assets/linuxfs/etc/xdg/fastfetch/config.jsonc' result[overlay.parent.parent / 'mangoapp/mangoapp'] = 'assets/linuxfs/usr/local/bin/mangoapp' return result diff --git a/tools/tests/ddfg_flow_levels_harness.cpp b/tools/tests/ddfg_flow_levels_harness.cpp index e5cf7bf701..4c8fdb30d4 100644 --- a/tools/tests/ddfg_flow_levels_harness.cpp +++ b/tools/tests/ddfg_flow_levels_harness.cpp @@ -1,4 +1,5 @@ #include "framegen.hpp" +#include "ddfg_engine.h" #include #include #include @@ -25,12 +26,19 @@ std::map buffers; std::map allocations; std::map buffer_memory; std::map> descriptors; +std::map set_pools; +std::map pool_capacities; std::map pipelines; std::map image_ids; std::map buffer_ids; std::vector dispatches; +std::vector external_views; uintptr_t serial = 100; -unsigned buffer_creates, set_creates; +unsigned buffer_creates, set_creates, pipeline_creates, idle_calls, image_creates, fail_image_at; +bool gpu_pending; +VkResult idle_result = VK_SUCCESS, reset_result = VK_SUCCESS; +const ddfg::DeviceDispatch *engine_dispatch; +const ddfg::InstanceDispatch *engine_instance; VkPipeline bound_pipeline; VkDescriptorSet bound_set; uint64_t command_hash = 14695981039346656037ull; @@ -61,6 +69,7 @@ template void VKAPI_CALL destroy(VkDevice, T, const VkAllocationCallbac VkResult VKAPI_CALL create_image(VkDevice, const VkImageCreateInfo *info, const VkAllocationCallbacks *, VkImage *out) { + if (++image_creates == fail_image_at) return VK_ERROR_OUT_OF_DEVICE_MEMORY; *out = handle(); images[*out] = {info->extent, info->format, info->usage}; return VK_SUCCESS; @@ -73,9 +82,11 @@ VkResult VKAPI_CALL create_view(VkDevice, const VkImageViewCreateInfo *info, return VK_SUCCESS; } void VKAPI_CALL destroy_image(VkDevice, VkImage image, const VkAllocationCallbacks *) { + assert(!gpu_pending); assert(images.erase(image) == 1); } void VKAPI_CALL destroy_view(VkDevice, VkImageView view, const VkAllocationCallbacks *) { + assert(!gpu_pending); assert(views.erase(view) == 1); } VkResult VKAPI_CALL create_buffer(VkDevice, const VkBufferCreateInfo *info, @@ -86,6 +97,7 @@ VkResult VKAPI_CALL create_buffer(VkDevice, const VkBufferCreateInfo *info, return VK_SUCCESS; } void VKAPI_CALL destroy_buffer(VkDevice, VkBuffer buffer, const VkAllocationCallbacks *) { + assert(!gpu_pending); assert(buffers.erase(buffer) == 1); buffer_memory.erase(buffer); } @@ -104,6 +116,7 @@ VkResult VKAPI_CALL allocate(VkDevice, const VkMemoryAllocateInfo *info, return VK_SUCCESS; } void VKAPI_CALL free_memory(VkDevice, VkDeviceMemory memory, const VkAllocationCallbacks *) { + assert(!gpu_pending); assert(allocations.erase(memory) == 1); } VkResult VKAPI_CALL bind_image(VkDevice, VkImage image, VkDeviceMemory memory, VkDeviceSize) { @@ -123,8 +136,14 @@ VkResult VKAPI_CALL map_memory(VkDevice, VkDeviceMemory memory, VkDeviceSize off *out = allocation.data.get(); return VK_SUCCESS; } -void VKAPI_CALL unmap(VkDevice, VkDeviceMemory memory) { assert(allocations.count(memory)); } -VkResult VKAPI_CALL idle(VkDevice) { return VK_SUCCESS; } +void VKAPI_CALL unmap(VkDevice, VkDeviceMemory memory) { + assert(!gpu_pending && allocations.count(memory)); +} +VkResult VKAPI_CALL idle(VkDevice) { + idle_calls++; + if (idle_result == VK_SUCCESS) gpu_pending = false; + return idle_result; +} void VKAPI_CALL memory_properties(VkPhysicalDevice, VkPhysicalDeviceMemoryProperties *out) { *out = {}; out->memoryTypeCount = 1; @@ -132,15 +151,42 @@ void VKAPI_CALL memory_properties(VkPhysicalDevice, VkPhysicalDeviceMemoryProper VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; } VkResult VKAPI_CALL allocate_sets(VkDevice, const VkDescriptorSetAllocateInfo *info, VkDescriptorSet *out) { + const auto used = std::count_if(set_pools.begin(), set_pools.end(), [&](const auto &entry) { + return entry.second == info->descriptorPool; + }); + if (used + info->descriptorSetCount > pool_capacities.at(info->descriptorPool)) + return VK_ERROR_OUT_OF_POOL_MEMORY; for (uint32_t i = 0; i < info->descriptorSetCount; i++) { out[i] = handle(); descriptors[out[i]] = {}; + set_pools[out[i]] = info->descriptorPool; set_creates++; } return VK_SUCCESS; } -VkResult VKAPI_CALL reset_pool(VkDevice, VkDescriptorPool, VkDescriptorPoolResetFlags) { - descriptors.clear(); +VkResult VKAPI_CALL create_pool(VkDevice, const VkDescriptorPoolCreateInfo *info, + const VkAllocationCallbacks *, VkDescriptorPool *out) { + *out = handle(); + pool_capacities[*out] = info->maxSets; + return VK_SUCCESS; +} +void drop_sets(VkDescriptorPool pool) { + assert(!gpu_pending); + for (auto it = set_pools.begin(); it != set_pools.end();) { + if (it->second == pool) { + descriptors.erase(it->first); + it = set_pools.erase(it); + } else ++it; + } +} +void VKAPI_CALL destroy_pool(VkDevice, VkDescriptorPool pool, const VkAllocationCallbacks *) { + drop_sets(pool); + assert(pool_capacities.erase(pool) == 1); +} +VkResult VKAPI_CALL reset_pool(VkDevice, VkDescriptorPool pool, VkDescriptorPoolResetFlags) { + assert(!gpu_pending); + if (reset_result != VK_SUCCESS) return reset_result; + drop_sets(pool); return VK_SUCCESS; } void VKAPI_CALL update_sets(VkDevice, uint32_t count, const VkWriteDescriptorSet *writes, @@ -164,12 +210,15 @@ VkResult VKAPI_CALL create_pipelines(VkDevice, VkPipelineCache, uint32_t count, const VkComputePipelineCreateInfo *, const VkAllocationCallbacks *, VkPipeline *out) { for (uint32_t i = 0; i < count; i++) { - const auto index = static_cast(pipelines.size()); + const auto index = pipeline_creates++ % 10; out[i] = handle(); pipelines[out[i]] = index; } return VK_SUCCESS; } +void VKAPI_CALL destroy_pipeline(VkDevice, VkPipeline pipeline, const VkAllocationCallbacks *) { + assert(!gpu_pending && pipelines.erase(pipeline) == 1); +} void VKAPI_CALL bind_pipeline(VkCommandBuffer, VkPipelineBindPoint, VkPipeline pipeline) { assert(pipelines.count(pipeline)); bound_pipeline = pipeline; @@ -248,10 +297,20 @@ VkImageView external_image(uint32_t width, uint32_t height) { images[image] = {{width, height, 1}, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT}; views[view] = image; + external_views.push_back(view); return view; } +void clear_external_images() { + for (auto view : external_views) { + images.erase(views.at(view)); + views.erase(view); + } + external_views.clear(); +} + void record(ddfg::FrameGen &fg, int model, uint32_t width, uint32_t height, unsigned generations) { + gpu_pending = false; const auto previous = external_image(width, height), current = external_image(width, height); const auto first = dispatches.size(); for (unsigned i = 0; i < generations; i++) @@ -275,14 +334,29 @@ void record(ddfg::FrameGen &fg, int model, uint32_t width, uint32_t height, unsi const auto &actual = dispatches[first + i], &want = expected[i]; assert(actual.pipeline == want.pipeline && actual.x == want.x && actual.y == want.y && actual.z == want.z); } - for (auto it = views.begin(); it != views.end();) { - if (images.at(it->second).format == VK_FORMAT_R8G8B8A8_UNORM) { - images.erase(it->second); - it = views.erase(it); - } else ++it; - } + clear_external_images(); + gpu_pending = true; } +void check_empty() { + assert(images.empty() && views.empty() && buffers.empty() && allocations.empty()); + assert(descriptors.empty() && set_pools.empty() && pool_capacities.empty() && pipelines.empty()); +} + +void check_working_set(const ddfg::FrameGen &fg) { + assert(images.size() == static_cast(32 - 2 * fg.flowFinest())); + assert(buffers.size() == static_cast(18 - fg.flowFinest())); + assert(descriptors.size() == static_cast(54 - 4 * fg.flowFinest())); + assert(allocations.size() == images.size() + buffers.size()); +} + +} + +struct VkTable {}; +bool ddfgVkdInit(const VkTable &, ddfg::DeviceDispatch &dd, ddfg::InstanceDispatch &id) { + dd = *engine_dispatch; + id = *engine_instance; + return true; } int main(int argc, char **argv) { @@ -312,25 +386,145 @@ int main(int argc, char **argv) { dd.DestroyDescriptorSetLayout = destroy; dd.CreatePipelineLayout = create; dd.DestroyPipelineLayout = destroy; - dd.CreateDescriptorPool = create; - dd.DestroyDescriptorPool = destroy; dd.ResetDescriptorPool = reset_pool; + dd.CreateDescriptorPool = create_pool; + dd.DestroyDescriptorPool = destroy_pool; dd.ResetDescriptorPool = reset_pool; dd.AllocateDescriptorSets = allocate_sets; dd.UpdateDescriptorSets = update_sets; - dd.CreateComputePipelines = create_pipelines; dd.DestroyPipeline = destroy; + dd.CreateComputePipelines = create_pipelines; dd.DestroyPipeline = destroy_pipeline; dd.CmdBindPipeline = bind_pipeline; dd.CmdBindDescriptorSets = bind_sets; dd.CmdDispatch = dispatch; dd.CmdPipelineBarrier = barrier; dd.CmdClearColorImage = clear_image; dd.CmdCopyImage = copy_image; - ddfg::FrameGen fg; - assert(fg.init(&dd, &id, reinterpret_cast(1), reinterpret_cast(2), - 0, reinterpret_cast(3))); + engine_dispatch = ⅆ + engine_instance = &id; ddfg::Config cfg; cfg.enabled = true; cfg.model = model; cfg.perfPreset = preset; cfg.flowScale = 0.6f; - fg.configure(cfg); - assert(fg.onResize({width, height}, VK_FORMAT_R8G8B8A8_UNORM)); + auto initialize = [&](ddfg::FrameGen &fg) { + assert(fg.init(&dd, &id, reinterpret_cast(1), reinterpret_cast(2), + 0, reinterpret_cast(3))); + fg.configure(cfg); + assert(fg.onResize({width, height}, VK_FORMAT_R8G8B8A8_UNORM)); + }; + if (mode == "steady" || mode == "automatic") { + const auto waits = idle_calls; + { + ddfg::FrameGen fg; + initialize(fg); + for (unsigned repeat = 0; repeat < repeats; repeat++) { + record(fg, model, width, height, generations); + assert(fg.onResize({width, height}, VK_FORMAT_R8G8B8A8_UNORM)); + assert(idle_calls == waits); + check_working_set(fg); + } + if (mode == "steady") { + fg.destroy(); + fg.destroy(); + assert(idle_calls == waits + 1); + } + } + check_empty(); + assert(idle_calls == waits + 1); + std::puts("PASS lifecycle=steady-and-idempotent-destruction"); + return 0; + } + if (mode == "restart" || mode == "instances") { + for (unsigned repeat = 0; repeat < repeats; repeat++) { + ddfg::FrameGen first; + initialize(first); + record(first, model, width, height, generations); + check_working_set(first); + if (mode == "instances") { + gpu_pending = false; + ddfg::FrameGen second; + initialize(second); + record(second, model, width, height, generations); + first.destroy(); + record(second, model, width, height, generations); + check_working_set(second); + second.destroy(); + } else first.destroy(); + check_empty(); + } + std::puts("PASS lifecycle=restart-and-instance-isolation"); + return 0; + } + if (mode == "engine" || mode == "engine-failure") { + { + ddfg::Engine engine; + assert(engine.init(VkTable{}, reinterpret_cast(1), + reinterpret_cast(2), 0, reinterpret_cast(3))); + engine.configure(generations + 1, model, preset, 0.6f); + assert(engine.prepare(width, height, VK_FORMAT_R8G8B8A8_UNORM)); + for (unsigned frame = 0; frame < 3; frame++) { + gpu_pending = false; + const auto source = external_image(width, height); + const auto output = external_image(width, height); + const auto count = engine.plan(generations); + engine.process(reinterpret_cast(1), views.at(source), width, height, count); + for (unsigned generation = 0; generation < count; generation++) + engine.generateInto(reinterpret_cast(1), generation, count, + views.at(output), output, width, height); + clear_external_images(); + gpu_pending = true; + } + if (mode == "engine-failure") { + idle_result = VK_ERROR_OUT_OF_DEVICE_MEMORY; + assert(!engine.prepare(width + 17, height + 9, VK_FORMAT_R8G8B8A8_UNORM)); + assert(engine.unavailable() && !engine.valid()); + } + } + if (mode == "engine") check_empty(); + else assert(gpu_pending && !images.empty() && !buffers.empty() && !descriptors.empty()); + std::puts("PASS lifecycle=engine-ownership"); + return 0; + } + if (mode == "idle-failure" || mode == "destroy-failure" || mode == "reset-failure" || mode == "partial") { + { + ddfg::FrameGen fg; + initialize(fg); + record(fg, model, width, height, generations); + const auto prior_buffers = buffers.size(), prior_images = images.size(), prior_sets = descriptors.size(); + if (mode == "partial") { + fail_image_at = image_creates + 2; + assert(!fg.onResize({width + 17, height + 9}, VK_FORMAT_R8G8B8A8_UNORM)); + assert(!fg.valid()); + } else { + if (mode == "reset-failure") reset_result = VK_ERROR_OUT_OF_HOST_MEMORY; + else idle_result = VK_ERROR_OUT_OF_DEVICE_MEMORY; + if (mode == "destroy-failure") fg.destroy(); + else assert(!fg.onResize({width + 17, height + 9}, VK_FORMAT_R8G8B8A8_UNORM)); + assert(!fg.valid()); + assert(buffers.size() == prior_buffers && images.size() == prior_images && + descriptors.size() == prior_sets); + const auto prior_dispatches = dispatches.size(); + const auto prior_waits = idle_calls; + fg.record(reinterpret_cast(1), VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, 0.5f); + assert(dispatches.size() == prior_dispatches); + if (mode != "reset-failure") { + assert(!fg.onResize({width, height}, VK_FORMAT_R8G8B8A8_UNORM)); + cfg.perfPreset = (preset + 1) % 3; + fg.configure(cfg); + if (mode == "destroy-failure") { + idle_result = VK_SUCCESS; + assert(fg.destroy()); + } else { + fg.destroy(); + assert(idle_calls == prior_waits + 1); + } + } + } + } + if (mode == "reset-failure" || mode == "partial" || mode == "destroy-failure") check_empty(); + else assert(gpu_pending && !images.empty() && !buffers.empty() && !descriptors.empty()); + std::puts("PASS lifecycle=failure-containment"); + return 0; + } + ddfg::FrameGen fg; + initialize(fg); assert(mode == "resources" || mode == "record" || mode == "resize" || mode == "preset"); for (unsigned repeat = 0; repeat < repeats; repeat++) { const auto old_buffers = buffer_creates, old_sets = set_creates; if (mode != "record") check_images(width, height, fg.flowFinest()); record(fg, model, width, height, generations); if (mode != "record") { + check_working_set(fg); assert(buffer_creates - old_buffers == static_cast(15 - fg.flowFinest())); assert(set_creates - old_sets == static_cast(54 - 4 * fg.flowFinest())); } @@ -356,4 +550,5 @@ int main(int argc, char **argv) { dispatches.size(), static_cast(command_hash)); fg.destroy(); assert(images.empty() && views.empty()); + if (mode != "record") check_empty(); } diff --git a/tools/tests/effects_source_cache_harness.c b/tools/tests/effects_source_cache_harness.c index f947b230b0..da9615d1c6 100644 --- a/tools/tests/effects_source_cache_harness.c +++ b/tools/tests/effects_source_cache_harness.c @@ -51,6 +51,73 @@ static VkResult VKAPI_CALL allocate_set(VkDevice dev, const VkDescriptorSetAlloc *out = (VkDescriptorSet)(uintptr_t)(200 + ++sets); return VK_SUCCESS; } + +static VkImageLayout restored_layout; +static VkPipelineStageFlags restored_stage; +static void VKAPI_CALL pipeline_barrier(VkCommandBuffer cmd, VkPipelineStageFlags src, VkPipelineStageFlags dst, + VkDependencyFlags flags, uint32_t nm, const VkMemoryBarrier *m, uint32_t nb, + const VkBufferMemoryBarrier *b, uint32_t ni, const VkImageMemoryBarrier *images) { + for (uint32_t k = 0; k < ni; k++) { + if (images[k].image == (VkImage)(uintptr_t)10 && images[k].newLayout == VK_IMAGE_LAYOUT_GENERAL) { + restored_layout = images[k].oldLayout; + restored_stage = src; + } + } +} +static void VKAPI_CALL begin_pass(VkCommandBuffer c, const VkRenderPassBeginInfo *i, VkSubpassContents s) {} +static void VKAPI_CALL viewport(VkCommandBuffer c, uint32_t f, uint32_t n, const VkViewport *v) {} +static void VKAPI_CALL scissor(VkCommandBuffer c, uint32_t f, uint32_t n, const VkRect2D *v) {} +static void VKAPI_CALL bind_pipeline(VkCommandBuffer c, VkPipelineBindPoint b, VkPipeline p) {} +static void VKAPI_CALL bind_sets(VkCommandBuffer c, VkPipelineBindPoint b, VkPipelineLayout l, uint32_t f, + uint32_t n, const VkDescriptorSet *s, uint32_t nd, const uint32_t *d) {} +static void VKAPI_CALL push(VkCommandBuffer c, VkPipelineLayout l, VkShaderStageFlags s, uint32_t o, + uint32_t n, const void *v) {} +static void VKAPI_CALL draw(VkCommandBuffer c, uint32_t n, uint32_t i, uint32_t f, uint32_t fi) {} +static void VKAPI_CALL end_pass(VkCommandBuffer c) {} +static void VKAPI_CALL blit(VkCommandBuffer c, VkImage a, VkImageLayout al, VkImage b, VkImageLayout bl, + uint32_t n, const VkImageBlit *r, VkFilter f) {} + +static void check_generated_settings_and_layout(void) { + g_vk.CmdPipelineBarrier = pipeline_barrier; + g_vk.CmdBeginRenderPass = begin_pass; + g_vk.CmdSetViewport = viewport; g_vk.CmdSetScissor = scissor; + g_vk.CmdBindPipeline = bind_pipeline; g_vk.CmdBindDescriptorSets = bind_sets; + g_vk.CmdPushConstants = push; g_vk.CmdDraw = draw; g_vk.CmdEndRenderPass = end_pass; + g_vk.CmdBlitImage = blit; + g_rp = (VkRenderPass)(uintptr_t)5; + g_pipe[P_SGSR] = (VkPipeline)(uintptr_t)6; + g_pipe[P_COLOR] = (VkPipeline)(uintptr_t)7; + g_ready = 1; + for (int k = 0; k < 2; k++) { + struct fx_target *t = &g_contexts[1].targets[k]; + t->img = (VkImage)(uintptr_t)(30 + k); t->w = 1920; t->h = 1080; + } + vkp_effects_set_scaling(3); + assert(vkp_effects_prepare_generated()); + vkp_effects_set_scaling(0); + vkp_effects_set_cas(1, 75); + vkp_effects_sync(); + assert(g_cur.scaling == 0 && cas_active(&g_cur)); + assert(g_generated_settings.scaling == 3 && !effect_count(&g_generated_settings)); + int w, h; + VkImage input = (VkImage)(uintptr_t)10; + assert(vkp_effects_run_before_generated(VK_NULL_HANDLE, input, 1280, 720, &w, &h) == input); + assert(w == 1280 && h == 720); + assert(vkp_effects_run_generated(VK_NULL_HANDLE, input, 1280, 720, 1920, 1080, 0, &w, &h) != input); + assert(w == 1920 && h == 1080); + assert(restored_layout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + assert(restored_stage == VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT); + g_generated_settings.scaling = 0; + g_generated_settings.color_on = 1; + assert(vkp_effects_run_generated(VK_NULL_HANDLE, input, 1280, 720, 1920, 1080, 0, &w, &h) != input); + assert(restored_layout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); + assert(restored_stage == VK_PIPELINE_STAGE_TRANSFER_BIT); + g_ready = -1; + assert(vkp_effects_run_generated(VK_NULL_HANDLE, input, 1280, 720, 1920, 1080, 0, &w, &h) == input); + assert(w == 1280 && h == 720); + assert(restored_layout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); + assert(g_context == 0); +} static void VKAPI_CALL update_set(VkDevice dev, uint32_t count, const VkWriteDescriptorSet *writes, uint32_t copies, const VkCopyDescriptorSet *copy) { (void)dev; (void)copies; (void)copy; @@ -84,7 +151,20 @@ int main(int argc, char **argv) { VkImage source = (VkImage)(uintptr_t)10; assert(scene_ensure(source, 1280, 720) == 0); VkImageView original = bound_view; - if (!strcmp(argv[1], "recycled")) { + if (!strcmp(argv[1], "generated-layout")) { + check_generated_settings_and_layout(); + } else if (!strcmp(argv[1], "generated")) { + for (int k = 1; k < FX_CONTEXTS; k++) { + g_context = k; + assert(scene_ensure((VkImage)(uintptr_t)(10 + k), 1280, 720) == 0); + } + assert(sets == FX_CONTEXTS && !freed_sets); + vkp_effects_release_generated_sources(); + assert(g_context == 0 && freed_sets == FX_CONTEXTS - 1); + assert(g_scene.img == source && g_scene.view == original); + vkp_effects_release_generated_sources(); + assert(freed_sets == FX_CONTEXTS - 1); + } else if (!strcmp(argv[1], "recycled")) { vkp_effects_forget_image(source); assert(freed_sets == 1 && freed_views == 1); assert(scene_ensure(source, 1280, 720) == 0); diff --git a/tools/tests/mali_compat_layer_test.c b/tools/tests/mali_compat_layer_test.c index 9b29e5c734..421f5524b0 100644 --- a/tools/tests/mali_compat_layer_test.c +++ b/tools/tests/mali_compat_layer_test.c @@ -203,10 +203,17 @@ static void test_handle_map_null_key(void) map_free(&map); } +static int zink_instance_table; +static struct object mock_zink_instance = {&zink_instance_table}; +static struct object mock_arm = {&instance_table}; +static struct object mock_zink_arm = {&zink_instance_table}, mock_zink_other = {&zink_instance_table}; + static VkResult VKAPI_CALL mock_create_instance(const VkInstanceCreateInfo *info, const VkAllocationCallbacks *allocator, VkInstance *instance) { - *instance = (VkInstance)&mock_instance; + const VkApplicationInfo *app = info->pApplicationInfo; + bool zink = app && app->pEngineName && !strcmp(app->pEngineName, "mesa zink"); + *instance = (VkInstance)(zink ? &mock_zink_instance : &mock_instance); return VK_SUCCESS; } @@ -223,6 +230,7 @@ static void VKAPI_CALL mock_features(VkPhysicalDevice physical, VkPhysicalDevice { memset(features, 0, sizeof(*features)); features->dualSrcBlend = physical == (VkPhysicalDevice)&mock_capable; + features->geometryShader = VK_TRUE; } static void VKAPI_CALL mock_features2(VkPhysicalDevice physical, VkPhysicalDeviceFeatures2 *features) @@ -234,6 +242,8 @@ static void VKAPI_CALL mock_properties(VkPhysicalDevice physical, VkPhysicalDevi { memset(properties, 0, sizeof(*properties)); strcpy(properties->deviceName, "mock"); + bool arm = physical == (VkPhysicalDevice)&mock_arm || physical == (VkPhysicalDevice)&mock_zink_arm; + properties->vendorID = arm ? 0x13b5 : 0; properties->limits.maxFragmentDualSrcAttachments = physical == (VkPhysicalDevice)&mock_capable; } @@ -385,6 +395,50 @@ static void destroy_device(VkDevice device) ((PFN_vkDestroyDevice)layer_gdpa(device, "vkDestroyDevice"))(device, NULL); } +static void test_geometry_shader_hidden_from_zink(void) +{ + VkPhysicalDeviceFeatures features; + PFN_vkGetPhysicalDeviceFeatures plain_features = + (PFN_vkGetPhysicalDeviceFeatures)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceFeatures"); + PFN_vkGetPhysicalDeviceFeatures2 plain_features2 = + (PFN_vkGetPhysicalDeviceFeatures2)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceFeatures2"); + VkPhysicalDeviceFeatures2 queried = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2}; + plain_features((VkPhysicalDevice)&mock_lacking, &features); + assert(features.geometryShader); + plain_features((VkPhysicalDevice)&mock_arm, &features); + assert(features.geometryShader); + plain_features2((VkPhysicalDevice)&mock_arm, &queried); + assert(queried.features.geometryShader); + + VkApplicationInfo app = {.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, .pEngineName = "mesa zink"}; + VkLayerInstanceLink link = {NULL, mock_gipa, NULL}; + VkLayerInstanceCreateInfo loader = {VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO, NULL, VK_LAYER_LINK_INFO, {&link}}; + VkInstanceCreateInfo info = {.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, .pNext = &loader, + .pApplicationInfo = &app}; + VkInstance zink; + assert(((PFN_vkCreateInstance)layer_gipa(NULL, "vkCreateInstance"))(&info, NULL, &zink) == VK_SUCCESS); + assert(zink == (VkInstance)&mock_zink_instance); + PFN_vkGetPhysicalDeviceFeatures zink_features = + (PFN_vkGetPhysicalDeviceFeatures)layer_gipa(zink, "vkGetPhysicalDeviceFeatures"); + PFN_vkGetPhysicalDeviceFeatures2 zink_features2 = + (PFN_vkGetPhysicalDeviceFeatures2)layer_gipa(zink, "vkGetPhysicalDeviceFeatures2"); + zink_features((VkPhysicalDevice)&mock_zink_arm, &features); + assert(!features.geometryShader && features.dualSrcBlend); + zink_features2((VkPhysicalDevice)&mock_zink_arm, &queried); + assert(!queried.features.geometryShader && queried.features.dualSrcBlend); + zink_features((VkPhysicalDevice)&mock_zink_other, &features); + assert(features.geometryShader); + + setenv("DROIDDECK_MALI_COMPAT_NO_GS", "0", 1); + zink_features((VkPhysicalDevice)&mock_zink_arm, &features); + assert(features.geometryShader); + setenv("DROIDDECK_MALI_COMPAT_NO_GS", "1", 1); + plain_features((VkPhysicalDevice)&mock_lacking, &features); + assert(!features.geometryShader); + unsetenv("DROIDDECK_MALI_COMPAT_NO_GS"); + ((PFN_vkDestroyInstance)layer_gipa(zink, "vkDestroyInstance"))(zink, NULL); +} + static const VkPipelineColorBlendAttachmentState dual_attachment = { VK_TRUE, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, VK_BLEND_OP_ADD, VK_BLEND_FACTOR_SRC1_ALPHA, VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, VK_BLEND_OP_ADD, 0xf, @@ -575,6 +629,7 @@ int main(int argc, char **argv) setenv("WINEPREFIX", "/nonexistent", 1); unsetenv("DROIDDECK_MALI_COMPAT"); unsetenv("DROIDDECK_MALI_COMPAT_TRACE"); + unsetenv("DROIDDECK_MALI_COMPAT_NO_GS"); VkNegotiateLayerInterface negotiate = {LAYER_NEGOTIATE_INTERFACE_STRUCT, NULL, 2, NULL, NULL, NULL}; assert(vkNegotiateLoaderLayerInterfaceVersion(&negotiate) == VK_SUCCESS); layer_gipa = negotiate.pfnGetInstanceProcAddr; @@ -587,6 +642,7 @@ int main(int argc, char **argv) PFN_vkCreateInstance create_instance = (PFN_vkCreateInstance)layer_gipa(NULL, "vkCreateInstance"); assert(create_instance(&info, NULL, &instance) == VK_SUCCESS); + test_geometry_shader_hidden_from_zink(); test_lacking_device(); test_capable_device(); test_depth_compare_op(); diff --git a/tools/tests/pen_pointer_harness.c b/tools/tests/pen_pointer_harness.c index 01dd5b45b9..cec9cf72bf 100644 --- a/tools/tests/pen_pointer_harness.c +++ b/tools/tests/pen_pointer_harness.c @@ -52,6 +52,16 @@ static int vkp_output_to_scene(double ox, double oy, double *x, double *y) { (void)ox; (void)oy; (void)x; (void)y; return 0; } +static int vkp_scene_to_output(double sx, double sy, double *ox, double *oy) { + (void)sx; (void)sy; (void)ox; (void)oy; + return 0; +} + +static int vkp_zoom_pan_cursor(double ox, double oy) { + (void)ox; (void)oy; + return 0; +} + static struct surface *toplevel_at(double x, double y) { (void)y; return x < 1000 ? &a : &b; @@ -124,7 +134,8 @@ static void hover_away(void) { assert(!g_grab); pen(PEN_IN, 1500); assert(nevents == 2); - left(0, &pointer_a, &surface_a); focus(1, &pointer_b, &surface_b); + left(0, &pointer_a, &surface_a); + focus(1, &pointer_b, &surface_b); } int main(int argc, char **argv) { @@ -151,7 +162,8 @@ int main(int argc, char **argv) { } else if (!strcmp(c, "swap")) { pen(PEN_IN | PEN_RIGHT, 600); assert(nevents == 2 && g_grab == &a); - button(0, PRESS, BTN_RIGHT); button(1, RELEASE, BTN_LEFT); + button(0, PRESS, BTN_RIGHT); + button(1, RELEASE, BTN_LEFT); pen(PEN_IN | PEN_RIGHT, 1500); assert(nevents == 0 && g_grab == &a); pen(PEN_IN, 1500); diff --git a/tools/tests/subsurface_release_harness.c b/tools/tests/subsurface_release_harness.c index 0921666d45..f162e53ce9 100644 --- a/tools/tests/subsurface_release_harness.c +++ b/tools/tests/subsurface_release_harness.c @@ -1,5 +1,6 @@ #define _POSIX_C_SOURCE 200809L #include +#include #include #include #include @@ -32,6 +33,7 @@ struct surface { struct wl_listener dmabuf_destroy; int64_t next_release_ns; int releases_pending; + int release_pace_open; enum surface_role role; struct surface *parent; int sub_desync; @@ -50,6 +52,9 @@ static struct dmabuf_buffer g_buf; static int64_t now_ns(void) { return g_now; } static void perf_note_release(int64_t since) { (void)since; } +static int g_pace_logs; +static void describe(const struct surface *s, char *out, size_t size) { (void)s; snprintf(out, size, "surface"); } +static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; g_pace_logs++; } static int buffer_release_blocked(struct wl_resource *b) { (void)b; return 0; } static int ahb_swapchain_defer_release(struct dmabuf_buffer *b, struct wl_resource *r, struct surface *s, int paced) { (void)b; (void)r; (void)s; (void)paced; @@ -300,6 +305,72 @@ static void set_desync_frees_held_release(void) { check(&d, 0); } +static void never_waits_toplevel(void) { + struct surface s; + enum { FRAMES = 40 }; + struct wl_resource b[FRAMES]; + surface_init(&s, ROLE_TOPLEVEL, NULL); + g_fps_limit = 60; + const int64_t interval = 1000000000LL / 60; + for (int i = 0; i < FRAMES; i++) { + buffer_init(&b[i]); + present(&b[i]); + commit(&s, &b[i]); + assert(s.releases_pending <= RELEASE_PACE_DEPTH); + assert(g_armed <= g_now + (RELEASE_PACE_DEPTH + 1) * interval); + } + int released = 0; + for (int i = 0; i < FRAMES; i++) released += b[i].releases; + assert(released == FRAMES - 1 - RELEASE_PACE_DEPTH); + assert(g_pace_logs == 1); + timer_fires(g_now + 1000000000LL); + for (int i = 0; i < FRAMES - 1; i++) check(&b[i], 1); + check(&b[FRAMES - 1], 0); +} + +static void never_waits_sync_child(void) { + struct surface root, child; + enum { FRAMES = 40 }; + struct wl_resource b[FRAMES]; + surface_init(&root, ROLE_TOPLEVEL, NULL); + surface_init(&child, ROLE_SUBSURFACE, &root); + g_fps_limit = 60; + for (int i = 0; i < FRAMES; i++) { + buffer_init(&b[i]); + present(&b[i]); + commit(&child, &b[i]); + commit(&root, NULL); + assert(child.releases_pending <= RELEASE_PACE_DEPTH); + } + int released = 0; + for (int i = 0; i < FRAMES; i++) released += b[i].releases; + assert(released == FRAMES - 1 - RELEASE_PACE_DEPTH); + present(&b[0]); + check(&b[FRAMES - 1], 0); +} + +static void deep_fixed_pool_stays_paced(void) { + struct surface s; + enum { POOL = RELEASE_PACE_DEPTH, FRAMES = 120 }; + struct wl_resource b[POOL]; + int used[POOL] = {0}; + surface_init(&s, ROLE_TOPLEVEL, NULL); + g_fps_limit = 60; + const int64_t interval = 1000000000LL / 60; + for (int i = 0; i < POOL; i++) buffer_init(&b[i]); + const int64_t start = g_now; + for (int i = 0; i < FRAMES; i++) { + struct wl_resource *next = &b[i % POOL]; + while (used[i % POOL] && next->releases < used[i % POOL]) timer_fires(g_armed); + present(next); + commit(&s, next); + used[i % POOL]++; + assert(s.releases_pending < POOL); + } + assert(g_pace_logs == 0); + assert(g_now - start >= (FRAMES - POOL) * interval - interval); +} + int main(int argc, char **argv) { assert(argc == 2); wl_list_init(&g_surfaces); @@ -313,6 +384,9 @@ int main(int argc, char **argv) { else if (!strcmp(argv[1], "destroyed")) holder_destroyed(); else if (!strcmp(argv[1], "nested")) desync_parent_holds_sync_grandchild(); else if (!strcmp(argv[1], "set-desync")) set_desync_frees_held_release(); + else if (!strcmp(argv[1], "never-waits")) never_waits_toplevel(); + else if (!strcmp(argv[1], "never-waits-sync")) never_waits_sync_child(); + else if (!strcmp(argv[1], "deep-pool")) deep_fixed_pool_stays_paced(); else return 2; return 0; } diff --git a/tools/tests/test_appimage_run.py b/tools/tests/test_appimage_run.py index 84c92f49b8..da5e3115d2 100644 --- a/tools/tests/test_appimage_run.py +++ b/tools/tests/test_appimage_run.py @@ -6,7 +6,7 @@ import unittest from pathlib import Path RUN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-appimage-run" -KEYS = ("TU_DEBUG", "DROIDDECK_GAME_TU_DEBUG", "QT_QPA_PLATFORM", "WAYLAND_DISPLAY", "SDL_VIDEODRIVER", "XDG_SESSION_TYPE", "QT_WAYLAND_DISABLE_WINDOWDECORATION", "DISABLE_GAMESCOPE_WSI") +KEYS = ("TU_DEBUG", "DROIDDECK_GAME_TU_DEBUG", "QT_QPA_PLATFORM", "WAYLAND_DISPLAY", "SDL_VIDEODRIVER", "XDG_SESSION_TYPE", "QT_WAYLAND_DISABLE_WINDOWDECORATION", "DISABLE_GAMESCOPE_WSI", "QTWEBENGINE_DISABLE_SANDBOX") QUICK = ("usr/lib/libQt6Quick.so.6", "usr/lib/libvulkan.so.1", "usr/plugins/platforms/libqwayland-generic.so") RUN_MODE = {"GAMESCOPE_WAYLAND_DISPLAY": "gamescope-0", "WAYLAND_DISPLAY": "gamescope-0", "DISPLAY": ":0", "QT_QPA_PLATFORM": "xcb", "SDL_VIDEODRIVER": "x11", "XDG_SESSION_TYPE": "x11"} @@ -128,6 +128,11 @@ class AppImageRunTest(unittest.TestCase): self.assertEqual("wayland;xcb", env["QT_QPA_PLATFORM"]) + def test_a_web_engine_app_starts_as_root_in_either_session(self): + for session in (RUN_MODE, DESKTOP): + env, _ = self.launch(session) + self.assertEqual("1", env["QTWEBENGINE_DISABLE_SANDBOX"]) + def test_a_program_drops_the_sessions_sysmem_like_a_steam_game(self): env, _ = self.launch(dict(RUN_MODE, TU_DEBUG="sysmem", DROIDDECK_GAME_TU_DEBUG="")) self.assertEqual("unset", env["TU_DEBUG"]) diff --git a/tools/tests/test_battlenet.py b/tools/tests/test_battlenet.py index 06fdc779c4..c06924e42f 100644 --- a/tools/tests/test_battlenet.py +++ b/tools/tests/test_battlenet.py @@ -295,6 +295,37 @@ class DriveTest(Temp): self.assertEqual(BNET["install_path"](self.root, str(self.card)), "D:\\") self.assertEqual(sorted(os.listdir(self.devices)), ["d:"]) + def test_a_folder_chosen_in_battlenet_on_the_library_drive_is_kept(self): + path = Path(BNET["drive_c"](self.root)).joinpath(*BNET["CONFIG"]) + BNET["write_config"](self.root) + self.assertEqual(BNET["write_config"](self.root, str(self.library)), "library") + (self.card / "Battle.net").mkdir() + config = json.loads(path.read_text()) + config["Client"]["Install"]["DefaultInstallPath"] = "D:\\Battle.net" + path.write_text(json.dumps(config)) + self.assertIsNone(BNET["write_config"](self.root, str(self.library))) + self.assertEqual(json.loads(path.read_text())["Client"]["Install"]["DefaultInstallPath"], "D:\\Battle.net") + + def test_a_chosen_folder_inside_the_native_rootfs_is_not_kept_whatever_its_spacing(self): + BNET["write_config"](self.root, str(self.library)) + rootfs = self.card / "files/linuxfs" + (rootfs / "Games").mkdir(parents=True) + with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}): + for current in ("D:\\files\\linuxfs\\Games", " D:\\files\\linuxfs\\Games"): + self.assertFalse(BNET["chosen_folder"](self.root, current, str(self.library))) + + def test_a_folder_on_another_drive_or_missing_moves_to_the_library(self): + path = Path(BNET["drive_c"](self.root)).joinpath(*BNET["CONFIG"]) + BNET["write_config"](self.root, str(self.library)) + internal = self.tmp / "root/Games/Stores/Battle.net" + internal.mkdir(parents=True) + for current in ("Z:" + str(internal), "D:\\Gone"): + config = json.loads(path.read_text()) + config["Client"]["Install"]["DefaultInstallPath"] = current + path.write_text(json.dumps(config)) + self.assertEqual(BNET["write_config"](self.root, str(self.library)), "library") + self.assertEqual(json.loads(path.read_text())["Client"]["Install"]["DefaultInstallPath"], "D:\\Games\\Battle.net") + def test_drives_in_use_and_the_ones_proton_owns_are_left_alone(self): self.devices.mkdir(parents=True) os.symlink("/somewhere/else", self.devices / "d:") diff --git a/tools/tests/test_bionic_paths.py b/tools/tests/test_bionic_paths.py index 3671aa68bd..55c371b303 100644 --- a/tools/tests/test_bionic_paths.py +++ b/tools/tests/test_bionic_paths.py @@ -65,6 +65,14 @@ class ToolArguments(unittest.TestCase): def test_wine_keeps_the_guest_root(self): self.assertIn('DROIDDECK_GUEST_ROOT) ;;', LAUNCH.read_text()) + def test_directaudio_settings_reach_the_built_in_driver(self): + text = LAUNCH.read_text() + block = text[text.index('KEEP="'):text.index('export PATH=/system/bin')] + script = block + 'env | grep -E "AUDIO_DIRECT_|^OTHER=" | sort\n' + env = {'PATH': os.environ['PATH'], 'DROIDDECK_BIONIC_KEEP': 'PATH', 'AUDIO_DIRECT_MIC': '1', 'AUDIO_DIRECT_MS': '60', 'OTHER': 'x'} + result = subprocess.run(['sh', '-c', script], env=env, text=True, capture_output=True, check=True) + self.assertEqual(['BANNER_AUDIO_DIRECT_MIC=1', 'BANNER_AUDIO_DIRECT_MS=60'], result.stdout.split()) + class SessionLogs(unittest.TestCase): SESSION = '/data/user/0/com.droiddeck.launcher/files/logs/2026-11-22-09-steam' @@ -136,6 +144,53 @@ class LaunchLog(unittest.TestCase): self.assertIn('DXVK_LOG_PATH=${DXVK_LOG_PATH:-$COMPAT}', text) +class PrefixFromProton(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.addCleanup(self.tmp.cleanup) + self.compat = Path(self.tmp.name) / 'compatdata/236850' + self.drives = self.compat / 'pfx/dosdevices' + self.drives.mkdir(parents=True) + + def test_guest_drive_links_get_android_paths(self): + for name, target in (('c:', '../drive_c'), ('s:', '/root/.local/share/Steam'), ('d:', '/mnt/sd/Steam'), + ('e:', '/storage/emulated/0/Games'), ('z:', '/')): + os.symlink(target, self.drives / name) + out = proton_function('android_drives "$1"', str(self.compat)) + links = {p.name: os.readlink(p) for p in self.drives.iterdir()} + self.assertEqual({'c:': '../drive_c', 's:': ANDROID + '/root/.local/share/Steam', 'd:': '/storage/1234-5678/Steam/Steam', + 'e:': '/storage/emulated/0/Games', 'z:': '/'}, links) + self.assertEqual(2, len(out.splitlines())) + self.assertEqual('', proton_function('android_drives "$1"', str(self.compat))) + + def test_a_prefix_without_drives_is_left_alone(self): + self.assertEqual('', proton_function('android_drives "$1"', str(Path(self.tmp.name) / 'compatdata/1'))) + + def steam_pid(self, reg): + text = LAUNCH.read_text() + function = text[text.index('steam_pid() {'):text.index('prefix_busy || steam_pid')] + (self.compat / 'pfx/user.reg').write_text(reg) + out = subprocess.run(['sh', '-c', function + 'steam_pid'], env=dict(os.environ, COMPAT=str(self.compat)), + capture_output=True, text=True, check=True).stdout + return out, (self.compat / 'pfx/user.reg').read_text() + + def test_steams_process_id_is_this_tools(self): + reg = ('[Software\\\\Valve\\\\Steam\\\\ActiveProcess] 1795314478\n#time=1dd7a2916a0be94\n"PID"=dword:00000020\n' + '"SteamPath"="C:\\\\Program Files (x86)\\\\Steam"\n\n[Software\\\\Other] 1\n"PID"=dword:00000020\n') + out, after = self.steam_pid(reg) + self.assertIn('process ID', out) + self.assertEqual(reg.replace('"PID"=dword:00000020', '"PID"=dword:0000fffe', 1), after) + out, again = self.steam_pid(after) + self.assertEqual(('', after), (out, again)) + + def test_a_prefix_without_steams_key_is_unchanged(self): + reg = '[Software\\\\Wine] 1\n"PID"=dword:00000020\n' + self.assertEqual(('', reg), self.steam_pid(reg)) + + def test_the_network_list_uses_getifaddrs(self): + self.assertIn('export WINE_NEW_NDIS=${WINE_NEW_NDIS:-1}', LAUNCH.read_text()) + + class StorePaths(unittest.TestCase): def setUp(self): self.tmp = tempfile.TemporaryDirectory() diff --git a/tools/tests/test_ci_checks.py b/tools/tests/test_ci_checks.py index bf3db6ec69..a5982366ac 100644 --- a/tools/tests/test_ci_checks.py +++ b/tools/tests/test_ci_checks.py @@ -24,6 +24,28 @@ class CiChecksTest(unittest.TestCase): gradle = (ROOT / 'app/build.gradle').read_text() self.assertIn("gitValue(['show', '-s', '--format=%ct', '--end-of-options', sourceCommit])", gradle) + def test_robolectric_cache_saves_and_restores_the_same_absolute_path(self): + steps = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']['build']['steps'] + caches = [step['with'] for step in steps if step.get('uses', '').startswith('actions/cache')] + for cache in caches: + for path in cache['path'].split('\n'): + self.assertNotIn('..', path.split('/')) + robolectric = [cache['path'] for cache in caches if cache['key'].startswith('robolectric-')] + self.assertEqual(robolectric, ['${{ steps.robolectric-jars.outputs.path }}'] * 2) + + def test_unit_test_retry_requires_maven_exception(self): + steps = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']['build']['steps'] + run = next(step['run'] for step in steps if step.get('id') == 'unit-tests') + line = next(line for line in run.splitlines() if 'grep -Eq' in line) + pattern = shlex.split(line)[shlex.split(line).index('-Eq') + 1] + for log, expected in ( + ("Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not GET 'https://repo.maven.apache.org/maven2/a.jar'. Received status code 429 from server: Too Many Requests", 0), + ("Caused by: java.io.IOException: Server returned HTTP response code: 429 for URL: https://repo.maven.apache.org/maven2/a.jar", 0), + ("SomeTest > test FAILED: Too Many Requests", 1), + ("Caused by: java.lang.AssertionError: HTTP 429", 1), + ): + self.assertEqual(subprocess.run(['grep', '-Eq', pattern], input=log, text=True).returncode, expected) + def test_report_comment_lookup_ignores_human_marker(self): if not shutil.which('jq'): self.skipTest('jq required to execute comment selection') @@ -60,7 +82,7 @@ class CiChecksTest(unittest.TestCase): sudo = root / 'sudo' sudo.write_text('#!/bin/bash\nprintf "%s\\n" "$*" >> "$APT_LOG"\n' 'for arg; do case "$arg" in Dir::Etc::sourcelist=*) ' - 'grep -h "^URIs:" "${arg#*=}" >> "$APT_LOG.mirrors";; esac; done\n' + 'grep -hE "^(URIs|Suites):" "${arg#*=}" >> "$APT_LOG.mirrors";; esac; done\n' 'exit "${APT_RESULT:-0}"\n') sudo.chmod(0o755) query = root / 'dpkg-query' @@ -105,12 +127,35 @@ class CiChecksTest(unittest.TestCase): self.assertIn('install -y -q --no-install-recommends qemu-user', install) log.unlink() - absent = dict(env, UBUNTU_SOURCES_FILE=str(root / 'missing.sources'), APT_RESULT='17') + mirrors.unlink() + release = root / 'os-release' + release.write_text('ID=ubuntu\n') + absent = dict(env, UBUNTU_SOURCES_FILE=str(root / 'missing.sources'), APT_RESULT='17', + OS_RELEASE_FILE=str(release)) result = subprocess.run(['bash', str(installer), 'qemu-user'], env=absent) self.assertEqual(result.returncode, 1) self.assertEqual(len(log.read_text().splitlines()), 1) self.assertNotIn('Dir::Etc::sourceparts', log.read_text()) + log.unlink() + release.write_text('ID=ubuntu\nVERSION_CODENAME=noble\nUBUNTU_CODENAME=noble\n') + result = subprocess.run(['bash', str(installer), 'qemu-user'], env=absent) + self.assertEqual(result.returncode, 17) + first, *fallbacks = log.read_text().splitlines() + self.assertNotIn('Dir::Etc::sourcelist', first) + self.assertEqual(len(fallbacks), 2) + for command in (first, *fallbacks): + self.assertIn('Acquire::Retries=1', command) + self.assertIn('Acquire::https::Timeout=15', command) + for command in fallbacks: + self.assertIn('Dir::Etc::sourceparts=-', command) + self.assertEqual(mirrors.read_text().splitlines(), [ + 'URIs: https://archive.ubuntu.com/ubuntu', + 'Suites: noble noble-updates noble-security', + 'URIs: https://mirrors.edge.kernel.org/ubuntu', + 'Suites: noble noble-updates noble-security', + ]) + def test_required_status_rejects_failed_cancelled_or_skipped_test_jobs(self): jobs = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs'] gate = jobs['checks'] diff --git a/tools/tests/test_commit_waits_for_client_writes.py b/tools/tests/test_commit_waits_for_client_writes.py new file mode 100644 index 0000000000..39b37e93a9 --- /dev/null +++ b/tools/tests/test_commit_waits_for_client_writes.py @@ -0,0 +1,293 @@ +"""A commit whose dma-buf the client's GPU is still writing is held until the buffer polls readable. + +The compiled functions come from compositor.c; libwayland's lists and event loop, poll and the clock are faked. +""" +import os +from pathlib import Path +import re +import shutil +import subprocess +import tempfile +import unittest + +SOURCE = Path(__file__).resolve().parents[2] / 'app/src/main/cpp/waylandcomp/src/compositor.c' + + +def function(text, name): + match = re.search(r'^(?:static )?[^\n;]+\b' + name + r'\([^;]*?\)\s*\{', text, re.M) + if not match: + raise AssertionError('Production function not found: ' + name) + pos = text.index('{', match.start()) + depth, end = 1, pos + 1 + while depth: + depth += (text[end] == '{') - (text[end] == '}') + end += 1 + return text[match.start():end] + + +def block(text, start): + begin = text.index(start) + return text[begin:text.index('\n};\n', begin) + 4] + + +HARNESS = r''' +#include +#include +#include +#include +#include +#include +#define DAMAGE_RECTS 4 +#define POLLIN 1 +#define F_DUPFD_CLOEXEC 1030 +#define WL_EVENT_READABLE 1 +struct pollfd { int fd; short events, revents; }; +struct wl_list { struct wl_list *prev, *next; }; +struct wl_listener { struct wl_list link; void (*notify)(struct wl_listener *, void *); }; +static void wl_list_init(struct wl_list *l) { l->prev = l->next = l; } +static void wl_list_remove(struct wl_list *l) { l->prev->next = l->next; l->next->prev = l->prev; l->prev = l->next = NULL; } +static void wl_list_insert(struct wl_list *list, struct wl_list *elm) { + elm->prev = list; elm->next = list->next; list->next = elm; elm->next->prev = elm; +} +static void wl_list_insert_list(struct wl_list *list, struct wl_list *other) { + if (other->next == other) return; + other->next->prev = list; other->prev->next = list->next; list->next->prev = other->prev; list->next = other->next; +} +static int wl_list_length(const struct wl_list *l) { int n = 0; for (struct wl_list *e = l->next; e != l; e = e->next) n++; return n; } +#define wl_container_of(ptr, sample, member) (__typeof__(sample))((char *)(ptr) - offsetof(__typeof__(*sample), member)) + +struct dmabuf_buffer { int fd[4]; int n_planes; int ahb; }; +struct wl_resource { struct wl_list link; struct wl_listener *listener; struct dmabuf_buffer *db; int released, destroyed; }; +static struct wl_resource *from_link(struct wl_list *l) { return wl_container_of(l, (struct wl_resource *)0, link); } +#define wl_resource_for_each_safe(r, t, list) \ + for (r = from_link((list)->next), t = from_link(r->link.next); &r->link != (list); r = t, t = from_link(t->link.next)) +static void wl_resource_destroy(struct wl_resource *r) { wl_list_remove(&r->link); r->destroyed = 1; } +static void wl_resource_add_destroy_listener(struct wl_resource *r, struct wl_listener *l) { r->listener = l; wl_list_init(&l->link); } +static void client_destroys(struct wl_resource *r) { + if (r->listener) { struct wl_listener *l = r->listener; r->listener = NULL; l->notify(l, r); } +} + +static int ready[64], dup_of[64], next_dup = 40, closed[64]; +static int poll(struct pollfd *p, unsigned n, int timeout) { + if (n != 1 || timeout != 0 || p->events != POLLIN) { puts("FAIL poll args"); exit(1); } + return ready[p->fd] ? 1 : 0; +} +static int fcntl(int fd, int cmd, int arg) { (void)cmd; (void)arg; dup_of[next_dup] = fd; return next_dup++; } +static int close(int fd) { closed[fd]++; return 0; } + +struct wl_event_source { int fd; int (*fd_cb)(int, uint32_t, void *); int (*timer_cb)(void *); void *data; int armed_ms, removed; }; +struct wl_event_loop; +struct wl_display; +static struct wl_display *g_display; +static struct wl_event_source sources[32]; +static int n_sources; +static struct wl_event_loop *wl_display_get_event_loop(struct wl_display *d) { (void)d; return NULL; } +static struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *l, int fd, uint32_t mask, + int (*cb)(int, uint32_t, void *), void *data) { + (void)l; (void)mask; struct wl_event_source *s = &sources[n_sources++]; memset(s, 0, sizeof(*s)); + s->fd = fd; s->fd_cb = cb; s->data = data; return s; +} +static struct wl_event_source *wl_event_loop_add_timer(struct wl_event_loop *l, int (*cb)(void *), void *data) { + (void)l; struct wl_event_source *s = &sources[n_sources++]; memset(s, 0, sizeof(*s)); + s->fd = -1; s->timer_cb = cb; s->data = data; return s; +} +static int wl_event_source_timer_update(struct wl_event_source *s, int ms) { s->armed_ms = ms; return 0; } +static int wl_event_source_remove(struct wl_event_source *s) { s->removed = 1; return 0; } +static void dispatch(int timers_expire) { + for (int i = 0; i < n_sources; i++) { + struct wl_event_source *s = &sources[i]; + if (s->removed) continue; + if (s->fd_cb && ready[dup_of[s->fd]]) s->fd_cb(s->fd, WL_EVENT_READABLE, s->data); + else if (s->timer_cb && s->armed_ms && timers_expire) { s->armed_ms = 0; s->timer_cb(s->data); } + } +} + +static int64_t clock_ns; +static int64_t now_ns(void) { return clock_ns; } +static struct { unsigned replaced; } g_pace; +static struct { unsigned commit_waits, commit_wait_limits; int64_t commit_wait_ns, commit_wait_max_ns; } g_perf; +static int logged; +static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; logged++; } +static void send_buffer_release(struct wl_resource *r) { r->released++; } +static unsigned feedback_discard_all(struct wl_list *list) { + unsigned n = 0; struct wl_resource *r, *t; wl_resource_for_each_safe(r, t, list) { wl_resource_destroy(r); n++; } return n; +} +static struct dmabuf_buffer *get_dmabuf(struct wl_resource *r) { return r ? r->db : NULL; } +static int ahb_swapchain_has_ahb(const struct dmabuf_buffer *b) { return b->ahb; } +static int64_t rect_area(const int32_t *r, int bw, int bh) { (void)bw; (void)bh; return (int64_t)r[2] * r[3]; } + +struct damage_list { int32_t r[DAMAGE_RECTS][4]; int n; }; +struct surface { + struct wl_resource *resource, *xdg_toplevel; + int toplevel_committed; + struct wl_resource *pending_buffer; + struct wl_listener pending_buffer_destroy; + int pending_attach, pending_src_set, pending_dst_set, pending_opaque_set; + float pending_src[4]; + int pending_dst[2], pending_opaque[4]; + struct damage_list pending_damage_buf, pending_damage_local; + struct wl_list pending_frames, pending_feedback; + struct surface_state *waiting; + struct wl_event_source *waiting_source, *waiting_timer; + int waiting_fd; + int64_t waiting_since_ns; +}; +static void send_toplevel_configure(struct surface *s) { (void)s; } +struct wl_client; +static struct surface surf; + +STATE_STRUCT + +static int applies, applied_attach, applied_frames, applied_opaque, applied_damage; +static struct wl_resource *applied_buffer; +static void surface_state_apply(struct surface *s, struct surface_state *st); + +FUNCTIONS + +static void surface_state_apply(struct surface *s, struct surface_state *st) { + (void)s; + applies++; + applied_attach = st->attach; + applied_buffer = st->attach ? st->buffer : NULL; + applied_frames = wl_list_length(&st->frames); + applied_opaque = st->opaque_set ? st->opaque[2] : -1; + applied_damage = st->damage_buf.n; + if (st->attach) { wl_list_remove(&st->buffer_destroy.link); wl_list_init(&st->buffer_destroy.link); } + struct wl_resource *r, *t; + wl_resource_for_each_safe(r, t, &st->frames) wl_resource_destroy(r); + feedback_discard_all(&st->feedback); +} + +static struct wl_resource frame_res[16]; +static int n_frames; +static void attach(struct wl_resource *b) { + if (surf.pending_buffer) wl_list_remove(&surf.pending_buffer_destroy.link); + wl_list_init(&surf.pending_buffer_destroy.link); + surf.pending_buffer = b; surf.pending_attach = 1; +} +static void frame(void) { struct wl_resource *f = &frame_res[n_frames++]; wl_list_insert(surf.pending_frames.prev, &f->link); } +static void damage(int w) { surf.pending_damage_buf.r[surf.pending_damage_buf.n][2] = w; + surf.pending_damage_buf.r[surf.pending_damage_buf.n][3] = 1; surf.pending_damage_buf.n++; } +static void commit(void) { surface_commit(NULL, NULL); } +#define CHECK(c, what) do { if (!(c)) { printf("FAIL %s (line %d)\n", what, __LINE__); return 1; } } while (0) + +int main(void) { + wl_list_init(&surf.pending_frames); wl_list_init(&surf.pending_feedback); + wl_list_init(&surf.pending_buffer_destroy.link); + surf.waiting_fd = -1; + struct dmabuf_buffer d1 = {{10, -1}, 1, 0}, d2 = {{11, -1}, 1, 0}, d3 = {{12, -1}, 1, 0}, dz = {{13, -1}, 1, 1}; + struct wl_resource b1 = {.db = &d1}, b2 = {.db = &d2}, b3 = {.db = &d3}, bz = {.db = &dz}; + + ready[10] = 1; + attach(&b1); frame(); commit(); + CHECK(applies == 1 && applied_buffer == &b1 && applied_frames == 1 && !surf.waiting && n_sources == 0, "ready buffer"); + + ready[11] = 0; + clock_ns = 1000000; + attach(&b2); frame(); damage(5); commit(); + CHECK(applies == 1 && surf.waiting && surf.waiting_fd >= 40 && dup_of[surf.waiting_fd] == 11, "held"); + CHECK(sources[0].armed_ms == 0 && sources[1].armed_ms == 1000, "waits on the buffer with a 1 s limit"); + dispatch(0); + CHECK(applies == 1, "nothing before the writes end"); + clock_ns = 4000000; + ready[11] = 1; + dispatch(0); + CHECK(applies == 2 && applied_buffer == &b2 && applied_frames == 1 && applied_damage == 1 && !surf.waiting, "applied once ready"); + CHECK(closed[40] == 1 && sources[0].removed && sources[1].removed, "wait cleaned up"); + CHECK(g_perf.commit_waits == 1 && g_perf.commit_wait_max_ns == 3000000, "wait counted"); + + ready[11] = 0; ready[12] = 0; + attach(&b2); frame(); damage(7); commit(); + attach(&b3); frame(); damage(9); commit(); + CHECK(applies == 2 && b2.released == 1 && dup_of[surf.waiting_fd] == 12, "replaced while waiting"); + ready[12] = 1; + dispatch(0); + CHECK(applies == 3 && applied_buffer == &b3 && applied_frames == 2 && applied_damage == 2, "newest shown with both callbacks"); + CHECK(g_perf.commit_waits == 2, "merged wait counted once"); + + ready[11] = 0; + attach(&b2); commit(); + surf.pending_opaque[2] = 640; surf.pending_opaque_set = 1; frame(); commit(); + CHECK(applies == 3 && b2.released == 1 && dup_of[surf.waiting_fd] == 11, "the waiting buffer is not released"); + ready[11] = 1; + dispatch(0); + CHECK(applies == 4 && applied_buffer == &b2 && applied_opaque == 640 && applied_frames == 1, "buffer kept, opaque applied"); + + g_zero_copy_shown = &surf; + attach(&bz); commit(); + CHECK(applies == 5 && applied_buffer == &bz && !surf.waiting && g_unwaited == &surf, "zero-copy buffer"); + g_zero_copy_shown = NULL; + ready[13] = 0; + attach(&bz); commit(); + CHECK(applies == 5 && surf.waiting, "a droiddeck-ahb buffer not shown zero-copy waits"); + ready[13] = 1; + dispatch(0); + CHECK(applies == 6 && !g_unwaited, "waited buffer clears the mark"); + ready[13] = 0; + + ready[10] = 0; + attach(&b1); frame(); commit(); + client_destroys(&b1); + ready[10] = 1; + dispatch(0); + CHECK(applies == 7 && !applied_attach && applied_frames == 1, "destroyed buffer dropped from the commit"); + + ready[11] = 0; + attach(&b2); commit(); + dispatch(1); + CHECK(applies == 8 && applied_buffer == &b2 && g_perf.commit_wait_limits == 1 && logged == 1 && !surf.waiting, "limit"); + + ready[11] = 0; ready[12] = 0; + clock_ns = 10000000000; + attach(&b2); commit(); + CHECK(applies == 8 && sources[n_sources - 1].armed_ms == 1000, "held again"); + clock_ns += 600000000; + attach(&b3); commit(); + CHECK(applies == 8 && surf.waiting && sources[n_sources - 1].armed_ms == 400, "a newer commit keeps the first deadline"); + clock_ns += 500000000; + attach(&b2); commit(); + CHECK(applies == 9 && applied_buffer == &b2 && g_perf.commit_wait_limits == 2 && !surf.waiting, "commits past the deadline are applied at once"); + puts("PASS"); + return 0; +} +''' + + +class CommitWaitsForClientWritesTest(unittest.TestCase): + def test_commits_wait_for_the_clients_gpu_writes(self): + compiler = shutil.which(os.environ.get('CC', 'cc')) + if not compiler: + self.skipTest('A host C compiler is required') + source = SOURCE.read_text() + functions = '\n'.join(re.search(pattern, source, re.M).group(0) for pattern in + (r'^#define COMMIT_WAIT_LIMIT_MS .*$', r'^static struct surface \*g_zero_copy_shown, \*g_unwaited;$')) + '\n' + '\n'.join( + function(source, name) for name in + ('note_damage', 'on_state_buffer_destroyed', 'surface_state_take', 'state_unfinished_fd', + 'surface_state_discard', 'surface_state_merge', 'surface_wait_stop', 'surface_wait_end', 'on_commit_ready', + 'on_commit_wait_limit', 'surface_wait_start', 'surface_commit')) + probe = HARNESS.replace('STATE_STRUCT', block(source, 'struct surface_state {')).replace('FUNCTIONS', functions) + probe = probe.replace('struct surface *s = wl_resource_get_user_data(r);', 'struct surface *s = &surf; (void)r;') + with tempfile.TemporaryDirectory(prefix='droiddeck-commit-wait-') as temp: + folder = Path(temp) + (folder / 'probe.c').write_text(probe) + built = subprocess.run([compiler, '-std=gnu11', '-Wall', '-Wextra', '-Wno-unused-parameter', '-Wno-unused-function', + str(folder / 'probe.c'), '-o', str(folder / 'probe')], + capture_output=True, text=True) + self.assertEqual(built.returncode, 0, built.stdout + built.stderr) + run = subprocess.run([str(folder / 'probe')], capture_output=True, text=True, timeout=10) + self.assertEqual(run.returncode, 0, run.stdout + run.stderr) + self.assertEqual(run.stdout.strip(), 'PASS') + + def test_scenes_settle_an_unwaited_buffer_before_copying_it(self): + body = function(SOURCE.read_text(), 'render_scene').splitlines() + copies = [i for i, line in enumerate(body) if 'vkp_render(w, h, dl.d, dl.n)' in line] + self.assertGreaterEqual(len(copies), 4) + for i in copies: + self.assertTrue(any('settle_unwaited();' in line for line in body[max(0, i - 3):i]), body[i]) + text = '\n'.join(body) + self.assertIn('if (hdr_route == 1 || hdr_route == 2) settle_unwaited();', text) + self.assertIn('settle_unwaited();\n render_stream();', text) + self.assertIn('if (r == 0 && !fg_pass) g_zero_copy_shown = ls;\n else settle_unwaited();', text) + +if __name__ == '__main__': + unittest.main() diff --git a/tools/tests/test_ddfg_flow_levels.py b/tools/tests/test_ddfg_flow_levels.py index d5efd6355d..eb5f5a0186 100644 --- a/tools/tests/test_ddfg_flow_levels.py +++ b/tools/tests/test_ddfg_flow_levels.py @@ -40,6 +40,7 @@ class DdfgFlowLevelsTest(unittest.TestCase): "-Wno-missing-field-initializers", "-Wno-misleading-indentation", "-I" + str(work / "include"), "-I" + str(CHAIN), str(ROOT / "tools/tests/ddfg_flow_levels_harness.cpp"), str(CHAIN / "framegen.cpp"), + str(CHAIN / "ddfg_engine.cpp"), "-o", str(cls.binary), ], capture_output=True, text=True, timeout=120) if build.returncode: @@ -97,6 +98,38 @@ class DdfgFlowLevelsTest(unittest.TestCase): with self.subTest(model=model): self.run_case("preset", model=model, generations=3, repeats=4) + def test_many_resizes_do_not_accumulate_scratch_resources(self): + for model in (3, 4): + for preset in range(3): + with self.subTest(model=model, preset=preset): + self.run_case("resize", model=model, preset=preset, generations=3, repeats=16) + + def test_same_size_engine_restarts_use_fresh_scratch(self): + self.run_case("restart", generations=3, repeats=8) + + def test_instances_do_not_share_or_destroy_each_others_scratch(self): + self.run_case("instances", generations=3, repeats=3) + + def test_engine_teardown_waits_before_destroying_its_input_ring(self): + self.run_case("engine", generations=3) + + def test_failed_gpu_wait_stops_recording_and_retains_resources(self): + for mode in ("idle-failure", "destroy-failure", "engine-failure"): + with self.subTest(mode=mode): + self.run_case(mode, generations=3) + + def test_descriptor_pool_reset_failure_does_not_free_live_scratch(self): + self.run_case("reset-failure", generations=3) + + def test_partial_resize_allocation_is_cleaned_up(self): + self.run_case("partial", generations=3) + + def test_steady_frames_and_same_size_prepare_add_no_gpu_waits(self): + self.run_case("steady", generations=3, repeats=10) + + def test_scope_exit_releases_resources_without_an_explicit_destroy(self): + self.run_case("automatic", generations=3, repeats=3) + if __name__ == "__main__": unittest.main() diff --git a/tools/tests/test_desktop_program_diagnostics.py b/tools/tests/test_desktop_program_diagnostics.py index aafb89d20b..9124f2a810 100644 --- a/tools/tests/test_desktop_program_diagnostics.py +++ b/tools/tests/test_desktop_program_diagnostics.py @@ -6,6 +6,7 @@ import runpy import subprocess import sys import tempfile +import time import unittest @@ -13,6 +14,58 @@ BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin" DEBUG = runpy.run_path(str(BIN / "droiddeck-game-debug")) +class ProtonLogCapTest(unittest.TestCase): + def test_only_an_enabled_proton_log_is_watched(self): + self.assertEqual(DEBUG["proton_log_paths"]({"PROTON_LOG": "0", "SteamGameId": "1"}), []) + self.assertEqual(DEBUG["proton_log_paths"]({"SteamGameId": "1"}), []) + self.assertEqual(DEBUG["proton_log_paths"]({"PROTON_LOG": "1", "PROTON_LOG_DIR": "/logs", "SteamGameId": "584400"}), + ["/logs/steam-584400.log", "/logs/steam-proton.log"]) + self.assertEqual(DEBUG["proton_log_paths"]({"PROTON_LOG": "+seh", "HOME": "/root"}), ["/root/steam-proton.log"]) + + def test_the_watcher_outlives_nothing_but_the_launcher(self): + calls = [] + DEBUG["cap_proton_log"]({"PROTON_LOG": "1", "PROTON_LOG_DIR": "/logs", "SteamGameId": "7"}, pid=42, + popen=lambda argv, **kw: calls.append((argv, kw))) + argv, kw = calls[0] + self.assertEqual(argv[3:], ["42", str(DEBUG["PROTON_LOG_CAP"]), str(DEBUG["PROTON_LOG_CHECK_S"]), + "/logs/steam-7.log", "/logs/steam-proton.log"]) + self.assertTrue(kw["start_new_session"]) + self.assertIsNone(DEBUG["cap_proton_log"]({"PROTON_LOG": "0"}, popen=lambda *a, **k: self.fail("spawned"))) + + def test_a_flooding_log_is_cut_back_and_appends_continue_after_the_cut(self): + with tempfile.TemporaryDirectory() as folder: + log = Path(folder) / "steam-9.log" + launcher = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(3)"]) + with open(log, "ab") as proton: + proton.write(b"Proton: header\n" + b"x" * 300_000) + proton.flush() + watcher = DEBUG["cap_proton_log"]({"PROTON_LOG": "1", "PROTON_LOG_DIR": folder, "SteamGameId": "9"}, + pid=launcher.pid, limit=1000, every=0.1) + deadline = time.monotonic() + 5 + while log.stat().st_size > 1000 and time.monotonic() < deadline: + time.sleep(0.05) + self.assertEqual(log.stat().st_size, 1000) + proton.write(b"tail") + proton.flush() + self.assertTrue(log.read_bytes().startswith(b"Proton: header")) + self.assertTrue(log.read_bytes().endswith(b"tail")) + self.assertEqual(log.stat().st_size, 1004) + launcher.wait() + watcher.wait(timeout=5) + + def test_symlinks_are_left_alone(self): + with tempfile.TemporaryDirectory() as folder: + target = Path(folder) / "other" + target.write_bytes(b"y" * 5000) + (Path(folder) / "steam-3.log").symlink_to(target) + launcher = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(0.5)"]) + watcher = DEBUG["cap_proton_log"]({"PROTON_LOG": "1", "PROTON_LOG_DIR": folder, "SteamGameId": "3"}, + pid=launcher.pid, limit=10, every=0.1) + launcher.wait() + watcher.wait(timeout=5) + self.assertEqual(target.stat().st_size, 5000) + + class DesktopProgramDiagnosticsTest(unittest.TestCase): def launch(self, folder, desktop=True, **settings): env = dict(os.environ, DD_DEBUG_DIR=folder, WINEDEBUG="-all", PROTON_LOG="0") diff --git a/tools/tests/test_desktop_return_gaming.py b/tools/tests/test_desktop_return_gaming.py new file mode 100644 index 0000000000..d059205b5f --- /dev/null +++ b/tools/tests/test_desktop_return_gaming.py @@ -0,0 +1,75 @@ +import os +import re +import shlex +import subprocess +import tempfile +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[2] +DESKTOP = ROOT / "tools/linuxfs/desktop" +SCRIPT = (DESKTOP / "droiddeck-desktop").read_text() +ENTRY = (DESKTOP / "droiddeck-return-gaming.desktop").read_text() + + +class DesktopReturnGamingTest(unittest.TestCase): + def session(self, logout, rc=0, bottom=False): + with tempfile.TemporaryDirectory() as tmp: + run = Path(tmp, "run") + launched = Path(tmp, "launched") + exec_line = re.search(r"^Exec=(.*)$", ENTRY, re.M).group(1) + inner = shlex.split(exec_line)[2].replace("dbus-send", "true") + plasma = Path(tmp, "plasma") + plasma.write_text("#!/bin/sh\n%s\nexit %d\n" % (inner if logout == "return" else ":", rc)) + plasma.chmod(0o755) + steam = Path(tmp, "steam-launch") + steam.write_text('#!/bin/sh\necho "$*" > %s\n' % launched) + steam.chmod(0o755) + tail = SCRIPT[SCRIPT.index("return_gaming="):] + tail = tail.replace("dbus-run-session -- startplasma-wayland", str(plasma)) + tail = tail.replace("/usr/local/bin/droiddeck-pipewire stop", ":") + tail = tail.replace("/usr/local/bin/droiddeck-steam-launch", str(steam)) + tail = tail.replace("sleep 30", ":") + tail = tail.replace("/run/droiddeck", str(run)) + plasma.write_text(plasma.read_text().replace("/run/droiddeck", str(run))) + env = {k: v for k, v in os.environ.items() if k != "DD_BOTTOM_DESKTOP"} + if bottom: + env["DD_BOTTOM_DESKTOP"] = "1" + run.mkdir() + (run / "return-gaming").write_text("") + status = subprocess.run(["sh", "-c", tail], env=env, capture_output=True, text=True).returncode + return status, launched.read_text().strip() if launched.exists() else None, (run / "return-gaming").exists() + + def test_return_to_gaming_mode_opens_steam(self): + self.assertEqual(self.session("return"), (0, "bigpicture", False)) + + def test_log_out_goes_back_without_steam_even_after_an_earlier_request(self): + self.assertEqual(self.session("logout"), (0, None, False)) + + def test_a_failed_session_and_the_bottom_desktop_never_open_steam(self): + self.assertEqual(self.session("return", rc=1)[:2], (1, None)) + self.assertEqual(self.session("return", bottom=True)[:2], (0, None)) + + def test_the_logout_request_outlives_starting_the_shutdown_service(self): + exec_line = re.search(r"^Exec=(.*)$", ENTRY, re.M).group(1) + call = shlex.split(shlex.split(exec_line)[2].split(";")[-1]) + self.assertEqual(call[0], "dbus-send") + self.assertIn("--print-reply", call) + + def test_a_rejected_logout_request_forgets_the_return_to_gaming_mode(self): + exec_line = re.search(r"^Exec=(.*)$", ENTRY, re.M).group(1) + with tempfile.TemporaryDirectory() as tmp: + inner = shlex.split(exec_line)[2].replace("/run/droiddeck", tmp) + for sender, kept in (("true", True), ("false", False)): + subprocess.run(["sh", "-c", inner.replace("dbus-send", sender, 1)], check=False) + self.assertEqual(Path(tmp, "return-gaming").exists(), kept) + + def test_the_app_ships_the_shortcut_with_the_script(self): + source = (ROOT / "app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt").read_text() + self.assertIn('"usr/share/applications/droiddeck-return-gaming.desktop" to ' + '"usr/share/applications/droiddeck-return-gaming.desktop"', source) + self.assertIn("droiddeck-return-gaming.desktop", (ROOT / "tools/release/check_session_assets.py").read_text()) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_desktop_root_apps.py b/tools/tests/test_desktop_root_apps.py new file mode 100644 index 0000000000..3f9d3e9397 --- /dev/null +++ b/tools/tests/test_desktop_root_apps.py @@ -0,0 +1,36 @@ +import os +from pathlib import Path +import subprocess +import unittest + +TOOLS = Path(__file__).resolve().parents[1] +DESKTOP = (TOOLS / "linuxfs/desktop/droiddeck-desktop").read_text() +PACKAGES = (TOOLS / "ubuntu/packages-desktop.txt").read_text().split() +SANDBOXES = ("MOZ_DISABLE_CONTENT_SANDBOX", "MOZ_SHM_NO_SEALS", "QTWEBENGINE_DISABLE_SANDBOX") + + +class DesktopRootAppsTest(unittest.TestCase): + def desktop_environment(self): + head = DESKTOP[:DESKTOP.index("\nexport KWIN_COMPOSE=")] + env = {k: v for k, v in os.environ.items() if k not in SANDBOXES} + probe = "".join('echo %s=${%s-unset}\n' % (name, name) for name in SANDBOXES) + result = subprocess.run(["bash", "-c", head + "\nsh -c '" + probe + "'"], env=env, + capture_output=True, text=True, timeout=10) + self.assertEqual(0, result.returncode, result.stderr) + return dict(line.split("=", 1) for line in result.stdout.splitlines()) + + def test_web_engine_apps_start_as_root_like_firefox(self): + self.assertEqual({name: "1" for name in SANDBOXES}, self.desktop_environment()) + + def test_the_sandbox_switches_are_set_before_plasma(self): + self.assertLess(DESKTOP.index("export QTWEBENGINE_DISABLE_SANDBOX=1"), + DESKTOP.index("dbus-run-session -- startplasma-wayland")) + + def test_software_sources_gets_the_modules_it_imports(self): + self.assertIn("software-properties-qt", PACKAGES) + for module in ("pyqt6-dev-tools", "ubuntu-drivers-common"): + self.assertIn(module, PACKAGES) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_droiddeck_fex.py b/tools/tests/test_droiddeck_fex.py index e59b21c7c2..79f7043cbb 100644 --- a/tools/tests/test_droiddeck_fex.py +++ b/tools/tests/test_droiddeck_fex.py @@ -1161,9 +1161,20 @@ class LaunchTest(FexTestCase): self.assertTrue(guest["FEX_APP_CONFIG_LOCATION"].endswith("/config/")) self.assertEqual((guest["FEX_SILENTLOG"], guest["FEX_OUTPUTLOG"]), ("0", "stderr")) self.assertEqual(guest["GC_DISABLE_INCREMENTAL"], "1") + self.assertEqual(guest["DOTNET_INTERNAL_ThreadSuspendInjection"], "0") + self.assertEqual(guest["COMPlus_INTERNAL_ThreadSuspendInjection"], "0") + legacy = FEX["guest_environment"]({"portable": False}, {"COMPlus_INTERNAL_ThreadSuspendInjection": "1"}) + self.assertEqual(legacy["COMPlus_INTERNAL_ThreadSuspendInjection"], "1") + self.assertNotIn("DOTNET_INTERNAL_ThreadSuspendInjection", legacy) + blank = FEX["guest_environment"]({"portable": False}, {"COMPlus_INTERNAL_ThreadSuspendInjection": "", + "DOTNET_INTERNAL_ThreadSuspendInjection": ""}) + self.assertEqual(blank["DOTNET_INTERNAL_ThreadSuspendInjection"], "0") + self.assertEqual(blank["COMPlus_INTERNAL_ThreadSuspendInjection"], "0") guest = FEX["guest_environment"]({"portable": False}, {"LD_PRELOAD": str(arm), "FEX_PORTABLE": "1", "FEX_OUTPUTLOG": "/tmp/fex.log", - "GC_DISABLE_INCREMENTAL": "0"}) + "GC_DISABLE_INCREMENTAL": "0", "DOTNET_INTERNAL_ThreadSuspendInjection": "1"}) self.assertEqual((guest["FEX_OUTPUTLOG"], guest["GC_DISABLE_INCREMENTAL"]), ("/tmp/fex.log", "0")) + self.assertEqual(guest["DOTNET_INTERNAL_ThreadSuspendInjection"], "1") + self.assertEqual(guest["COMPlus_INTERNAL_ThreadSuspendInjection"], "1") self.assertNotIn("LD_PRELOAD", guest) self.assertNotIn("FEX_PORTABLE", guest) diff --git a/tools/tests/test_effects_lazy_pipelines.py b/tools/tests/test_effects_lazy_pipelines.py new file mode 100644 index 0000000000..9f2782989d --- /dev/null +++ b/tools/tests/test_effects_lazy_pipelines.py @@ -0,0 +1,68 @@ +import pathlib +import unittest + + +ROOT = pathlib.Path(__file__).resolve().parents[2] +SOURCE = ROOT / "app/src/main/cpp/waylandcomp/src/effects_chain.c" + + +def function_body(source: str, signature: str) -> str: + start = source.index(signature) + opening = source.index("{", start) + depth = 0 + for pos in range(opening, len(source)): + if source[pos] == "{": + depth += 1 + elif source[pos] == "}": + depth -= 1 + if depth == 0: + return source[opening + 1:pos] + raise AssertionError(f"unterminated function: {signature}") + + +class LazyEffectPipelineSourceTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.source = SOURCE.read_text(encoding="utf-8") + + def test_shared_setup_does_not_create_graphics_pipelines(self): + body = function_body(self.source, "static int objects_ensure(void)") + self.assertNotIn("post_pipeline_for_renderpass(", body) + self.assertNotIn("shader(upscale_vert_code", body) + self.assertIn("effect pipelines are created when needed", body) + + def test_pipelines_are_prepared_before_effect_chain_resources_and_draws(self): + body = function_body(self.source, "static VkImage effects_run(") + prepare = body.index("pipelines_ensure(spatial, s)") + scene = body.index("scene_ensure(scene, scene_w, scene_h)") + self.assertLess(prepare, scene) + self.assertIn("objects_ensure() == 0 && pipelines_ensure(spatial, s) == 0", body) + + def test_lazy_path_covers_active_upscalers_and_effects(self): + body = function_body(self.source, "static int pipelines_ensure(") + for required in ( + "spatial == 3", "spatial == 8", "spatial == 4 || spatial == 5", + "spatial == 6", "spatial == 7", "cas_active(s)", + "s->color_on", "s->aa_mode == 1 || s->aa_mode == 2", + "s->aa_mode == 2", "s->toon", "s->hdr_on", "s->ntsc", + "s->crt", "deband_active(s)", + ): + with self.subTest(required=required): + self.assertIn(required, body) + + def test_existing_fallback_pipelines_are_prepared(self): + body = function_body(self.source, "static int pipelines_ensure(") + self.assertIn("s->aa_mode == 1 || s->aa_mode == 2", body) + self.assertIn("else if (g_upscale_half) MK(1, P_SGSR, sgsr_half_code", body) + self.assertIn("if (!g_nis_fast) MK(1, P_NIS, nis_code", body) + + def test_failed_preparation_uses_whole_chain_fallback(self): + body = function_body(self.source, "static int pipelines_ensure(") + self.assertIn("return chain_failed();", body) + failure = function_body(self.source, "static int chain_failed(void)") + self.assertIn("objects_destroy();", failure) + self.assertIn("g_ready = -1;", failure) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_effects_source_cache.py b/tools/tests/test_effects_source_cache.py index d42045b1cf..163bef4bb6 100644 --- a/tools/tests/test_effects_source_cache.py +++ b/tools/tests/test_effects_source_cache.py @@ -57,6 +57,12 @@ class EffectsSourceCacheTest(unittest.TestCase): def test_resize_replaces_the_cached_view_and_descriptor(self): self.check_cache('resize') + def test_generated_frames_keep_separate_descriptors_until_completion(self): + self.check_cache('generated') + + def test_generated_settings_snapshot_and_source_layout_restoration(self): + self.check_cache('generated-layout') + if __name__ == '__main__': unittest.main() diff --git a/tools/tests/test_effects_source_resolution.py b/tools/tests/test_effects_source_resolution.py index cd63c69d64..fbbff9271e 100644 --- a/tools/tests/test_effects_source_resolution.py +++ b/tools/tests/test_effects_source_resolution.py @@ -106,6 +106,9 @@ class EffectsSourceResolutionTest(unittest.TestCase): def test_frame_generation_keeps_upscaling_and_sharpening_at_panel_size(self): self.check_case('framegen-sharpening') + def test_frame_generation_runs_spatial_post_upscale(self): + self.check_case('framegen-upscale') + TYPES = r''' #include @@ -157,12 +160,20 @@ typedef struct { #define HDR_FMT 101 #define FG_HDR_FMT 102 #define VK_FORMAT_R8G8B8A8_UNORM SCENE_FMT -#define VKP_FG_MAX_GENERATIONS 2 +#define VKP_FG_MAX_GENERATIONS 3 #define HDRC_OUT_PQ 1 #define HDRC_OUT_SDR 2 #define droiddeck_log(...) ((void)0) #define LOGE(...) ((void)0) struct droiddeck_color { uint32_t identity; }; +enum vkp_image_source { + VKP_IMAGE_SOURCE_NONE = 0, + VKP_IMAGE_SOURCE_DMABUF, + VKP_IMAGE_SOURCE_AHB_WLEGL, + VKP_IMAGE_SOURCE_AHB_SOURCE, + VKP_IMAGE_SOURCE_AHB_TARGET, + VKP_IMAGE_SOURCE_SHM +}; typedef struct AHardwareBuffer AHardwareBuffer; ''' @@ -196,7 +207,7 @@ static int g_dev_state = 1, g_window = 1, g_swapchain, g_swap_extra; static int g_colorspace_ext, g_swap_hdr_unavailable, g_swap_is_hdr, g_swap_hdr_want; static int g_plain_frame, g_first_frame_done, g_base_black; static int g_qfam, g_queue, g_dev, g_fence, g_swap_fmt = SCENE_FMT; -static int g_cmds[3], g_acqs[3], g_rnds[3], images[1] = {2}, *g_images = images; +static int g_cmds[4], g_acqs[4], g_rnds[4] = {11, 12, 13, 14}, g_rnd_count = 4, images[1] = {2}, *g_images = images; static uint32_t g_swap_md_identity; static VkExtent2D g_extent = {1920, 1080}; static struct { float kx, ky, off_x, off_y; int rx, ry, rw, rh; } g_map; @@ -262,15 +273,39 @@ static void record_draw(int cmd, const struct vkp_draw *draw, const VkImageBlit copy_count++; copied = *blit; copied_w = draw->dw; copied_h = draw->dh; target_w = w; target_h = h; } -static void vkp_effects_set_formats(int input, int output) {} +static void vkp_effects_set_formats(int input, int output, int scene_is_pq) {} static VkImage vkp_effects_run(int cmd, int source, int w, int h, int ow, int oh, int *rw, int *rh) { effects_count++; effects_w = w; effects_h = h; output_w = ow; output_h = oh; if (!hdr_count) assert(g_scene.w == w && g_scene.h == h); if (fail_effects) { *rw = w; *rh = h; return source; } *rw = ow; *rh = oh; return 4; } -static int vkp_framegen_run(int cmd, int result, int depth, int w, int h, int format, int *generated) { return 0; } +static int vkp_effects_prepare_generated(void) { + return g_cur.scaling >= 3 && g_cur.scaling <= 8 && g_cur.scaling != 6 && !postprocessing; +} +static VkImage vkp_effects_run_before_generated(int cmd, int source, int w, int h, int *rw, int *rh) { + return vkp_effects_run(cmd, source, w, h, w, h, rw, rh); +} +static int generations, post_count, fg_w, fg_h; +static int post_sources[4], screen_widths[4], screen_heights[4], screen_images[4]; +static int vkp_framegen_run(int cmd, int result, int depth, int w, int h, int format, int *generated) { + fg_w = w; fg_h = h; + for (int i = 0; i < generations; i++) generated[i] = 20 + i; + return generations; +} +static void vkp_effects_release_generated_sources(void) {} +static VkImage vkp_effects_run_generated(int cmd, int source, int w, int h, int ow, int oh, + int slot, int *rw, int *rh) { + assert(slot == post_count && slot < 4); + assert(w == fg_w && h == fg_h); + post_sources[post_count++] = source; + *rw = fail_effects ? w : ow; *rh = fail_effects ? h : oh; + return fail_effects ? source : 40 + slot; +} static void record_screen_blit(int cmd, int result, int w, int h, int sw, int sh, int image, int filter, int cb) { + assert(screen_count < 4); + screen_widths[screen_count] = w; screen_heights[screen_count] = h; + screen_images[screen_count] = result; screen_count++; logical_w = sw; logical_h = sh; } static void device_lost(const char *reason) {} @@ -294,6 +329,7 @@ static void reset(void) { effects_active = 1; g_cur = (struct fx_settings){4}; framegen = cardboard = fail_scene = fail_effects = postprocessing = g_plain_frame = 0; g_pass.active = 0; g_extent = (VkExtent2D){1920, 1080}; + generations = post_count = fg_w = fg_h = 0; image.w = 1280; image.h = 720; } static void check_helper(void) { @@ -567,24 +603,62 @@ static void check_allocation(void) { assert(recorded_blits[1].dstOffsets[1].x == 1920 && recorded_blits[1].dstOffsets[1].y == 1080); assert(target_w == 1920 && target_h == 1080); } -static void check_framegen_output(int scaling, int cas, int grading, int panel) { +static void check_framegen_output(int scaling, int cas, int grading, int panel, int post_upscale) { reset(); framegen = 1; postprocessing = grading; g_cur = (struct fx_settings){scaling, cas, cas ? 60 : 0}; g_extent = (VkExtent2D){2880, 1620}; struct vkp_draw draw = fullscreen(); run_path(0, &draw, 1, NULL); assert(effects_count == 1); - assert(output_w == (panel ? 2880 : 1920) && output_h == (panel ? 1620 : 1080)); + if (post_upscale) { + assert(output_w == 1280 && output_h == 720); + assert(screen_count == 1); + assert(screen_widths[0] == 2880 && screen_heights[0] == 1620); + } else { + assert(output_w == (panel ? 2880 : 1920) && output_h == (panel ? 1620 : 1080)); + } } static void check_framegen_sharpening(void) { - check_framegen_output(4, 0, 0, 1); - check_framegen_output(3, 0, 0, 1); - check_framegen_output(8, 0, 0, 1); - check_framegen_output(0, 1, 1, 1); - check_framegen_output(1, 1, 1, 1); - check_framegen_output(0, 0, 1, 0); - check_framegen_output(6, 0, 0, 0); - check_framegen_output(2, 0, 1, 0); + check_framegen_output(4, 0, 0, 1, 1); + check_framegen_output(3, 0, 0, 1, 1); + check_framegen_output(8, 0, 0, 1, 1); + check_framegen_output(0, 1, 1, 1, 0); + check_framegen_output(1, 1, 1, 1, 0); + check_framegen_output(0, 0, 1, 0, 0); + check_framegen_output(6, 0, 0, 0, 0); + check_framegen_output(2, 0, 1, 0, 0); +} +static void check_framegen_upscale(void) { + for (int count = 0; count <= VKP_FG_MAX_GENERATIONS; count++) { + reset(); framegen = 1; generations = count; + struct vkp_draw draw = fullscreen(); + run_path(0, &draw, 1, NULL); + assert(fg_w == 1280 && fg_h == 720); + assert(post_count == count + 1 && screen_count == count + 1); + for (int k = 0; k < screen_count; k++) { + assert(screen_widths[k] == 1920 && screen_heights[k] == 1080); + assert(post_sources[k] == (k < count ? 20 + k : 4)); + assert(screen_images[k] == 40 + k); + } + } + for (int mode = 0; mode <= 8; mode++) { + reset(); framegen = 1; g_cur.scaling = mode; + struct vkp_draw draw = fullscreen(); + run_path(0, &draw, 1, NULL); + assert(post_count == (mode >= 3 && mode != 6)); + } + reset(); framegen = 1; fail_effects = 1; + struct vkp_draw draw = fullscreen(); + run_path(0, &draw, 1, NULL); + assert(post_count == 1 && screen_widths[0] == 1280 && screen_heights[0] == 720); + assert(screen_images[0] == 1); + reset(); framegen = 1; postprocessing = 1; + run_path(0, &draw, 1, NULL); assert(post_count == 0); + reset(); framegen = 1; cardboard = 1; + run_path(0, &draw, 1, NULL); assert(post_count == 0); + reset(); framegen = 1; + struct vkp_hdr_frame hdr = {0}; + run_path(0, &draw, 1, &hdr); assert(post_count == 0); } int main(int argc, char **argv) { assert(argc == 2); reset(); @@ -602,6 +676,7 @@ int main(int argc, char **argv) { else if (!strcmp(argv[1], "overlay-barriers")) check_overlay_barriers(); else if (!strcmp(argv[1], "postprocessing")) check_postprocessing(); else if (!strcmp(argv[1], "framegen-sharpening")) check_framegen_sharpening(); + else if (!strcmp(argv[1], "framegen-upscale")) check_framegen_upscale(); else assert(0); puts("PASS"); } diff --git a/tools/tests/test_fakeinput_bionic.py b/tools/tests/test_fakeinput_bionic.py new file mode 100644 index 0000000000..68f06430a3 --- /dev/null +++ b/tools/tests/test_fakeinput_bionic.py @@ -0,0 +1,30 @@ +from pathlib import Path +import re +import unittest + +SOURCE = Path(__file__).resolve().parents[2] / "app/src/main/cpp/fakeinput_steam.cpp" + + +def code_only(text): + """The source without its comments and string literals.""" + text = re.sub(r"/\*.*?\*/", " ", text, flags=re.S) + text = re.sub(r"//[^\n]*", " ", text) + return re.sub(r'"(?:\\.|[^"\\\n])*"', '""', text) + + +class FakeinputBionicTest(unittest.TestCase): + # DroidDeck-Bionic preloads this library into its Wine processes (tools/bionic-runtime/build.sh). bionic + # exports no __chk_fail: a library that names it there cannot be loaded, so no Wine program starts + # ("cannot locate symbol "__chk_fail""). + def test_glibcs_fortify_failure_is_named_only_off_bionic(self): + code = code_only(SOURCE.read_text()) + guarded = re.compile(r"#if defined\(__BIONIC__\)\n(?P.*?)#else\n(?P.*?)#endif\n", re.S) + blocks = [m for m in guarded.finditer(code) if "__chk_fail" in m.group("glibc")] + self.assertTrue(blocks, "the glibc-only __chk_fail is behind #if defined(__BIONIC__) ... #else") + for block in blocks: + self.assertNotIn("__chk_fail", block.group("bionic")) + self.assertNotIn("__chk_fail", guarded.sub("", code)) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_fakeinput_ring.py b/tools/tests/test_fakeinput_ring.py index b032f8ea76..c3d625fbc7 100644 --- a/tools/tests/test_fakeinput_ring.py +++ b/tools/tests/test_fakeinput_ring.py @@ -29,14 +29,21 @@ PAD_TYPE_STEAM = 1 READER = r""" #include #include +#include #include #include #include +ssize_t __read_chk(int fd, void *buffer, size_t size, size_t buffer_size); +int __poll_chk(struct pollfd *fds, nfds_t nfds, int timeout, size_t fds_size); + static int vector_count; +static int fortified; static ssize_t controller_read(int fd, void *buffer, size_t size) { + if (fortified) + return __read_chk(fd, buffer, size, size); if (!vector_count) return read(fd, buffer, size); struct iovec vectors[3] = { @@ -53,7 +60,8 @@ static ssize_t controller_read(int fd, void *buffer, size_t size) int main(int argc, char **argv) { - vector_count = argc > 1 ? (argv[1][0] == '1' ? 1 : 3) : 0; + fortified = argc > 1 && argv[1][0] == 'f'; + vector_count = argc > 1 && !fortified ? (argv[1][0] == '1' ? 1 : 3) : 0; struct input_event events[64]; int fd = open("/dev/input/event16", O_RDONLY | O_NONBLOCK); if (fd < 0) { @@ -62,11 +70,17 @@ int main(int argc, char **argv) } while (controller_read(fd, events, sizeof(events)) > 0) ; + struct pollfd idle = {fd, POLLIN, 0}; + if (fortified && __poll_chk(&idle, 1, 0, sizeof(idle)) != 0) + return 3; puts("ready"); fflush(stdout); char go; if (read(0, &go, 1) != 1) return 1; + struct pollfd ready = {fd, POLLIN, 0}; + if (fortified && (__poll_chk(&ready, 1, 1000, sizeof(ready)) != 1 || !(ready.revents & POLLIN))) + return 2; ssize_t got = controller_read(fd, events, sizeof(events)); for (ssize_t i = 0; i < got / (ssize_t)sizeof(events[0]); i++) printf("%ld.%06ld %u %u %d\n", (long)events[i].time.tv_sec, (long)events[i].time.tv_usec, events[i].type, @@ -345,7 +359,7 @@ class FakeinputRingTest(unittest.TestCase): subprocess.run(["gcc", bits, "-o", str(binary), str(self.tmp / (name + ".c"))], check=True) return library, binary - def read_through(self, bits, vectors=None, overlay=False, virtual=True, program=READER): + def read_through(self, bits, vectors=None, overlay=False, virtual=True, program=READER, fortified=False): if not virtual: program = program.replace("event16", "event0") library, reader = self.build(bits, program, "reader") @@ -359,7 +373,7 @@ class FakeinputRingTest(unittest.TestCase): overlay_library = self.tmp / "overlay.so" subprocess.run(["gcc", bits, "-shared", "-fPIC", "-o", str(overlay_library), str(source)], check=True) env["LD_PRELOAD"] = str(overlay_library) + ":" + str(library) - command = [str(reader)] + ([str(vectors)] if vectors else []) + command = [str(reader)] + (["fortified"] if fortified else [str(vectors)] if vectors else []) process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env, text=True) self.addCleanup(process.kill) self.assertEqual(process.stdout.readline(), "ready\n") @@ -381,6 +395,10 @@ class FakeinputRingTest(unittest.TestCase): self.assertEqual(self.read_through("-m64"), "1700000000.250000 1 304 1\n1700000001.250000 3 1 -32768\n1700000002.250000 0 0 0\n") + def test_a_fortified_guest_polls_and_reads_the_ring(self): + self.assertEqual(self.read_through("-m64", virtual=False, fortified=True), + "1700000000.250000 1 304 1\n1700000001.250000 3 1 -32768\n1700000002.250000 0 0 0\n") + def test_readv_reads_events_instead_of_the_backing_file(self): self.assertEqual(self.read_through("-m64", vectors=1), "1700000000.250000 1 304 1\n1700000001.250000 3 1 -32768\n1700000002.250000 0 0 0\n") diff --git a/tools/tests/test_feedback_refresh.py b/tools/tests/test_feedback_refresh.py new file mode 100644 index 0000000000..0f4f772824 --- /dev/null +++ b/tools/tests/test_feedback_refresh.py @@ -0,0 +1,72 @@ +import shutil +import subprocess +import tempfile +import unittest +from pathlib import Path + +from test_output_refresh import SOURCE, extract_function + + +PROBE = r''' +#include +#include +#include +#include + +static atomic_int g_output_refresh_mhz; +static volatile int g_fps_limit; +static volatile int g_release_unpaced; + +%s +%s + +int main(int argc, char **argv) { + atomic_store(&g_output_refresh_mhz, atoi(argv[1])); + g_fps_limit = atoi(argv[2]); + g_release_unpaced = atoi(argv[3]); + printf("%%u\n", feedback_refresh_ns()); + return 0; +} +''' + + +@unittest.skipUnless(shutil.which('cc'), 'needs a C compiler') +class FeedbackRefreshTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + source = SOURCE.read_text() + cls.tmp = tempfile.TemporaryDirectory() + probe = Path(cls.tmp.name) / 'probe.c' + probe.write_text(PROBE % (extract_function(source, 'nominal_refresh_ns'), + extract_function(source, 'feedback_refresh_ns'))) + cls.binary = Path(cls.tmp.name) / 'probe' + subprocess.run(['cc', '-std=c11', '-Wall', '-Werror', str(probe), '-o', str(cls.binary)], check=True) + + @classmethod + def tearDownClass(cls): + cls.tmp.cleanup() + + def refresh(self, mhz, limit, unpaced=0): + out = subprocess.run([str(self.binary), str(mhz), str(limit), str(unpaced)], + check=True, capture_output=True, text=True).stdout + return int(out) + + def test_no_limit_reports_the_panel_refresh(self): + self.assertEqual(self.refresh(120000, 0), 8333333) + self.assertEqual(self.refresh(60000, 0), 16666666) + + def test_limit_below_the_panel_reports_the_limit_interval(self): + self.assertEqual(self.refresh(120000, 60), 16666666) + self.assertEqual(self.refresh(120000, 30), 33333333) + self.assertEqual(self.refresh(90000, 45), 22222222) + + def test_limit_at_or_above_the_panel_keeps_the_panel_refresh(self): + self.assertEqual(self.refresh(60000, 60), 16666666) + self.assertEqual(self.refresh(60000, 144), 16666666) + + def test_unpaced_sessions_keep_the_panel_refresh(self): + self.assertEqual(self.refresh(120000, 60, unpaced=1), 8333333) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/tests/test_framegen_ring_lifetime.py b/tools/tests/test_framegen_ring_lifetime.py new file mode 100644 index 0000000000..ca39670844 --- /dev/null +++ b/tools/tests/test_framegen_ring_lifetime.py @@ -0,0 +1,59 @@ +import os +from pathlib import Path +import shutil +import subprocess +import tempfile +import unittest + +from test_vk_pending_completion import function + + +class FramegenRingLifetimeTest(unittest.TestCase): + def test_ring_forgets_effect_sources_before_releasing_images(self): + compiler = shutil.which(os.environ.get('CC', 'cc')) + if not compiler: + self.skipTest('A host C compiler is required') + root = Path(__file__).resolve().parents[2] + source = (root / 'app/src/main/cpp/waylandcomp/src/framegen_bridge.c').read_text() + code = r''' +#include +#include +#include +#include +static int g_dev, g_engine_ok = 1, idle, forgotten[4], images, views, memory, engine; +static uint32_t g_ring_n = 3; +static struct { int img, view, mem; } g_ring[3]; +static void wait_idle(int d) { idle++; } +static void vkp_effects_forget_image(int image) { assert(idle == 1); forgotten[image]++; } +static void destroy_image(int d, int image, const void *a) { + assert(forgotten[image] == 1); images++; +} +static void destroy_view(int d, int view, const void *a) { assert(idle == 1); views++; } +static void free_memory(int d, int mem, const void *a) { assert(images > memory); memory++; } +static void fge_forget_targets(void) { assert(images == 3); engine++; } +static struct { + void (*DeviceWaitIdle)(int); + void (*DestroyImage)(int, int, const void *); + void (*DestroyImageView)(int, int, const void *); + void (*FreeMemory)(int, int, const void *); +} vk = {wait_idle, destroy_image, destroy_view, free_memory}; +''' + code += function(source, 'destroy_ring') + code += r''' +int main(void) { + for (int i = 0; i < 3; i++) g_ring[i].img = g_ring[i].view = g_ring[i].mem = i + 1; + destroy_ring(); + assert(g_ring_n == 0 && images == 3 && views == 3 && memory == 3 && engine == 1); + for (int i = 0; i < 3; i++) assert(!g_ring[i].img && !g_ring[i].view && !g_ring[i].mem); + destroy_ring(); + assert(idle == 1 && engine == 1); +} +''' + with tempfile.TemporaryDirectory() as tmp: + folder = Path(tmp) + probe = folder / 'ring.c' + binary = folder / 'ring' + probe.write_text(code) + subprocess.run([compiler, '-std=c11', str(probe), '-o', str(binary)], check=True, + capture_output=True, text=True) + subprocess.run([str(binary)], check=True, capture_output=True, timeout=10) diff --git a/tools/tests/test_game_cpus_live.py b/tools/tests/test_game_cpus_live.py new file mode 100644 index 0000000000..c035200029 --- /dev/null +++ b/tools/tests/test_game_cpus_live.py @@ -0,0 +1,67 @@ +import os +from pathlib import Path +import runpy +import subprocess +import tempfile +import unittest + +BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin" +COMPAT = runpy.run_path(str(BIN / "steam-compatibility")) + + +class LiveGameCpusTest(unittest.TestCase): + def setUp(self): + self.temp = tempfile.TemporaryDirectory() + self.addCleanup(self.temp.cleanup) + base = Path(self.temp.name) + self.live = base / "game-cores" + tools = base / "tools" + tools.mkdir() + for name, body in (("taskset", "exit 0"), ("nproc", "echo 8")): + tool = tools / name + tool.write_text("#!/bin/sh\n" + body + "\n") + tool.chmod(0o755) + self.path = str(tools) + os.pathsep + os.environ.get("PATH", "") + + def run_setup(self, live=None, **extra): + if live is not None: + self.live.write_bytes(live.encode()) + setup = COMPAT["DD_GAME_CPUS_SETUP"].replace("/root/.config/droiddeck/game-cores", str(self.live)) + script = setup + '\ndd_game_cpus\necho "taskset=${DD_TASKSET:-}"\necho "cpus=${DD_GAME_CPUS-unset}"\n' + env = {key: value for key, value in os.environ.items() if not key.startswith("DD_")} + env.update(PATH=self.path, **extra) + result = subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True, check=True) + return result.stdout.splitlines() + + def test_a_change_made_during_the_session_wins_over_the_session_value(self): + self.assertEqual(self.run_setup("6,7\n", DD_GAME_CPUS="3,4,5,6,7"), + ["taskset=taskset -c 6,7", "cpus=6,7"]) + + def test_every_core_chosen_during_the_session_drops_the_session_pin(self): + self.assertEqual(self.run_setup("\n", DD_GAME_CPUS="3,4,5,6,7"), ["taskset=", "cpus=unset"]) + + def test_every_core_with_a_pinned_client_still_frees_the_game_from_the_client_cores(self): + self.assertEqual(self.run_setup("\n", DD_GAME_CPUS="0-7", DD_CLIENT_CPUS="0"), + ["taskset=taskset -c 0-7", "cpus=0-7"]) + + def test_without_the_live_file_the_session_value_is_used(self): + self.assertEqual(self.run_setup(DD_GAME_CPUS="3,4,5,6,7"), + ["taskset=taskset -c 3,4,5,6,7", "cpus=3,4,5,6,7"]) + self.assertEqual(self.run_setup(), ["taskset=", "cpus=unset"]) + + def test_a_file_caught_mid_write_keeps_the_session_value(self): + for partial in ("", "6,7", "6"): + self.assertEqual(self.run_setup(partial, DD_GAME_CPUS="4,5"), ["taskset=taskset -c 4,5", "cpus=4,5"], partial) + + def test_an_unreadable_value_keeps_the_session_value(self): + for bad in ("3;rm\n", "6-\n", "-3\n", "3,,4\n", "3,\n", "3\n4\n", "3\n4", "\n3\n", "3\0,4\n", "\0\n"): + self.assertEqual(self.run_setup(bad, DD_GAME_CPUS="4,5"), ["taskset=taskset -c 4,5", "cpus=4,5"], bad) + + def test_the_file_is_found_whatever_home_the_client_runs_with(self): + self.assertEqual(self.run_setup("6,7\n", DD_GAME_CPUS="3,4,5,6,7", HOME="/root/.droiddeck-x64"), + ["taskset=taskset -c 6,7", "cpus=6,7"]) + self.assertIn("live=/root/.config/droiddeck/game-cores ", COMPAT["DD_GAME_CPUS_SETUP"]) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index 830b7f2e5d..b7b658f21b 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -1741,6 +1741,94 @@ class GameEnvironmentTest(unittest.TestCase): (asylum / name).touch() self.assertEqual(MODULE["engine_fixes"](str(asylum / "BmLauncher.exe"), []), ({}, [], [])) + def test_store_launcher_resolves_the_game_executable_from_the_sidecar(self): + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) / "BatmanArkhamCity" + bin_dir = root / "Binaries/Win32" + bin_dir.mkdir(parents=True) + for name in ("Batman2.exe", "BatmanAC.exe"): + (bin_dir / name).touch() + launcher = root / ".droiddeck-launch.bat" + launcher.touch() + (root / ".droiddeck-store.json").write_text(json.dumps({ + "store": "epic", "id": "Egret", "title": "Batman Arkham City", + "exe": "Binaries/Win32/Batman2.exe", "launcher": ".droiddeck-launch.bat", + })) + env, extra, notes = MODULE["engine_fixes"](str(launcher), []) + self.assertEqual((env, extra), ({"FEX_X87REDUCEDPRECISION": "0"}, [])) + self.assertTrue(notes) + + home = Path(tmp) / "home" + config = home / ".config/droiddeck/game-environment.json" + config.parent.mkdir(parents=True) + config.write_text(json.dumps({"version": 1, "shared": {"FEX_X87REDUCEDPRECISION": "1"}})) + probe = home / "proton" + probe.write_text("#!" + sys.executable + "\nimport os, sys\n" + "print(os.environ.get('FEX_X87REDUCEDPRECISION', ''))\n" + "print(sys.argv[2])\n") + probe.chmod(0o755) + base = {k: v for k, v in os.environ.items() if not k.startswith(("FEX_", "WINE", "PROTON", "DROIDDECK", "DD_", "STEAM"))} + base.update(HOME=str(home), STEAM_COMPAT_DATA_PATH=str(home / "compatdata/3648205350")) + result = subprocess.run([sys.executable, str(BIN / "droiddeck-game-env"), str(probe), "waitforexitandrun", str(launcher)], + env=base, text=True, capture_output=True, check=True) + self.assertEqual(result.stdout.splitlines(), ["0", str(launcher)]) + self.assertIn("Batman: Arkham City: FEX with full x87 precision", result.stderr) + + rebirth = Path(tmp) / "FF7Rebirth" + rebirth_exe = rebirth / "End/Binaries/Win64/ff7rebirth_.exe" + rebirth_exe.parent.mkdir(parents=True) + rebirth_exe.touch() + rebirth_launcher = rebirth / ".droiddeck-launch.bat" + rebirth_launcher.touch() + (rebirth / ".droiddeck-store.json").write_text(json.dumps({ + "store": "epic", "id": "ff7", "title": "FF7 Rebirth", + "exe": r"End\Binaries\Win64\ff7rebirth_.exe", "launcher": ".droiddeck-launch.bat", + })) + self.assertEqual(MODULE["engine_fixes"](str(rebirth_launcher), [])[0], {"VKD3D_FEATURE_LEVEL": "12_2"}) + + def test_store_launcher_ignores_missing_invalid_or_escaping_sidecar_paths(self): + with tempfile.TemporaryDirectory() as tmp: + outside = Path(tmp) / "Outside" + outside.mkdir() + outside_exe = outside / "BatmanAC.exe" + outside_exe.touch() + + root = Path(tmp) / "Game" + sub = root / "sub" + sub.mkdir(parents=True) + (root / "real.exe").touch() + (sub / "nested.exe").touch() + (root / "escape.exe").symlink_to(outside_exe) + (root / "linkdir").symlink_to(outside) + launcher = root / ".droiddeck-launch.bat" + launcher.touch() + sidecar = root / ".droiddeck-store.json" + + resolve = MODULE["store_game_exe"] + self.assertEqual(resolve(str(launcher)), str(launcher)) + + for payload in ("not-json", "[]", json.dumps({"exe": ""}), json.dumps({"exe": 123}), + json.dumps({"exe": "missing.exe"}), json.dumps({"exe": "sub"}), + json.dumps({"exe": "../Outside/BatmanAC.exe"}), + json.dumps({"exe": "sub/../real.exe"}), + json.dumps({"exe": r"sub\..\real.exe"}), + json.dumps({"exe": "linkdir/../real.exe"}), + json.dumps({"exe": "sub/../../Outside/BatmanAC.exe"}), + json.dumps({"exe": str(outside_exe)}), + json.dumps({"exe": r"C:\Windows\notepad.exe"}), + json.dumps({"exe": "escape.exe"})): + with self.subTest(payload=payload): + sidecar.write_text(payload) + self.assertEqual(resolve(str(launcher)), str(launcher)) + + sidecar.write_text(json.dumps({"exe": "real.exe"})) + self.assertEqual(resolve(str(launcher)), str(root / "real.exe")) + sidecar.write_text(json.dumps({"exe": "sub/nested.exe"})) + self.assertEqual(resolve(str(launcher)), str(sub / "nested.exe")) + other_bat = root / "custom.bat" + other_bat.touch() + self.assertEqual(resolve(str(other_bat)), str(other_bat)) + def test_split_second_gets_x87_fip_unless_the_game_sets_jit_features(self): with tempfile.TemporaryDirectory() as tmp: game = Path(tmp) / "SplitSecond" @@ -1762,6 +1850,76 @@ class GameEnvironmentTest(unittest.TestCase): config["games"] = {"297860": {"FEX_JITFEATURES": "off"}} self.assertEqual(MODULE["apply_config"]({}, config, "297860", env)["FEX_JITFEATURES"], "off") + def test_inno_setup_installers_get_the_stability_preset_over_the_default(self): + stability = {"FEX_TSOENABLED": "1", "FEX_VECTORTSOENABLED": "1", "FEX_MEMCPYSETTSOENABLED": "1", + "FEX_HALFBARRIERTSOENABLED": "1", "FEX_X87REDUCEDPRECISION": "0", "FEX_MULTIBLOCK": "0"} + performance_tso = {"FEX_TSOENABLED": "1", "FEX_VECTORTSOENABLED": "0", "FEX_MEMCPYSETTSOENABLED": "0", + "FEX_HALFBARRIERTSOENABLED": "0", "FEX_X87REDUCEDPRECISION": "1", "FEX_MULTIBLOCK": "1"} + + def loader(path, resources=b"", machine=0x14C, section=b".rsrc", legacy=False): + dos = bytearray(0x80) + dos[:2] = b"MZ" + dos[0x3C:0x40] = (0x80).to_bytes(4, "little") + if legacy: + dos[0x30:0x34] = b"Inno" + header = b"PE\0\0" + machine.to_bytes(2, "little") + (1).to_bytes(2, "little") + bytes(12) \ + + (0xE0).to_bytes(2, "little") + bytes(2) + entry = section.ljust(8, b"\0") + bytes(8) + len(resources).to_bytes(4, "little") \ + + (0x400).to_bytes(4, "little") + bytes(16) + path.write_bytes((bytes(dos) + header + bytes(0xE0) + entry).ljust(0x400, b"\0") + resources) + return str(path) + + with tempfile.TemporaryDirectory() as tmp: + folder = Path(tmp) + table = bytes(64) + b"rDlPtS\xcd\xe6\xd7{\x0b*" + bytes(64) + installers = [ + loader(folder / "setup.exe", table), + loader(folder / "setup_game_1.0.exe", bytes(64) + b"nS5W7dT\x83\xaa\x1b\x0fj"), + loader(folder / "old_setup.exe", legacy=True), + ] + for installer in installers: + env, extra, notes = MODULE["engine_fixes"](installer, []) + self.assertEqual((env, extra), (stability, []), installer) + self.assertTrue(notes) + config = {"version": 1, "shared": performance_tso} + self.assertEqual({k: v for k, v in MODULE["apply_config"]({}, config, "42", env).items() if k in stability}, + stability) + config["games"] = {"42": {"FEX_MULTIBLOCK": "1"}} + self.assertEqual(MODULE["apply_config"]({}, config, "42", env)["FEX_MULTIBLOCK"], "1") + + not_installers = [ + loader(folder / "Game.exe", bytes(256)), + loader(folder / "Game64.exe", table, machine=0x8664), + loader(folder / "Data.exe", table, section=b".data"), + folder / "missing.exe", + ] + (folder / "notes.exe").write_bytes(b"rDlPtS\xcd\xe6\xd7{\x0b*") + not_installers.append(folder / "notes.exe") + for other in not_installers: + self.assertEqual(MODULE["engine_fixes"](str(other), []), ({}, [], []), other) + + # The run verb skips engine_fixes; an installer started that way still gets Stability. + probe = folder / "proton" + probe.write_text("#!" + sys.executable + "\nimport json, os\nprint(json.dumps(dict(os.environ)))\n") + probe.chmod(0o755) + base = {**os.environ, **performance_tso, "HOME": tmp, "STEAM_COMPAT_DATA_PATH": str(folder / "compatdata/42")} + + def run_verb(program): + out = subprocess.run([sys.executable, str(BIN / "droiddeck-game-env"), str(probe), "run", program], + env=base, text=True, capture_output=True, check=True).stdout + return {name: value for name, value in json.loads(out).items() if name in stability} + + self.assertEqual(run_verb(installers[0]), stability) + self.assertEqual(run_verb(str(folder / "Game.exe")), performance_tso) + config_path = folder / ".config/droiddeck/game-environment.json" + config_path.parent.mkdir(parents=True) + config_path.write_text(json.dumps({"version": 1, "shared": {"WINEESYNC": "1"}})) + self.assertEqual(run_verb(installers[0]), stability) + config_path.write_text(json.dumps({"version": 1, "games": {"42": {"FEX_MULTIBLOCK": "1"}}})) + self.assertEqual(run_verb(installers[0]), {**stability, "FEX_MULTIBLOCK": "1"}) + config_path.write_text(json.dumps({"version": 1, "games": {"42": {"FEX_MULTIBLOCK": None}}})) + self.assertNotIn("FEX_MULTIBLOCK", run_verb(installers[0])) + def test_d3dgear_capture_hook_beside_the_game_is_turned_off(self): with tempfile.TemporaryDirectory() as tmp: game = Path(tmp) / "The Crew 2" diff --git a/tools/tests/test_gamescope_forwarded_buffer_scanout.py b/tools/tests/test_gamescope_forwarded_buffer_scanout.py new file mode 100644 index 0000000000..77e6f32a30 --- /dev/null +++ b/tools/tests/test_gamescope_forwarded_buffer_scanout.py @@ -0,0 +1,222 @@ +from pathlib import Path +import os +import shutil +import subprocess +import tempfile +import unittest + + +ROOT = Path(__file__).resolve().parents[2] +PATCHES = ROOT / "tools/gamescope/patches" +PICK = PATCHES / "0146-composite-waits-for-scanout.patch" +FORWARD = PATCHES / "0147-forwarded-buffers-wait-for-scanout.patch" + + +def post_image(patch, name): + out, current = [], None + for line in patch.read_text().splitlines(): + if line.startswith("+++ "): + current = line[6:] if line.startswith("+++ b/") else line[4:] + continue + if current != name or line.startswith("--- ") or line.startswith("@@"): + continue + if line.startswith("+") or line.startswith(" "): + out.append(line[1:]) + elif line == "": + out.append("") + return "\n".join(out) + + +def block(text, start, end="\n }\n"): + begin = text.index(start) + return text[begin:text.index(end, begin) + len(end)] + + +PREAMBLE = r''' +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct wl_buffer {}; +static struct { void debugf(const char *, ...) {} void errorf(const char *, ...) { ++oh_no; } int oh_no = 0; } xdg_log; +namespace droiddeck::frame_trace { enum class Event { OutputRelease }; inline void Record(Event) {} } + +namespace gamescope +{ + PICK + + class IWaitable + { + public: + virtual ~IWaitable() {} + virtual int GetFD() { return -1; } + virtual void OnPollOut() {} + virtual void OnPollHangUp() {} + }; + + template + class CAsyncWaiter + { + public: + CAsyncWaiter( const char * ) {} + bool AddWaitable( IWaitable *p, uint32_t ) { waiting.push_back( p ); return true; } + void RemoveWaitable( IWaitable *p ) { std::erase( waiting, p ); } + std::vector waiting; + }; + + class CWaylandBackend; + + class CBaseBackendFb + { + public: + uint32_t IncRef() { return refs++; } + uint32_t DecRef() { return --refs; } + bool ShowsClientBuffer() const { return client; } + uint32_t refs = 1; + bool client = false; + }; + + class CWaylandFb final : public CBaseBackendFb + { + public: + CWaylandFb( int nDmabufFd ) : m_pHostBuffer{ &m_Buffer }, m_nDmabufFd{ nDmabufFd } {} + void OnCompositorAcquire(); + void OnCompositorRelease(); + void OnScanoutDone( uint64_t ulAcquireSerial ); + void Wayland_Buffer_Release( wl_buffer *pBuffer ); + wl_buffer m_Buffer; + wl_buffer *m_pHostBuffer; + int m_nDmabufFd = -1; + std::mutex m_AcquireMutex; + uint64_t m_ulAcquireSerial = 0; + bool m_bCompositorAcquired = false; + }; + + SCANOUT + + METHODS +} +''' + +MAIN = r''' +using namespace gamescope; + +static CAsyncWaiter<> &waiter() { return CWaylandScanoutRelease::Waiter(); } + +struct Display { + int fds[2]; + Display() { assert( pipe2( fds, O_NONBLOCK ) == 0 ); } + ~Display() { close( fds[0] ); close( fds[1] ); } + void scanning() { char b[4096] = {}; while ( write( fds[1], b, sizeof( b ) ) > 0 ) {} } + void done() { char b[4096]; while ( read( fds[0], b, sizeof( b ) ) > 0 ) {} } + int fd() { return fds[1]; } +}; + +static void fire() { + assert( waiter().waiting.size() == 1 ); + waiter().waiting.front()->OnPollOut(); + assert( waiter().waiting.empty() ); +} + +int main( int argc, char **argv ) { + std::string which = argv[1]; + Display d; + CWaylandFb fb{ fcntl( d.fd(), F_DUPFD_CLOEXEC, 0 ) }; + if ( which == "client-scanning" ) { + fb.client = true; + fb.OnCompositorAcquire(); + assert( fb.refs == 2 ); + d.scanning(); + fb.Wayland_Buffer_Release( fb.m_pHostBuffer ); + assert( fb.refs == 2 && fb.m_bCompositorAcquired ); + d.done(); + fire(); + assert( fb.refs == 1 && !fb.m_bCompositorAcquired && xdg_log.oh_no == 0 ); + } else if ( which == "client-idle" ) { + fb.client = true; + fb.OnCompositorAcquire(); + fb.Wayland_Buffer_Release( fb.m_pHostBuffer ); + assert( fb.refs == 1 && waiter().waiting.empty() ); + } else if ( which == "composite-scanning" ) { + fb.OnCompositorAcquire(); + d.scanning(); + fb.Wayland_Buffer_Release( fb.m_pHostBuffer ); + assert( fb.refs == 1 && waiter().waiting.empty() ); + } else if ( which == "shown-again" ) { + fb.client = true; + fb.OnCompositorAcquire(); + d.scanning(); + fb.Wayland_Buffer_Release( fb.m_pHostBuffer ); + fb.OnCompositorAcquire(); + d.done(); + fire(); + assert( fb.refs == 2 && fb.m_bCompositorAcquired ); + fb.Wayland_Buffer_Release( fb.m_pHostBuffer ); + assert( fb.refs == 1 && !fb.m_bCompositorAcquired && xdg_log.oh_no == 0 ); + } else if ( which == "no-dmabuf" ) { + CWaylandFb plain{ -1 }; + plain.client = true; + plain.OnCompositorAcquire(); + plain.Wayland_Buffer_Release( plain.m_pHostBuffer ); + assert( plain.refs == 1 && waiter().waiting.empty() ); + } else { + return 2; + } + return 0; +} +''' + + +class ForwardedBufferScanoutTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + cxx = shutil.which(os.environ.get("CXX", "c++")) + if not cxx: + raise AssertionError("C++ compiler required") + pick = post_image(PICK, "src/output_image_pick.hpp") + pick = pick[pick.index("struct OutputImagePick"):pick.rindex("}")] + wayland = post_image(FORWARD, "src/Backends/WaylandBackend.cpp") + scanout = block(wayland, " class CWaylandScanoutRelease", "\n };\n") + methods = "\n".join(block(wayland, " void CWaylandFb::" + name) for name in + ("OnCompositorAcquire()", "OnCompositorRelease()", "OnScanoutDone(", "Wayland_Buffer_Release(")) + source = PREAMBLE.replace("PICK", pick).replace("SCANOUT", scanout).replace("METHODS", methods) + MAIN + cls.tmp = tempfile.TemporaryDirectory(prefix="droiddeck-forwarded-scanout-") + cls.addClassCleanup(cls.tmp.cleanup) + probe = Path(cls.tmp.name) / "probe.cpp" + probe.write_text(source) + cls.binary = probe.with_suffix("") + built = subprocess.run([cxx, "-std=c++20", "-Wall", "-Wextra", "-Werror", "-Wno-unused-parameter", "-UNDEBUG", + "-include", "string", str(probe), "-o", str(cls.binary)], capture_output=True, text=True) + if built.returncode: + raise AssertionError(built.stdout + built.stderr) + + def scenario(self, name): + result = subprocess.run([str(self.binary), name], capture_output=True, text=True, timeout=10) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + + def test_forwarded_buffer_is_held_until_scanout_ends(self): + self.scenario("client-scanning") + + def test_idle_forwarded_buffer_is_released_at_once(self): + self.scenario("client-idle") + + def test_composite_output_image_keeps_the_release_at_latch(self): + self.scenario("composite-scanning") + + def test_buffer_shown_again_waits_for_its_next_release(self): + self.scenario("shown-again") + + def test_buffer_without_dmabuf_is_released_at_once(self): + self.scenario("no-dmabuf") + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_gamescope_pointer_hold_edge.py b/tools/tests/test_gamescope_pointer_hold_edge.py new file mode 100644 index 0000000000..e405474e88 --- /dev/null +++ b/tools/tests/test_gamescope_pointer_hold_edge.py @@ -0,0 +1,102 @@ +from pathlib import Path +import shutil +import subprocess +import tempfile +import unittest + + +ROOT = Path(__file__).resolve().parents[2] +HOLD = ROOT / "tools/gamescope/patches/0133-constraint-relative-when-held.patch" +EDGE = ROOT / "tools/gamescope/patches/0144-pointer-hold-ignores-motion-into-the-edge.patch" + + +def added_source(patch): + return "\n".join(line[1:] for line in patch.read_text().splitlines() if line.startswith("+") and not line.startswith("+++")) + + +def block(text, start): + begin = text.index(start) + return text[begin:text.index("\n}", begin) + 3] + + +PREAMBLE = r''' +#include +#include +#include +#include +''' + +MAIN = r''' +static const uint64_t FRAME = 16'666'667ul; + +struct Pointer { + PointerHold hold; + int x; + int width; + uint64_t now = 1'000'000'000ul; + bool step(double seatDX, int pointerDX) { + now += FRAME; + const double reach = pointer_reach(x, seatDX, width); + x += pointerDX; + return pointer_hold_step(hold, true, reach, 0.0, pointerDX, 0.0, now); + } +}; + +int main() { + assert(pointer_reach(1279, 26.0, 1280) == 0.0); + assert(pointer_reach(1270, 26.0, 1280) == 9.0); + assert(pointer_reach(0, -13.0, 1280) == 0.0); + assert(pointer_reach(640, -13.0, 1280) == -13.0); + assert(pointer_reach(5, 3.0, 0) == -5.0); + + Pointer pinned{{}, 1279, 1280}; + for (int i = 0; i < 20; i++) assert(!pinned.step(26.0, 0)); + + Pointer release{{}, 1279, 1280}; + release.hold.bHeld = true; + for (int i = 0; i < 20; i++) assert(release.step(26.0, 0)); + for (int i = 0; i < 10; i++) assert(release.step(-13.0, -13)); + for (int i = 0; i < 10; i++) assert(release.step(13.0, 13)); + assert(release.x == 1279); + for (int i = 0; i < 20; i++) assert(release.step(26.0, 0)); + for (int i = 0; i < 9; i++) assert(release.step(-13.0, -13)); + assert(!release.step(-13.0, -13)); + bool held = false; + + Pointer recentre{{}, 640, 1280}; + held = false; + for (int i = 0; i < 3; i++) held = recentre.step(26.0, 0); + assert(held); + return 0; +} +''' + + +class GamescopePointerHoldEdgeTest(unittest.TestCase): + def test_motion_into_the_screen_edge_neither_holds_nor_resets_the_release(self): + compiler = shutil.which("c++") or shutil.which("g++") or shutil.which("clang++") + if not compiler: + self.skipTest("no C++ compiler") + hold = added_source(HOLD) + edge = added_source(EDGE) + source = PREAMBLE + "\n".join([ + block(hold, "struct PointerHold"), + block(hold, "static bool pointer_hold_step"), + block(edge, "static double pointer_reach"), + ]) + MAIN + with tempfile.TemporaryDirectory() as tmp: + src = Path(tmp) / "pointer_hold_edge.cpp" + exe = Path(tmp) / "pointer_hold_edge" + src.write_text(source) + subprocess.run([compiler, "-std=c++17", "-Wall", "-Werror", "-UNDEBUG", str(src), "-o", str(exe)], check=True) + subprocess.run([str(exe)], check=True) + + def test_the_hold_rule_compares_against_the_reachable_motion(self): + edge = added_source(EDGE) + self.assertIn("pointer_reach( s_nRootX, flDX, pCtx->root_width )", edge) + self.assertIn("pointer_reach( s_nRootY, flDY, pCtx->root_height )", edge) + self.assertIn("pointer_hold_step( s_Hold, true, flReachX, flReachY,", edge) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_gamescope_pointer_hold_touch_down.py b/tools/tests/test_gamescope_pointer_hold_touch_down.py new file mode 100644 index 0000000000..7f8f2b01d7 --- /dev/null +++ b/tools/tests/test_gamescope_pointer_hold_touch_down.py @@ -0,0 +1,109 @@ +from pathlib import Path +import shutil +import subprocess +import tempfile +import unittest + + +ROOT = Path(__file__).resolve().parents[2] +HOLD = ROOT / "tools/gamescope/patches/0133-constraint-relative-when-held.patch" +DOWN = ROOT / "tools/gamescope/patches/0145-pointer-hold-skips-touch-down-warps.patch" + + +def added_source(patch): + return "\n".join(line[1:] for line in patch.read_text().splitlines() if line.startswith("+") and not line.startswith("+++")) + + +def block(text, start): + begin = text.index(start) + return text[begin:text.index("\n}", begin) + 3] + + +PREAMBLE = r''' +#include +#include +#include +#include +''' + +MAIN = r''' +static const uint64_t FRAME = 16'666'667ul; + +struct Session { + PointerHold hold; + uint64_t now = 1'000'000'000ul; + bool skipTouchDown; + bool frame(double seatDX, double pointerDX, bool touchDown) { + now += FRAME; + if (touchDown && skipTouchDown) return hold.bHeld; + return pointer_hold_step(hold, true, seatDX, 0.0, pointerDX, 0.0, now); + } + void held() { + hold = PointerHold{}; + hold.bHeld = true; + } + bool strokes() { + held(); + bool result = true; + for (int i = 0; i < 17; i++) result = frame(80.0, 80.0, false); + result = frame(41.0, -1106.0, true); + for (int i = 0; i < 15; i++) result = frame(73.3, 73.0, false); + return result; + } +}; + +int main() { + Session counted{{}, 1'000'000'000ul, false}; + assert(counted.strokes()); + + Session skipped{{}, 1'000'000'000ul, true}; + assert(!skipped.strokes()); + + Session drag{{}, 1'000'000'000ul, true}; + drag.held(); + bool result = drag.frame(41.0, -1106.0, true); + assert(result); + for (int i = 0; i < 29; i++) result = drag.frame(12.0, 12.0, false); + assert(result); + result = drag.frame(12.0, 12.0, false); + assert(!result); + + Session recentre{{}, 1'000'000'000ul, true}; + for (int i = 0; i < 3; i++) result = recentre.frame(26.0, 0.0, false); + assert(result); + result = recentre.frame(-400.0, 300.0, true); + assert(result); + for (int i = 0; i < 40; i++) result = recentre.frame(12.0, 0.0, false); + assert(result); + return 0; +} +''' + + +class GamescopePointerHoldTouchDownTest(unittest.TestCase): + def test_touch_down_is_skipped_and_touch_drags_release_the_hold(self): + compiler = shutil.which("c++") or shutil.which("g++") or shutil.which("clang++") + if not compiler: + self.skipTest("no C++ compiler") + hold = added_source(HOLD) + source = PREAMBLE + "\n".join([ + block(hold, "struct PointerHold"), + block(hold, "static bool pointer_hold_step"), + ]) + MAIN + with tempfile.TemporaryDirectory() as tmp: + src = Path(tmp) / "pointer_hold_touch_down.cpp" + exe = Path(tmp) / "pointer_hold_touch_down" + src.write_text(source) + subprocess.run([compiler, "-std=c++17", "-Wall", "-Werror", "-UNDEBUG", str(src), "-o", str(exe)], check=True) + subprocess.run([str(exe)], check=True) + + def test_only_touch_down_warps_are_skipped(self): + added = added_source(DOWN) + self.assertIn(" \t\t\t\twlserver_mousewarp( tx, ty, time, false, true );\n+\t\t\t\twlserver.ulTouchDownWarps++;", DOWN.read_text()) + self.assertEqual(1, added.count("wlserver.ulTouchDownWarps++")) + self.assertIn("const bool bTouchDown = ulTouchDownWarps != s_ulTouchDownWarps;", added) + self.assertIn("else if ( !bTouchDown )", added) + self.assertNotIn("bFromTouch )\n\t\twlserver.ulTouchDownWarps++", added) + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_gamescope_touch_click_owner.py b/tools/tests/test_gamescope_touch_click_owner.py new file mode 100644 index 0000000000..1063838a35 --- /dev/null +++ b/tools/tests/test_gamescope_touch_click_owner.py @@ -0,0 +1,121 @@ +from pathlib import Path +import shutil +import subprocess +import tempfile +import unittest + + +ROOT = Path(__file__).resolve().parents[2] +PATCH = ROOT / "tools/gamescope/patches/0143-touch-click-first-finger-drives.patch" + + +def added_source(): + return "\n".join(line[1:] for line in PATCH.read_text().splitlines() if line.startswith("+") and not line.startswith("+++")) + + +def block(text, start): + begin = text.index(start) + return text[begin:text.index("\n}", begin) + 3] + + +PREAMBLE = r''' +#include +#include +''' + +MAIN = r''' +struct Pointer { + TouchClickState state; + int warps = 0; + int presses = 0; + int releases = 0; + void down(int id) { if (touch_click_claim(state, id)) { warps++; presses++; } } + void move(int id, bool nested = false) { if (nested || touch_click_drives(state, id)) warps++; } + void up(int id) { if (touch_click_lift(state, id)) releases++; } +}; + +int main() { + Pointer tap; + tap.down(1); + tap.move(1); + tap.up(1); + assert(tap.presses == 1 && tap.releases == 1 && tap.warps == 2); + + Pointer drag; + drag.down(1); + drag.move(1); + drag.down(2); + drag.move(2); + drag.move(1); + drag.up(2); + assert(drag.presses == 1 && drag.releases == 0 && drag.warps == 3); + drag.move(1); + drag.up(1); + assert(drag.releases == 1 && drag.warps == 4); + + Pointer handover; + handover.down(1); + handover.down(2); + handover.up(1); + assert(handover.releases == 1); + handover.move(2); + handover.down(3); + handover.move(3); + assert(handover.warps == 1 && handover.presses == 1); + handover.up(3); + handover.up(2); + assert(handover.releases == 1); + handover.down(4); + handover.move(4); + handover.up(4); + assert(handover.presses == 2 && handover.releases == 2 && handover.warps == 3); + + Pointer nested; + nested.move(0, true); + nested.down(1); + nested.move(0, true); + assert(nested.warps == 3); + + Pointer stray; + stray.up(7); + assert(stray.releases == 1); + stray.down(1); + stray.up(7); + assert(stray.releases == 1); + stray.up(1); + assert(stray.releases == 2); + return 0; +} +''' + + +class GamescopeTouchClickOwnerTest(unittest.TestCase): + def test_only_the_first_finger_drives_the_emulated_mouse(self): + compiler = shutil.which("c++") or shutil.which("g++") or shutil.which("clang++") + if not compiler: + self.skipTest("no C++ compiler") + added = added_source() + helpers = "\n".join(block(added, start) for start in ( + "struct TouchClickState", + "static bool touch_click_claim", + "static bool touch_click_drives", + "static bool touch_click_lift", + )) + source = PREAMBLE + helpers + MAIN + with tempfile.TemporaryDirectory() as tmp: + src = Path(tmp) / "touch_click_owner.cpp" + exe = Path(tmp) / "touch_click_owner" + src.write_text(source) + subprocess.run([compiler, "-std=c++17", "-Wall", "-Werror", "-UNDEBUG", str(src), "-o", str(exe)], check=True) + subprocess.run([str(exe)], check=True) + + def test_the_patch_gates_every_finger_path(self): + added = added_source() + self.assertIn("else if ( bAlwaysWarpCursor || touch_click_drives( s_TouchClick, touch_id ) )", added) + self.assertIn("if ( touch_click_drives( s_TouchClick, touch_id ) )", added) + self.assertIn("else if ( touch_click_claim( s_TouchClick, touch_id ) )", added) + self.assertIn("bClickTouch && i < WLSERVER_BUTTON_COUNT", added) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_inputudev_preload.py b/tools/tests/test_inputudev_preload.py index 06f8a8f95f..0195e6ff1e 100644 --- a/tools/tests/test_inputudev_preload.py +++ b/tools/tests/test_inputudev_preload.py @@ -260,6 +260,7 @@ static void *(*next)(void *); static void *(*by_name)(void *, const char *); static const char *(*name)(void *); static const char *(*value)(void *); +static const char *(*sysattr)(void *, const char *); static void *sym(const char *symbol) { return dlsym(lib, symbol); } @@ -463,6 +464,20 @@ static void run_every(int count, char **entries) { printf("pad %d real calls %d\n", pad != NULL, real_calls != NULL ? *real_calls : -1); } +static void print_product(const char *label, void *device) { + const char *uevent = device != NULL ? sysattr(device, "uevent") : NULL; + + printf("%s %.*s\n", label, uevent != NULL ? (int)strcspn(uevent, "\n") : 4, uevent != NULL ? uevent : "none"); +} + +static void run_identity(void) { + int udev; + void *device = new_device(&udev, PAD); + + print_product("pad", device); + print_product("parent", device != NULL ? get_parent(device) : NULL); +} + static void run_probe(void) { int udev; @@ -539,7 +554,9 @@ int main(int argc, char **argv) { by_name = sym("udev_list_entry_get_by_name"); name = sym("udev_list_entry_get_name"); value = sym("udev_list_entry_get_value"); + sysattr = sym("udev_device_get_sysattr_value"); if (strcmp(argv[1], "probe") == 0) run_probe(); + else if (strcmp(argv[1], "identity") == 0) run_identity(); else if (strcmp(argv[1], "every") == 0) run_every(argc - 3, argv + 3); else if (strcmp(argv[1], "stable") == 0) run_stable(); else if (strcmp(argv[1], "enumerate") == 0) run_enumerate(); @@ -597,10 +614,13 @@ class InputUdevPreloadTest(unittest.TestCase): (pads / node).write_text("") return pads - def run_program(self, mode, *preloads, pads=None, slots="0=/pad", program=None, args=()): + def run_program(self, mode, *preloads, pads=None, slots="0=/pad", program=None, args=(), extra=None): env = dict(os.environ, LD_PRELOAD=":".join(str(self.dir / name) for name in ("libddsession.so", *preloads)), FAKE_EVDEV_MEMFD_PATHS=slots, FAKE_EVDEV_DIR=str(pads or self.pads)) - env.pop("FAKE_EVDEV_UINPUT", None) + for key in ("FAKE_EVDEV_UINPUT", "FAKE_EVDEV_STEAM_VIRTUAL", "SDL_GAMECONTROLLER_IGNORE_DEVICES", + "SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT"): + env.pop(key, None) + env.update(extra or {}) result = subprocess.run([str(program or self.program), mode, str(self.udev), *args], env=env, capture_output=True, text=True, timeout=20) self.assertEqual(result.returncode, 0, result.stderr) @@ -684,6 +704,27 @@ class InputUdevPreloadTest(unittest.TestCase): "nothing added scan -1", ]) + def identity(self, pads=None, **extra): + return self.run_program("identity", pads=pads, extra=extra) + + def test_a_ring_pad_keeps_the_steam_input_identity_whatever_sdl_is_told(self): + steam = ["pad PRODUCT=6/28de/11ff/110", "parent PRODUCT=6/28de/11ff/110"] + for extra in ({}, {"FAKE_EVDEV_UINPUT": "1"}, {"FAKE_EVDEV_STEAM_VIRTUAL": "0"}, {"FAKE_EVDEV_STEAM_VIRTUAL": "1"}, + {"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142"}, + {"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142,0x045E/0x028E"}, + {"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x045e/0x028e"}, + {"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x28de/0x11ff"}, + {"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": ""}, + {"FAKE_EVDEV_UINPUT": "1", "SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x045e/0x028e"}): + with self.subTest(**extra): + self.assertEqual(self.identity(**extra), steam) + + def test_a_pad_under_steam_inputs_own_virtual_pad_stays_an_xbox_pad(self): + pads = self.pad_dir("under-virtual", "event0", "event16") + (pads / ".uinput-event16.uevent").write_text('PRODUCT=6/28de/11ff/1\nNAME="Microsoft X-Box 360 pad 0"\n') + self.assertEqual(self.identity(pads, FAKE_EVDEV_UINPUT="1", SDL_GAMECONTROLLER_IGNORE_DEVICES="0x045e/0x028e"), + ["pad PRODUCT=3/45e/28e/110", "parent PRODUCT=3/45e/28e/110"]) + def test_a_program_that_closes_and_reopens_libudev_keeps_working(self): self.assertEqual(self.run_program("reload"), ["reload real0 real1"]) diff --git a/tools/tests/test_msi_install.py b/tools/tests/test_msi_install.py index 60d8fc8df4..153c699cbf 100644 --- a/tools/tests/test_msi_install.py +++ b/tools/tests/test_msi_install.py @@ -33,6 +33,62 @@ def installer(tables, out="/tmp/unused", summary=None): return MSI["Installer"]("fake.msi", out, FakePackage(tables, summary)) +class ChoosePackagesTest(unittest.TestCase): + + def choose(self, platforms): + class Stub: + def __init__(self, path): + self.summary = {"template": platforms[Path(path).name] + ";1033"} + + root = Path(tempfile.mkdtemp()) + found = [] + for name in platforms: + (root / name).write_bytes(b"") + found.append(root / name) + choose = MSI["choose_packages"] + previous = choose.__globals__["Package"] + choose.__globals__["Package"] = Stub + try: + return [entry.name for entry in choose(found, root)] + finally: + choose.__globals__["Package"] = previous + + def test_arm_packages_are_dropped_beside_native_ones(self): + self.assertEqual(self.choose({"a.msi": "x64", "b.msi": "Arm64", "c.msi": "Intel"}), ["a.msi", "c.msi"]) + + def test_an_all_arm64_bundle_is_kept(self): + self.assertEqual(self.choose({"min.msi": "Arm64", "extra.msi": "Arm64"}), ["min.msi", "extra.msi"]) + + +class InstallWrapperTest(unittest.TestCase): + + def wrap(self, count): + wrap = MSI["install_wrapper"] + names = wrap.__globals__ + saved = {key: names[key] for key in ("unpack_installer", "packages_in", "choose_packages", "Installer")} + + class Empty: + def __init__(self, *args, **kwargs): + pass + + def install(self): + raise MSI["MsiError"]("the package installs nothing here") + + names["unpack_installer"] = lambda path, dest: "bundle" + names["packages_in"] = lambda dest: [] + names["choose_packages"] = lambda found, root: [Path("p%d.msi" % index) for index in range(count)] + names["Installer"] = Empty + root = Path(tempfile.mkdtemp()) + try: + return wrap(root / "setup.exe", root / "out") + finally: + names.update(saved) + + def test_a_bundle_whose_packages_all_install_nothing_is_rejected(self): + with self.assertRaises(MSI["MsiError"]): + self.wrap(2) + + class ToolsTest(unittest.TestCase): def test_the_tools_find_their_own_libraries(self): paths = MSI["tool_env"]()["LD_LIBRARY_PATH"].split(":") @@ -118,6 +174,39 @@ class LayoutTest(unittest.TestCase): inst.select() self.assertEqual(inst.included_components, {"Up", "Wide"}) + def architecture_package(self, platform, key="SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", name="PROCESSOR_ARCHITECTURE"): + return installer({ + "Feature": rows("Feature Feature_Parent Level", ("Main", "", "1")), + "AppSearch": rows("Property Signature_", ("ARM64CHECK", "arch"), ("OTHER", "unrelated")), + "RegLocator": rows("Signature_ Root Key Name Type", + ("arch", "2", key, name, "2"), + ("unrelated", "2", "SOFTWARE\\Vendor", "Path", "2")), + "Component": rows("Component Directory_ Attributes Condition", + ("Native", "TARGETDIR", "256", 'ARM64CHECK = "ARM64"'), + ("Always", "TARGETDIR", "256", "")), + "FeatureComponents": rows("Feature_ Component_", ("Main", "Native"), ("Main", "Always")), + }, summary={"template": "%s;1033" % platform}) + + def test_the_architecture_lookup_enables_arm64_components_in_an_arm64_package(self): + inst = self.architecture_package("Arm64") + inst.run_app_search() + inst.select() + self.assertEqual(inst.included_components, {"Native", "Always"}) + self.assertNotIn("OTHER", inst.props) + + def test_the_architecture_lookup_ignores_registry_name_case(self): + inst = self.architecture_package("Arm64", "System\\CurrentControlSet\\Control\\Session Manager\\Environment\\", "Processor_Architecture") + inst.run_app_search() + inst.select() + self.assertEqual(inst.props["ARM64CHECK"], "ARM64") + self.assertEqual(inst.included_components, {"Native", "Always"}) + + def test_the_architecture_lookup_leaves_other_packages_alone(self): + inst = self.architecture_package("x64") + inst.run_app_search() + inst.select() + self.assertEqual(inst.included_components, {"Always"}) + def test_a_duplicate_onto_the_file_itself_is_skipped(self): with tempfile.TemporaryDirectory() as tmp: src = Path(tmp) / "cab" / "dotnet.exe" diff --git a/tools/tests/test_native_hook_ldso_spawn.py b/tools/tests/test_native_hook_ldso_spawn.py index 8d8b417f82..37cd7402e9 100644 --- a/tools/tests/test_native_hook_ldso_spawn.py +++ b/tools/tests/test_native_hook_ldso_spawn.py @@ -120,6 +120,14 @@ class NativeHookLdsoSpawnTest(unittest.TestCase): script.parent.mkdir(exist_ok=True) script.write_text(f"#!{interpreter}\n") script.chmod(0o755) + cls.app_files = tmp / "app-files" + cls.app_files.mkdir() + shutil.copy(cls.probe, cls.app_files / "tool") + shutil.copy(cls.android / "sh", cls.app_files / "android-tool") + for name, interpreter in (("guest.py", GUEST_TOOL), ("android.sh", f"{ANDROID_DIR}/sh")): + (cls.app_files / name).write_text(f"#!{interpreter}\n") + for entry in cls.app_files.iterdir(): + entry.chmod(0o755) @classmethod def tearDownClass(cls): @@ -220,6 +228,32 @@ class NativeHookLdsoSpawnTest(unittest.TestCase): call = self.call(how, "/opt/host.sh", "x", binds=f"{self.runtime}:{BOUND_DIR}") self.assertEqual([HOST_SHELL, HOST_SHELL, str(self.root / "opt/host.sh"), "x"], call) + def test_a_script_on_a_mount_at_its_host_path_runs_with_the_guest_interpreter(self): + script = str(self.app_files / "guest.py") + for how in ("exec", "spawn"): + with self.subTest(how=how): + call = self.call(how, script, "x", binds=f"{self.app_files}:{self.app_files}") + self.assertEqual(str(self.root / GUEST_LDSO.lstrip("/")), call[0]) + self.assertEqual([str(self.root / GUEST_TOOL.lstrip("/")), script, "x"], call[-3:]) + + def test_a_glibc_program_on_a_mount_at_its_host_path_starts_through_the_guest_ldso(self): + tool = str(self.app_files / "tool") + for how in ("exec", "spawn"): + with self.subTest(how=how): + call = self.call(how, tool, "x", binds=f"{self.app_files}:{self.app_files}") + self.assertEqual(str(self.root / GUEST_LDSO.lstrip("/")), call[0]) + self.assertEqual([tool, "x"], call[-2:]) + + def test_android_programs_on_a_mount_at_its_host_path_stay_on_the_host(self): + tool = str(self.app_files / "android-tool") + script = str(self.app_files / "android.sh") + sh = str(self.android / "sh") + binds = f"{self.app_files}:{self.app_files}|{self.android}:{ANDROID_DIR}" + for how in ("exec", "spawn"): + with self.subTest(how=how): + self.assertEqual([tool, tool, "x"], self.call(how, tool, "x", binds=binds)) + self.assertEqual([sh, sh, script, "x"], self.call(how, script, "x", binds=binds)) + def test_an_android_interpreter_reached_through_a_bind_stays_on_the_host(self): sh = str(self.android / "sh") for how in ("exec", "spawn"): diff --git a/tools/tests/test_native_hook_mounts.py b/tools/tests/test_native_hook_mounts.py index 8aafe5857b..0774f059e0 100644 --- a/tools/tests/test_native_hook_mounts.py +++ b/tools/tests/test_native_hook_mounts.py @@ -42,6 +42,27 @@ int main(int argc, char **argv) { if (fd >= 0) close(fd); continue; } + if (strncmp(argv[i], "exec-without:", 13) == 0) { + extern char **environ; + char *program = strchr(argv[i] + 13, '='); + if (!program) continue; + size_t n = 0, len = (size_t)(program++ - (argv[i] + 13)); + while (environ[n]) n++; + char **env = calloc(n + 1, sizeof(char *)); + size_t used = 0; + for (size_t k = 0; k < n; k++) + if (strncmp(environ[k], argv[i] + 13, len) != 0 || environ[k][len] != '=') env[used++] = environ[k]; + char *args[] = {program, "env:DDNATV_BINDS_KERNEL", NULL}; + fflush(stdout); + pid_t pid = fork(); + if (pid == 0) { + execve(program, args, env); + _exit(127); + } + waitpid(pid, NULL, 0); + free(env); + continue; + } if (strncmp(argv[i], "fork:", 5) == 0) { fflush(stdout); pid_t pid = fork(); @@ -67,6 +88,18 @@ int main(int argc, char **argv) { printf("%s\t%s\n", argv[i], ok ? cwd : "-"); continue; } + if (strncmp(argv[i], "cdnull:", 7) == 0) { + char *got = chdir(argv[i] + 7) == 0 ? getcwd(NULL, 0) : NULL; + printf("%s\t%s\n", argv[i], got ? got : "-"); + free(got); + continue; + } + if (strncmp(argv[i], "realnull:", 9) == 0) { + char *got = realpath(argv[i] + 9, NULL); + printf("%s\t%s\n", argv[i], got ? got : "-"); + free(got); + continue; + } if (strncmp(argv[i], "lstat:", 6) == 0) { int ok = lstat(argv[i] + 6, &st) == 0; printf("%s\t%d\t%d\n", argv[i], ok, ok && S_ISLNK(st.st_mode)); @@ -163,6 +196,8 @@ class NativeHookMountTest(unittest.TestCase): (cls.links / "real/sub/deeper/more/leaf.txt").write_text("leaf") os.symlink("real", cls.links / "dir") os.symlink(str(cls.links / "real"), cls.links / "hostdir") + (cls.links / "real|data").mkdir() + os.symlink(str(cls.links / "real|data"), cls.links / "barlink") os.symlink("/etc/hostname", cls.links / "guest") os.symlink("real/sub/file.txt", cls.links / "file") os.symlink("/mnt/links/real", cls.links / "real/up") @@ -178,10 +213,12 @@ class NativeHookMountTest(unittest.TestCase): def tearDownClass(cls): cls.tmp.cleanup() - def run_probe(self, *args, binds=None, mounts=None, syscalls=False): + def run_probe(self, *args, binds=None, mounts=None, syscalls=False, table=None): if binds is None: binds = f"{self.library}:/mnt/library|{self.private}:/mnt/private|{self.eqlen_src}:{self.eqlen_dst}" hook_env = {"DDNATV_ROOT": str(self.root), "DDNATV_BINDS": binds, "LD_PRELOAD": str(self.hook)} + if table is not None: + hook_env["DDNATV_BINDS_KERNEL"] = table if mounts is not None: table = Path(self.tmp.name) / f"mountinfo-{len(list(Path(self.tmp.name).glob('mountinfo-*')))}" table.write_text("".join(f"{i + 20} 1 0:{i + 40} / {point} rw - {kind} {source} rw\n" @@ -195,7 +232,7 @@ class NativeHookMountTest(unittest.TestCase): if syscalls and not shutil.which("strace"): self.skipTest("no strace") if syscalls: - cmd = ["strace", "-f", "-qq", "-e", "trace=readlinkat,newfstatat,fstatat64,statx"] + cmd = ["strace", "-f", "-qq", "-e", "trace=openat,readlinkat,newfstatat,fstatat64,statx"] cmd += [arg for key, value in hook_env.items() for arg in ("-E", f"{key}={value}")] else: cmd = [] @@ -206,6 +243,68 @@ class NativeHookMountTest(unittest.TestCase): result = {line.split("\t")[0]: line.split("\t")[1:] for line in out.stdout.splitlines()} return (result, out.stderr) if syscalls else result + def bind_table(self, binds, *sources): + h = 1469598103934665603 + for byte in binds.encode(): + h = ((h ^ byte) * 1099511628211) & 0xFFFFFFFFFFFFFFFF + return "%016x" % h + "".join("|" + source for source in sources) + + def test_a_bind_source_through_a_link_is_resolved_once_and_handed_to_children(self): + binds = f"{self.links}/hostdir:/mnt/viahost|{self.links}/hostdir:/mnt/again|/dev:/dev" + out, log = self.run_probe("cd:/mnt/viahost/sub/", "env:DDNATV_BINDS_KERNEL", binds=binds, syscalls=True) + self.assertEqual(["/mnt/viahost/sub"], out["cd:/mnt/viahost/sub/"]) + real = os.path.realpath(self.links / "real") + self.assertEqual([self.bind_table(binds, real, real, "")], out["env:DDNATV_BINDS_KERNEL"]) + self.assertEqual(1, log.count(f'"{self.links}/hostdir"')) + + def test_a_child_given_the_bind_spec_without_its_table_gets_the_table(self): + binds = f"{self.links}/hostdir:/mnt/viahost" + child = self.root / "child-probe" + subprocess.run([self.cc, "-static", "-O1", "-o", str(child), str(self.probe) + ".c"], check=True) + try: + subprocess.run([str(child)], capture_output=True, timeout=60) + except OSError: + self.skipTest("the host cannot start the probe's architecture directly") + out =self.run_probe("exec-without:DDNATV_BINDS_KERNEL=/child-probe", binds=binds) + self.assertEqual([self.bind_table(binds, os.path.realpath(self.links / "real"))], out["env:DDNATV_BINDS_KERNEL"]) + + def test_process_specific_bind_sources_are_not_handed_to_children(self): + binds = "/proc/self/fd/0:/dev/stdin|/proc/self/fd:/dev/fd|//proc/self/fd/0:/mnt/input" + out = self.run_probe("env:DDNATV_BINDS_KERNEL", binds=binds) + self.assertEqual([self.bind_table(binds, "", "", "")], out["env:DDNATV_BINDS_KERNEL"]) + + def test_a_bind_source_whose_real_place_holds_the_separator_is_not_handed_to_children(self): + binds = f"{self.links}/barlink:/mnt/bar" + out = self.run_probe("cd:/mnt/bar/", "env:DDNATV_BINDS_KERNEL", binds=binds) + self.assertEqual(["/mnt/bar"], out["cd:/mnt/bar/"]) + self.assertEqual([self.bind_table(binds, "")], out["env:DDNATV_BINDS_KERNEL"]) + + def test_a_bind_table_too_long_for_the_environment_is_not_handed_to_children(self): + far = self.links.joinpath(*["f" * 200] * 9) + far.mkdir(parents=True, exist_ok=True) + (far / "marker").write_text("far") + if not (self.links / "farlink").is_symlink(): + os.symlink(str(far), self.links / "farlink") + binds = "|".join(f"{self.links}/farlink:/mnt/far{n}" for n in range(80)) + out = self.run_probe("ls:/mnt/far79", "env:DDNATV_BINDS_KERNEL", binds=binds) + self.assertEqual(["marker"], out["ls:/mnt/far79"]) + self.assertEqual(["-"], out["env:DDNATV_BINDS_KERNEL"]) + + def test_a_handed_down_bind_table_is_used_without_looking_the_sources_up(self): + binds = f"{self.links}/hostdir:/mnt/viahost" + real = os.path.realpath(self.links / "real") + table = self.bind_table(binds, real) + out, log = self.run_probe("cd:/mnt/viahost/sub/", binds=binds, table=table, syscalls=True) + self.assertEqual(["/mnt/viahost/sub"], out["cd:/mnt/viahost/sub/"]) + self.assertNotIn(f"{self.links}/hostdir", log) + + def test_a_bind_table_for_other_binds_is_ignored(self): + binds = f"{self.links}/hostdir:/mnt/viahost" + stale = self.bind_table(f"{self.library}:/mnt/viahost", str(self.library)) + out = self.run_probe("cd:/mnt/viahost/sub/", "env:DDNATV_BINDS_KERNEL", binds=binds, table=stale) + self.assertEqual(["/mnt/viahost/sub"], out["cd:/mnt/viahost/sub/"]) + self.assertEqual([self.bind_table(binds, os.path.realpath(self.links / "real"))], out["env:DDNATV_BINDS_KERNEL"]) + def readlinks_of(self, log, host): return [line for line in log.splitlines() if (m := re.search(r'readlinkat\([^,"]*,\s*"([^"]*)"', line)) and m.group(1) == host] @@ -237,6 +336,19 @@ class NativeHookMountTest(unittest.TestCase): arg = f"cd:/pfx/native/dosdevices/z:{GAME}/" self.assertEqual(self.run_probe(arg)[arg], [GAME]) + def test_allocated_working_directory_and_real_path_name_a_longer_guest_mount(self): + guest = "/root/Games/" + "g" * len(str(self.library)) + binds = f"{self.library}:{guest}" + args = [f"cd:{guest}/Some Game", f"cdnull:{guest}/Some Game", f"realnull:{guest}/Some Game/game.txt"] + result = self.run_probe(*args, binds=binds) + self.assertEqual(result[args[0]], [f"{guest}/Some Game"]) + self.assertEqual(result[args[1]], [f"{guest}/Some Game"]) + self.assertEqual(result[args[2]], [f"{guest}/Some Game/game.txt"]) + + def test_allocated_working_directory_names_a_shorter_guest_mount(self): + arg = f"cdnull:{GAME}" + self.assertEqual(self.run_probe(arg)[arg], [GAME]) + def test_rootfs_path_under_a_mount_point_reaches_the_mount(self): path = f"{self.root}{GAME}/game.txt" self.assertEqual(self.run_probe(path)[path], ["1", "library"]) diff --git a/tools/tests/test_native_hook_named_semaphores.py b/tools/tests/test_native_hook_named_semaphores.py index 09abea076b..e2242187f3 100644 --- a/tools/tests/test_native_hook_named_semaphores.py +++ b/tools/tests/test_native_hook_named_semaphores.py @@ -1,5 +1,6 @@ from pathlib import Path import os +import signal import subprocess import tempfile import unittest @@ -54,12 +55,70 @@ FORKER = r""" #include #include #include +#include #include +#include +#include #include #include static const char *name; static _Atomic int done; +static _Atomic int parked_word; +static _Atomic pid_t parked_tid; + +// the host's futex call: 202 on x86-64, where qemu-user runs, 98 on aarch64 +static int blocked_futex(const char *path, unsigned long *addr) { + unsigned long nr = 0; + FILE *f = fopen(path, "r"); + int got = f && fscanf(f, "%lu %lx", &nr, addr) == 2; + if (f) fclose(f); + return got && (nr == 202 || nr == 98); +} + +static void *park(void *arg) { + parked_tid = (pid_t)syscall(SYS_gettid); + while (!parked_word) syscall(SYS_futex, &parked_word, 0 /* FUTEX_WAIT */, 0, NULL, NULL, 0); + return arg; +} + +// How far qemu-user moved the guest in the host's address space (its guest_base; 0 natively): a +// thread parked on a futex this program knows shows that futex's host address in its syscall file, +// which qemu-user passes through unlike /proc/self/maps. +static long guest_base(void) { + char path[96]; + unsigned long addr = 0; + while (!parked_tid) usleep(1000); + snprintf(path, sizeof(path), "/proc/%d/task/%d/syscall", (int)getpid(), (int)parked_tid); + for (int i = 0; i < 5000; i++) { + if (blocked_futex(path, &addr) && addr) return (long)(addr - (unsigned long)&parked_word); + usleep(1000); + } + return -1; +} + +// A child that hangs in qemu-user itself: a fork while another thread is inside the emulator's +// own locks (its mmap() handling) can leave the child waiting on a futex in qemu's memory, which no +// guest lock is. The child's blocking call shows the host's address; under qemu-user this +// program's /proc/self/maps lists the guest's mappings only, and a futex outside all of them, once +// moved back by the guest base, is the emulator's. Natively every futex is in the process's own +// mappings: never counted. Seen on x86 runners; there is no emulator on a device. +static int stuck_in_emulator(pid_t pid, long base) { + char path[64], line[512]; + unsigned long addr = 0; + snprintf(path, sizeof(path), "/proc/%d/syscall", (int)pid); + if (base < 0 || !blocked_futex(path, &addr)) return 0; + addr -= (unsigned long)base; + FILE *f = fopen("/proc/self/maps", "r"); + if (!f) return 0; + int guest = 0; + while (!guest && fgets(line, sizeof(line), f)) { + unsigned long start, end; + if (sscanf(line, "%lx-%lx", &start, &end) == 2 && addr >= start && addr < end) guest = 1; + } + fclose(f); + return !guest; +} static void *churn(void *arg) { while (!done) { @@ -71,24 +130,40 @@ static void *churn(void *arg) { int main(int argc, char **argv) { name = argv[1]; - pthread_t thread; + pthread_t parked, thread; + if (pthread_create(&parked, NULL, park, NULL) != 0) return 1; + long base = guest_base(); + printf("base\t%ld\n", base); if (pthread_create(&thread, NULL, churn, NULL) != 0) return 1; - int finished = 0; + int finished = 0, emulator = 0; for (int i = 0; i < 200; i++) { pid_t pid = fork(); if (pid < 0) break; if (pid == 0) { - alarm(10); sem_t *sem = sem_open(name, O_CREAT, 0600, 0); _exit(sem == SEM_FAILED || sem_close(sem) != 0); } - int status; - if (waitpid(pid, &status, 0) == pid && WIFEXITED(status) && WEXITSTATUS(status) == 0) finished++; + int status = 0, stalled = 0; + pid_t r; + for (int waited = 0; (r = waitpid(pid, &status, WNOHANG)) == 0; waited++) { + if (waited == 1000) { // 10 s + stalled = stuck_in_emulator(pid, base); + kill(pid, SIGKILL); + } + usleep(10000); + } + if (r != pid) continue; + if (stalled) emulator++; + else if (WIFEXITED(status) && WEXITSTATUS(status) == 0) finished++; } done = 1; pthread_join(thread, NULL); + parked_word = 1; + syscall(SYS_futex, &parked_word, 1 /* FUTEX_WAKE */, 1, NULL, NULL, 0); + pthread_join(parked, NULL); sem_unlink(name); printf("finished\t%d\n", finished); + printf("emulator\t%d\n", emulator); return 0; } """ @@ -116,7 +191,7 @@ class NativeHookNamedSemaphoresTest(unittest.TestCase): def tearDownClass(cls): cls.tmp.cleanup() - def run_hooked(self, program, *args): + def run_hooked(self, program, *args, timeout=120): hook_env = {"DDNATV_ROOT": str(self.shm.parent.parent), "LD_PRELOAD": str(self.hook)} env = {k: v for k, v in os.environ.items() if k != "LD_PRELOAD"} if self.prefix: @@ -124,9 +199,17 @@ class NativeHookNamedSemaphoresTest(unittest.TestCase): else: cmd = [] env.update(hook_env) - out = subprocess.run(cmd + [str(program), *args], env=env, capture_output=True, text=True, timeout=120) - self.assertEqual(out.returncode, 0, out.stderr) - return dict(line.split("\t") for line in out.stdout.splitlines()) + # its own process group, so a timeout also ends a child still blocked once the program is gone + proc = subprocess.Popen(cmd + [str(program), *args], env=env, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True, start_new_session=True) + try: + stdout, stderr = proc.communicate(timeout=timeout) + except subprocess.TimeoutExpired: + os.killpg(proc.pid, signal.SIGKILL) + proc.communicate() + raise + self.assertEqual(proc.returncode, 0, stderr) + return dict(line.split("\t") for line in stdout.splitlines()) def test_a_named_semaphore_lives_in_the_rootfs_and_is_shared_between_processes(self): name = f"/ddsem-{os.getpid()}" @@ -139,7 +222,20 @@ class NativeHookNamedSemaphoresTest(unittest.TestCase): source.write_text(FORKER) forker = self.probe.with_name("forker") subprocess.run([self.cc, "-O1", "-pthread", "-o", str(forker), str(source)], check=True) - self.assertEqual({"finished": "200"}, self.run_hooked(forker, f"/ddsem-fork-{os.getpid()}")) + name = f"/ddsem-fork-{os.getpid()}" + # left by a run that did not get to sem_unlink(), it would fail the other tests' empty /dev/shm + self.addCleanup(lambda: (self.shm / f"sem.{name[1:]}").unlink(missing_ok=True)) + # 200 forks under a loaded qemu-user, and 10 s for each child that hangs in the emulator + result = self.run_hooked(forker, name, timeout=300) + # every child opened one, but for one now and then that hung in qemu-user itself (a fork during + # the emulator's own locking), which a native run never has + if self.prefix: + self.assertNotEqual("-1", result.get("base"), result) + else: + self.assertEqual("0", result.get("base"), result) + emulator = int(result.get("emulator", "0")) + self.assertEqual(200, int(result.get("finished", "0")) + emulator, result) + self.assertLessEqual(emulator, 0 if not self.prefix else 3, result) def test_a_created_semaphore_keeps_its_name_and_mode(self): name = f"ddsem-kept-{os.getpid()}" diff --git a/tools/tests/test_native_hook_popen.py b/tools/tests/test_native_hook_popen.py new file mode 100644 index 0000000000..0293fecbba --- /dev/null +++ b/tools/tests/test_native_hook_popen.py @@ -0,0 +1,129 @@ +import os +import subprocess +import tempfile +import unittest +from pathlib import Path + +from tools.tests.test_usr2_preload import runner + +HOOK_BUILD = Path(__file__).resolve().parents[1] / "nativeguest/build.sh" + +# The rootfs' /bin/sh for these tests: "sh -c 'echo WORDS'" prints WORDS, "sh -c 'exit N'" exits N. +SHELL = r""" +#include +#include +#include + +int main(int argc, char **argv) { + if (argc < 3 || strcmp(argv[1], "-c") != 0) return 2; + if (strncmp(argv[2], "echo ", 5) == 0) { + puts(argv[2] + 5); + return 0; + } + if (strncmp(argv[2], "exit ", 5) == 0) return atoi(argv[2] + 5); + return 127; +} +""" + +# posix_spawn() of argv[1] -c "exit 3", without the hook: prints the exit status it got +SPAWN_PROBE = r""" +#include +#include +#include + +extern char **environ; + +int main(int argc, char **argv) { + pid_t pid; + char *args[] = {"sh", "-c", "exit 3", NULL}; + int status = 0; + if (posix_spawn(&pid, argv[1], NULL, NULL, args, environ) != 0 || waitpid(pid, &status, 0) != pid) return 1; + printf("%d\n", WIFEXITED(status) ? WEXITSTATUS(status) : -1); + return 0; +} +""" + +# popen() and system() through the hook (which starts the shell with posix_spawn()) +PROGRAM = r""" +#include +#include +#include +#include + +int main(int argc, char **argv) { + if (strcmp(argv[1], "system") == 0) { + int status = system("exit 3"); + printf("system\t%d\n", WIFEXITED(status) ? WEXITSTATUS(status) : -1); + return 0; + } + // a second stream open while the first is read: the shell of the first must not hold it + FILE *other = popen("echo other", "r"); + FILE *f = popen("echo from the shell", "r"); + char line[64] = ""; + if (f && !fgets(line, sizeof(line), f)) line[0] = 0; + line[strcspn(line, "\n")] = 0; + int status = f ? pclose(f) : -1; + if (other) pclose(other); + printf("popen\t%s\n", line); + printf("pclose\t%d\n", WIFEXITED(status) ? WEXITSTATUS(status) : -1); + return 0; +} +""" + + +class NativeHookPopenTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.cc, cls.prefix = runner() + if cls.cc is None: + raise unittest.SkipTest("no aarch64 compiler and runner") + cls.tmp = tempfile.TemporaryDirectory(dir="/tmp") + tmp = Path(cls.tmp.name) + cls.hook = tmp / "hook.so" + subprocess.run(["bash", str(HOOK_BUILD), str(cls.hook), cls.cc], check=True, capture_output=True) + cls.root = tmp / "root" + (cls.root / "bin").mkdir(parents=True) + (tmp / "sh.c").write_text(SHELL) + subprocess.run([cls.cc, "-static", "-O1", "-o", str(cls.root / "bin/sh"), str(tmp / "sh.c")], check=True) + # posix_spawn()'s child execs the shell itself. Under qemu-user that exec works only where the + # kernel runs aarch64 programs (binfmt_misc), which a plain x86 runner does not. + (tmp / "spawn.c").write_text(SPAWN_PROBE) + subprocess.run([cls.cc, "-static", "-O1", "-o", str(tmp / "spawn"), str(tmp / "spawn.c")], check=True) + probe = subprocess.run(list(cls.prefix or []) + [str(tmp / "spawn"), str(cls.root / "bin/sh")], + capture_output=True, text=True, timeout=60) + if probe.stdout.strip() != "3": + cls.tmp.cleanup() + raise unittest.SkipTest("this runner cannot exec an aarch64 program from a posix_spawn() child") + (tmp / "prog.c").write_text(PROGRAM) + cls.program = tmp / "prog" + subprocess.run([cls.cc, "-O1", "-o", str(cls.program), str(tmp / "prog.c")], check=True) + + @classmethod + def tearDownClass(cls): + cls.tmp.cleanup() + + def run_program(self, mode): + hook_env = {"DDNATV_ROOT": str(self.root), "LD_PRELOAD": str(self.hook)} + # Only what the program needs: other test modules in the same run change os.environ + env = {"PATH": os.environ.get("PATH", "/usr/bin:/bin")} + if self.prefix: + cmd = list(self.prefix) + [arg for key, value in hook_env.items() for arg in ("-E", f"{key}={value}")] + else: + cmd = [] + env.update(hook_env) + out = subprocess.run(cmd + [str(self.program), mode], env=env, capture_output=True, text=True, timeout=60) + self.assertEqual(0, out.returncode, out.stderr) + return dict(line.split("\t", 1) for line in out.stdout.splitlines() if "\t" in line), out + + def test_popen_reads_the_shells_output(self): + result, out = self.run_program("popen") + self.assertEqual("from the shell", result.get("popen"), out.stdout + out.stderr) + self.assertEqual("0", result.get("pclose"), out.stdout) + + def test_system_returns_the_shells_status(self): + result, out = self.run_program("system") + self.assertEqual("3", result.get("system"), out.stdout + out.stderr) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_output_refresh.py b/tools/tests/test_output_refresh.py index 96817b2f4f..e931c4b187 100644 --- a/tools/tests/test_output_refresh.py +++ b/tools/tests/test_output_refresh.py @@ -45,6 +45,8 @@ static int g_input_pipe[2] = {-1, -1}; static atomic_int g_output_refresh_mhz = 60000; static atomic_int g_output_refresh_pending; static atomic_int g_panel_rates_pending; +static atomic_int g_zoom_request_percent = 100; +static atomic_int g_zoom_request_pending; static int g_output_announced_refresh_mhz = 60000; static int g_output_w = 1920, g_output_h = 1080; static int flushes, resizes, pointers, ticks; @@ -77,6 +79,7 @@ static void on_vsync(int64_t ns) { assert(ns > 0); ticks++; } static void vk_present_set_scale_mode(int mode, int alignment) { scale_changes++; scale_mode = mode; scale_alignment = alignment; } +static void vk_present_set_zoom(float zoom) { (void)zoom; } static void schedule_render(void) { renders++; } static void refresh_notify_rates(void) { rate_notifies++; } ''' diff --git a/tools/tests/test_qam_relay.py b/tools/tests/test_qam_relay.py new file mode 100644 index 0000000000..7a0ae9b408 --- /dev/null +++ b/tools/tests/test_qam_relay.py @@ -0,0 +1,98 @@ +import importlib.machinery +import importlib.util +import shutil +import socket +import tempfile +import threading +import unittest +from pathlib import Path +from unittest import mock + +HELPER = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-qam-relay" + + +def load(): + loader = importlib.machinery.SourceFileLoader("qam_relay", str(HELPER)) + spec = importlib.util.spec_from_loader("qam_relay", loader) + module = importlib.util.module_from_spec(spec) + loader.exec_module(module) + return module + + +class QamRelayTest(unittest.TestCase): + def setUp(self): + self.relay = load() + self.tmp = Path(tempfile.mkdtemp()) + self.addCleanup(shutil.rmtree, self.tmp, True) + self.relay.FLAG = str(self.tmp / "flag") + self.relay.INTERVAL = 0.05 + + def test_pipes_bytes_both_ways_until_its_own_port_is_stopped(self): + upstream = socket.socket() + upstream.bind(("127.0.0.1", 0)) + upstream.listen(1) + self.addCleanup(upstream.close) + + def echo(): + conn, _ = upstream.accept() + with conn: + conn.settimeout(2) + head = b"" + while not head.endswith(b"\r\n\r\n"): + head += conn.recv(100) + conn.sendall(b"answer:" + head) + + threading.Thread(target=echo, daemon=True).start() + server = socket.socket() + server.bind(("127.0.0.1", 0)) + server.listen(1) + port = server.getsockname()[1] + Path(self.relay.FLAG).write_text("me %d" % port) + serving = threading.Thread(target=self.relay.serve, args=(server, upstream.getsockname()[1], "me", "s3cret"), daemon=True) + serving.start() + with socket.create_connection(("127.0.0.1", port), 2) as client: + client.sendall(b"GET /s3cret/json HTTP/1.1\r\nHost: x\r\n\r\n") + client.settimeout(2) + expected = b"answer:GET /json HTTP/1.1\r\nHost: x\r\n\r\n" + got = b"" + while len(got) < len(expected): + data = client.recv(100) + if not data: + break + got += data + self.assertEqual(expected, got) + with mock.patch.object(self.relay.sys, "argv", ["x", "stop", str(port + 1)]): + self.assertEqual(0, self.relay.main()) + serving.join(0.3) + self.assertTrue(serving.is_alive()) + with mock.patch.object(self.relay.sys, "argv", ["x", "stop", str(port)]): + self.assertEqual(0, self.relay.main()) + serving.join(2) + self.assertFalse(serving.is_alive()) + + def test_refuses_requests_without_the_secret_or_outside_the_allowed_paths(self): + rewrite = self.relay.rewrite + self.assertEqual(b"GET /devtools/page/AB-1 HTTP/1.1\r\n", rewrite(b"GET /k/devtools/page/AB-1 HTTP/1.1\r\n", "k")) + for head in (b"GET /json HTTP/1.1\r\n", b"GET /x/json HTTP/1.1\r\n", b"POST /k/json HTTP/1.1\r\n", + b"GET /k/devtools/browser/1 HTTP/1.1\r\n", b"GET /k/json/new?x HTTP/1.1\r\n", b"GET /k/json HTTP/1.1"): + self.assertIsNone(rewrite(head, "k"), head) + + def test_stops_after_an_idle_period(self): + self.relay.IDLE_SECONDS = 0.1 + server = socket.socket() + server.bind(("127.0.0.1", 0)) + server.listen(1) + Path(self.relay.FLAG).write_text("me %d" % server.getsockname()[1]) + serving = threading.Thread(target=self.relay.serve, args=(server, 1, "me", "k"), daemon=True) + serving.start() + serving.join(2) + self.assertFalse(serving.is_alive()) + + def test_rejects_unknown_commands(self): + for argv in (["x"], ["x", "start"], ["x", "stop", "1", "2"]): + with mock.patch.object(self.relay.sys, "argv", argv), mock.patch.object(self.relay.sys, "stderr"): + self.assertEqual(2, self.relay.main()) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_ring_pad_sdl_identity.py b/tools/tests/test_ring_pad_sdl_identity.py new file mode 100644 index 0000000000..d10ca0257f --- /dev/null +++ b/tools/tests/test_ring_pad_sdl_identity.py @@ -0,0 +1,125 @@ +from pathlib import Path +import os +import shutil +import subprocess +import sys +import tempfile +import unittest + +PRELOAD = Path(__file__).resolve().parents[1] / "linuxfs/preload" + +SHIM = r""" +#include +#include +#include + +int ioctl(int fd, unsigned long request, ...) { + va_list ap; + va_start(ap, request); + struct input_id *id = va_arg(ap, struct input_id *); + va_end(ap); + (void)fd; + if (request != EVIOCGID) return -1; + memset(id, 0, sizeof(*id)); + id->bustype = 3; + id->vendor = 0x045e; + id->product = 0x028e; + return 0; +} +""" + +QUERY = r""" +#include +#include +#include +#include +#include + +void query(const char *path) { + struct input_id id; + int fd = open(path, O_RDONLY | O_CLOEXEC); + int rc = ioctl(fd, EVIOCGID, &id); + printf("%d %04x:%04x\n", rc, id.vendor, id.product); + close(fd); +} +""" + +PROGRAM = r""" +#include +#include +#include + +void query(const char *path); + +int main(int argc, char **argv) { + (void)argc; + if (strcmp(argv[1], "-") != 0) dlopen(argv[1], RTLD_NOW); + if (strcmp(argv[2], "program") == 0) { + query(argv[3]); + } else { + void *sdl = dlopen(argv[2], RTLD_NOW | RTLD_LOCAL); + void (*sdl_query)(const char *) = (void (*)(const char *))dlsym(sdl, "query"); + sdl_query(argv[3]); + } + fflush(stdout); + return 0; +} +""" + + +@unittest.skipUnless(sys.platform == "linux" and shutil.which("cc"), "needs Linux and cc") +class RingPadSdlIdentityTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.dir = Path(tempfile.mkdtemp()) + build = cls.dir / "build" + build.mkdir() + for name, text in (("shim.c", SHIM), ("query.c", QUERY), ("program.c", PROGRAM), ("empty.c", "int bus;\n")): + (build / name).write_text(text) + cls.lib = cls.dir / "libddsession.so" + subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-Wall", "-pthread", "-o", str(cls.lib), + *map(str, sorted(PRELOAD.glob("*.c"))), "-ldl"], check=True) + cls.shim = cls.dir / "libshim.so" + subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.shim), str(build / "shim.c")], check=True) + cls.winebus = cls.dir / "winebus.so" + subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.winebus), str(build / "empty.c")], check=True) + cls.sdl_library = cls.dir / "libSDL2-2.0.so.0" + subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.sdl_library), str(build / "query.c")], check=True) + cls.program = cls.dir / "program" + subprocess.run(["cc", "-O2", "-o", str(cls.program), str(build / "program.c"), str(build / "query.c"), "-ldl"], + check=True) + cls.ring = cls.dir / "ring0" + cls.ring.write_text("") + cls.virtual = cls.dir / "ring16" + cls.virtual.write_text("") + + @classmethod + def tearDownClass(cls): + shutil.rmtree(cls.dir, True) + + def query(self, winebus=True, caller="sdl", path=None, **extra): + env = dict(os.environ, LD_PRELOAD="%s:%s" % (self.lib, self.shim), + FAKE_EVDEV_MEMFD_PATHS="0=%s;16=%s" % (self.ring, self.virtual)) + env.pop("FAKE_EVDEV_STEAM_PAD_AS_X360", None) + env.update(extra) + result = subprocess.run([str(self.program), str(self.winebus) if winebus else "-", + str(self.sdl_library) if caller == "sdl" else "program", str(path or self.ring)], + env=env, capture_output=True, text=True, timeout=10, check=True) + return result.stdout.strip() + + def test_sdl_in_a_winebus_process_sees_a_ring_pad_as_the_steam_input_pad(self): + self.assertEqual(self.query(), "0 28de:11ff") + + def test_sdl_outside_winebus_keeps_the_pad_identity(self): + self.assertEqual(self.query(winebus=False), "0 045e:028e") + + def test_other_callers_and_devices_keep_their_identity(self): + self.assertEqual(self.query(caller="program"), "0 045e:028e") + self.assertEqual(self.query(path=self.virtual), "0 045e:028e") + + def test_a_winebus_without_a_udev_bus_keeps_the_pad_for_sdl(self): + self.assertEqual(self.query(FAKE_EVDEV_STEAM_PAD_AS_X360="1"), "0 045e:028e") + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_session_webhelper_layout.py b/tools/tests/test_session_webhelper_layout.py index fe7b71105c..958051c6a7 100644 --- a/tools/tests/test_session_webhelper_layout.py +++ b/tools/tests/test_session_webhelper_layout.py @@ -6,6 +6,7 @@ from pathlib import Path SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session" KEYS = ("DD_VKBRIDGE_WEBHELPER_ARGS", "DD_VKBRIDGE_CEF_ANGLE", "DD_VKBRIDGE_CEF_VULKAN") +BASE = "--no-zygote --in-process-gpu -AudioServiceOutOfProcess" def layout_function(): @@ -27,14 +28,14 @@ class WebhelperLayoutTest(unittest.TestCase): def test_angle_on_vulkan_brings_chromiums_vulkan_compositing(self): self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan"), - "--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan") + BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan") - def test_vulkan_compositing_can_be_left_off(self): + def test_vulkan_compositing_can_be_left_off_without_zygotes(self): self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan", DD_VKBRIDGE_CEF_VULKAN="0"), - "--use-gl=angle --use-angle=vulkan") + BASE + " --use-gl=angle --use-angle=vulkan") def test_other_angle_backends_get_only_the_angle_switches(self): - self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="gl"), "--use-gl=angle --use-angle=gl") + self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="gl"), BASE + " --use-gl=angle --use-angle=gl") def test_explicit_layout_wins(self): self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan", DD_VKBRIDGE_WEBHELPER_ARGS="--x +Y"), @@ -57,10 +58,10 @@ class WebhelperLayoutTest(unittest.TestCase): env = {k: v for k, v in os.environ.items() if k not in KEYS} run = lambda **s: subprocess.run(["bash", "-c", "set -u\n" + script], env={**env, **s}, capture_output=True, text=True, check=True).stdout.strip() - self.assertEqual(run(), "--use-gl=angle --use-angle=vulkan") + self.assertEqual(run(), BASE + " --use-gl=angle --use-angle=vulkan") self.assertEqual(run(DD_VKBRIDGE_CEF_VULKAN="1"), - "--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan") - self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE="gl"), "--use-gl=angle --use-angle=gl") + BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan") + self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE="gl"), BASE + " --use-gl=angle --use-angle=gl") def test_empty_settings_are_kept_as_set(self): script = ': "${DD_VKBRIDGE_CEF_ANGLE=vulkan}" "${DD_VKBRIDGE_CEF_VULKAN=0}"\n' + layout_function() + "dd_webhelper_layout\n" @@ -69,7 +70,7 @@ class WebhelperLayoutTest(unittest.TestCase): capture_output=True, text=True, check=True).stdout.strip() self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE=""), "stock") self.assertEqual(run(DD_VKBRIDGE_CEF_VULKAN=""), - "--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan") + BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan") if __name__ == "__main__": diff --git a/tools/tests/test_steam_tool_manifest_seed.py b/tools/tests/test_steam_tool_manifest_seed.py new file mode 100644 index 0000000000..54d547c451 --- /dev/null +++ b/tools/tests/test_steam_tool_manifest_seed.py @@ -0,0 +1,205 @@ +import runpy +import tempfile +import unittest +from pathlib import Path +from unittest import mock + +from tools.tests.test_droiddeck_fex import AppInfoTest + +BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin" +SESSION = BIN / "droiddeck-session" +COMPAT = runpy.run_path(str(BIN / "steam-compatibility")) +EAC = 1826330 +SCOUT = 1070560 +EAC_ID = str(EAC) +SCOUT_ID = str(SCOUT) +EAC_NAME = "Proton EasyAntiCheat Runtime" +SCOUT_NAME = "Steam Linux Runtime 1.0 (scout)" + + +def tool(name, osarch="", kind="tool", installdir=None): + return { + "common": {"name": name, "oslist": "linux", "osarch": osarch, "type": kind}, + "config": {"installdir": installdir or name}, + } + + +class SteamToolManifestSeedTest(unittest.TestCase): + def setUp(self): + temporary = tempfile.TemporaryDirectory() + self.addCleanup(temporary.cleanup) + self.root = Path(temporary.name) + self.steam = self.root / "Steam" + (self.steam / "appcache").mkdir(parents=True) + (self.steam / "steamapps").mkdir() + self.entries = {EAC: tool(EAC_NAME), SCOUT: tool(SCOUT_NAME)} + self.write_appinfo() + + def write_appinfo(self, entries=None): + COMPAT["APPINFO_CACHE"].clear() + (self.steam / "appcache/appinfo.vdf").write_bytes( + AppInfoTest.appinfo(self.entries if entries is None else entries)) + + def manifest(self, app, root=None): + return (root or self.steam) / ("steamapps/appmanifest_%s.acf" % app) + + def seed(self): + return COMPAT["seed_unavailable_arm64_tools"](str(self.steam)) + + def test_seeds_bare_manifests_for_unavailable_tool_dependencies(self): + self.assertEqual(self.seed(), [EAC_ID, SCOUT_ID]) + for app, name in ((EAC_ID, EAC_NAME), (SCOUT_ID, SCOUT_NAME)): + text = self.manifest(app).read_text() + for expected in ('"appid" "%s"' % app, '"Universe" "1"', '"StateFlags" "4"', + '"name" "%s"' % name, '"installdir" "%s"' % name, + '"AutoUpdateBehavior" "1"'): + self.assertIn(expected, text) + self.assertFalse(self.manifest("976730").exists()) + + def test_seeding_is_idempotent(self): + self.seed() + first = {app: self.manifest(app).read_text() for app in (EAC_ID, SCOUT_ID)} + self.assertEqual(self.seed(), []) + self.assertEqual({app: self.manifest(app).read_text() for app in first}, first) + + def test_a_real_install_in_another_library_is_never_overwritten(self): + other = self.root / "SD" + (other / "steamapps").mkdir(parents=True) + existing = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"4"\n}\n' % SCOUT_ID + (other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).write_text(existing) + (self.steam / "steamapps/libraryfolders.vdf").write_text( + '"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n}\n' % other) + self.assertEqual(self.seed(), [EAC_ID]) + self.assertFalse(self.manifest(SCOUT_ID).exists()) + self.assertEqual((other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).read_text(), existing) + + def test_a_partial_install_in_another_library_is_completed_in_place(self): + other = self.root / "SD" + (other / "steamapps").mkdir(parents=True) + partial = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"2"\n}\n' % SCOUT_ID + (other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).write_text(partial) + (self.steam / "steamapps/libraryfolders.vdf").write_text( + '"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n}\n' % other) + self.assertEqual(self.seed(), [EAC_ID, SCOUT_ID]) + self.assertFalse(self.manifest(SCOUT_ID).exists()) + self.assertIn('"StateFlags" "4"', + (other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).read_text()) + + def test_a_real_install_in_any_library_wins_over_a_partial_one(self): + other = self.root / "SD" + (other / "steamapps").mkdir(parents=True) + partial = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"2"\n}\n' % SCOUT_ID + installed = '"AppState"\n{\n\t"appid"\t"%s"\n\t"StateFlags"\t"4"\n}\n' % SCOUT_ID + self.manifest(SCOUT_ID).write_text(partial) + (other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).write_text(installed) + (self.steam / "steamapps/libraryfolders.vdf").write_text( + '"libraryfolders"\n{\n\t"0"\n\t{\n\t\t"path"\t\t"%s"\n\t}\n}\n' % other) + self.assertEqual(self.seed(), [EAC_ID]) + self.assertEqual(self.manifest(SCOUT_ID).read_text(), partial) + self.assertEqual((other / ("steamapps/appmanifest_%s.acf" % SCOUT_ID)).read_text(), installed) + + def test_a_failed_write_leaves_no_manifest_behind(self): + real_link = COMPAT["os"].link + + def fail_for_scout(source, target): + if SCOUT_ID in str(target): + raise OSError("disk full") + return real_link(source, target) + + with mock.patch.object(COMPAT["os"], "link", side_effect=fail_for_scout): + self.assertEqual(self.seed(), [EAC_ID]) + self.assertFalse(self.manifest(SCOUT_ID).exists()) + self.assertEqual(sorted(p.name for p in (self.steam / "steamapps").iterdir()), + ["appmanifest_%s.acf" % EAC_ID]) + self.assertEqual(self.seed(), [SCOUT_ID]) + self.assertEqual(self.manifest(SCOUT_ID).read_text(), + COMPAT["manifest_text"](SCOUT_ID, SCOUT_NAME, SCOUT_NAME, True)) + + def test_new_manifest_publication_preserves_a_concurrent_install(self): + real_link = COMPAT["os"].link + installed = COMPAT["manifest_text"](SCOUT_ID, "Existing tool", "Existing", False) + + def publish(source, target): + if SCOUT_ID in str(target): + Path(target).write_text(installed) + return real_link(source, target) + + with mock.patch.object(COMPAT["os"], "link", side_effect=publish): + self.assertEqual(self.seed(), [EAC_ID]) + self.assertEqual(self.manifest(SCOUT_ID).read_text(), installed) + self.assertEqual(self.seed(), []) + self.assertFalse(list((self.steam / "steamapps").glob(".appmanifest_*"))) + + def test_partial_staged_write_is_not_published_and_retry_repairs(self): + real_temporary = COMPAT["tempfile"].NamedTemporaryFile + + def temporary(*args, **kwargs): + output = real_temporary(*args, **kwargs) + real_write = output.write + + def write(text): + if SCOUT_ID in text: + real_write(text[:text.index(' "installdir"')]) + output.flush() + raise OSError("disk full") + return real_write(text) + + output.write = write + return output + + with mock.patch.object(COMPAT["tempfile"], "NamedTemporaryFile", side_effect=temporary): + self.assertEqual(self.seed(), [EAC_ID]) + self.assertFalse(self.manifest(SCOUT_ID).exists()) + self.assertFalse(list((self.steam / "steamapps").glob(".appmanifest_*"))) + self.assertEqual(self.seed(), [SCOUT_ID]) + self.assertEqual(self.manifest(SCOUT_ID).read_text(), + COMPAT["manifest_text"](SCOUT_ID, SCOUT_NAME, SCOUT_NAME, True)) + + def test_failed_replacement_preserves_partial_manifest_and_retry_repairs(self): + partial = '"AppState" { "appid" "%s" "StateFlags" "2" }' % SCOUT_ID + self.manifest(SCOUT_ID).write_text(partial) + with mock.patch.object(COMPAT["os"], "replace", side_effect=OSError("disk full")): + self.assertEqual(self.seed(), [EAC_ID]) + self.assertEqual(self.manifest(SCOUT_ID).read_text(), partial) + self.assertFalse(list((self.steam / "steamapps").glob(".appmanifest_*"))) + self.assertEqual(self.seed(), [SCOUT_ID]) + self.assertEqual(self.manifest(SCOUT_ID).read_text(), + COMPAT["manifest_text"](SCOUT_ID, SCOUT_NAME, SCOUT_NAME, True)) + + def test_tools_with_an_arm64_depot_are_skipped(self): + entries = dict(self.entries) + entries[SCOUT] = tool(SCOUT_NAME, osarch="arm64") + self.write_appinfo(entries) + self.assertEqual(self.seed(), [EAC_ID]) + self.assertFalse(self.manifest(SCOUT_ID).exists()) + + def test_an_app_that_is_not_a_tool_is_skipped(self): + entries = dict(self.entries) + entries[SCOUT] = tool(SCOUT_NAME, kind="game") + self.write_appinfo(entries) + self.assertEqual(self.seed(), [EAC_ID]) + self.assertFalse(self.manifest(SCOUT_ID).exists()) + + def test_missing_appinfo_uses_the_display_names(self): + (self.steam / "appcache/appinfo.vdf").unlink() + COMPAT["APPINFO_CACHE"].clear() + self.assertEqual(self.seed(), [EAC_ID, SCOUT_ID]) + self.assertIn('"name" "%s"' % SCOUT_NAME, self.manifest(SCOUT_ID).read_text()) + + def test_flag_seeds_without_running_full_compatibility_setup(self): + with mock.patch.object(COMPAT["sys"], "argv", + ["steam-compatibility", str(self.steam), "--seed-arm64-tools"]): + COMPAT["main"]() + self.assertTrue(self.manifest(EAC_ID).is_file()) + self.assertTrue(self.manifest(SCOUT_ID).is_file()) + self.assertFalse((self.steam / "compatibilitytools.d").exists()) + + def test_session_seeds_only_on_the_arm64_client_path(self): + arm64, x64 = SESSION.read_text().split( + " else\n _dd_x64_tool=$(droiddeck-steam-x64 --default-tool)", 1) + self.assertIn('steam-compatibility "$steam_root" --seed-arm64-tools', arm64) + self.assertNotIn("--seed-arm64-tools", x64) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_steamvr_helper.py b/tools/tests/test_steamvr_helper.py index f99f5cbdc2..95df651c7f 100644 --- a/tools/tests/test_steamvr_helper.py +++ b/tools/tests/test_steamvr_helper.py @@ -108,7 +108,8 @@ class SteamVrHelperTest(unittest.TestCase): receiver.bind(str(self.runtime / 'droiddeck-xr-frames')) self.assertIn('present=questwsi lease=unset', self.lease_log()) settings = json.loads((self.home / '.local/share/Steam/config/steamvr.vrsettings').read_text()) - self.assertEqual(settings['steamvr'], {'enableLinuxVulkanAsync': True, 'motionSmoothing': False}) + self.assertEqual(settings['steamvr'], {'enableLinuxVulkanAsync': True, 'motionSmoothing': False, + 'framesToThrottle': 0, 'powersaveFramesToThrottle': 0}) self.assertFalse(cvp.exists()) self.assertEqual(Path(str(cvp) + '.droiddeck-disabled').read_bytes(), b'frame-only backend') @@ -172,6 +173,31 @@ class SteamVrHelperTest(unittest.TestCase): self.assertEqual(json.loads(settings.read_text()), original) self.assertFalse(backup.exists()) + def test_backup_saved_before_new_overrides_keeps_their_current_values(self): + settings = self.root / 'steamvr.vrsettings' + backup = self.root / 'quest-backup.json' + helper = SOURCE.with_name('droiddeck-steamvr-settings') + settings.write_text(json.dumps({'steamvr': {'motionSmoothing': True, 'framesToThrottle': 2}})) + backup.write_text(json.dumps({'section': True, 'values': {'enableLinuxVulkanAsync': [False, None], + 'motionSmoothing': [True, True]}})) + subprocess.run([sys.executable, str(helper), 'apply', str(settings), str(backup)], check=True) + self.assertEqual(json.loads(settings.read_text())['steamvr']['framesToThrottle'], 0) + subprocess.run([sys.executable, str(helper), 'restore', str(settings), str(backup)], check=True) + self.assertEqual(json.loads(settings.read_text()), {'steamvr': {'motionSmoothing': True, 'framesToThrottle': 2}}) + self.assertFalse(backup.exists()) + + def test_backup_missing_an_original_override_is_rejected(self): + settings = self.root / 'steamvr.vrsettings' + backup = self.root / 'quest-backup.json' + helper = SOURCE.with_name('droiddeck-steamvr-settings') + settings.write_text(json.dumps({'steamvr': {'motionSmoothing': False}})) + content = json.dumps({'section': True, 'values': {'motionSmoothing': [True, True]}}) + backup.write_text(content) + result = subprocess.run([sys.executable, str(helper), 'restore', str(settings), str(backup)], + capture_output=True, text=True) + self.assertNotEqual(result.returncode, 0) + self.assertEqual(backup.read_text(), content) + def test_quest_update_preserves_previous_cvp_backup(self): self.environment['DROIDDECK_VR_PRESENT'] = 'questwsi' cvp = self.steamvr / 'drivers/cv/bin/linuxarm64/libArcturusPerception.so' diff --git a/tools/tests/test_store_launch.py b/tools/tests/test_store_launch.py index e5a01aa1ce..1e40a391be 100644 --- a/tools/tests/test_store_launch.py +++ b/tools/tests/test_store_launch.py @@ -452,6 +452,107 @@ class Launchers(unittest.TestCase): self.assertEqual(-2, rc) + def test_a_steam_ea_link_is_swapped_for_droiddecks_launcher_and_reports_its_exit(self): + with tempfile.TemporaryDirectory() as root: + hook = Path(root) / 'hook' + record = Path(root) / 'ran' + hook.write_text('#!/bin/sh\necho "$@" >> "%s"\n' % record) + hook.chmod(0o755) + setup = compat.DD_STORE_SETUP.replace('/usr/local/bin/droiddeck-store-launch', str(hook)).replace( + '[ -x %s ] || return 0' % hook, '[ -x %s ] || return 0; verb=waitforexitandrun' % hook) + setup = setup.replace(' %s "$@"\n rc=$?' % hook, ' %s "$@"\n rc=13' % hook) + script = setup + '\nverb=waitforexitandrun\ndd_store_launch steam2ea://launchgame/1237970 -dev\nDD_STORE_ARGS=(steam2ea://launchgame/1237970 -dev)\ndd_run %s proton waitforexitandrun Steam2EA://launchgame/1237970 -dev\n' % hook + done = subprocess.run(['bash', '-c', script], env=dict(os.environ, STEAM_COMPAT_DATA_PATH=root + '/'), timeout=20) + self.assertEqual(0, done.returncode) + lines = record.read_text().splitlines() + self.assertEqual('proton waitforexitandrun %s/droiddeck-ea-steam.bat -dev' % root, lines[1]) + self.assertEqual('--exited --code 0 steam2ea://launchgame/1237970 -dev', lines[2]) + + +MANIFEST = """ + + + 1039093 + + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Respawn\\Titanfall2\\Install Dir]Titanfall2.exe0 + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Respawn\\Titanfall2\\Install Dir]Titanfall2_trial.exe1 + + Titanfall 2 + +""" + + +class SteamEa(unittest.TestCase): + def steam_copy(self, root): + folder = Path(root) / 'steamapps/common/Titanfall2' + (folder / '__Installer/LOC').mkdir(parents=True) + (folder / '__Installer/installerdata.xml').write_bytes(b'\xff\xfe' + MANIFEST.encode('utf-16-le')) + (folder / '__Installer/LOC/Origin.OFR.50.0001456.dat').write_text('') + (folder / '__Installer/LOC/Origin.OFR.50.0001452.dat').write_text('') + (folder / 'Titanfall2.exe').write_text('') + (folder / 'Titanfall2_trial.exe').write_text('') + data = Path(root) / 'compatdata/1237970' + (data / 'pfx').mkdir(parents=True) + return folder, data + + def test_the_manifest_names_the_full_game_its_content_and_version(self): + with tempfile.TemporaryDirectory() as root: + folder, _ = self.steam_copy(root) + manifest = store.ea_manifest(folder) + self.assertEqual(folder / 'Titanfall2.exe', manifest['exe']) + self.assertEqual(['1039093'], manifest['contentIds']) + self.assertEqual('1.0.1.3', manifest['version']) + self.assertEqual('Titanfall 2', manifest['title']) + self.assertEqual(['Origin.OFR.50.0001452', 'Origin.OFR.50.0001456'], store.steam_ea_offers(folder)) + + def test_a_steam_ea_launch_gets_a_session_and_a_launcher_that_reads_it_once(self): + with tempfile.TemporaryDirectory() as root: + folder, data = self.steam_copy(root) + asked = [] + answer = {'ok': True, 'id': 'Origin.OFR.50.0001452', 'env': {'EALsxPort': '3216', 'ContentId': '1039093'}} + prepare = lambda *a: asked.append(a) or answer + env = {'STEAM_COMPAT_INSTALL_PATH': str(folder), 'STEAM_COMPAT_DATA_PATH': str(data), 'DD_LAUNCH_DIR': str(Path(root) / 'session')} + with patch.dict(os.environ, env), patch.object(store, 'prepare_ea', side_effect=prepare): + self.assertEqual(store.REPLACED, store.main(['steam2ea://launchgame/1237970?platform=steam&theme=tf2'])) + steam = asked[0][4] + self.assertEqual(['Origin.OFR.50.0001452', 'Origin.OFR.50.0001456'], steam['offers']) + self.assertEqual(['1039093'], steam['contentIds']) + self.assertEqual('Titanfall2.exe', steam['exe']) + self.assertEqual(b'EALsxPort=3216\r\nContentId=1039093\r\n', (data / store.STEAM_EA_ENV).read_bytes()) + bat = (data / store.STEAM_EA_LAUNCHER).read_text() + envfile = store.windows_path(str(data / store.STEAM_EA_ENV)) + self.assertIn('cd /d "%s"' % store.windows_path(str(folder)), bat) + self.assertIn('for /f "usebackq tokens=1,* delims==" %%%%a in ("%s") do set "%%%%a=%%%%b"' % envfile, bat) + self.assertIn('del "%s"' % envfile, bat) + self.assertIn('"%s" %%*' % store.windows_path(str(folder / 'Titanfall2.exe')), bat) + self.assertEqual({'id': 'Origin.OFR.50.0001452'}, json.loads((data / store.STEAM_EA_STATE).read_text())) + asked.clear() + record = lambda channel, request, timeout=5.0, claim=False: asked.append(request) + with patch.dict(os.environ, env), patch.object(store, 'ask', side_effect=record): + self.assertEqual(0, store.main(['--exited', 'steam2ea://launchgame/1237970'])) + self.assertEqual([{'op': 'ea-exited', 'store': 'ea', 'id': 'Origin.OFR.50.0001452'}], asked) + + def test_the_manifests_launch_parameters_keep_their_quotes(self): + with tempfile.TemporaryDirectory() as root: + folder, data = self.steam_copy(root) + bat = store.steam_ea_launcher(folder, folder / 'Titanfall2.exe', '-config "game profile.cfg" -rate 50%', str(data)) + self.assertIn('Titanfall2.exe" -config "game profile.cfg" -rate 50%% %*', bat) + + def test_steam_keeps_the_link_when_droiddeck_cannot_start_the_game(self): + with tempfile.TemporaryDirectory() as root: + folder, data = self.steam_copy(root) + env = {'STEAM_COMPAT_INSTALL_PATH': str(folder), 'STEAM_COMPAT_DATA_PATH': str(data), 'DD_LAUNCH_DIR': str(Path(root) / 'session')} + link = ['steam2ea://launchgame/1237970'] + with patch.dict(os.environ, env), patch.object(store, 'prepare_ea', return_value={'ok': False, 'reason': 'signed-out'}): + self.assertEqual(0, store.main(link)) + client = data / 'pfx' / store.STEAM_EA_CLIENT + client.parent.mkdir(parents=True) + client.write_text('') + with patch.dict(os.environ, env), patch.object(store, 'prepare_ea', side_effect=AssertionError('the EA app is installed')): + self.assertEqual(0, store.main(link)) + self.assertFalse((data / store.STEAM_EA_LAUNCHER).exists()) + + if __name__ == '__main__': unittest.main() diff --git a/tools/tests/test_subsurface_release.py b/tools/tests/test_subsurface_release.py index 2254eb1a71..c8ad7fcf12 100644 --- a/tools/tests/test_subsurface_release.py +++ b/tools/tests/test_subsurface_release.py @@ -41,7 +41,8 @@ class SubsurfaceReleaseTest(unittest.TestCase): start = cls.source.index('struct pending_release {') end = cls.source.index('\n};\n', start) + 4 parts = [extract_function(cls.source, name) for name in FUNCTIONS] - code = cls.source[start:end] + '\n'.join(p[0] for p in parts) + '\n' + '\n'.join(p[1] for p in parts) + '\n' + depth = re.search(r'^#define RELEASE_PACE_DEPTH \d+$', cls.source, re.MULTILINE).group(0) + code = depth + '\n' + cls.source[start:end] + '\n'.join(p[0] for p in parts) + '\n' + '\n'.join(p[1] for p in parts) + '\n' cls.temp = tempfile.TemporaryDirectory(prefix='droiddeck-subsurface-release-') cls.addClassCleanup(cls.temp.cleanup) folder = Path(cls.temp.name) @@ -74,6 +75,15 @@ class SubsurfaceReleaseTest(unittest.TestCase): def test_toplevel_release_pacing_is_unchanged(self): self.check_case('toplevel') + def test_client_that_never_waits_keeps_a_bounded_release_queue(self): + self.check_case('never-waits') + + def test_sync_child_that_never_waits_keeps_a_bounded_release_queue(self): + self.check_case('never-waits-sync') + + def test_fixed_pool_as_deep_as_the_cap_stays_held_to_the_limit(self): + self.check_case('deep-pool') + def test_held_release_is_sent_when_the_parent_is_destroyed(self): self.check_case('destroyed') @@ -85,7 +95,7 @@ class SubsurfaceReleaseTest(unittest.TestCase): def test_compositor_attach_and_commit_use_the_release_hold(self): self.assertIn('pending_releases_cancel(buffer);', function_body(self.source, 'take_dmabuf')) - commit = function_body(self.source, 'surface_commit') + commit = function_body(self.source, 'surface_state_apply') self.assertIn('pending_releases_apply(s);', commit) self.assertLess(commit.index('take_dmabuf(s, db, buffer);'), commit.index('pending_releases_apply(s);')) self.assertLess(commit.index('buf_trace_attach(buffer);'), commit.index('if (s->role == ROLE_CURSOR)')) diff --git a/tools/tests/test_vk_dmabuf_quarantine.py b/tools/tests/test_vk_dmabuf_quarantine.py index 5bd0f1b016..8ba72d84e9 100644 --- a/tools/tests/test_vk_dmabuf_quarantine.py +++ b/tools/tests/test_vk_dmabuf_quarantine.py @@ -55,6 +55,12 @@ class VkDmabufQuarantineTest(unittest.TestCase): helpers += ['static void release_due_buffers(void);', 'static void arm_release_timer(void);', function(comp, 'sync_holder')] names.insert(names.index('on_release_timer'), 'release_due_buffers') + depth = re.search(r'^#define RELEASE_PACE_DEPTH \d+$', comp, re.M) + if depth: + helpers += [depth.group(0), + 'static void describe(const struct surface *s, char *out, size_t size) ' + '{ (void)s; if (size) out[0] = 0; }', + 'static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; }'] if re.search(r'\bvolatile int g_release_unpaced;', comp): # Releases stay paced in these scenarios (fps limit -1 sends them at once). helpers.insert(0, 'static int g_release_unpaced;') diff --git a/tools/tests/test_vk_linear_dmabuf.py b/tools/tests/test_vk_linear_dmabuf.py index bcbedc04e9..ad39af709a 100644 --- a/tools/tests/test_vk_linear_dmabuf.py +++ b/tools/tests/test_vk_linear_dmabuf.py @@ -20,6 +20,14 @@ LAYER_HARNESS = r''' #include "vk_linear_dmabuf.h" typedef struct AHardwareBuffer AHardwareBuffer; +enum vkp_image_source { + VKP_IMAGE_SOURCE_NONE = 0, + VKP_IMAGE_SOURCE_DMABUF, + VKP_IMAGE_SOURCE_AHB_WLEGL, + VKP_IMAGE_SOURCE_AHB_SOURCE, + VKP_IMAGE_SOURCE_AHB_TARGET, + VKP_IMAGE_SOURCE_SHM +}; %(image)s struct vkp_draw { struct vkp_image *img; diff --git a/tools/tests/test_vk_pending_completion.py b/tools/tests/test_vk_pending_completion.py index 8f3dc48eb0..7ad8a6f784 100644 --- a/tools/tests/test_vk_pending_completion.py +++ b/tools/tests/test_vk_pending_completion.py @@ -31,8 +31,10 @@ def function(text, name): HARNESS = r''' #include #include +#include #include #include +#include typedef int VkResult; typedef uintptr_t VkFence; #define VK_TRUE 1 @@ -45,13 +47,18 @@ static int g_dev_state, g_base_black; static uintptr_t g_dev = 1; static struct { int64_t wait_ns, wait_max_ns; unsigned waits; } g_perf; static VkResult answer; +static unsigned timeouts, wait_calls; static unsigned destroyed, unmapped, freed_memory, forgotten, errors; static int64_t perf_now(void) { return 10; } static void perf_add(int64_t *s, int64_t *m, unsigned *c, int64_t d) { *s+=d; *m=d; ++*c; } static void __attribute__((unused)) droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; ++errors; } #define LOGE(...) droiddeck_log("error", __VA_ARGS__) static VkResult wait_fn(uintptr_t dev, unsigned n, const VkFence *f, int all, uint64_t timeout) { - (void)dev; (void)n; (void)f; (void)all; (void)timeout; return answer; + (void)dev; (void)n; (void)f; (void)all; + ++wait_calls; + if (wait_calls > 1) assert(timeout == UINT64_MAX); + if (timeouts) { --timeouts; return VK_TIMEOUT; } + return answer; } static void unmap_fn(uintptr_t dev, uintptr_t mem) { (void)dev; (void)mem; ++unmapped; } static void destroy_fn(uintptr_t dev, uintptr_t img, void *allocator) { (void)dev; (void)img; (void)allocator; ++destroyed; } @@ -69,12 +76,31 @@ static struct { typedef struct AHardwareBuffer AHardwareBuffer; static int released_buffers; static void AHardwareBuffer_release(AHardwareBuffer *b) { (void)b; ++released_buffers; } -struct vkp_image { uintptr_t image, mem; void *map; AHardwareBuffer *android_buffer; uintptr_t linear_buf, linear_mem; int staged, in_general; }; +enum vkp_image_source { + VKP_IMAGE_SOURCE_NONE = 0, + VKP_IMAGE_SOURCE_DMABUF, + VKP_IMAGE_SOURCE_AHB_WLEGL, + VKP_IMAGE_SOURCE_AHB_SOURCE, + VKP_IMAGE_SOURCE_AHB_TARGET, + VKP_IMAGE_SOURCE_SHM +}; +struct vkp_image { + uintptr_t image, mem; + void *map; + AHardwareBuffer *android_buffer; + uintptr_t linear_buf, linear_mem; + int staged, in_general; + enum vkp_image_source source_type; + int source_fd; + uint8_t *recovery_pixels; + struct vkp_image *next; +}; +static void image_unregister(struct vkp_image *img) { (void)img; } static void blendp_forget_image(uintptr_t image) { (void)image; ++forgotten; } /* PRODUCTION_FUNCTIONS */ static struct vkp_image *image(void) { struct vkp_image *p = calloc(1, sizeof(*p)); assert(p); - p->image=1; p->mem=2; p->map=p; return p; + p->image=1; p->mem=2; p->map=p; p->source_fd=-1; return p; } int main(void) { g_dev_state=1; answer=VK_SUCCESS; @@ -83,8 +109,15 @@ int main(void) { vkp_image_destroy(image()); assert(destroyed==1 && unmapped==1 && freed_memory==1 && forgotten==1); - g_dev_state=1; g_base_black=1; answer=VK_TIMEOUT; - assert(timed_wait(1, 1000)==VK_TIMEOUT); + for (unsigned delays=1; delays<=3; ++delays) { + g_dev_state=1; g_base_black=1; answer=VK_SUCCESS; + timeouts=delays; wait_calls=0; + assert(timed_wait(1, 1000)==VK_SUCCESS); + assert(g_dev_state==1 && g_base_black==1 && wait_calls==delays+1); + } + + g_dev_state=1; g_base_black=1; answer=VK_ERROR_UNKNOWN; wait_calls=0; + assert(timed_wait(1, 1000)==VK_ERROR_UNKNOWN); assert(g_dev_state!=1 && g_dev_state!=-2); /* pending work is not DEVICE_LOST */ struct vkp_image *pending=image(); vkp_image_destroy(pending); @@ -95,14 +128,14 @@ int main(void) { assert(errors==first_errors); /* one terminal diagnostic, no repeated recovery */ free(pending); /* fake GPU exists only in this test */ - g_dev_state=1; answer=VK_ERROR_OUT_OF_HOST_MEMORY; + g_dev_state=1; answer=VK_ERROR_OUT_OF_HOST_MEMORY; wait_calls=0; timeouts=1; assert(timed_wait(1, 1000)==VK_ERROR_OUT_OF_HOST_MEMORY); assert(g_dev_state!=1 && g_dev_state!=-2); pending=image(); vkp_image_destroy(pending); assert(destroyed==1 && unmapped==1 && freed_memory==1 && forgotten==1); free(pending); - g_dev_state=1; answer=VK_ERROR_DEVICE_LOST; + g_dev_state=1; answer=VK_ERROR_DEVICE_LOST; wait_calls=0; timeouts=2; assert(timed_wait(1, 1000)==VK_ERROR_DEVICE_LOST); assert(g_dev_state==1); /* existing caller performs genuine device-loss cleanup */ return 0; @@ -134,6 +167,8 @@ static struct { void (*DestroySurfaceKHR)(uintptr_t, uintptr_t, void *); } g_vk={idle_fn, destroy_fn, destroy_fn}; static void reset_sync(void) { ++resets; } +/* The swapchain test isolates idle-failure behavior; semaphore cleanup is tested separately. */ +static void destroy_present_semaphores(void) {} static void blendp_forget_image(uintptr_t img) { (void)img; ++forgotten; } static void device_lost(const char *where) { (void)where; ++lost; g_dev_state=-2; } /* PRODUCTION_FUNCTIONS */ diff --git a/tools/tests/test_vk_terminal_callers.py b/tools/tests/test_vk_terminal_callers.py index 582a6d84f5..c1e08bf6d5 100644 --- a/tools/tests/test_vk_terminal_callers.py +++ b/tools/tests/test_vk_terminal_callers.py @@ -111,11 +111,17 @@ int __android_log_print(int, const char *, const char *, ...); def test_later_framegen_surface_lost_idle_failure(self): self.run_scenario('later-surface-lost') - def test_finite_blit_timeout_same_size_shm_upload(self): - self.run_scenario('shm-timeout') + def test_blit_wait_error_same_size_shm_upload(self): + self.run_scenario('shm-wait-error') - def test_finite_blit_timeout_same_size_pixel_upload(self): - self.run_scenario('pixel-timeout') + def test_blit_wait_error_same_size_pixel_upload(self): + self.run_scenario('pixel-wait-error') + + def test_lost_device_shm_upload_keeps_cpu_snapshot(self): + self.run_scenario('lost-shm-upload') + + def test_delayed_blit_completes_and_next_frame_renders(self): + self.run_scenario('blit-delayed') def test_normal_present(self): self.run_scenario('normal') @@ -126,6 +132,9 @@ int __android_log_print(int, const char *, const char *, ...); def test_healthy_later_acquire_timeout_drains_work(self): self.run_scenario('later-timeout') + def test_device_loss_with_unconfirmed_idle_retains_resources(self): + self.run_scenario('acquire-device-lost-unconfirmed') + def test_real_device_lost_on_acquire(self): self.run_scenario('acquire-device-lost') diff --git a/tools/tests/test_winebus_rumble_preload.py b/tools/tests/test_winebus_rumble_preload.py index a18f541e7a..71616e7128 100644 --- a/tools/tests/test_winebus_rumble_preload.py +++ b/tools/tests/test_winebus_rumble_preload.py @@ -40,6 +40,39 @@ void upload(unsigned short type, unsigned short length) { } """ +SDL = r""" +#include +#include +#include +#include +#include + +int SDL_JoystickRumble(void *joystick, uint16_t low, uint16_t high, uint32_t duration) { + struct ff_effect effect; + (void)joystick; + printf("sdl %u %u duration %u\n", low, high, duration); + memset(&effect, 0, sizeof(effect)); + effect.id = -1; + effect.type = FF_RUMBLE; + effect.replay.length = 0xffff; + effect.u.rumble.strong_magnitude = low; + effect.u.rumble.weak_magnitude = high; + return ioctl(3, EVIOCSFF, &effect); +} +""" + +SDL_CALLER = r""" +#include +#include + +int rumble(const char *library, uint16_t low, uint16_t high, uint32_t duration) { + void *sdl = dlopen(library, RTLD_NOW | RTLD_LOCAL); + int (*call)(void *, uint16_t, uint16_t, uint32_t) = (int (*)(void *, uint16_t, uint16_t, uint32_t))dlsym(sdl, "SDL_JoystickRumble"); + call(0, low, high, duration); + return 0; +} +""" + PROGRAM = r""" #include #include @@ -47,8 +80,21 @@ PROGRAM = r""" void upload(unsigned short type, unsigned short length); +int rumble(const char *library, unsigned short low, unsigned short high, unsigned int duration); + int main(int argc, char **argv) { void *winebus = dlopen(argv[1], RTLD_NOW); + if (argv[2][0] == 's') { + int (*from_winebus)(const char *, unsigned short, unsigned short, unsigned int) = + (int (*)(const char *, unsigned short, unsigned short, unsigned int))dlsym(winebus, "rumble"); + for (const char *step = argv[3]; *step; step++) { + if (*step == 'w') from_winebus(argv[4], 65535, 32768, 1000); + if (*step == 'z') from_winebus(argv[4], 0, 0, 0); + if (*step == 'p') rumble(argv[4], 65535, 32768, 1000); + } + fflush(stdout); + return 0; + } void (*from_winebus)(unsigned short, unsigned short) = (void (*)(unsigned short, unsigned short))dlsym(winebus, "upload"); if (argv[2][0] == 'w') from_winebus(argv[3][0] == 'r' ? FF_RUMBLE : FF_PERIODIC, 1000); else upload(FF_RUMBLE, 1000); @@ -65,7 +111,8 @@ class WinebusRumblePreloadTest(unittest.TestCase): cls.dir = Path(tempfile.mkdtemp()) build = cls.dir / "build" build.mkdir() - for name, text in (("shim.c", SHIM), ("upload.c", UPLOAD), ("program.c", PROGRAM)): + for name, text in (("shim.c", SHIM), ("upload.c", UPLOAD), ("program.c", PROGRAM), ("sdl.c", SDL), + ("sdl_caller.c", SDL_CALLER)): (build / name).write_text(text) cls.lib = cls.dir / "libddsession.so" subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-Wall", "-pthread", "-o", str(cls.lib), @@ -73,10 +120,13 @@ class WinebusRumblePreloadTest(unittest.TestCase): cls.shim = cls.dir / "libshim.so" subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.shim), str(build / "shim.c")], check=True) cls.winebus = cls.dir / "winebus.so" - subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.winebus), str(build / "upload.c")], check=True) + subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.winebus), str(build / "upload.c"), + str(build / "sdl_caller.c"), "-ldl"], check=True) + cls.sdl_library = cls.dir / "libSDL2-2.0.so.0" + subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.sdl_library), str(build / "sdl.c")], check=True) cls.program = cls.dir / "program" - subprocess.run(["cc", "-O2", "-o", str(cls.program), str(build / "program.c"), str(build / "upload.c"), "-ldl"], - check=True) + subprocess.run(["cc", "-O2", "-o", str(cls.program), str(build / "program.c"), str(build / "upload.c"), + str(build / "sdl_caller.c"), "-ldl"], check=True) @classmethod def tearDownClass(cls): @@ -88,6 +138,21 @@ class WinebusRumblePreloadTest(unittest.TestCase): capture_output=True, text=True, timeout=10, check=True) return result.stdout.splitlines() + def sdl(self, steps): + env = dict(os.environ, LD_PRELOAD="%s:%s" % (self.lib, self.shim)) + result = subprocess.run([str(self.program), str(self.winebus), "sdl", steps, str(self.sdl_library)], env=env, + capture_output=True, text=True, timeout=10, check=True) + return result.stdout.splitlines() + + def test_rumble_winebus_starts_through_sdl_is_held_until_the_next_update(self): + self.assertEqual(self.sdl("wz"), ["sdl 65535 32768 duration 0", "shim type %d length 0" % 0x50, + "sdl 0 0 duration 0", "shim type %d length 0" % 0x50]) + + def test_sdl_rumble_from_other_code_keeps_its_duration_and_length(self): + self.assertEqual(self.sdl("p"), ["sdl 65535 32768 duration 1000", "shim type %d length 65535" % 0x50]) + self.assertEqual(self.sdl("wp"), ["sdl 65535 32768 duration 0", "shim type %d length 0" % 0x50, + "sdl 65535 32768 duration 1000", "shim type %d length 65535" % 0x50]) + def test_winebus_rumble_reaches_the_shim_held_and_comes_back_unchanged(self): self.assertEqual(self.upload("winebus"), ["shim type %d length 0" % 0x50, "caller length 1000"]) diff --git a/tools/tests/test_zero_copy_release_at_latch.py b/tools/tests/test_zero_copy_release_at_latch.py new file mode 100644 index 0000000000..e72a0bbabb --- /dev/null +++ b/tools/tests/test_zero_copy_release_at_latch.py @@ -0,0 +1,206 @@ +import os +from pathlib import Path +import re +import shutil +import subprocess +import tempfile +import unittest + +from test_vk_pending_completion import function + +ROOT = Path(__file__).resolve().parents[2] +SRC = ROOT / 'app/src/main/cpp/waylandcomp/src' + +HARNESS = r''' +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +struct wl_listener { struct wl_list link; void (*notify)(struct wl_listener *, void *); }; +struct wl_event_source { int unused; }; +struct wl_event_loop; +enum { WL_EVENT_READABLE = 1 }; +struct wl_client; +struct wl_resource { int unused; }; +struct surface; +struct dmabuf_buffer { int fd; }; +typedef struct AHardwareBuffer { int unused; } AHardwareBuffer; +DEFINES +STRUCT +static struct wl_list g_bufs; +static struct wl_event_loop *g_loop; +static int g_import_failed_logged; +static int import_ok, imports, imported_flags, deferred_releases, frees, sources, removes, merge_ok, merges; +static struct wl_event_source g_sources[4]; +static struct wl_event_source *g_removed; +void wl_list_init(struct wl_list *l) { l->prev = l; l->next = l; } +void wl_list_insert(struct wl_list *l, struct wl_list *e) { + e->next = l->next; e->prev = l; l->next->prev = e; l->next = e; +} +static int fake_ioctl(int fd, unsigned long req, void *arg) { + if (req == SYNC_IOC_MERGE) { + struct sync_merge_data *m = arg; + assert(fd >= 0 && m->fd2 >= 0 && fd != m->fd2); + ++merges; + if (!merge_ok) { errno = ENOTTY; return -1; } + m->fence = dup(m->fd2); return 0; + } + struct droiddeck_dma_buf_sync_file *f = arg; + (void)fd; + assert(req == DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE); + ++imports; imported_flags = (int)f->flags; + if (import_ok) return 0; + errno = ENOTTY; return -1; +} +#define ioctl fake_ioctl +static int droiddeck_dmabuf_fd(struct dmabuf_buffer *b) { return b->fd; } +static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; } +static struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *l, int fd, uint32_t m, + int (*cb)(int, uint32_t, void *), void *d) { + (void)l; (void)fd; (void)m; (void)cb; (void)d; return &g_sources[sources++]; +} +static void wl_event_source_remove(struct wl_event_source *s) { assert(s); ++removes; g_removed = s; } +static int on_fence_readable(int fd, uint32_t mask, void *data) { (void)fd; (void)mask; (void)data; return 0; } +static void send_deferred_release(struct ahb_buf *ab) { ++deferred_releases; ab->release_pending = 0; } +static void maybe_free(struct ahb_buf *ab) { (void)ab; ++frees; } +FUNCTIONS +static void reset(void) { + import_ok = imports = imported_flags = deferred_releases = frees = sources = removes = merge_ok = merges = 0; + g_removed = NULL; +} +static void run(int display, int can_import, int fence_signalled) { + reset(); + wl_list_init(&g_bufs); + struct dmabuf_buffer b = {.fd = 7}; + struct ahb_buf ab; + memset(&ab, 0, sizeof(ab)); + ab.id = 42; ab.b = &b; ab.display = display; ab.on_layer = 1; ab.release_pending = 1; ab.fence_fd = -1; + wl_list_insert(&g_bufs, &ab.link); + int fds[2]; assert(pipe(fds) == 0); + if (fence_signalled) assert(write(fds[1], "x", 1) == 1); + import_ok = can_import; + handle_released(42, fds[0]); + assert(!ab.on_layer && imports == 1 && imported_flags == DROIDDECK_DMA_BUF_SYNC_READ); + if (can_import || fence_signalled) { + assert(deferred_releases == 1 && frees == 1 && !ab.fence_src && ab.fence_fd == -1); + errno = 0; assert(fcntl(fds[0], F_GETFD) == -1 && errno == EBADF); + } else { + assert(deferred_releases == 0 && sources == 1 && ab.fence_src == &g_sources[0] && ab.fence_fd == fds[0]); + close(fds[0]); + } + close(fds[1]); +} +static int closed(int fd) { errno = 0; return fcntl(fd, F_GETFD) == -1 && errno == EBADF; } +static void rerelease(int can_merge, int second_import, int second_signalled) { + reset(); + wl_list_init(&g_bufs); + struct dmabuf_buffer b = {.fd = 7}; + struct ahb_buf ab; + memset(&ab, 0, sizeof(ab)); + ab.id = 42; ab.b = &b; ab.on_layer = 1; ab.release_pending = 1; ab.fence_fd = -1; + wl_list_insert(&g_bufs, &ab.link); + int first[2], second[2]; + assert(pipe(first) == 0 && pipe(second) == 0); + handle_released(42, first[0]); + assert(ab.fence_src == &g_sources[0] && ab.fence_fd == first[0] && deferred_releases == 0); + ab.on_layer = 1; + if (second_signalled) assert(write(second[1], "x", 1) == 1); + import_ok = second_import; merge_ok = can_merge; + handle_released(42, second[0]); + assert(!ab.on_layer && deferred_releases == 0 && frees == 0); + if (second_import || second_signalled) { + assert(removes == 0 && merges == 0 && sources == 1 && ab.fence_src == &g_sources[0] && ab.fence_fd == first[0]); + assert(closed(second[0])); + close(first[0]); + } else { + assert(merges == 1 && removes == 1 && g_removed == &g_sources[0]); + assert(sources == 2 && ab.fence_src == &g_sources[1] && ab.fence_fd >= 0); + assert(closed(first[0])); + if (can_merge) assert(closed(second[0]) && ab.fence_fd != second[0]); + else assert(ab.fence_fd == second[0]); + close(ab.fence_fd); + } + close(first[1]); close(second[1]); +} +int main(int argc, char **argv) { + if (argc == 5 && !strcmp(argv[1], "rerelease")) { + rerelease(atoi(argv[2]), atoi(argv[3]), atoi(argv[4])); + return 0; + } + assert(argc == 4); + run(atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); + return 0; +} +''' + + +class ZeroCopyReleaseAtLatchTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + cc = shutil.which(os.environ.get('CC', 'cc')) + if not cc: + raise AssertionError('C compiler required') + source_dir = Path(os.environ.get('DROIDDECK_DMABUF_TEST_SOURCE', SRC)) + ahb = (source_dir / 'ahb_swapchain.c').read_text() + defines = '\n'.join(re.findall(r'^(?:struct droiddeck_dma_buf_sync_file \{.*?\};|#define DROIDDECK_DMA_BUF_\w+ .*)$', + ahb, re.M)) + struct = re.search(r'struct ahb_buf \{.*?\n\};', ahb, re.S).group() + functions = '\n'.join(function(ahb, n) for n in ('find_buf', 'handle_released')) + source = HARNESS.replace('DEFINES', '#include \n#include \n#include \n' + defines) + source = source.replace('STRUCT', struct).replace('FUNCTIONS', functions) + cls.tmp = tempfile.TemporaryDirectory(prefix='droiddeck-release-latch-') + cls.addClassCleanup(cls.tmp.cleanup) + probe = Path(cls.tmp.name) / 'probe.c' + probe.write_text(source) + cls.binary = probe.with_suffix('') + built = subprocess.run([cc, '-std=c11', '-Wall', '-Wextra', '-Werror', '-Wno-unused-function', '-UNDEBUG', + '-I', str(SRC.parent / 'prebuilt/include'), str(probe), '-o', str(cls.binary)], + capture_output=True, text=True) + if built.returncode: + raise AssertionError(built.stdout + built.stderr) + + def scenario(self, display, can_import, fence_signalled): + result = subprocess.run([str(self.binary), str(display), str(can_import), str(fence_signalled)], + capture_output=True, text=True, timeout=10) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + + def test_display_buffer_released_at_latch_when_fence_attaches(self): + self.scenario(1, 1, 0) + + def test_swapchain_buffer_released_at_latch_when_fence_attaches(self): + self.scenario(0, 1, 0) + + def test_display_buffer_waits_for_fence_when_kernel_cannot_attach(self): + self.scenario(1, 0, 0) + + def test_swapchain_buffer_waits_for_fence_when_kernel_cannot_attach(self): + self.scenario(0, 0, 0) + + def test_signalled_fence_releases_without_waiting(self): + self.scenario(1, 0, 1) + + def rerelease(self, can_merge, second_import, second_signalled): + result = subprocess.run([str(self.binary), 'rerelease', str(can_merge), str(second_import), str(second_signalled)], + capture_output=True, text=True, timeout=10) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + + def test_second_unsignalled_fence_merges_into_the_pending_wait(self): + self.rerelease(1, 0, 0) + + def test_second_unsignalled_fence_replaces_the_wait_when_merge_fails(self): + self.rerelease(0, 0, 0) + + def test_second_imported_fence_keeps_the_pending_wait(self): + self.rerelease(1, 1, 0) + + def test_second_signalled_fence_keeps_the_pending_wait(self): + self.rerelease(1, 0, 1) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/tests/test_zram_preload.py b/tools/tests/test_zram_preload.py index 8a9f813480..58a77fb9dd 100644 --- a/tools/tests/test_zram_preload.py +++ b/tools/tests/test_zram_preload.py @@ -524,6 +524,18 @@ class ZramPreloadTest(unittest.TestCase): self.assertEqual([1], self.run_program(self.game)["handler"]) self.assertEqual(2, len(list(self.dir.glob("ctl.ack.*")))) + def test_control_files_resolve_under_the_native_guest_root(self): + # The native userland hook maps guest paths in libc; the preload's raw calls need the root added. + lib = self.dir / "build" / "libddsession-guest.so" + if not lib.exists(): + subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-Wall", "-pthread", "-DZR_CTL=\"/ctl\"", + "-o", str(lib), *map(str, sorted(PRELOAD.glob("*.c"))), "-ldl"], check=True) + for root, handler in ((str(self.dir), 1), (str(self.dir) + "/", 1), ("", 0)): + environment = dict(os.environ, LD_PRELOAD=str(lib), DDNATV_ROOT=root) + result = subprocess.run([str(self.steam), str(self.ctl), "8", "0"], env=environment, + capture_output=True, text=True, check=True, timeout=120) + self.assertIn("handler %d" % handler, result.stdout.splitlines(), root) + def test_nothing_is_installed_without_the_control_file(self): self.ctl.unlink() try: diff --git a/tools/tests/vk_dmabuf_quarantine_test.c b/tools/tests/vk_dmabuf_quarantine_test.c index f9dcf85bf0..f4163a4ca7 100644 --- a/tools/tests/vk_dmabuf_quarantine_test.c +++ b/tools/tests/vk_dmabuf_quarantine_test.c @@ -34,6 +34,7 @@ struct surface { struct dmabuf_buffer *dmabuf_buf; struct wl_listener dmabuf_destroy; int releases_pending; + int release_pace_open; int64_t next_release_ns; }; /* PRODUCTION_STRUCTS */ diff --git a/tools/tests/vk_terminal_callers_test.c b/tools/tests/vk_terminal_callers_test.c index 374c049a6f..9ca2ae495e 100644 --- a/tools/tests/vk_terminal_callers_test.c +++ b/tools/tests/vk_terminal_callers_test.c @@ -7,7 +7,7 @@ struct vk_api g_vk; static unsigned operations, acquires, submits, markers, waits, idle_calls, resets; static unsigned destroys, releases, lost_notifications, presented_notifications; static VkResult idle_answer, fence_answer, acquire_answer, present_answer; -static unsigned fail_acquire_at; +static unsigned fail_acquire_at, fence_timeouts; static int generated; /* Every work-issuing callback is an oracle: no GPU operation after a terminal @@ -19,7 +19,9 @@ static VkResult acquire(VkDevice d, VkSwapchainKHR s, uint64_t t, VkSemaphore a, } static VkResult idle(VkDevice d) { live(); ++idle_calls; return idle_answer; } static VkResult wait_fences(VkDevice d, uint32_t n, const VkFence *f, VkBool32 all, uint64_t t) { - live(); ++waits; return fence_answer; + live(); ++waits; + if (fence_timeouts) { --fence_timeouts; return VK_TIMEOUT; } + return fence_answer; } static VkResult submit(VkQueue q, uint32_t n, const VkSubmitInfo *s, VkFence f) { live(); ++submits; if (!s->commandBufferCount) ++markers; return VK_SUCCESS; @@ -38,7 +40,11 @@ static void blit(VkCommandBuffer c, VkImage s, VkImageLayout sl, VkImage d, VkIm uint32_t n, const VkImageBlit *b, VkFilter f) { live(); } static void destroy_swap(VkDevice d, VkSwapchainKHR s, const VkAllocationCallbacks *a) { ++destroys; } static void destroy_surface(VkInstance i, VkSurfaceKHR s, const VkAllocationCallbacks *a) { ++destroys; } -static void destroy_sem(VkDevice d, VkSemaphore s, const VkAllocationCallbacks *a) { live(); ++destroys; } +static void destroy_fence(VkDevice d, VkFence f, const VkAllocationCallbacks *a) { ++destroys; } +static void destroy_pool(VkDevice d, VkCommandPool p, const VkAllocationCallbacks *a) { ++destroys; } +static void destroy_device(VkDevice d, const VkAllocationCallbacks *a) { ++destroys; } +static void destroy_instance(VkInstance i, const VkAllocationCallbacks *a) { ++destroys; } +static void destroy_sem(VkDevice d, VkSemaphore s, const VkAllocationCallbacks *a) { ++destroys; } static VkResult create_sem(VkDevice d, const VkSemaphoreCreateInfo *c, const VkAllocationCallbacks *a, VkSemaphore *s) { live(); *s = (VkSemaphore)(uintptr_t)1; return VK_SUCCESS; } @@ -61,21 +67,32 @@ int sc_layer_base_black(int w, int h) { return 0; } void sc_layer_hide_base(void) {} void sc_layer_hide_overlay(void) {} void vkp_cardboard_bind_device(VkDevice d, const VkPhysicalDeviceMemoryProperties *m) {} +void vkp_cardboard_destroy(void) {} int vkp_cardboard_active(void) { return 0; } void vkp_cardboard_begin_frame(void) {} VkImage vkp_cardboard_run(VkCommandBuffer c, VkImage s, int sw, int sh, int ow, int oh) { return s; } -int vk_loader_open(const char *a, const char *b, const char *c) { assert(0); return -1; } -void vk_loader_close(void) { assert(0); } -void vk_loader_load_instance(VkInstance i) { assert(0); } -void vk_loader_load_device(VkDevice d) { assert(0); } +int vk_loader_open(const char *a, const char *b, const char *c) { return -1; } +void vk_loader_close(void) {} +void vk_loader_load_instance(VkInstance i) {} +void vk_loader_load_device(VkDevice d) {} PFN_vkGetInstanceProcAddr vk_loader_gipa(void) { return NULL; } void vkp_effects_bind_device(VkDevice d, VkPhysicalDevice p, const VkPhysicalDeviceMemoryProperties *m) {} +void vkp_effects_destroy(void) {} int vkp_effects_active(void) { return 0; } int vkp_effects_upscaling(void) { return 0; } int vkp_effects_sharpening(void) { return 0; } int vkp_effects_postprocessing(void) { return 0; } +void vkp_effects_release_generated_sources(void) {} +int vkp_effects_prepare_generated(void) { assert(0); return 0; } +VkImage vkp_effects_run_before_generated(VkCommandBuffer c, VkImage i, int w, int h, int *rw, int *rh) { + assert(0); *rw = w; *rh = h; return i; +} +VkImage vkp_effects_run_generated(VkCommandBuffer c, VkImage i, int w, int h, + int ow, int oh, int slot, int *rw, int *rh) { + assert(0); *rw = w; *rh = h; return i; +} VkFilter vkp_effects_blit_filter(void) { return VK_FILTER_NEAREST; } -void vkp_effects_set_formats(VkFormat a, VkFormat b) {} +void vkp_effects_set_formats(VkFormat a, VkFormat b, int scene_is_pq) {} VkImage vkp_effects_run(VkCommandBuffer c, VkImage i, int w, int h, int ow, int oh, int *rw, int *rh) { *rw = w; *rh = h; return i; } @@ -94,9 +111,11 @@ void vkp_framegen_presented(int n) { ++presented_notifications; } void vkp_gpu_busy_device(VkPhysicalDevice p, VkDevice d, uint32_t f) {} void vkp_gpu_busy_device_lost(void) {} void hdrc_bind_device(VkDevice d, const VkPhysicalDeviceMemoryProperties *m) {} +void hdrc_destroy(void) {} void hdrc_forget_image(VkImage i) {} int hdrc_encode(VkCommandBuffer c, VkImage a, VkImage b, VkFormat f, int w, int h, const struct hdrc_params *p) { return -1; } void blendp_bind_device(VkDevice d) {} +void blendp_destroy(void) {} void blendp_forget_image(VkImage i) {} void vkp_effects_forget_image(VkImage i) {} void blendp_begin_frame(void) {} @@ -155,6 +174,8 @@ static void setup(int extra) { .ResetCommandBuffer = reset_cmd, .ResetFences = reset_fence, .BeginCommandBuffer = begin_cmd, .EndCommandBuffer = end_cmd, .CmdPipelineBarrier = barrier, .CmdClearColorImage = clear, .CmdBlitImage = blit, .DestroySwapchainKHR = destroy_swap, .DestroySurfaceKHR = destroy_surface, + .DestroyFence = destroy_fence, .DestroyCommandPool = destroy_pool, + .DestroyDevice = destroy_device, .DestroyInstance = destroy_instance, .DestroySemaphore = destroy_sem, .CreateSemaphore = create_sem, .DestroyImage = destroy_image, .FreeMemory = free_memory, .UnmapMemory = unmap}; idle_answer = fence_answer = acquire_answer = present_answer = VK_SUCCESS; @@ -169,6 +190,8 @@ static void setup(int extra) { g_surface_checked_ns = INT64_MAX; /* no simulated geometry change */ g_scene.img = (VkImage)(uintptr_t)5; g_scene.mem = (VkDeviceMemory)(uintptr_t)6; g_scene.w = g_scene.h = 64; + g_rnds = calloc(MAX_PRESENTS, sizeof(*g_rnds)); assert(g_rnds); + g_rnd_count = MAX_PRESENTS; for (int k = 0; k < MAX_PRESENTS; ++k) { g_cmds[k] = (VkCommandBuffer)(uintptr_t)(10 + k); g_acqs[k] = (VkSemaphore)(uintptr_t)(20 + k); @@ -180,6 +203,7 @@ static void setup(int extra) { /* Probe the public GPU entry points after a terminal result. This includes an * active off-screen pass and consumed release fds, not just the render guard. */ static void assert_stopped(void) { + assert(g_dev_state == -3 || (g_dev_state == -2 && g_recovery_attempted)); unsigned before = operations, before_destroys = destroys; struct vkp_image src = {.image = (VkImage)(uintptr_t)7, .w = 1, .h = 1}; struct vkp_image dst = {.image = (VkImage)(uintptr_t)8, .w = 1, .h = 1, .blit_dst = 1}; @@ -222,7 +246,7 @@ static void acquire_failure(int later, VkResult result) { free(g_images); /* test-owned fake resources only */ } -static void upload_timeout(int single_pixel) { +static void upload_wait_error(int single_pixel) { setup(0); uint8_t bytes[48], saved[48], data[16]; memset(bytes, 0xa5, sizeof(bytes)); memset(data, 0x3c, sizeof(data)); @@ -238,7 +262,7 @@ static void upload_timeout(int single_pixel) { assert(bytes[3] == 0x3c && bytes[0] == 0xa5 && releases == 1); memcpy(saved, bytes, sizeof(saved)); struct vkp_image dst = {.image = (VkImage)(uintptr_t)9, .blit_dst = 1, .w = img->w, .h = img->h}; - fence_answer = VK_TIMEOUT; + fence_answer = VK_ERROR_OUT_OF_HOST_MEMORY; assert(vkp_blit_image(img, &dst, -1) == -1); assert(g_dev_state == -3 && submits == 1 && waits == 1); memset(data, 0x7e, sizeof(data)); @@ -266,9 +290,33 @@ int main(int argc, char **argv) { else if (!strcmp(name, "first-surface-lost")) acquire_failure(0, VK_ERROR_SURFACE_LOST_KHR); else if (!strcmp(name, "later-out-of-date")) acquire_failure(1, VK_ERROR_OUT_OF_DATE_KHR); else if (!strcmp(name, "later-surface-lost")) acquire_failure(1, VK_ERROR_SURFACE_LOST_KHR); - else if (!strcmp(name, "shm-timeout")) upload_timeout(0); - else if (!strcmp(name, "pixel-timeout")) upload_timeout(1); - else if (!strcmp(name, "pass-terminal")) { setup(0); g_dev_state = -3; assert_stopped(); free(g_images); } + else if (!strcmp(name, "shm-wait-error")) upload_wait_error(0); + else if (!strcmp(name, "pixel-wait-error")) upload_wait_error(1); + else if (!strcmp(name, "lost-shm-upload")) { + setup(0); + uint8_t bytes[64], data[16]; + memset(bytes, 0xa5, sizeof(bytes)); + for (unsigned i = 0; i < sizeof(data); i++) data[i] = (uint8_t)(i + 1); + struct vkp_image img = {.map = bytes, .offset = 3, .row_pitch = 16, .w = 2, .h = 2, + .source_type = VKP_IMAGE_SOURCE_SHM}; + g_dev_state = -2; + vkp_image_upload_shm(&img, data, 8); + assert(img.recovery_pixels && !memcmp(img.recovery_pixels, data, sizeof(data))); + assert(bytes[3] == 0xa5 && bytes[19] == 0xa5); + free(img.recovery_pixels); + free(g_images); + } else if (!strcmp(name, "pass-terminal")) { setup(0); g_dev_state = -3; assert_stopped(); free(g_images); } + else if (!strcmp(name, "blit-delayed")) { + setup(0); + struct vkp_image src = {.image = (VkImage)(uintptr_t)7, .w = 1, .h = 1}; + struct vkp_image dst = {.image = (VkImage)(uintptr_t)8, .w = 1, .h = 1, .blit_dst = 1}; + fence_timeouts = 3; + assert(vkp_blit_image(&src, &dst, -1) == 0); + assert(g_dev_state == 1 && submits == 1 && waits == 4 && destroys == 0); + assert(vkp_blit_image(&src, &dst, -1) == 0); + assert(g_dev_state == 1 && submits == 2 && waits == 5 && destroys == 0); + free(g_images); + } else if (!strcmp(name, "normal") || !strcmp(name, "framegen")) { int extra = !strcmp(name, "framegen"); setup(extra); assert(vkp_render(64, 64, NULL, 0) == 0 && g_dev_state == 1); @@ -279,6 +327,18 @@ int main(int argc, char **argv) { setup(1); fail_acquire_at = 2; acquire_answer = VK_TIMEOUT; assert(vkp_render(64, 64, NULL, 0) == -1 && g_dev_state == 1); assert(acquires == 2 && submits == 2 && markers == 1 && waits == 1); free(g_images); + } else if (!strcmp(name, "acquire-device-lost-unconfirmed")) { + setup(1); + fail_acquire_at = 2; + acquire_answer = VK_ERROR_DEVICE_LOST; + idle_answer = VK_ERROR_OUT_OF_HOST_MEMORY; + VkImage *retained = g_images; + assert(vkp_render(64, 64, NULL, 0) == -1); + assert(g_dev_state == -3 && vkp_completion_unknown() && !vkp_device_lost()); + assert(idle_calls == 1 && lost_notifications == 0 && waits == 0); + assert(g_images == retained && g_nimg == 1 && g_swapchain && g_surface && destroys == 0); + assert_stopped(); + free(g_images); /* test-owned fake resources only */ } else if (!strcmp(name, "acquire-device-lost") || !strcmp(name, "present-device-lost")) { setup(1); if (!strcmp(name, "acquire-device-lost")) { fail_acquire_at = 2; acquire_answer = VK_ERROR_DEVICE_LOST; } @@ -287,6 +347,8 @@ int main(int argc, char **argv) { assert(!vkp_completion_unknown()); assert(g_dev_state == -2 && lost_notifications == 1 && markers == 0 && waits == 0); assert(!g_images && !g_swapchain && !g_surface && destroys == 2); + assert(vkp_ready() == -1); + assert(g_dev_state == -2 && g_recovery_attempted); assert_stopped(); } else assert(0 && "unknown scenario"); return 0; diff --git a/tools/ubuntu/README.md b/tools/ubuntu/README.md index eefff4c6c7..ba7256ccf7 100644 --- a/tools/ubuntu/README.md +++ b/tools/ubuntu/README.md @@ -11,6 +11,8 @@ Steam on the desktop). The app installs it into `files/linuxfs` and runs it unde UBWC 5/6 (backported from upstream Mesa) and the KGSL device numbers for WSI (from [Droid-Deck/Drivers](https://github.com/Droid-Deck/Drivers)). It also carries Icenowy Zheng's upstream Zink fix that keeps the Imagination depth/stencil swizzle off colour views (Mesa d55418dae7). + Zink also reclaims the memory a client freed once it has been idle for a second: otherwise only its + next allocation does, and Steam's UI behind a game held 250 MiB more of unswappable GPU memory. - The runtime's built-in Vulkan driver is DroidDeck's DD-Turnip Linux build (`DD_TURNIP_URL` and `DD_TURNIP_SHA256` in `base.env`): Ubuntu's Turnip is diverted to `libvulkan_freedreno.so.distrib` because it lacks the Adreno 8xx fixes. Zink, EGL and llvmpipe stay Ubuntu's. diff --git a/tools/ubuntu/overlay-desktop/usr/share/applications/droiddeck-return-gaming.desktop b/tools/ubuntu/overlay-desktop/usr/share/applications/droiddeck-return-gaming.desktop deleted file mode 100644 index 67f1d7f218..0000000000 --- a/tools/ubuntu/overlay-desktop/usr/share/applications/droiddeck-return-gaming.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=Return to Gaming Mode -Comment=Log out of the desktop and go back to Steam -Exec=dbus-send --session --type=method_call --dest=org.kde.Shutdown /Shutdown org.kde.Shutdown.logout -Icon=steamdeck-gaming-return -Terminal=false -Type=Application -StartupNotify=false -NoDisplay=true diff --git a/tools/ubuntu/packages-desktop.txt b/tools/ubuntu/packages-desktop.txt index df725eab90..d6ce8fe5d9 100644 --- a/tools/ubuntu/packages-desktop.txt +++ b/tools/ubuntu/packages-desktop.txt @@ -215,6 +215,7 @@ power-profiles-daemon powerdevil ppa-purge print-manager +pyqt6-dev-tools python3-dbus python3-launchpadlib python3-setuptools @@ -241,6 +242,7 @@ software-properties-qt squashfs-tools synaptic systemsettings +ubuntu-drivers-common udisks2 unrar-free upower diff --git a/tools/ubuntu/patches/mesa/0006-zink-reclaim-freed-memory-while-the-client-is-idle.patch b/tools/ubuntu/patches/mesa/0006-zink-reclaim-freed-memory-while-the-client-is-idle.patch new file mode 100644 index 0000000000..a2081913f2 --- /dev/null +++ b/tools/ubuntu/patches/mesa/0006-zink-reclaim-freed-memory-while-the-client-is-idle.patch @@ -0,0 +1,143 @@ +Subject: zink: reclaim freed slab entries and cached buffers while the client is idle + +zink only reclaims slab entries and expired cached buffers during its next +allocation, and pb_slabs_reclaim stops at the first entries still in use. A +client that frees a lot and then goes idle keeps all of it allocated: Steam's web helper held 500-700 MiB of KGSL memory behind a +fullscreen game after scrolling its library, and released it the moment the +overlay drew a frame. A thread now reclaims once a second after a second +without allocations. + +--- a/src/util/pb_slab.h ++++ b/src/util/pb_slab.h +@@ -145,6 +145,9 @@ + unsigned + pb_slabs_reclaim(struct pb_slabs *slabs); + ++unsigned ++pb_slabs_reclaim_all(struct pb_slabs *slabs); ++ + bool + pb_slabs_init(struct pb_slabs *slabs, + unsigned min_order, unsigned max_order, +--- a/src/util/pb_slab.c ++++ b/src/util/pb_slab.c +@@ -231,6 +231,19 @@ + return num_reclaims; + } + ++/* Like pb_slabs_reclaim, but skips entries that are still in use instead of ++ * stopping at the first ones, so entries freed behind them are reclaimed too. ++ */ ++unsigned ++pb_slabs_reclaim_all(struct pb_slabs *slabs) ++{ ++ unsigned num_reclaims; ++ simple_mtx_lock(&slabs->mutex); ++ num_reclaims = pb_slabs_reclaim_all_locked(slabs); ++ simple_mtx_unlock(&slabs->mutex); ++ return num_reclaims; ++} ++ + /* Initialize the slabs manager. + * + * The minimum and maximum size of slab entries are 2^min_order and +--- a/src/gallium/drivers/zink/zink_types.h ++++ b/src/gallium/drivers/zink/zink_types.h +@@ -1427,6 +1427,12 @@ + struct pb_slabs bo_slabs[NUM_SLAB_ALLOCATORS]; + unsigned min_alloc_size; + uint32_t next_bo_unique_id; ++ uint32_t alloc_serial; ++ thrd_t reclaim_thread; ++ mtx_t reclaim_lock; ++ cnd_t reclaim_cond; ++ bool reclaim_stop; ++ bool reclaim_running; + } pb; + uint8_t heap_map[ZINK_HEAP_MAX][VK_MAX_MEMORY_TYPES]; // mapping from zink heaps to memory type indices + uint8_t heap_count[ZINK_HEAP_MAX]; // number of memory types per zink heap +--- a/src/gallium/drivers/zink/zink_bo.c ++++ b/src/gallium/drivers/zink/zink_bo.c +@@ -34,6 +34,7 @@ + #include "zink_resource.h" + #include "zink_screen.h" + #include "util/u_hash_table.h" ++#include "util/u_thread.h" + + #ifdef HAVE_LIBDRM + #define ZINK_USE_DMABUF +@@ -577,6 +578,7 @@ + zink_bo_create(struct zink_screen *screen, uint64_t size, unsigned alignment, enum zink_heap heap, enum zink_alloc_flag flags, unsigned mem_type_idx, const void *pNext) + { + struct zink_bo *bo; ++ p_atomic_inc(&screen->pb.alloc_serial); + /* pull in sparse flag */ + flags |= zink_alloc_flags_from_heap(heap); + +@@ -1390,6 +1392,40 @@ + return bo_slab_alloc(priv, mem_type_idx, entry_size, group_index, false); + } + ++/* Slab entries and cached buffers a client frees are otherwise only reclaimed by its next ++ * allocation, so a client that goes idle (a browser UI behind a fullscreen game) keeps all of ++ * that memory allocated. On UMA devices it is system RAM that cannot be swapped. */ ++static int ++bo_reclaim_thread(void *data) ++{ ++ struct zink_screen *screen = data; ++ uint32_t seen = p_atomic_read(&screen->pb.alloc_serial); ++ ++ u_thread_setname("zink_reclaim"); ++ mtx_lock(&screen->pb.reclaim_lock); ++ while (!screen->pb.reclaim_stop) { ++ struct timespec deadline; ++ timespec_get(&deadline, TIME_UTC); ++ deadline.tv_sec += 1; ++ cnd_timedwait(&screen->pb.reclaim_cond, &screen->pb.reclaim_lock, &deadline); ++ if (screen->pb.reclaim_stop) ++ break; ++ mtx_unlock(&screen->pb.reclaim_lock); ++ ++ uint32_t serial = p_atomic_read(&screen->pb.alloc_serial); ++ if (serial == seen) { ++ for (unsigned i = 0; i < NUM_SLAB_ALLOCATORS; i++) ++ pb_slabs_reclaim_all(&screen->pb.bo_slabs[i]); ++ pb_cache_release_all_buffers(&screen->pb.bo_cache); ++ } ++ seen = serial; ++ ++ mtx_lock(&screen->pb.reclaim_lock); ++ } ++ mtx_unlock(&screen->pb.reclaim_lock); ++ return 0; ++} ++ + bool + zink_bo_init(struct zink_screen *screen) + { +@@ -1425,12 +1461,25 @@ + min_slab_order = max_order + 1; + } + screen->pb.min_alloc_size = 1 << screen->pb.bo_slabs[0].min_order; ++ ++ mtx_init(&screen->pb.reclaim_lock, mtx_plain); ++ cnd_init(&screen->pb.reclaim_cond); ++ screen->pb.reclaim_running = ++ u_thread_create(&screen->pb.reclaim_thread, bo_reclaim_thread, screen) == thrd_success; + return true; + } + + void + zink_bo_deinit(struct zink_screen *screen) + { ++ if (screen->pb.reclaim_running) { ++ mtx_lock(&screen->pb.reclaim_lock); ++ screen->pb.reclaim_stop = true; ++ cnd_signal(&screen->pb.reclaim_cond); ++ mtx_unlock(&screen->pb.reclaim_lock); ++ thrd_join(screen->pb.reclaim_thread, NULL); ++ screen->pb.reclaim_running = false; ++ } + for (unsigned i = 0; i < NUM_SLAB_ALLOCATORS; i++) { + if (screen->pb.bo_slabs[i].groups) + pb_slabs_deinit(&screen->pb.bo_slabs[i]); diff --git a/tools/venus/layer/layer.c b/tools/venus/layer/layer.c index 9aeb0bcf0e..0948fee234 100644 --- a/tools/venus/layer/layer.c +++ b/tools/venus/layer/layer.c @@ -344,12 +344,31 @@ static void report_limits(VkPhysicalDeviceLimits *limits, uint32_t gaps) } } +/* Mali's driver crashes compiling Zink's geometry shaders (SIGSEGV at 0x40 in + * cmpbe_v2_compile_multiple_shaders) and takes the render server and the application with it; a plain + * one draws nothing. Zink draws GL_QUADS through one; without the feature Mesa splits quads into + * triangles itself. DXVK needs the feature for D3D10 and 11, so only Zink loses it. + * DROIDDECK_MALI_COMPAT_NO_GS=0 keeps it for Zink, =1 hides it from every application. */ +static bool hide_geometry_shader(struct instance *inst, VkPhysicalDevice physical_device) +{ + const char *setting = getenv("DROIDDECK_MALI_COMPAT_NO_GS"); + if (setting && *setting) + return strcmp(setting, "1") == 0; + if (!inst->zink) + return false; + VkPhysicalDeviceProperties properties; + inst->GetPhysicalDeviceProperties(physical_device, &properties); + return properties.vendorID == 0x13b5; /* ARM */ +} + static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures(VkPhysicalDevice physical_device, VkPhysicalDeviceFeatures *features) { struct instance *inst = instance_from_handle(physical_device); inst->GetPhysicalDeviceFeatures(physical_device, features); report_features(features, physical_device_gaps(inst, physical_device)); + if (hide_geometry_shader(inst, physical_device)) + features->geometryShader = VK_FALSE; } static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures2(VkPhysicalDevice physical_device, @@ -363,6 +382,8 @@ static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures2(VkPhysicalDevice ph inst->GetPhysicalDeviceFeatures2(physical_device, features); relink(dropped, dropped_count); report_features(&features->features, gaps); + if (hide_geometry_shader(inst, physical_device)) + features->features.geometryShader = VK_FALSE; if (tracing()) { char chain[512] = ""; size_t used = 0; @@ -463,6 +484,8 @@ static VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo inst->key = dispatch_key(*instance); inst->handle = *instance; inst->active = wanted(); + const char *engine = info->pApplicationInfo ? info->pApplicationInfo->pEngineName : NULL; + inst->zink = engine && strcmp(engine, "mesa zink") == 0; inst->gipa = gipa; pthread_mutex_init(&inst->lock, NULL); #define LOAD(name) inst->name = (PFN_vk##name)gipa(*instance, "vk" #name); @@ -624,6 +647,9 @@ static VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physical_dev if (properties.limits.maxFragmentInputComponents < components) components = properties.limits.maxFragmentInputComponents; dev->max_varying_locations = components / 4; + if (inst->active && hide_geometry_shader(inst, physical_device)) + layer_log("geometryShader is hidden from %s: the driver crashes compiling geometry shaders", + inst->zink ? "Zink" : "every application"); pthread_mutex_lock(&global_lock); dev->next = devices; diff --git a/tools/venus/layer/mali_compat.h b/tools/venus/layer/mali_compat.h index 073907f41a..4ba59428e1 100644 --- a/tools/venus/layer/mali_compat.h +++ b/tools/venus/layer/mali_compat.h @@ -63,6 +63,7 @@ struct instance { void *key; VkInstance handle; bool active; + bool zink; /* the engine is Mesa's Zink */ PFN_vkGetInstanceProcAddr gipa; PFN_vkDestroyInstance DestroyInstance; PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties; diff --git a/tools/vr/src/driver_droiddeck.cpp b/tools/vr/src/driver_droiddeck.cpp index 05f3aec58b..c0b2f92ab1 100644 --- a/tools/vr/src/driver_droiddeck.cpp +++ b/tools/vr/src/driver_droiddeck.cpp @@ -530,6 +530,9 @@ bool JoyConLive(const droiddeck_joycon_hand &hand, int64_t nowNs) { nowNs - hand.time_ns < kJoyConStaleNs && hand.time_ns - nowNs < kJoyConStaleNs; } +// Older SteamVR games pick Touch or Vive controls from the tracking system name and treat anything but "oculus" as Vive. +static const char *TrackingSystemName(bool quest) { return quest ? "oculus" : "droiddeck"; } + class HandController : public ITrackedDeviceServerDriver { public: explicit HandController(bool right) : right_(right), arm_(right), camera_(right), luma_(right) {} @@ -1041,7 +1044,8 @@ public: const char *model = touch_ ? "DroidDeck Quest Touch" : index_ ? "DroidDeck Index Hand" : "DroidDeck Pad Hand"; VRProperties()->SetStringProperty(c, Prop_ModelNumber_String, model); VRProperties()->SetStringProperty(c, Prop_ManufacturerName_String, touch_ ? "Meta" : index_ ? "Valve" : "DroidDeck"); - VRProperties()->SetStringProperty(c, Prop_TrackingSystemName_String, "droiddeck"); + VRProperties()->SetStringProperty(c, Prop_TrackingSystemName_String, TrackingSystemName(xrMode_)); + VRProperties()->SetStringProperty(c, Prop_ActualTrackingSystemName_String, "droiddeck"); VRProperties()->SetStringProperty(c, Prop_RenderModelName_String, touch_ ? (right_ ? "oculus_quest_plus_controller_right" : "oculus_quest_plus_controller_left") : (right_ ? "{indexcontroller}valve_controller_knu_1_0_right" : "{indexcontroller}valve_controller_knu_1_0_left")); @@ -1378,7 +1382,8 @@ public: sentAspect_ = eyeAspect_; VRProperties()->SetStringProperty(c, Prop_ModelNumber_String, xrMode_ ? "DroidDeck Quest OpenXR" : "DroidDeck Cardboard"); VRProperties()->SetStringProperty(c, Prop_ManufacturerName_String, "DroidDeck"); - VRProperties()->SetStringProperty(c, Prop_TrackingSystemName_String, "droiddeck"); + VRProperties()->SetStringProperty(c, Prop_TrackingSystemName_String, TrackingSystemName(xrMode_)); + VRProperties()->SetStringProperty(c, Prop_ActualTrackingSystemName_String, "droiddeck"); VRProperties()->SetFloatProperty(c, Prop_UserIpdMeters_Float, 0.064f); if (xrMode_) { VRServerDriverHost()->SetDisplayEyeToHead(id_, XrEyeToHead(xr.head, xr.eyes[0].pose), XrEyeToHead(xr.head, xr.eyes[1].pose)); @@ -1447,6 +1452,22 @@ public: DriverPose_t GetPose() override { return GetPose(nullptr); } + static DriverPose_t XrHeadPose(const DroidDeckXrTracking &xr, bool fresh) { + DriverPose_t p = {}; + p.qWorldFromDriverRotation.w = 1; + p.qDriverFromHeadRotation.w = 1; + p.qRotation.w = 1; + p.deviceIsConnected = true; + p.poseIsValid = fresh && XrTrackingFile::Tracked(xr.head); + p.result = p.poseIsValid ? TrackingResult_Running_OK : TrackingResult_Running_OutOfRange; + if (p.poseIsValid) { + p.qRotation = {xr.head.orientation[3], xr.head.orientation[0], xr.head.orientation[1], xr.head.orientation[2]}; + for (int axis = 0; axis < 3; axis++) p.vecPosition[axis] = xr.head.position[axis]; + p.poseTimeOffset = XrTrackingFile::PoseTimeOffset(xr.predicted_ns, XrTrackingFile::Now()); + } + return p; + } + DriverPose_t GetPose(droiddeck_spatialpose *snapshot) { std::lock_guard lock(spatialMutex_); DriverPose_t p = {}; @@ -1455,17 +1476,7 @@ public: p.qRotation.w = 1; DroidDeckXrTracking xr; bool freshXr = xr_.Read(&xr) && XrTrackingFile::Fresh(xr); - if (freshXr || xrMode_) { - p.deviceIsConnected = true; - p.poseIsValid = freshXr && XrTrackingFile::Tracked(xr.head); - p.result = p.poseIsValid ? TrackingResult_Running_OK : TrackingResult_Running_OutOfRange; - if (p.poseIsValid) { - p.qRotation = {xr.head.orientation[3], xr.head.orientation[0], xr.head.orientation[1], xr.head.orientation[2]}; - for (int axis = 0; axis < 3; axis++) p.vecPosition[axis] = xr.head.position[axis]; - p.poseTimeOffset = XrTrackingFile::PoseTimeOffset(xr.predicted_ns, XrTrackingFile::Now()); - } - return p; - } + if (freshXr || xrMode_) return XrHeadPose(xr, freshXr); p.vecPosition[1] = 1.6; droiddeck_headpose hp; bool ok = pose_.Read(&hp); @@ -1580,19 +1591,44 @@ private: droiddeck_joycon joyCons = {}; bool haveJoyCons = false; auto lastSent = std::chrono::steady_clock::now(); + uint32_t lastLatch = 0; + bool headInvalid = false; + auto lastHands = lastSent - std::chrono::seconds(1); + auto publishHead = [&](const DriverPose_t &head) { + headInvalid = !head.poseIsValid; + VRServerDriverHost()->TrackedDevicePoseUpdated(id_, head, sizeof(head)); + }; while (running_) { DroidDeckXrTracking xr; if (xrMode_) { - bool fresh = xr_.Read(&xr) && XrTrackingFile::Fresh(xr); - if (fresh) PublishChaperone(xr); - DriverPose_t head = GetPose(); - VRServerDriverHost()->TrackedDevicePoseUpdated(id_, head, sizeof(head)); - for (int hand = 0; hand < 2; hand++) if (CardboardController *pad = ActiveHand(hand)) { - DroidDeckXrHand state = fresh ? xr.hands[hand] : DroidDeckXrHand{}; - pad->UpdateXr(state, fresh ? xr.predicted_ns : 0); + DroidDeckXrTracking latched; + const bool haveLatch = latch_.Read(&latched) && XrTrackingFile::Fresh(latched); + const auto now = std::chrono::steady_clock::now(); + const bool latchAdvanced = haveLatch && latched.seq != lastLatch; + if (haveLatch) { + if (latchAdvanced) { + lastLatch = latched.seq; + publishHead(XrHeadPose(latched, true)); + } + } else if (now - lastHands >= std::chrono::milliseconds(2)) { + publishHead(GetPose()); } - VRDriverInput()->UpdateBooleanComponent(proximity_, fresh, 0); - std::this_thread::sleep_for(std::chrono::milliseconds(2)); + if (now - lastHands >= std::chrono::milliseconds(2)) { + lastHands = now; + bool fresh = xr_.Read(&xr) && XrTrackingFile::Fresh(xr); + if (fresh) PublishChaperone(xr); + if (haveLatch && !latchAdvanced) { + if (!(fresh && XrTrackingFile::Tracked(xr.head))) publishHead(XrHeadPose(xr, fresh)); + else if (!XrTrackingFile::Tracked(latched.head)) publishHead(XrHeadPose(xr, fresh)); + else if (headInvalid) publishHead(XrHeadPose(latched, true)); + } + for (int hand = 0; hand < 2; hand++) if (CardboardController *pad = ActiveHand(hand)) { + DroidDeckXrHand state = fresh ? xr.hands[hand] : DroidDeckXrHand{}; + pad->UpdateXr(state, fresh ? xr.predicted_ns : 0); + } + VRDriverInput()->UpdateBooleanComponent(proximity_, fresh, 0); + } + std::this_thread::sleep_for(std::chrono::microseconds(500)); continue; } droiddeck_headpose hp; @@ -1735,7 +1771,7 @@ private: if (!poses[i].bDeviceIsConnected) continue; PropertyContainerHandle_t c = VRProperties()->TrackedDeviceToPropertyContainer(i); if (VRProperties()->GetInt32Property(c, Prop_DeviceClass_Int32) != TrackedDeviceClass_Controller) continue; - if (VRProperties()->GetStringProperty(c, Prop_TrackingSystemName_String) != "droiddeck") return true; + if (VRProperties()->GetStringProperty(c, Prop_SerialNumber_String).rfind("droiddeck-", 0) != 0) return true; } return false; } @@ -1770,6 +1806,7 @@ private: DriverPose_t lastSpatial_{}; droiddeck_spatialpose lastSpatialSnapshot_{}; XrTrackingFile xr_; + XrTrackingFile latch_{"/run/droiddeck/" DROIDDECK_XR_LATCH_FILE}; XrChaperoneOrigin chaperone_; bool xrMode_ = false; PadRing pad_; diff --git a/tools/vr/src/scheduling.c b/tools/vr/src/scheduling.c index 381397cea7..fd87c20472 100644 --- a/tools/vr/src/scheduling.c +++ b/tools/vr/src/scheduling.c @@ -1,8 +1,11 @@ #define _GNU_SOURCE +#include #include #include #include +#include #include +#include #include #include #include @@ -19,6 +22,38 @@ static int cannot_schedule_realtime(void) { return !(caps[CAP_SYS_NICE / 32].effective & (UINT32_C(1) << (CAP_SYS_NICE % 32))); } +/* Without real-time scheduling, vrcompositor's frame threads ran at the same nice level as Steam's web helpers on + * the guest's three cores and missed refreshes. Its threads at normal priority take the highest nice level instead; + * some are started where they do not inherit it, so they are raised again once a second. */ +static int compositor_without_realtime(void) { + return !strcmp(program_invocation_short_name, "vrcompositor") && cannot_schedule_realtime(); +} + +static void raise_threads(void) { + DIR *tasks = opendir("/proc/self/task"); + if (!tasks) return; + for (struct dirent *task; (task = readdir(tasks));) { + const int tid = atoi(task->d_name); + if (tid <= 0) continue; + errno = 0; + const int nice = getpriority(PRIO_PROCESS, (id_t)tid); + if (!errno && nice <= 0 && nice > -20) setpriority(PRIO_PROCESS, (id_t)tid, -20); + } + closedir(tasks); +} + +static void *raise_loop(void *unused) { + for (;;) { raise_threads(); sleep(1); } + return unused; +} + +__attribute__((constructor)) static void raise_compositor(void) { + if (!compositor_without_realtime()) return; + setpriority(PRIO_PROCESS, 0, -20); + pthread_t thread; + if (!pthread_create(&thread, NULL, raise_loop, NULL)) pthread_detach(thread); +} + int setrlimit(__rlimit_resource_t resource, const struct rlimit *limit) { int (*next)(__rlimit_resource_t, const struct rlimit *) = dlsym(RTLD_NEXT, "setrlimit"); if (!next) { errno = ENOSYS; return -1; } diff --git a/tools/vr/src/vk_layer_droiddeck_vr.c b/tools/vr/src/vk_layer_droiddeck_vr.c index be74139e5f..8eddc8a840 100644 --- a/tools/vr/src/vk_layer_droiddeck_vr.c +++ b/tools/vr/src/vk_layer_droiddeck_vr.c @@ -294,9 +294,12 @@ static void forget_device_semaphores(VkDevice dev); static void track_forget_device(VkDevice dev); static void producer_destroy_device(struct dev *device, const VkAllocationCallbacks *allocator); +static void warp_forget(VkDevice device, VkRenderPass pass); + static void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks *alloc) { struct dev *d = dev_for(device); if (!d) return; + warp_forget(device, VK_NULL_HANDLE); #ifdef DROIDDECK_WSI_CAPTURE droiddeck_wsi_destroy(device); #endif @@ -585,9 +588,28 @@ static void VKAPI_CALL DestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapc NEXT(device, DestroySwapchainKHR)(device, swapchain, allocator); } +static VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, + VkFence fence, uint32_t *index) { + VkResult r = NEXT(device, AcquireNextImageKHR)(device, swapchain, timeout, semaphore, fence, index); +#ifdef DROIDDECK_WSI_CAPTURE + if (r == VK_SUCCESS || r == VK_SUBOPTIMAL_KHR) droiddeck_wsi_acquired(device, swapchain, *index); +#endif + return r; +} + +static VkResult VKAPI_CALL AcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *info, uint32_t *index) { + VkResult r = NEXT(device, AcquireNextImage2KHR)(device, info, index); +#ifdef DROIDDECK_WSI_CAPTURE + if (r == VK_SUCCESS || r == VK_SUBOPTIMAL_KHR) droiddeck_wsi_acquired(device, info->swapchain, *index); +#endif + return r; +} + static PFN_vkVoidFunction display_device_hook(const char *name) { HOOK_AS("vkCreateSwapchainKHR", CreateSwapchainKHR) HOOK_AS("vkDestroySwapchainKHR", DestroySwapchainKHR) + HOOK_AS("vkAcquireNextImageKHR", AcquireNextImageKHR) + HOOK_AS("vkAcquireNextImage2KHR", AcquireNextImage2KHR) HOOK_AS("vkDisplayPowerControlEXT", DisplayPowerControlEXT) HOOK_AS("vkRegisterDeviceEventEXT", RegisterDeviceEventEXT) HOOK_AS("vkRegisterDisplayEventEXT", RegisterDisplayEventEXT) @@ -1383,6 +1405,100 @@ static VkResult VKAPI_CALL CreateImage(VkDevice d, const VkImageCreateInfo *ci, return r; } +/* vrcompositor renders both eyes through one shared texture and warps each into its half of the output in the + * same command buffer. On Turnip its barrier before the right eye's warp left the texture cache holding the + * left eye, so blocks of the left eye showed in the right one. A full barrier before each warp pass fixes it. */ +#define WARP_PASSES 32 +static struct { VkDevice device; VkRenderPass pass; } g_warp_passes[WARP_PASSES]; +static pthread_mutex_t g_warp_lock = PTHREAD_MUTEX_INITIALIZER; + +static int warp_wanted(void) { + static int wanted = -1; + if (wanted < 0) { + const char *mode = getenv("DROIDDECK_VR_PRESENT"); + wanted = mode && !strcmp(mode, "questwsi") && !strcmp(program_invocation_short_name, "vrcompositor"); + } + return wanted; +} + +static void warp_note(VkDevice device, VkRenderPass pass, uint32_t attachments, VkSampleCountFlagBits samples) { + if (attachments != 1 || samples != VK_SAMPLE_COUNT_1_BIT) return; + pthread_mutex_lock(&g_warp_lock); + for (int i = 0; i < WARP_PASSES; i++) + if (!g_warp_passes[i].pass) { g_warp_passes[i].device = device; g_warp_passes[i].pass = pass; break; } + pthread_mutex_unlock(&g_warp_lock); +} + +static void warp_forget(VkDevice device, VkRenderPass pass) { + pthread_mutex_lock(&g_warp_lock); + for (int i = 0; i < WARP_PASSES; i++) + if (g_warp_passes[i].device == device && (!pass || g_warp_passes[i].pass == pass)) + g_warp_passes[i].device = VK_NULL_HANDLE, g_warp_passes[i].pass = VK_NULL_HANDLE; + pthread_mutex_unlock(&g_warp_lock); +} + +static int warp_pass(VkRenderPass pass) { + int found = 0; + pthread_mutex_lock(&g_warp_lock); + for (int i = 0; i < WARP_PASSES && !found; i++) found = pass && g_warp_passes[i].pass == pass; + pthread_mutex_unlock(&g_warp_lock); + return found; +} + +static VkResult VKAPI_CALL CreateRenderPass(VkDevice d, const VkRenderPassCreateInfo *ci, const VkAllocationCallbacks *a, VkRenderPass *out) { + VkResult r = NEXT(d, CreateRenderPass)(d, ci, a, out); + if (r == VK_SUCCESS) warp_note(d, *out, ci->attachmentCount, ci->attachmentCount ? ci->pAttachments[0].samples : 0); + return r; +} + +static void VKAPI_CALL DestroyRenderPass(VkDevice d, VkRenderPass pass, const VkAllocationCallbacks *a) { + if (pass) warp_forget(d, pass); + NEXT(d, DestroyRenderPass)(d, pass, a); +} + +static VkResult VKAPI_CALL CreateRenderPass2(VkDevice d, const VkRenderPassCreateInfo2 *ci, const VkAllocationCallbacks *a, VkRenderPass *out) { + PFN_vkCreateRenderPass2 next = (PFN_vkCreateRenderPass2)dev_for(d)->gdpa(d, "vkCreateRenderPass2"); + if (!next) next = (PFN_vkCreateRenderPass2)dev_for(d)->gdpa(d, "vkCreateRenderPass2KHR"); + VkResult r = next(d, ci, a, out); + if (r == VK_SUCCESS) warp_note(d, *out, ci->attachmentCount, ci->attachmentCount ? ci->pAttachments[0].samples : 0); + return r; +} + +static void warp_barrier(VkCommandBuffer cb, VkRenderPass pass) { + if (!warp_pass(pass)) return; + struct dev *d = dev_for(cb); + VkMemoryBarrier all = {VK_STRUCTURE_TYPE_MEMORY_BARRIER, NULL, VK_ACCESS_MEMORY_WRITE_BIT, + VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT}; + ((PFN_vkCmdPipelineBarrier)d->gdpa(d->handle, "vkCmdPipelineBarrier"))(cb, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 1, &all, 0, NULL, 0, NULL); +} + +static void VKAPI_CALL CmdBeginRenderPass(VkCommandBuffer cb, const VkRenderPassBeginInfo *bi, VkSubpassContents contents) { + warp_barrier(cb, bi->renderPass); + struct dev *d = dev_for(cb); + ((PFN_vkCmdBeginRenderPass)d->gdpa(d->handle, "vkCmdBeginRenderPass"))(cb, bi, contents); +} + +static void VKAPI_CALL CmdBeginRenderPass2(VkCommandBuffer cb, const VkRenderPassBeginInfo *bi, const VkSubpassBeginInfo *si) { + warp_barrier(cb, bi->renderPass); + struct dev *d = dev_for(cb); + PFN_vkCmdBeginRenderPass2 next = (PFN_vkCmdBeginRenderPass2)d->gdpa(d->handle, "vkCmdBeginRenderPass2"); + if (!next) next = (PFN_vkCmdBeginRenderPass2)d->gdpa(d->handle, "vkCmdBeginRenderPass2KHR"); + next(cb, bi, si); +} + +static PFN_vkVoidFunction warp_hook(const char *name) { + if (!warp_wanted()) return NULL; + HOOK_AS("vkCreateRenderPass", CreateRenderPass) + HOOK_AS("vkCreateRenderPass2", CreateRenderPass2) + HOOK_AS("vkCreateRenderPass2KHR", CreateRenderPass2) + HOOK_AS("vkDestroyRenderPass", DestroyRenderPass) + HOOK_AS("vkCmdBeginRenderPass", CmdBeginRenderPass) + HOOK_AS("vkCmdBeginRenderPass2", CmdBeginRenderPass2) + HOOK_AS("vkCmdBeginRenderPass2KHR", CmdBeginRenderPass2) + return NULL; +} + static PFN_vkVoidFunction semaphore_hook(const char *name) { HOOK_AS("vkCreateImage", CreateImage) HOOK_AS("vkCreateSemaphore", CreateSemaphore) @@ -1445,7 +1561,8 @@ EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL DroidDeckVr_GetInstanceProcAddr( if (f) return f; } if (in) { - PFN_vkVoidFunction f = semaphore_hook(name); + PFN_vkVoidFunction f = warp_hook(name); + if (!f) f = semaphore_hook(name); if (f && in->gipa(instance, name)) return f; } return in ? in->gipa(instance, name) : NULL; @@ -1461,7 +1578,8 @@ EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL DroidDeckVr_GetDeviceProcAddr(Vk if (f) return f; } if (d) { - PFN_vkVoidFunction mine = semaphore_hook(name); + PFN_vkVoidFunction mine = warp_hook(name); + if (!mine) mine = semaphore_hook(name); if (mine && d->gdpa(device, name)) return mine; } return d ? d->gdpa(device, name) : NULL; diff --git a/tools/vr/src/wsi_capture.cpp b/tools/vr/src/wsi_capture.cpp index ee7a7266c9..2c9c2f2181 100644 --- a/tools/vr/src/wsi_capture.cpp +++ b/tools/vr/src/wsi_capture.cpp @@ -41,6 +41,7 @@ struct CaptureSlot { bool rgbaInitialized{}; void *mapping{}; VkFence fence{}; + uint64_t uses{}; bool busy{}, queued{}; DroidDeckXrFrameHeader header{}; ~CaptureSlot() { Clear(); } @@ -134,9 +135,13 @@ struct Swapchain { VkFormat format{}; std::vector images; std::vector ready; + std::vector> copying; std::array slots; uint64_t frame{}; XrTrackingFile tracking; + XrLatchWriter latch; + DroidDeckXrTracking previous{}; + bool latched{}; XrFrameSender sender; XrGpuSender gpuSender; bool gpu{}; @@ -158,17 +163,47 @@ struct Swapchain { std::fprintf(stderr, "[droiddeck-vr-layer] WSI worker failed; restart SteamVR\n"); } } + // The headset takes one frame per display refresh, so waiting for each acknowledgement before sending the + // next left SteamVR's frames missing that refresh: up to two frames travel at once, each slot freed by its ack. + static constexpr size_t kInFlight = 2; + std::vector> inFlight; + int64_t oldestSent{}; + bool CollectAcks(int timeout) { + if (!gpu || inFlight.empty()) return true; + bool ok = gpuSender.Acks(timeout, [this](uint64_t ack) { + auto it = std::find_if(inFlight.begin(), inFlight.end(), [ack](const auto &item) { return item.first == ack; }); + if (it == inFlight.end()) return false; + { std::lock_guard lock(sendMutex); it->second->busy = false; } + inFlight.erase(it); + oldestSent = XrTrackingFile::Now(); + return true; + }); + return ok && (inFlight.empty() || XrTrackingFile::Now() - oldestSent < 5000000000LL); + } void Loop() { for (;;) { + if (!CollectAcks(0)) { + std::lock_guard lock(sendMutex); + std::fprintf(stderr, "[droiddeck-vr-layer] WSI headset stopped acknowledging frames; restart SteamVR\n"); + failed = true; return; + } CaptureSlot *slot; { std::unique_lock lock(sendMutex); - sendReady.wait(lock, [this] { - return stopping || std::any_of(slots.begin(), slots.end(), [](const auto &item) { return item.queued; }); - }); + auto ready = [this] { + return stopping || (inFlight.size() < kInFlight + && std::any_of(slots.begin(), slots.end(), [](const auto &item) { return item.queued; })); + }; + if (inFlight.empty()) sendReady.wait(lock, ready); + else if (!ready()) { + lock.unlock(); + CollectAcks(1); + continue; + } + if (stopping) return; slot = nullptr; for (auto &item : slots) if (item.queued && (!slot || item.header.frame_id < slot->header.frame_id)) slot = &item; - if (!slot) return; + if (!slot) continue; slot->queued = false; } auto &d = *device; @@ -182,10 +217,16 @@ struct Swapchain { VkMappedMemoryRange range{VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE}; range.memory = memory; range.size = VK_WHOLE_SIZE; if (result == VK_SUCCESS && !gpu) result = d.InvalidateMappedMemoryRanges(d.handle, 1, &range); int64_t invalidated = XrTrackingFile::Now(); + bool posted = false; if (result == VK_SUCCESS && XrTrackingFile::Now() - header.captured_ns < 200000000LL) { if (gpu) { uint32_t flags = (format == VK_FORMAT_B8G8R8A8_UNORM || format == VK_FORMAT_B8G8R8A8_SRGB) ? XR_GPU_BGRA : 0; - if (!gpuSender.Send(header, static_cast(slot - slots.data()), flags)) result = VK_ERROR_DEVICE_LOST; + if (!gpuSender.Post(header, static_cast(slot - slots.data()), flags)) result = VK_ERROR_DEVICE_LOST; + else { + if (inFlight.empty()) oldestSent = XrTrackingFile::Now(); + inFlight.emplace_back(header.frame_id, slot); + posted = true; + } } else sender.SendShared("/run/droiddeck/" DROIDDECK_XR_FRAME_SOCKET, header, sharedFd); } if (header.frame_id % 120 == 0) std::fprintf(stderr, "[droiddeck-vr-layer] WSI ms wait=%.2f invalidate=%.2f shared=%.2f\n", @@ -195,7 +236,7 @@ struct Swapchain { std::fprintf(stderr, "[droiddeck-vr-layer] WSI buffer quarantined: result=%d leaseLost=%d; restart SteamVR\n", result, sender.SharedLeaseLost()); failed = true; return; } - slot->busy = false; + if (!posted) slot->busy = false; } } bool Initialize(VkSwapchainKHR chain, VkQueue queue) { @@ -211,6 +252,7 @@ struct Swapchain { images.resize(count); if (d.GetSwapchainImagesKHR(d.handle, chain, &count, images.data())) return false; ready.resize(count); + copying.assign(count, {nullptr, 0}); VkSemaphoreCreateInfo semaphoreInfo{VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO}; for (auto &semaphore : ready) if (d.CreateSemaphore(d.handle, &semaphoreInfo, nullptr, &semaphore)) return false; XrGpuPoolInfo info; @@ -236,8 +278,11 @@ struct Swapchain { return result; } bool Header(DroidDeckXrFrameHeader &header) { - DroidDeckXrTracking packet{}; - if (!tracking.Read(&packet) || !XrTrackingFile::Fresh(packet)) return false; + DroidDeckXrTracking latest{}; + if (!tracking.Read(&latest) || !XrTrackingFile::Fresh(latest)) return false; + DroidDeckXrTracking packet = latched && XrTrackingFile::Fresh(previous) ? previous : latest; + previous = latest; latched = true; + latch.Write(latest); header = {}; header.magic = DROIDDECK_XR_FRAME_MAGIC; header.version = DROIDDECK_XR_FRAME_VERSION; header.width = extent.width; header.height = extent.height; @@ -260,6 +305,15 @@ struct Swapchain { } return xr_frame_valid(header); } + // The headless swapchain hands an image back as soon as it is presented, and KGSL has no implicit sync, so + // the compositor drew its next frame into an image this copy still read: blocky panels. The copy is waited + // for when the image is acquired again, by which time it has nearly always finished, rather than stalling + // the compositor in every present. + void Acquired(uint32_t index) { + if (index >= copying.size() || !copying[index].first) return; + CaptureSlot &slot = *copying[index].first; + if (slot.uses == copying[index].second) device->WaitForFences(device->handle, 1, &slot.fence, VK_TRUE, UINT64_MAX); + } VkResult Capture(VkQueue queue, uint32_t index, const VkPresentInfoKHR &present, VkSemaphore *completion) { auto &d = *device; if (index >= images.size()) return VK_ERROR_OUT_OF_DATE_KHR; @@ -329,6 +383,8 @@ struct Swapchain { submit.pWaitDstStageMask = stages.data(); submit.commandBufferCount = 1; submit.pCommandBuffers = &command; submit.signalSemaphoreCount = 1; submit.pSignalSemaphores = &ready[index]; if ((result = d.QueueSubmit(queue, 1, &submit, fence))) return Fail(result, slot); + if (copying.size() < images.size()) copying.resize(images.size(), {nullptr, 0}); + copying[index] = {&slot, ++slot.uses}; rgbaInitialized = true; { std::lock_guard lock(sendMutex); slot.header = header; slot.queued = true; sendReady.notify_all(); } *completion = ready[index]; @@ -379,6 +435,11 @@ extern "C" void droiddeck_wsi_swapchain(VkDevice device, VkSwapchainKHR chain, c chainState->extent = create->imageExtent; chainState->format = create->imageFormat; swapchains[chain] = std::move(chainState); } +extern "C" void droiddeck_wsi_acquired(VkDevice device, VkSwapchainKHR chain, uint32_t index) { + (void)device; std::lock_guard lock(mutex); + auto it = swapchains.find(chain); + if (it != swapchains.end() && it->second->initialized) it->second->Acquired(index); +} extern "C" void droiddeck_wsi_forget(VkDevice device, VkSwapchainKHR chain) { (void)device; std::lock_guard lock(mutex); swapchains.erase(chain); } diff --git a/tools/vr/src/wsi_capture.h b/tools/vr/src/wsi_capture.h index d56aab4eac..887b87a395 100644 --- a/tools/vr/src/wsi_capture.h +++ b/tools/vr/src/wsi_capture.h @@ -10,6 +10,7 @@ void droiddeck_wsi_device(VkDevice device, VkPhysicalDevice physical, VkInstance void droiddeck_wsi_destroy(VkDevice device); void droiddeck_wsi_swapchain(VkDevice device, VkSwapchainKHR swapchain, const VkSwapchainCreateInfoKHR *create); void droiddeck_wsi_forget(VkDevice device, VkSwapchainKHR swapchain); +void droiddeck_wsi_acquired(VkDevice device, VkSwapchainKHR swapchain, uint32_t index); VkResult droiddeck_wsi_present(VkDevice device, VkQueue queue, const VkPresentInfoKHR *present, PFN_vkQueuePresentKHR next); #ifdef __cplusplus diff --git a/tools/vr/src/xr_gpu_channel.h b/tools/vr/src/xr_gpu_channel.h index 52fb5d9d39..c0b9797ff5 100644 --- a/tools/vr/src/xr_gpu_channel.h +++ b/tools/vr/src/xr_gpu_channel.h @@ -111,6 +111,21 @@ public: || !xr_gpu_receive(socket_, &ack, sizeof(ack)) || ack != header.frame_id) { Close(); return false; } return true; } + bool Post(const DroidDeckXrFrameHeader &header, uint32_t slot, uint32_t flags = 0) { + if (socket_ < 0 || slot >= XR_GPU_SLOTS || (flags & ~XR_GPU_BGRA) || !xr_frame_valid(header)) return false; + XrGpuFrame frame; frame.header = header; frame.slot = slot; frame.flags = flags; + if (!xr_gpu_send(socket_, &frame, sizeof(frame))) { Close(); return false; } + return true; + } + template bool Acks(int timeout, Visit visit) { + if (socket_ < 0) return false; + while (xr_gpu_wait(socket_, timeout)) { + uint64_t ack{}; + if (!xr_gpu_receive(socket_, &ack, sizeof(ack)) || !visit(ack)) { Close(); return false; } + timeout = 0; + } + return true; + } void Close() { if (socket_ >= 0) close(socket_); socket_ = -1; } private: int socket_ = -1; diff --git a/tools/vr/src/xr_tracking_file.h b/tools/vr/src/xr_tracking_file.h index 1b122d412d..5bd314fde0 100644 --- a/tools/vr/src/xr_tracking_file.h +++ b/tools/vr/src/xr_tracking_file.h @@ -2,6 +2,7 @@ #include "xr_tracking.h" #include #include +#include #include #include #include @@ -38,8 +39,16 @@ public: } return false; } + // Android stamps these packets with the real monotonic clock. The session's clockpause preload holds the + // guest's clock back by the time spent suspended, so read libc's clock directly. static int64_t Now() { - timespec now{}; clock_gettime(CLOCK_MONOTONIC, &now); + using ClockGettime = int (*)(clockid_t, timespec *); + static const ClockGettime real = [] { + void *libc = dlopen("libc.so.6", RTLD_LAZY | RTLD_NOLOAD); + void *symbol = libc ? dlsym(libc, "clock_gettime") : nullptr; + return symbol ? reinterpret_cast(symbol) : &clock_gettime; + }(); + timespec now{}; real(CLOCK_MONOTONIC, &now); return (int64_t)now.tv_sec * 1000000000LL + now.tv_nsec; } static double PoseTimeOffset(int64_t predicted, int64_t now) { @@ -66,3 +75,36 @@ private: std::mutex mutex_; std::string path_; }; + +#define DROIDDECK_XR_LATCH_FILE "droiddeck-xr-latch" + +// The compositor's capture latches one head pose per frame here; the driver hands SteamVR exactly that pose, +// so the frame drawn next and the pose the headset reprojects it with are the same sample. +class XrLatchWriter { +public: + ~XrLatchWriter() { if (mapping_) munmap(mapping_, sizeof(*mapping_)); } + void Write(const DroidDeckXrTracking &packet) { + if (!mapping_ && !Open()) return; + const uint32_t sequence = __atomic_load_n(&mapping_->seq, __ATOMIC_RELAXED) | 1u; + __atomic_store_n(&mapping_->seq, sequence, __ATOMIC_RELAXED); + __atomic_thread_fence(__ATOMIC_RELEASE); + DroidDeckXrTracking copy = packet; copy.seq = sequence; + std::memcpy(mapping_, ©, sizeof(copy)); + __atomic_store_n(&mapping_->seq, sequence + 1, __ATOMIC_RELEASE); + } +private: + bool Open() { + if (attempted_) return false; + attempted_ = true; + int descriptor = open("/run/droiddeck/" DROIDDECK_XR_LATCH_FILE, O_RDWR | O_CREAT | O_CLOEXEC, 0600); + if (descriptor < 0) return false; + void *mapping = ftruncate(descriptor, sizeof(*mapping_)) == 0 + ? mmap(nullptr, sizeof(*mapping_), PROT_READ | PROT_WRITE, MAP_SHARED, descriptor, 0) : MAP_FAILED; + close(descriptor); + if (mapping == MAP_FAILED) return false; + mapping_ = static_cast(mapping); + return true; + } + DroidDeckXrTracking *mapping_ = nullptr; + bool attempted_ = false; +};