Compare commits

...
Author SHA1 Message Date
vii a9987546d5 fix(packaging): refresh AnyLinux debloated package hashes to 2026-09-15
pkgforge rebuilt six of the eight rolling packages, so the AppImage build
failed on the ffmpeg-mini checksum.
2026-09-15 08:10:55 -05:00
vii 6a39887e8f docs(roadmap): add Nightcap roadmap and link it from the README 2026-09-15 08:04:17 -05:00
vii 349e314850 feat(packaging): rename app ID to io.github.CoderDayton.nightcap and publish Flatpak
Rename the desktop entry, metainfo, icons, Flatpak manifest, and SDL app
identity so Nightcap installs side by side with upstream. Build a signed
Flatpak on v* tags, publish the OSTree repo and landing page to GitHub
Pages, and attach the bundle to the release. Release creation tolerates
the AppImage and Flatpak workflows racing on the same tag.
2026-09-15 07:10:26 -05:00
vii b1112d8cdc feat(graphics): default small texture upscale to 4
Unset or non-numeric MOCKTAIL_SMALL_TEXTURE_UPSCALE now means 4, so the
upscale applies on every launch path. Drop the variable from the desktop
entry Exec line.
2026-09-15 03:49:13 -05:00
vii 27c383a5d9 feat(branding): recolor app icon to the Nightcap purple palette
Indigo #2F2A6B, violet #6C4FD1, lavender #A78BFA. PNGs rendered with resvg.
2026-09-14 22:26:10 -05:00
vii 7cf24feef6 feat(branding): rename fork to Nightcap and add AppImage release workflow
Show Nightcap as the app name in the desktop entry, window title,
dialogs, and metainfo. Binary, config paths, and desktop ID keep the
mocktail name. Publish Nightcap-x86_64.AppImage to GitHub Releases on
v* tags. README points at the fork's releases instead of upstream
packages.
2026-09-14 22:19:19 -05:00
vii 4443766d39 chore(hooks): add lefthook config mirroring CI repository checks 2026-09-14 18:19:15 -05:00
vii ea2166b09a docs(license): mark files modified from upstream per Apache 2.0
Add a modified-by notice to every upstream file this fork changes.
Ignore build-test/.
2026-09-14 18:08:12 -05:00
vii 9e4e69be1c docs(readme): describe fork changes and replace dead FAQ link with settings 2026-09-14 16:48:00 -05:00
vii dd0655bfde Merge branch 'pc-improvements' into main
Resolve src/update/host_abi_deriver.cc: keep upstream's FMOD vtable layout
versions and input-method derivation inside the optional output-device
bridge, so a mismatch omits the bridge instead of failing derivation.
2026-09-14 16:09:33 -05:00
vii d2d275706b perf(graphics): present through fifo-latest-ready by default to cut input latency
Roblox requests FIFO with 3 swapchain images, which queues up to two frames
before display. The default vsync policy (auto, unmanaged frame cap) now
resolves to the vsync policy so the lowest-latency synchronized present mode
the host offers is used.
2026-09-14 15:51:35 -05:00
vii b7b63dd30f feat(packaging): launch with MOCKTAIL_SMALL_TEXTURE_UPSCALE=4 from the desktop entry 2026-09-14 10:10:40 -05:00
vii aacab4036c feat(graphics): replace and upscale small ETC2 textures
Level-0 uploads are hashed against the override store; MOCKTAIL_SMALL_TEXTURE_UPSCALE
creates colour images up to 64px N times larger, snaps block-rounded regions to the
host mip, fills every host mip from level 0 and turns image copies touching scaled
images into blits. MOCKTAIL_ADVERTISE_ETC2=0 hides the feature bit.
2026-09-14 10:10:40 -05:00
vii e104b1d936 feat(graphics): add PNG texture override and dump store keyed by upload hash
Adds libpng, MOCKTAIL_TEXTURE_OVERRIDE_DIR (default ~/.config/mocktail/textures)
and MOCKTAIL_TEXTURE_DUMP_DIR.
2026-09-14 10:10:40 -05:00
vii bf6a6b417d fix(packaging): write the install path into the installed desktop entry 2026-09-14 04:53:50 -05:00
vii dfd35b8cc8 feat(packaging): launch on Wayland from the desktop entry 2026-09-14 04:44:25 -05:00
vii 1632681e6c fix(jnivm): answer NativeQuoteInterface.requestResponse so servers stop kicking with 319
The client asks Java for a keystore attestation quote after joining. With no
handler the call returned null, the server never got an answer and dropped
the session with error 319. Reply with the no-keystore form [1, 0, message].
2026-09-14 04:44:25 -05:00
vii 88d10d53f2 perf(graphics): decode ETC2 uploads off mapped memory on worker threads
Compressed bytes are copied to heap scratch, decoded heap to heap across
up to 8 threads in block-row bands, and streamed into the staging buffer.
Decoding straight from uncached Vulkan memory caused 200-460 ms hitches.
The FPS trace now reports the longest frame gap per window.
2026-09-14 04:18:43 -05:00
vii eae9fa7030 feat(graphics): emulate ETC2/EAC textures on Vulkan
Hosts without native ETC2 now report ETC2/EAC support. Uploads into emulated images are decoded to RGBA8/R16 staging buffers at submit. MOCKTAIL_DISABLE_ETC2_EMULATION=1 turns it off.
2026-09-13 11:45:28 -05:00
vii ad76f68224 fix(runtime): report real host memory and display size
DeviceParams now carry host RAM instead of a low-RAM device profile, and screen, window and configuration sizes follow the host display and window with a 1920x1080 fallback.
2026-09-13 11:45:28 -05:00
vii d783793b4e fix(update): make the FMOD output-device bridge optional
Candidate payloads without a matching FMOD output-device signature now derive without the bridge instead of failing activation.
2026-09-13 11:45:28 -05:00
86 changed files with 4954 additions and 587 deletions

No files matched your search

+3 -2
View File
@@ -1,5 +1,6 @@
# Modified by vii from komaruworld/mocktail. See README "About this fork".
name: Bug report
description: Report a reproducible problem in Mocktail
description: Report a reproducible problem in Nightcap
title: "[Bug]: "
labels:
- bug
@@ -75,7 +76,7 @@ body:
value: |
Latest log:
- Flatpak: `~/.var/app/space.bigrat.mocktail/.local/state/mocktail/logs/latest.log`
- Flatpak: `~/.var/app/io.github.CoderDayton.nightcap/.local/state/mocktail/logs/latest.log`
- Other installs: `~/.local/state/mocktail/logs/latest.log`
Older logs are in the `sessions` directory next to `latest.log`.
+61 -68
View File
@@ -1,9 +1,9 @@
# Modified by vii from komaruworld/mocktail. See README "About this fork".
name: Flatpak
on:
workflow_run:
workflows: [Native packages]
types: [completed]
push:
tags: ['v*']
pull_request:
paths:
- '.github/workflows/flatpak.yml'
@@ -15,13 +15,11 @@ on:
- 'config/**'
- 'include/**'
- 'packaging/flatpak/**'
- 'packaging/discord-join.html'
- 'packaging/icons/**'
- 'packaging/space.bigrat.mocktail.desktop'
- 'packaging/space.bigrat.mocktail.metainfo.xml'
- 'packaging/space.bigrat.mocktail.svg'
- 'packaging/io.github.CoderDayton.nightcap.desktop'
- 'packaging/io.github.CoderDayton.nightcap.metainfo.xml'
- 'packaging/io.github.CoderDayton.nightcap.svg'
- 'scripts/assemble_flatpak_pages.sh'
- 'scripts/assemble_native_repositories.sh'
- 'site/**'
- 'src/**'
- 'stubs/**'
@@ -29,61 +27,28 @@ on:
workflow_dispatch:
permissions:
actions: read
contents: read
concurrency:
group: flatpak-${{ github.event.workflow_run.head_sha || github.ref }}
cancel-in-progress: true
group: flatpak-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
flatpak:
name: Flatpak build
if: >-
github.event_name != 'workflow_run' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event != 'pull_request' &&
github.event.workflow_run.head_branch == 'main')
runs-on: ubuntu-24.04
timeout-minutes: 120
env:
MOCKTAIL_PUBLISH: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event != 'pull_request' && github.event.workflow_run.head_branch == 'main') || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }}
MOCKTAIL_SOURCE_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
# Publish on release tags and on manual runs from main. Pull requests
# only verify that the manifest still builds.
MOCKTAIL_PUBLISH: ${{ startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }}
steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
submodules: recursive
- name: Download package repositories
if: env.MOCKTAIL_PUBLISH == 'true'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -Eeuo pipefail
run_id="${{ github.event.workflow_run.id }}"
if [[ -z "$run_id" ]]; then
run_id="$(gh run list \
--workflow packages.yml \
--branch main \
--event push \
--status success \
--limit 1 \
--json databaseId \
--jq '.[0].databaseId')"
fi
[[ -n "$run_id" ]]
gh run download "$run_id" \
--name Mocktail-native-repositories \
--dir native-repositories
[[ -d native-repositories/apt && \
-d native-repositories/rpm && \
-d native-repositories/downloads && \
-s native-repositories/mocktail-packages.gpg ]]
- name: Install Flatpak builder
shell: bash
run: |
@@ -99,22 +64,23 @@ jobs:
FLATPAK_GPG_KEY_ID: ${{ secrets.FLATPAK_GPG_KEY_ID }}
run: |
set -Eeuo pipefail
git update-ref refs/heads/main "$MOCKTAIL_SOURCE_SHA"
# The manifest builds the local checkout from refs/heads/main.
git update-ref refs/heads/main "$GITHUB_SHA"
builder_signing=()
bundle_keys=()
if [[ "$MOCKTAIL_PUBLISH" == true ]]; then
[[ -n "$FLATPAK_GPG_PRIVATE_KEY" && \
-n "$FLATPAK_GPG_KEY_ID" ]]
install -d -m 0700 "$RUNNER_TEMP/mocktail-gnupg"
install -d -m 0700 "$RUNNER_TEMP/nightcap-gnupg"
printf '%s' "$FLATPAK_GPG_PRIVATE_KEY" | \
gpg --batch --homedir "$RUNNER_TEMP/mocktail-gnupg" --import
gpg --batch --homedir "$RUNNER_TEMP/mocktail-gnupg" \
--export "$FLATPAK_GPG_KEY_ID" >mocktail-flatpak.gpg
gpg --batch --homedir "$RUNNER_TEMP/nightcap-gnupg" --import
gpg --batch --homedir "$RUNNER_TEMP/nightcap-gnupg" \
--export "$FLATPAK_GPG_KEY_ID" >nightcap-flatpak.gpg
builder_signing=(
"--gpg-sign=$FLATPAK_GPG_KEY_ID"
"--gpg-homedir=$RUNNER_TEMP/mocktail-gnupg"
"--gpg-homedir=$RUNNER_TEMP/nightcap-gnupg"
)
bundle_keys=(--gpg-keys=mocktail-flatpak.gpg)
bundle_keys=(--gpg-keys=nightcap-flatpak.gpg)
fi
flatpak-builder \
--arch=x86_64 \
@@ -127,34 +93,33 @@ jobs:
--repo=repo \
"${builder_signing[@]}" \
build-flatpak-ci \
packaging/flatpak/space.bigrat.mocktail.json
packaging/flatpak/io.github.CoderDayton.nightcap.json
if [[ "$MOCKTAIL_PUBLISH" == true ]]; then
flatpak build-update-repo \
--generate-static-deltas \
--static-delta-jobs=2 \
--prune \
--gpg-sign="$FLATPAK_GPG_KEY_ID" \
--gpg-homedir="$RUNNER_TEMP/mocktail-gnupg" \
--gpg-homedir="$RUNNER_TEMP/nightcap-gnupg" \
repo
fi
flatpak build-bundle \
--arch=x86_64 \
"${bundle_keys[@]}" \
repo \
Mocktail-x86_64.flatpak \
space.bigrat.mocktail \
Nightcap-x86_64.flatpak \
io.github.CoderDayton.nightcap \
stable
if [[ "$MOCKTAIL_PUBLISH" == true ]]; then
./scripts/assemble_flatpak_pages.sh \
repo Mocktail-x86_64.flatpak mocktail-flatpak.gpg \
public native-repositories
repo Nightcap-x86_64.flatpak nightcap-flatpak.gpg public
fi
- name: Upload Flatpak
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: Mocktail-x86_64-flatpak
path: Mocktail-x86_64.flatpak
name: Nightcap-x86_64-flatpak
path: Nightcap-x86_64.flatpak
if-no-files-found: error
retention-days: 14
@@ -170,13 +135,7 @@ jobs:
deploy-pages:
name: Publish Flatpak repository
if: >-
(github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event != 'pull_request' &&
github.event.workflow_run.head_branch == 'main') ||
(github.event_name == 'workflow_dispatch' &&
github.ref == 'refs/heads/main')
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
needs: flatpak
runs-on: ubuntu-24.04
timeout-minutes: 10
@@ -191,3 +150,37 @@ jobs:
- name: Deploy GitHub Pages
id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
release:
name: Attach bundle to GitHub release
if: startsWith(github.ref, 'refs/tags/v')
needs: flatpak
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: write
steps:
- name: Download Flatpak
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Nightcap-x86_64-flatpak
path: release
- name: Upload to release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -Eeuo pipefail
tag="${GITHUB_REF_NAME}"
(cd release && sha256sum Nightcap-x86_64.flatpak > Nightcap-x86_64.flatpak.sha256)
# The Release workflow creates the same release; whichever job
# arrives second sees "already exists" and continues.
if ! gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release create "$tag" --repo "$GITHUB_REPOSITORY" \
--title "Nightcap $tag" --generate-notes ||
gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null
fi
gh release upload "$tag" --repo "$GITHUB_REPOSITORY" --clobber \
release/Nightcap-x86_64.flatpak \
release/Nightcap-x86_64.flatpak.sha256
+154
View File
@@ -0,0 +1,154 @@
name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
appimage:
name: AppImage (AnyLinux)
runs-on: ubuntu-24.04
timeout-minutes: 90
steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
submodules: recursive
- name: Build AppImage
shell: bash
run: |
docker run --rm \
--volume "$GITHUB_WORKSPACE:/workspace" \
--workdir /workspace \
ghcr.io/archlinux/archlinux:base-devel@sha256:c3953446016873a756fb7814f10087cac1634c127f7302e80c81c512da796d05 bash -Eeuo pipefail -c '
pacman -Syu --noconfirm --needed \
cmake git ninja pkgconf lld sdl3 sdl3_ttf curl openssl \
nlohmann-json libyaml libelf minizip minizip-ng capstone gtk4 \
libadwaita webkitgtk-6.0 libutf8proc fontconfig libglvnd \
vulkan-headers zlib libplacebo bubblewrap xdg-dbus-proxy \
patchelf jq unzip file ca-certificates dbus zsync
./scripts/install_anylinux_dependencies.sh
curl --fail --location --retry 3 \
--output /tmp/quick-sharun \
https://raw.githubusercontent.com/pkgforge-dev/Anylinux-AppImages/2a025cef14483c5bc2a75b479071f4d5c58a906f/useful-tools/quick-sharun.sh
echo "fa66d0189e1e87df781c049dfb23cbb1e753786056f693a4483d6d3af61e7ee1 /tmp/quick-sharun" | \
sha256sum --check --strict
chmod 0755 /tmp/quick-sharun
curl --fail --location --retry 3 \
--output /tmp/sharun \
https://github.com/pkgforge-dev/Anylinux-sharun/releases/download/2.2.6/sharun-x86_64
echo "a4d51752f9861b4870ca529fea04087310b28f8943cc55b99a95b777d4db92ec /tmp/sharun" | \
sha256sum --check --strict
chmod 0755 /tmp/sharun
curl --fail --location --retry 3 \
--output /tmp/anylinux.c \
https://raw.githubusercontent.com/pkgforge-dev/Anylinux-AppImages/2a025cef14483c5bc2a75b479071f4d5c58a906f/useful-tools/lib/anylinux.c
echo "f50650ad96d177559bdd0737df509fa20bd4af08887631c738fc1f31bfac185f /tmp/anylinux.c" | \
sha256sum --check --strict
curl --fail --location --retry 3 \
--output /tmp/appimagetool \
https://github.com/pkgforge-dev/appimagetool/releases/download/0.3.3/appimagetool-x86_64-linux
echo "0d01a4e2628efc897be9663f0faeed6a171e1851270b4e1ce4c22434a36ecebd /tmp/appimagetool" | \
sha256sum --check --strict
chmod 0755 /tmp/appimagetool
curl --fail --location --retry 3 \
--output /tmp/uruntime \
https://github.com/VHSgunzo/uruntime/releases/download/v0.5.9/uruntime-appimage-dwarfs-lite-x86_64
echo "cef962c299f2fa19b2b3cdf2fa1565ee8541796cc89b9a97a591f94041e8b083 /tmp/uruntime" | \
sha256sum --check --strict
chmod 0755 /tmp/uruntime
curl --fail --location --retry 3 \
--output /tmp/mkdwarfs \
https://github.com/mhx/dwarfs/releases/download/v0.15.6/dwarfs-universal-0.15.6-Linux-x86_64
echo "50891c38ba359db8271819a6cbf6aaa8068681523f0c4f2b8242007a45edaa28 /tmp/mkdwarfs" | \
sha256sum --check --strict
chmod 0755 /tmp/mkdwarfs
git config --global --add safe.directory /workspace
git config --global --add safe.directory /workspace/third_party/Vulkan-Headers
git config --global --add safe.directory /workspace/third_party/libjnivm
export MOCKTAIL_ANYLINUX_SYSTEM_INSTALL=1
export MOCKTAIL_ANYLINUX_SHARUN=/tmp/sharun
export MOCKTAIL_ANYLINUX_C_SOURCE=/tmp/anylinux.c
export RUNTIME=/tmp/uruntime
export DWARFS_CMD=/tmp/mkdwarfs
make appimage BUILD_DIR=build-appimage JOBS=4 \
APPIMAGE=dist/Mocktail-x86_64.AppImage \
PORTABLE_MODE=standalone APPIMAGE_FORMAT=anylinux \
ANYLINUX_PACKAGER=/tmp/quick-sharun \
ANYLINUX_APPIMAGETOOL=/tmp/appimagetool
test -x dist/Mocktail-x86_64.AppImage
'
- name: Smoke-test AppImage without FUSE
shell: bash
run: |
smoke_dir="$(mktemp -d)"
trap 'rm -rf -- "$smoke_dir"' EXIT
export XDG_DATA_HOME="$smoke_dir/data"
export XDG_CONFIG_HOME="$smoke_dir/config"
export XDG_CACHE_HOME="$smoke_dir/cache"
export XDG_STATE_HOME="$smoke_dir/state"
mkdir -p "$XDG_DATA_HOME" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME" "$XDG_STATE_HOME"
timeout 60s dist/Mocktail-x86_64.AppImage --appimage-extract-and-run --help
timeout 60s dist/Mocktail-x86_64.AppImage --appimage-extract-and-run mocktail_updater status
- name: Upload AppImage
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: Mocktail-AppImage
path: dist/Mocktail-x86_64.AppImage
if-no-files-found: error
retention-days: 14
publish:
name: Publish GitHub release
if: startsWith(github.ref, 'refs/tags/v')
needs: [appimage]
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: write
steps:
- name: Download AppImage
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Mocktail-AppImage
path: release
- name: Create release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -Eeuo pipefail
tag="${GITHUB_REF_NAME}"
mv release/Mocktail-x86_64.AppImage release/Nightcap-x86_64.AppImage
(cd release && sha256sum Nightcap-x86_64.AppImage > Nightcap-x86_64.AppImage.sha256)
# The Flatpak workflow creates the same release; whichever job
# arrives second sees "already exists" and continues.
if ! gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release create "$tag" --repo "$GITHUB_REPOSITORY" \
--title "Nightcap $tag" --generate-notes ||
gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null
fi
gh release upload "$tag" --repo "$GITHUB_REPOSITORY" --clobber \
release/Nightcap-x86_64.AppImage \
release/Nightcap-x86_64.AppImage.sha256
+1
View File
@@ -1,5 +1,6 @@
# Build
/build/
/build-test/
/build_*/
/build-flatpak/
/build-anylinux*/
+19 -6
View File
@@ -1,3 +1,4 @@
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -300,6 +301,7 @@ add_library(mocktail_runtime STATIC
src/runtime/support_bundle.cc
src/runtime/system_proxy.cc
src/runtime/texture_memory_policy.cc
src/runtime/device_memory_profile.cc
)
add_library(Mocktail::Runtime ALIAS mocktail_runtime)
target_include_directories(mocktail_runtime PUBLIC include)
@@ -724,13 +726,24 @@ install(FILES
config/roblox_signing_certificates.json
DESTINATION "${MOCKTAIL_INSTALL_DATA_DIR}/metadata"
)
install(FILES packaging/space.bigrat.mocktail.desktop
DESTINATION "${CMAKE_INSTALL_DATADIR}/applications"
)
install(FILES packaging/space.bigrat.mocktail.metainfo.xml
# The installed desktop entry names the binary by its install path, so it
# launches from sessions whose PATH lacks the install prefix. Uses the prefix
# given at install time, not the configure-time one.
install(CODE "
file(READ \"${CMAKE_SOURCE_DIR}/packaging/io.github.CoderDayton.nightcap.desktop\"
MOCKTAIL_DESKTOP_ENTRY)
string(REPLACE \"Exec=env SDL_VIDEODRIVER=wayland,x11 mocktail %u\"
\"Exec=env SDL_VIDEODRIVER=wayland,x11 \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/mocktail %u\"
MOCKTAIL_DESKTOP_ENTRY \"\${MOCKTAIL_DESKTOP_ENTRY}\")
file(WRITE \"${CMAKE_BINARY_DIR}/io.github.CoderDayton.nightcap.desktop\"
\"\${MOCKTAIL_DESKTOP_ENTRY}\")
file(INSTALL \"${CMAKE_BINARY_DIR}/io.github.CoderDayton.nightcap.desktop\"
DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/applications\")
")
install(FILES packaging/io.github.CoderDayton.nightcap.metainfo.xml
DESTINATION "${CMAKE_INSTALL_DATADIR}/metainfo"
)
install(FILES packaging/space.bigrat.mocktail.svg
install(FILES packaging/io.github.CoderDayton.nightcap.svg
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps"
)
set(MOCKTAIL_HICOLOR_ICON_SIZES
@@ -739,7 +752,7 @@ set(MOCKTAIL_HICOLOR_ICON_SIZES
# Generated icons are committed, so ImageMagick is not a build dependency.
foreach(icon_size IN LISTS MOCKTAIL_HICOLOR_ICON_SIZES)
install(FILES
"packaging/icons/hicolor/${icon_size}x${icon_size}/apps/space.bigrat.mocktail.png"
"packaging/icons/hicolor/${icon_size}x${icon_size}/apps/io.github.CoderDayton.nightcap.png"
DESTINATION
"${CMAKE_INSTALL_DATADIR}/icons/hicolor/${icon_size}x${icon_size}/apps"
)
+4 -3
View File
@@ -1,3 +1,4 @@
# Modified by vii from komaruworld/mocktail. See README "About this fork".
.DEFAULT_GOAL := all
.PHONY: all build release debug test apk install register-url-handler release-runtime portable portable-test standalone appimage flatpak run-flatpak run run-smoke run-unlimited run-game run-input run-resize run-network auto-run run-gles run-angle update-roblox update-auto update-auto-launch payload-status payload-rollback support-bundle clean submodules help
@@ -19,7 +20,7 @@ ANYLINUX_PACKAGER ?= quick-sharun
ANYLINUX_APPIMAGETOOL ?= appimagetool
PREFIX ?= /usr
FLATPAK_BUILD_DIR ?= build-flatpak
FLATPAK_MANIFEST ?= packaging/flatpak/space.bigrat.mocktail.json
FLATPAK_MANIFEST ?= packaging/flatpak/io.github.CoderDayton.nightcap.json
FLATPAK_JOBS ?= 4
define build_native_runtime
@@ -55,7 +56,7 @@ install: ## Install an already-built dynamic runtime (use: sudo make install)
register-url-handler: build ## Select this build for Roblox website links
@./scripts/register_url_handler.sh --set-default \
--executable "$(abspath $(BINARY))" \
--desktop-file "$(abspath packaging/space.bigrat.mocktail.desktop)"
--desktop-file "$(abspath packaging/io.github.CoderDayton.nightcap.desktop)"
test: ## Build and run all unit tests
$(call build_native_runtime,Debug,ON)
@@ -91,7 +92,7 @@ flatpak: ## Build and install the local x86-64 Flatpak
--jobs "$(FLATPAK_JOBS)"
run-flatpak: ## Run the installed Flatpak
@flatpak run space.bigrat.mocktail
@flatpak run io.github.CoderDayton.nightcap
run: export MOCKTAIL_AUTO_EXIT_AFTER_PRESENT_MS = 0
run: build ## Run the native binary interactively until the window is closed
+98 -91
View File
@@ -1,19 +1,67 @@
# Mocktail
<!-- Modified by vii from komaruworld/mocktail. See "About this fork" below. -->
# Nightcap
[![CI](https://github.com/komaruworld/mocktail/actions/workflows/ci.yml/badge.svg)](https://github.com/komaruworld/mocktail/actions/workflows/ci.yml)
[![Stars](https://img.shields.io/github/stars/komaruworld/mocktail?style=flat&logo=github)](https://github.com/komaruworld/mocktail/stargazers)
[![Downloads](https://img.shields.io/github/downloads/komaruworld/mocktail/total?logo=github)](https://github.com/komaruworld/mocktail/releases/latest)
[![CI](https://github.com/CoderDayton/nightcap/actions/workflows/ci.yml/badge.svg)](https://github.com/CoderDayton/nightcap/actions/workflows/ci.yml)
[![Stars](https://img.shields.io/github/stars/CoderDayton/nightcap?style=flat&logo=github)](https://github.com/CoderDayton/nightcap/stargazers)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
[![Discord](https://img.shields.io/discord/1543955607869063269?label=discord)](https://discord.gg/rhgpfcmFSD)
Mocktail runs the Android `x86_64` Roblox client on Linux, including a Linux
userspace hosted by FreeBSD's Linuxulator. It provides the Android ABI and JNI
pieces the client expects, then connects them to SDL3 and Vulkan or OpenGL on
the Linux side.
Nightcap is Mocktail, tuned for playing on a real PC. It runs the Android
`x86_64` Roblox client on Linux, including a Linux userspace hosted by
FreeBSD's Linuxulator. It provides the Android ABI and JNI pieces the client
expects, then connects them to SDL3 and Vulkan or OpenGL on the Linux side.
Mocktail is an independent community project. It is not affiliated with Roblox
Nightcap is an independent community project. It is not affiliated with Roblox
Corporation or VinegarHQ and does not distribute the Roblox client.
## About this fork
Nightcap is a fork of [komaruworld/mocktail](https://github.com/komaruworld/mocktail)
with extra fixes for playing on a PC. The program and config paths keep the
`mocktail` name so upstream fixes still apply cleanly. The app ID is
`io.github.CoderDayton.nightcap`, so Nightcap and upstream can be installed
side by side.
- **Lower input lag.** Frames are shown as soon as they are ready instead of
waiting in a queue.
- **Sharper textures.** Small textures are upscaled 4x by default, and you
can replace any texture with your own PNG in `~/.config/mocktail/textures`.
Set `MOCKTAIL_SMALL_TEXTURE_UPSCALE=1` to turn the upscale off.
- **ETC2 textures on any GPU.** Games that use compressed mobile textures now
render correctly on desktop GPUs, without stutter.
- **No more error 319 kicks.** Servers no longer drop you shortly after
joining.
- **Correct device info.** Roblox sees your real RAM and screen size.
- **Better desktop launcher.** Runs on Wayland and always finds the installed
binary.
Everything else works the same as upstream. See the
[roadmap](docs/ROADMAP.md) for what is coming next.
## Install with Flatpak
```bash
flatpak install --user https://coderdayton.github.io/nightcap/nightcap.flatpakref
flatpak run io.github.CoderDayton.nightcap
```
Updates arrive through `flatpak update`. Nightcap is not on Flathub yet.
## AppImage
Grab the AppImage from the
[latest release](https://github.com/CoderDayton/nightcap/releases/latest),
make it executable, and run it:
```bash
chmod +x Nightcap-x86_64.AppImage
./Nightcap-x86_64.AppImage
```
Or build and install it from source using the steps under
[Building](#building). There are no AUR, DEB, or RPM packages of Nightcap.
Upstream ships those for unmodified Mocktail, see
[komaruworld/mocktail](https://github.com/komaruworld/mocktail#readme).
## How it works
```
@@ -21,91 +69,24 @@ Roblox APK -> signature and ABI checks -> Bionic + JNI -> SDL3 + Vulkan/OpenGL
```
The APK is checked before any native code is loaded. It is downloaded on first
launch and is not bundled with Mocktail. The last working copy is kept in case
launch and is not bundled with Nightcap. The last working copy is kept in case
an update fails.
## Install with Flatpak
Install the stable release from Flathub:
```bash
flatpak install flathub space.bigrat.mocktail
flatpak run space.bigrat.mocktail
```
Nightly builds are produced automatically from the latest `main` branch:
```bash
flatpak install --user https://mocktail.bigrat.space/mocktail.flatpakref
flatpak run space.bigrat.mocktail
```
## Install from the AUR
Arch Linux users can install either the pinned source release (`mocktail`) or
the current development version (`mocktail-git`) with an AUR helper:
```bash
paru -S mocktail-git
# or
yay -S mocktail-git
```
Use `mocktail` instead of `mocktail-git` to build the pinned release from
source, or install the stable prebuilt package with `paru -S mocktail-bin` or
`yay -S mocktail-bin`.
## Install with DNF
Fedora 44 users can install either the stable `mocktail` package or the
`mocktail-nightly` package built from `main`:
```bash
sudo curl -fsSL https://mocktail.bigrat.space/rpm/mocktail.repo \
-o /etc/yum.repos.d/mocktail.repo
sudo dnf install mocktail
# or
sudo dnf install mocktail-nightly
```
## Install with APT
Ubuntu 26.04 users can install either the stable `mocktail` package or the
`mocktail-nightly` package built from `main`:
```bash
sudo install -d -m 0755 /etc/apt/keyrings
sudo curl -fsSL https://mocktail.bigrat.space/mocktail-packages.gpg \
-o /etc/apt/keyrings/mocktail.gpg
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/mocktail.gpg] https://mocktail.bigrat.space/apt mocktail main" | \
sudo tee /etc/apt/sources.list.d/mocktail.list >/dev/null
sudo apt update
sudo apt install mocktail
# or
sudo apt install mocktail-nightly
```
## Direct downloads
Direct AppImage, DEB, and RPM downloads are available from the
[Website](https://mocktail.bigrat.space/) and
[GitHub Releases](https://github.com/komaruworld/mocktail/releases).
<details>
<summary>Screenshots</summary>
![Roblox home in Mocktail](assets/screenshots/flatpak-home.png)
![Roblox home in Nightcap](assets/screenshots/flatpak-home.png)
![Roblox gameplay in Mocktail](assets/screenshots/flatpak-gameplay-tower.png)
![Roblox gameplay in Nightcap](assets/screenshots/flatpak-gameplay-tower.png)
![Roblox experience in Mocktail](assets/screenshots/flatpak-gameplay-lobby.png)
![Roblox experience in Nightcap](assets/screenshots/flatpak-gameplay-lobby.png)
</details>
## FFlag overrides
Put a JSON object in `$XDG_CONFIG_HOME/mocktail/fflags.json` (usually
`~/.config/mocktail/fflags.json`). Mocktail applies it on the next launch.
`~/.config/mocktail/fflags.json`). Nightcap applies it on the next launch.
PC profiles use the legacy Charts page by default to avoid the blank screen
caused by `Color3` errors in the newer SDUI page. An explicit
@@ -117,15 +98,18 @@ caused by `Color3` errors in the newer SDUI page. An explicit
"DFIntExample": "120"
}
```
## FAQ
## Settings
To see the most Frequently Asked Question go check [FAQ.md](FAQ.md)
Edit `~/.config/mocktail/config.yaml`. Useful options:
- `graphics.frame_rate_limit: display` to unlock FPS to your monitor's rate.
- `graphics.vsync: off` for the lowest lag, at the cost of tearing.
- `graphics.backend: opengl` if Vulkan does not work on your GPU.
## Building
Linux `x86_64` is supported. Experimental FreeBSD 15.1 Linuxulator support has
been tested with an `x86_64` Fedora 44 userspace. On FreeBSD, Mocktail runs
been tested with an `x86_64` Fedora 44 userspace. On FreeBSD, Nightcap runs
inside Linuxulator; it is not a native FreeBSD binary. Building requires CMake
3.20+, Git, pkg-config, LLD, binutils, a C++17 compiler, SDL 3.4+, SDL3_ttf,
Vulkan, EGL, libplacebo, fontconfig, libcurl, OpenSSL, libelf, libyaml, minizip,
@@ -172,17 +156,34 @@ sudo dnf install gcc-c++ cmake git ninja-build pkgconf-pkg-config lld \
</details>
```bash
git clone --recurse-submodules https://github.com/komaruworld/mocktail.git
cd mocktail
git clone --recurse-submodules https://github.com/CoderDayton/nightcap.git
cd nightcap
make build
./build/mocktail
```
To install it for your user, with an app menu entry and Roblox link handling:
```bash
make install PREFIX=~/.local
```
Use `sudo make install` instead to install system-wide under `/usr`. To make
Roblox website links open the build tree copy without installing, run
`make register-url-handler`.
To run the same checks as CI before each commit and push, install
[lefthook](https://github.com/evilmartians/lefthook) and run once:
```bash
lefthook install
```
## Known limitations
Mocktail does not currently work with `hardened_malloc`. Using
`hardened_malloc` may cause Mocktail to fail to start or crash during runtime.
Run Mocktail without `hardened_malloc` enabled.
Nightcap does not currently work with `hardened_malloc`. Using
`hardened_malloc` may cause Nightcap to fail to start or crash during runtime.
Run Nightcap without `hardened_malloc` enabled.
## License
@@ -190,7 +191,13 @@ Run Mocktail without `hardened_malloc` enabled.
## Support
You can support the project by giving it a star or with cryptocurrency:
Support this fork by giving it a star or with cryptocurrency:
- LTC: `LdABR2ELRYrUESWZWrEk1uNx38gHHMuHUU`
- SOL: `tjeDnPoWeyW8zfTf8c5CVAm5QTV8vFPaPouaScAdwfT`
- BCH: `qpktw5jwut9ae8e6898qt3v7rj3km44utgk2r9mj8n`
Support the upstream project, which does most of the heavy lifting:
- USDT (TON): `UQCi6Yzcc9cOctoij6n_r1K90-OdVxAT0D_xo2UzGKkQaJDY`
- USDT (TRC20): `TNPMG9Vig2xiuo2r1QqnXRChPH7Vu28Jmx`
+2 -1
View File
@@ -1,3 +1,4 @@
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# Licensed under the Apache License, Version 2.0.
@@ -12,7 +13,7 @@ find_path(MOCKTAIL_EGL_INCLUDE_DIR EGL/egl.h REQUIRED)
find_path(MOCKTAIL_GLES3_INCLUDE_DIR GLES3/gl3.h REQUIRED)
set(MOCKTAIL_WINDOW_ICON_PNG
"${MOCKTAIL_PLATFORM_GRAPHICS_ROOT}/packaging/icons/hicolor/48x48/apps/space.bigrat.mocktail.png"
"${MOCKTAIL_PLATFORM_GRAPHICS_ROOT}/packaging/icons/hicolor/48x48/apps/io.github.CoderDayton.nightcap.png"
)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
"${MOCKTAIL_WINDOW_ICON_PNG}"
+4 -1
View File
@@ -1,3 +1,4 @@
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Mocktail configuration.
# The file is created once with mode 0600. Mocktail never replaces your edits.
@@ -46,7 +47,9 @@ graphics:
# display, unlimited, or any positive integer; fixed values are forwarded to
# DFIntTaskSchedulerTargetFps without a whitelist.
# frame_rate_limit: -1
# Optional presentation synchronization override: auto, on, or off.
# Optional presentation synchronization override: auto, on, or off. auto
# presents through the lowest-latency synchronized mode the driver offers
# unless frame_rate_limit is unlimited.
# vsync: off
performance:
+85
View File
@@ -0,0 +1,85 @@
# Nightcap roadmap
What Nightcap is working toward, in priority order. Items move to
[Shipped](#shipped) when they land on `main`. Open an issue to propose a
change to this list.
## 1. Settings UI
Nightcap is configured by editing `~/.config/mocktail/config.yaml`. Most
people never open it, so they never find the FPS unlock or the vsync switch.
Goal: a small GTK4 settings window, reachable from the app menu and from a
`--settings` flag, that reads and writes the same `config.yaml`.
- Graphics tab: backend, frame rate limit, vsync, small texture upscale.
- Input tab: raw mouse and controller options (see item 2).
- Advanced tab: FFlag overrides with a plain text editor for `fflags.json`.
- Discord tab: the `discord_rpc` block (see item 3).
- Changes apply on next launch. A restart button restarts Nightcap.
Done when every option in `config/mocktail.example.yaml` that a player would
touch can be set without a text editor.
## 2. Controller and raw mouse input
Upstream added Xbox and PlayStation gamepad support through SDL. Desktop play
still has rough edges.
- Raw mouse input in first-person games, with no acceleration or clamping.
- Better controller support: hot-plug without a restart, correct button
glyphs for the connected pad, and no stuck inputs after a disconnect.
Done when a mouse feels like a mouse and a plugged-in controller just works.
## 3. Discord Rich Presence
Upstream ships Discord RPC, off by default, behind `discord_rpc.enabled`. It
shows the experience name, elapsed time, and a join button when the server is
public.
- Turn it on by default. It never reads a Discord token, so the privacy cost
is only the experience name, which the player already shares in Roblox.
- Show the experience icon as the large image instead of a static logo.
- Show the current server region and player count when Roblox exposes them.
- Make the join button work for private servers the player has a link for.
- A Discord tab in the settings window to toggle each field.
Done when a friend can see what you are playing and join in one click, and
you can switch it all off in one click.
## 4. Performance profiling
Every performance change should come with numbers. Today they come with a
feeling.
- A frame time overlay, toggled by a key and a config flag, showing CPU time,
GPU time, and present latency.
- Shader compile and pipeline cache tracing, so first-load stutter can be
measured and cut.
- A `--profile` flag that writes a trace file readable by Perfetto.
- A short benchmark guide in `docs/` with a fixed set of experiences, so
before and after numbers can be compared across machines.
Done when a pull request that claims a speedup can show the trace that
proves it.
## Shipped
- Lower input latency: frames are presented as soon as they are ready.
- Small textures upscaled 4x by default, with PNG overrides in
`~/.config/mocktail/textures`.
- ETC2 textures decoded on desktop GPUs without stutter.
- No more error 319 kicks after joining a server.
- Roblox sees the real host RAM and screen size.
- Desktop launcher that works on Wayland and finds the installed binary.
- Own app ID `io.github.CoderDayton.nightcap`, so Nightcap installs next to
upstream.
- AppImage and signed Flatpak releases on every `v*` tag, with the Flatpak
repo on GitHub Pages.
## Not planned
- Replacing the `mocktail` binary and config names. Keeping them makes
upstream merges clean.
- DEB, RPM, and AUR packages. Upstream ships those for unmodified Mocktail.
+71
View File
@@ -0,0 +1,71 @@
#ifndef MOCKTAIL_GRAPHICS_ETC2_DECODER_H_
#define MOCKTAIL_GRAPHICS_ETC2_DECODER_H_
#include <cstddef>
#include <cstdint>
namespace mocktail::graphics {
// ETC2 and EAC block encodings from the OpenGL ES 3.0 / Vulkan core formats.
// sRGB variants share the unorm encoding; the colour space belongs to the
// destination format.
enum class EtcFormat {
kEtc2Rgb8,
kEtc2Rgb8A1,
kEtc2Rgba8,
kEacR11,
kEacR11Signed,
kEacRg11,
kEacRg11Signed,
};
// Compressed bytes per 4x4 block.
std::size_t EtcBlockBytes(EtcFormat format);
// Decoded bytes per texel: 4 (RGBA8) for ETC2 formats, 2 per channel
// (16-bit, little-endian) for EAC formats.
std::size_t EtcDecodedTexelBytes(EtcFormat format);
// Decodes a width x height image stored as ceil(width/4) x ceil(height/4)
// blocks into row-major texels. Returns false, writing nothing, when a buffer
// is smaller than the image requires.
bool DecodeEtcImage(EtcFormat format, const std::uint8_t* source,
std::size_t source_bytes, std::uint32_t width,
std::uint32_t height, std::uint8_t* destination,
std::size_t destination_bytes);
// Decodes block rows [first_block_row, first_block_row + block_row_count) of
// the image DecodeEtcImage describes, writing only the texel rows those blocks
// cover. Bands that together cover every block row produce DecodeEtcImage's
// output. Returns false, writing nothing, when a buffer is too small or the
// rows lie outside the image.
bool DecodeEtcImageBlockRows(EtcFormat format, const std::uint8_t* source,
std::size_t source_bytes, std::uint32_t width,
std::uint32_t height,
std::uint32_t first_block_row,
std::uint32_t block_row_count,
std::uint8_t* destination,
std::size_t destination_bytes);
// One DecodeEtcImage call. Jobs must not share destination bytes.
struct EtcDecodeJob {
EtcFormat format = EtcFormat::kEtc2Rgb8;
const std::uint8_t* source = nullptr;
std::size_t source_bytes = 0;
std::uint32_t width = 0;
std::uint32_t height = 0;
std::uint8_t* destination = nullptr;
std::size_t destination_bytes = 0;
// Set to DecodeEtcImage's result.
bool ok = false;
};
// Decodes every job before returning. Large batches are split into block-row
// bands decoded on up to worker_count threads, the caller included; small
// batches decode on the caller only.
void DecodeEtcJobs(EtcDecodeJob* jobs, std::size_t count,
unsigned worker_count);
} // namespace mocktail::graphics
#endif // MOCKTAIL_GRAPHICS_ETC2_DECODER_H_
@@ -0,0 +1,68 @@
#ifndef MOCKTAIL_GRAPHICS_TEXTURE_OVERRIDE_H_
#define MOCKTAIL_GRAPHICS_TEXTURE_OVERRIDE_H_
#include <cstddef>
#include <cstdint>
#include <memory>
#include <mutex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace mocktail::graphics {
// Tightly packed RGBA8 pixels, row-major, top row first.
struct RgbaImage {
std::uint32_t width = 0;
std::uint32_t height = 0;
std::vector<std::uint8_t> pixels;
};
// FNV-1a over the bytes; the texture identity used for dump and override
// file names.
std::uint64_t HashBytes(const std::uint8_t* data, std::size_t size);
// 16 lowercase hex digits.
std::string HashName(std::uint64_t hash);
bool ReadPngRgba(const std::string& path, RgbaImage* image);
bool WritePngRgba(const std::string& path, const RgbaImage& image);
// Writes width x height RGBA8 pixels to destination, each destination pixel
// the average of the source box it covers. Growing repeats source pixels.
void ResampleRgba(const RgbaImage& source, std::uint32_t width,
std::uint32_t height, std::uint8_t* destination);
void ResampleRgba(const std::uint8_t* source, std::uint32_t source_width,
std::uint32_t source_height, std::uint32_t width,
std::uint32_t height, std::uint8_t* destination);
// Replacement textures keyed by the hash of a texture's level-0 compressed
// bytes. An override lives at <override_dir>/<hash>.png. With a dump
// directory, every level-0 texture seen is written once as
// <dump_dir>/<hash>_<width>x<height>.png so the hash can be found.
// Thread-safe.
class TextureOverrides {
public:
TextureOverrides(std::string override_dir, std::string dump_dir);
// MOCKTAIL_TEXTURE_OVERRIDE_DIR and MOCKTAIL_TEXTURE_DUMP_DIR.
static TextureOverrides FromEnvironment();
bool enabled() const { return !override_dir_.empty() || !dump_dir_.empty(); }
bool dumping() const { return !dump_dir_.empty(); }
// Null when no override file exists; lookups are cached either way.
std::shared_ptr<const RgbaImage> Lookup(std::uint64_t hash);
void Dump(std::uint64_t hash, std::uint32_t width, std::uint32_t height,
const std::uint8_t* rgba);
private:
std::string override_dir_;
std::string dump_dir_;
std::mutex mutex_;
std::unordered_map<std::uint64_t, std::shared_ptr<const RgbaImage>> cache_;
std::unordered_set<std::uint64_t> dumped_;
};
} // namespace mocktail::graphics
#endif // MOCKTAIL_GRAPHICS_TEXTURE_OVERRIDE_H_
@@ -0,0 +1,131 @@
#ifndef MOCKTAIL_GRAPHICS_VULKAN_ETC2_EMULATION_H_
#define MOCKTAIL_GRAPHICS_VULKAN_ETC2_EMULATION_H_
#include <vulkan/vulkan.h>
#include <cstdint>
#include "mocktail/graphics/etc2_decoder.h"
namespace mocktail::graphics {
// Host format that stores a decoded ETC2/EAC image, with its block encoding.
struct Etc2EmulatedFormat {
VkFormat host_format = VK_FORMAT_UNDEFINED;
EtcFormat etc_format = EtcFormat::kEtc2Rgb8;
};
// Maps an ETC2/EAC Vulkan format to its decoded host format. Returns false for
// every other format.
bool LookupEmulatedEtc2Format(VkFormat format, Etc2EmulatedFormat* out);
// Format features reported for an emulated ETC2/EAC format: the host format's
// sampling and transfer features only, as for a native compressed format.
VkFormatFeatureFlags EmulatedEtc2FormatFeatures(
VkFormatFeatureFlags host_features);
// Staging bytes consumed and decoded bytes produced by one 2D upload region.
// Returns false for an empty extent, a depth other than 1, or no layers.
bool Etc2UploadByteCounts(EtcFormat format, const VkExtent3D& extent,
std::uint32_t layer_count, VkDeviceSize* compressed,
VkDeviceSize* decoded);
// Whether emulated ETC2 is reported to the application as a supported
// feature, from the MOCKTAIL_ADVERTISE_ETC2 value: "0" hides it, anything
// else (or unset) reports it. Hidden ETC2 still decodes ETC2 images the
// application creates; it only steers the application toward other formats.
bool Etc2SupportAdvertised(const char* value);
bool Etc2SupportAdvertised();
// Factor applied to emulated ETC2 colour images no larger than
// kSmallTextureMaxExtent, from the MOCKTAIL_SMALL_TEXTURE_UPSCALE value:
// 1 leaves them alone; 2..8 create them that many times larger and resample
// every upload, so a texture override can carry more detail than the
// original. Unset or non-numeric values use kDefaultSmallTextureUpscale;
// numeric values out of range are clamped.
inline constexpr std::uint32_t kSmallTextureMaxExtent = 64;
inline constexpr std::uint32_t kDefaultSmallTextureUpscale = 4;
std::uint32_t SmallTextureUpscale(const char* value);
// Reports ETC2/EAC support on hosts without native ETC2 (desktop GPUs) and
// stores those textures decoded. Images are created with the host format;
// each staged upload into one is redirected to a host-visible staging buffer
// that is filled by decoding the application's staging bytes when the
// command buffer is submitted. Every submit decodes again, as a native copy
// re-reads its source on each execution.
// Staging buffers live until their command buffer is begun, reset or freed.
// MOCKTAIL_DISABLE_ETC2_EMULATION=1 turns the emulation off.
class VulkanEtc2Emulation final {
public:
VulkanEtc2Emulation();
~VulkanEtc2Emulation();
VulkanEtc2Emulation(const VulkanEtc2Emulation&) = delete;
VulkanEtc2Emulation& operator=(const VulkanEtc2Emulation&) = delete;
// True when this physical device lacks native ETC2 and emulation is on.
bool PhysicalDeviceNeedsEmulation(VkPhysicalDevice physical_device,
PFN_vkGetPhysicalDeviceFeatures host);
void RegisterDevice(VkDevice device, VkPhysicalDevice physical_device,
bool emulated,
const VkPhysicalDeviceMemoryProperties& memory,
PFN_vkGetDeviceProcAddr get_device_proc_addr);
void DestroyDevice(VkDevice device);
VkResult CreateImage(VkDevice device, const VkImageCreateInfo* create_info,
const VkAllocationCallbacks* allocator, VkImage* image);
void DestroyImage(VkDevice device, VkImage image,
const VkAllocationCallbacks* allocator);
VkResult CreateImageView(VkDevice device,
const VkImageViewCreateInfo* create_info,
const VkAllocationCallbacks* allocator,
VkImageView* view);
VkResult BindBufferMemory(VkDevice device, VkBuffer buffer,
VkDeviceMemory memory, VkDeviceSize offset);
VkResult BindBufferMemory2(VkDevice device, std::uint32_t count,
const VkBindBufferMemoryInfo* infos);
VkResult MapMemory(VkDevice device, VkDeviceMemory memory,
VkDeviceSize offset, VkDeviceSize size,
VkMemoryMapFlags flags, void** data);
VkResult MapMemory2(VkDevice device, const VkMemoryMapInfo* info,
void** data);
void UnmapMemory(VkDevice device, VkDeviceMemory memory);
VkResult UnmapMemory2(VkDevice device, const VkMemoryUnmapInfo* info);
void FreeMemory(VkDevice device, VkDeviceMemory memory,
const VkAllocationCallbacks* allocator);
void DestroyBuffer(VkDevice device, VkBuffer buffer,
const VkAllocationCallbacks* allocator);
void CmdCopyBufferToImage(VkDevice device, VkCommandBuffer command_buffer,
VkBuffer source, VkImage destination,
VkImageLayout layout, std::uint32_t region_count,
const VkBufferImageCopy* regions);
void CmdCopyBufferToImage2(VkDevice device, VkCommandBuffer command_buffer,
const VkCopyBufferToImageInfo2* info);
void CmdCopyImage(VkDevice device, VkCommandBuffer command_buffer,
VkImage source, VkImageLayout source_layout,
VkImage destination, VkImageLayout destination_layout,
std::uint32_t region_count, const VkImageCopy* regions);
void CmdCopyImage2(VkDevice device, VkCommandBuffer command_buffer,
const VkCopyImageInfo2* info);
void CmdExecuteCommands(VkDevice device, VkCommandBuffer command_buffer,
std::uint32_t count,
const VkCommandBuffer* secondaries);
// Decodes every upload recorded into these command buffers and the
// secondary command buffers they execute. Large batches decode on worker
// threads; this returns once every upload is decoded.
void PrepareSubmit(const VkCommandBuffer* command_buffers,
std::uint32_t count);
// Destroys the staging buffers owned by a command buffer that is no longer
// pending.
void ReleaseCommandBuffer(VkCommandBuffer command_buffer);
struct State;
private:
State* state_;
};
} // namespace mocktail::graphics
#endif // MOCKTAIL_GRAPHICS_VULKAN_ETC2_EMULATION_H_
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#ifndef MOCKTAIL_PLATFORM_SDL_APPLICATION_METADATA_H_
#define MOCKTAIL_PLATFORM_SDL_APPLICATION_METADATA_H_
@@ -6,9 +7,9 @@
namespace mocktail {
namespace platform {
inline constexpr char kMocktailApplicationName[] = "Mocktail";
inline constexpr char kMocktailApplicationName[] = "Nightcap";
inline constexpr char kMocktailApplicationIdentifier[] =
"space.bigrat.mocktail";
"io.github.CoderDayton.nightcap";
// Configures the stable compositor identity before SDL initializes. The
// identifier matches the installed desktop file and icon name so Wayland and
+28
View File
@@ -0,0 +1,28 @@
#ifndef MOCKTAIL_RUNTIME_DEVICE_MEMORY_PROFILE_H_
#define MOCKTAIL_RUNTIME_DEVICE_MEMORY_PROFILE_H_
#include <cstdint>
namespace mocktail {
namespace runtime {
// Android ActivityManager memory values published through DeviceParams.
// Roblox derives its device RAM tier, and tiered render budgets, from them.
struct DeviceMemoryProfile {
std::int32_t total_memory_mb = 0;
std::int32_t memory_class_mb = 0;
std::int32_t large_memory_class_mb = 0;
std::int64_t low_memory_killer_background_threshold = 0;
std::int64_t low_memory_killer_foreground_threshold = 0;
bool low_ram_device = false;
};
// Hosts with at least 4 GiB report their real total memory as a normal-RAM
// device. Smaller hosts, or an unreadable total (0), keep the 2 GiB low-RAM
// profile.
DeviceMemoryProfile BuildDeviceMemoryProfile(std::uint64_t host_memory_bytes);
} // namespace runtime
} // namespace mocktail
#endif // MOCKTAIL_RUNTIME_DEVICE_MEMORY_PROFILE_H_
+73
View File
@@ -0,0 +1,73 @@
#ifndef MOCKTAIL_RUNTIME_DISPLAY_SIZE_H_
#define MOCKTAIL_RUNTIME_DISPLAY_SIZE_H_
#include <cstdint>
#include <limits>
namespace mocktail {
namespace runtime {
// Host display or window size in physical pixels, published to the Android
// guest. Header-only so the JNI VM can use it without link dependencies.
struct DisplaySize {
std::int32_t width = 1920;
std::int32_t height = 1080;
};
// Environment handoffs written after the host window exists, as
// "WIDTHxHEIGHT": the window's display mode and the window's initial pixels.
inline constexpr const char* kDisplaySizeEnvironment =
"MOCKTAIL_DISPLAY_SIZE_INTERNAL";
inline constexpr const char* kWindowSizeEnvironment =
"MOCKTAIL_WINDOW_SIZE_INTERNAL";
// Parses "WIDTHxHEIGHT". A null, malformed or non-positive value, or one that
// does not fit a Java int, yields the 1920x1080 fallback.
inline DisplaySize ParseDisplaySize(const char* value) {
const DisplaySize fallback;
if (value == nullptr) {
return fallback;
}
std::int64_t parts[2] = {0, 0};
const char* cursor = value;
for (int index = 0; index < 2; ++index) {
if (*cursor < '0' || *cursor > '9') {
return fallback;
}
std::int64_t parsed = 0;
while (*cursor >= '0' && *cursor <= '9') {
parsed = parsed * 10 + (*cursor - '0');
if (parsed > std::numeric_limits<std::int32_t>::max()) {
return fallback;
}
++cursor;
}
if (parsed == 0) {
return fallback;
}
parts[index] = parsed;
if (index == 0) {
if (*cursor != 'x') {
return fallback;
}
++cursor;
}
}
if (*cursor != '\0') {
return fallback;
}
return {static_cast<std::int32_t>(parts[0]),
static_cast<std::int32_t>(parts[1])};
}
// Physical length of a pixel span at the guest's fixed 160 dpi, rounded down
// to whole millimetres.
inline std::int32_t PixelsToMillimetersAt160Dpi(std::int32_t pixels) {
return static_cast<std::int32_t>(static_cast<std::int64_t>(pixels) * 254 /
1600);
}
} // namespace runtime
} // namespace mocktail
#endif // MOCKTAIL_RUNTIME_DISPLAY_SIZE_H_
+23
View File
@@ -0,0 +1,23 @@
# Local git hooks. Install once with: lefthook install
# Mirrors the "Repository contracts" job in .github/workflows/ci.yml.
pre-commit:
parallel: true
commands:
shell-syntax:
glob: "{scripts,tests,packaging}/**/*.sh"
run: for f in {staged_files}; do bash -n "$f" || exit 1; done
json:
glob: "{config,packaging}/**/*.json"
run: for f in {staged_files}; do jq empty "$f" || exit 1; done
desktop-entry:
glob: "*.desktop"
run: desktop-file-validate {staged_files}
pre-push:
commands:
packaging-contracts:
run: >-
bash tests/managed_payload_build_contract_test.sh . &&
bash tests/flatpak_packaging_test.sh . &&
bash tests/native_packaging_test.sh .
+8 -7
View File
@@ -1,11 +1,12 @@
# pkgforge-dev/archlinux-pkgs-debloated, continuous release, 2026-09-12.
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# pkgforge-dev/archlinux-pkgs-debloated, continuous release, 2026-09-15.
# These assets are rolling. Refresh names/hashes together; do not bypass a
# checksum mismatch. Only the disposable AppImage build container installs them.
0bc7a050142b9e39e85035171c4c7a35ded6cada85e541ada8a04c812847a4b3 ffmpeg-mini-x86_64.pkg.tar.zst
7d033d304468bcf71798e93ef482f6eee9751ec73d9fce2d119714425c8dfa9e gdk-pixbuf2-mini-x86_64.pkg.tar.zst
eb87771dabc819b318e0ddf94e7ea175a662c1b6fbe748661126c520a0fd4627 ffmpeg-mini-x86_64.pkg.tar.zst
e62d30173cc87d3a717a218610c9291b9f647b29b99ee86a0a591226c39a0728 gdk-pixbuf2-mini-x86_64.pkg.tar.zst
ca18bc00a343650cde3d674135fa482b54faa639017f82792906db8c68ca9fb6 gtk4-mini-x86_64.pkg.tar.zst
5c178d1d0be438fda3f87efdb3d65eddf68187738fdfe1e1c563e46ce540ac8b icu-mini-x86_64.pkg.tar.zst
8500f31bb0f793d159d58f2e428594baba63f0c1a0276394c5a3f1ac1da422ef icu-mini-x86_64.pkg.tar.zst
3d51ee49d0e49a065971703b3f61b610bd1c307cd5165ec16846d75f3efe4a08 librsvg-mini-x86_64.pkg.tar.zst
217bbd71516e8d0678d9c1c052a4370e07ca05525cfe9f8f844837a2554a03fc libxml2-mini-x86_64.pkg.tar.zst
1952bc61dcbf7c880203c67d0df2b8fe4f77805abd0fe34f7552e87b8567fd3e mesa-mini-x86_64.pkg.tar.zst
8c24921b4c4fe8b0e08ccdeb6c46e755fafa9f3665ab98ad77fc37dc048732b0 opus-mini-x86_64.pkg.tar.zst
fd52222372202ac7d37ff3f6ef0a47b0decee224aab37ac2b24086fb623b8b86 libxml2-mini-x86_64.pkg.tar.zst
da5598b3f8e3a33ba0811c225752466a1abd3821053a19b480410937454feb04 mesa-mini-x86_64.pkg.tar.zst
ca23eed050345d8c3f45a21610f91aecc273569b09d8d6eed574014e2e560d89 opus-mini-x86_64.pkg.tar.zst
@@ -1,5 +1,5 @@
{
"app-id": "space.bigrat.mocktail",
"app-id": "io.github.CoderDayton.nightcap",
"runtime": "org.gnome.Platform",
"runtime-version": "50",
"sdk": "org.gnome.Sdk",
+8 -8
View File
@@ -1,3 +1,4 @@
<!-- Modified by vii from komaruworld/mocktail. See the top-level README "About this fork". -->
# FreeBSD Linuxulator
FreeBSD Linuxulator support is experimental. I tested it on FreeBSD
@@ -15,7 +16,7 @@ tested source revision is `aadd58dddcbc78f4d5594827b46b5633552b15ce`. Run
the following commands as root.
```sh
fetch -o /root/linuxulator.patch https://raw.githubusercontent.com/komaruworld/mocktail/main/packaging/freebsd/linuxulator.patch
fetch -o /root/linuxulator.patch https://raw.githubusercontent.com/CoderDayton/nightcap/main/packaging/freebsd/linuxulator.patch
cd /usr/src
git apply /root/linuxulator.patch
make -j2 kernel-toolchain
@@ -40,11 +41,10 @@ After reboot, verify the result from the Fedora userspace. It must print
chroot /compat/linux stat -f -c %t /proc
```
## Run Mocktail
## Run Nightcap
You can simply run the Mocktail AppImage from the
[latest release](https://github.com/komaruworld/mocktail/releases/latest) or
[nightly build](https://github.com/komaruworld/mocktail/releases/tag/continuous)
You can simply run the Nightcap AppImage from the
[latest release](https://github.com/CoderDayton/nightcap/releases/latest)
inside the Fedora userspace.
## Audio
@@ -72,11 +72,11 @@ ctl.!default {
EOF
```
Launch Mocktail with the ALSA audio driver.
Launch Nightcap with the ALSA audio driver.
```sh
SDL_AUDIO_DRIVER=alsa ./Mocktail-x86_64.AppImage
SDL_AUDIO_DRIVER=alsa ./Nightcap-x86_64.AppImage
```
Mocktail cannot override this check because Roblox reads `/proc` directly. The
Nightcap cannot override this check because Roblox reads `/proc` directly. The
Linuxulator patch fixes the value before Roblox sees it.
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 903 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

@@ -0,0 +1,13 @@
# Modified by vii from komaruworld/mocktail. See README "About this fork".
[Desktop Entry]
Type=Application
Name=Nightcap
GenericName=Roblox Player
Comment=Play Roblox on Linux
Exec=env SDL_VIDEODRIVER=wayland,x11 mocktail %u
Icon=io.github.CoderDayton.nightcap
StartupWMClass=io.github.CoderDayton.nightcap
Categories=Game;
Terminal=false
MimeType=x-scheme-handler/roblox;x-scheme-handler/roblox-player;
X-Mocktail-Managed=true
@@ -1,20 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Modified by vii from komaruworld/mocktail. See README "About this fork". -->
<!-- Copyright 2026 Mocktail Project Authors -->
<!-- SPDX-License-Identifier: CC0-1.0 -->
<component type="desktop-application">
<id>space.bigrat.mocktail</id>
<name>Mocktail</name>
<id>io.github.CoderDayton.nightcap</id>
<name>Nightcap</name>
<summary>Play Roblox on Linux</summary>
<metadata_license>CC0-1.0</metadata_license>
<project_license>Apache-2.0</project_license>
<developer id="space.bigrat">
<name>Mocktail Project Authors</name>
<developer id="io.github.coderdayton">
<name>vii</name>
</developer>
<branding>
<color type="primary" scheme_preference="light">#CEB3EF</color>
<color type="primary" scheme_preference="dark">#2F2A6B</color>
</branding>
<url type="homepage">https://github.com/komaruworld/mocktail</url>
<url type="homepage">https://github.com/CoderDayton/nightcap</url>
<description>
<p>
Sign in to Roblox, browse experiences, and play them on Linux.
@@ -38,7 +39,7 @@
<caption>Play DOORS on Linux</caption>
</screenshot>
</screenshots>
<launchable type="desktop-id">space.bigrat.mocktail.desktop</launchable>
<launchable type="desktop-id">io.github.CoderDayton.nightcap.desktop</launchable>
<content_rating type="oars-1.1">
<content_attribute id="violence-cartoon">moderate</content_attribute>
<content_attribute id="violence-fantasy">moderate</content_attribute>
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Modified by vii from komaruworld/mocktail. See README "About this fork". -->
<!-- Copyright 2026 Mocktail Project Authors -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<svg xmlns="http://www.w3.org/2000/svg"
@@ -6,7 +7,7 @@
height="512"
viewBox="96 96 320 320"
fill="none">
<title>Mocktail</title>
<title>Nightcap</title>
<mask id="mocktail-mark"
mask-type="alpha"
maskUnits="userSpaceOnUse"
@@ -19,12 +20,12 @@
</mask>
<g mask="url(#mocktail-mark)">
<path d="M461.343 267.246L461.165 265.65L444.708 108.145C444.345 105.047 443.009 102.143 440.894 99.8515C438.769 97.5865 436.001 96.028 432.962 95.3864C429.924 94.7448 426.761 95.051 423.903 96.2637C421.056 97.5364 418.67 99.6554 417.07 102.332L356.5 146L206 108.145L193.521 42.4325C193.5 39.3045 192.493 36.2626 190.644 33.7398C188.774 31.2601 186.189 29.4138 183.237 28.4502C180.285 27.4866 177.108 27.4521 174.135 28.3513C171.161 29.2864 168.555 31.1314 166.685 33.6262L73.5931 161.71L72.6616 163.009C59.2667 181.485 52.2413 203.814 52.6444 226.631C53.0476 249.448 60.8576 271.515 74.8967 289.505L75.0459 289.702L75.453 290.192L142.096 374.97L174.978 417.241L195.02 442.943C197.361 445.962 200.625 448.131 204.315 449.12C208.005 450.109 211.918 449.862 215.455 448.418L245.662 436.181L295.274 416.014L395.981 375.674L396.235 375.562C417.35 366.989 435.112 351.794 446.852 332.262C458.593 312.73 463.678 289.915 461.343 267.246Z"
fill="#E24329"/>
fill="#2F2A6B"/>
<path d="M461.403 267.484L461.225 265.887C433.09 264.216 404.933 268.779 378.766 279.25L234.209 337.935C266.844 379.87 295.27 416.324 295.27 416.324L403.5 418L396.231 375.873C417.371 367.306 435.156 352.105 446.91 332.557C458.664 313.009 463.75 290.172 461.403 267.484Z"
fill="#FC6D26"/>
fill="#6C4FD1"/>
<path d="M142.135 375.279L175.016 417.549L195.058 443.252C197.399 446.271 200.664 448.44 204.354 449.429C208.044 450.418 211.956 450.171 215.493 448.727L245.701 436.489L295.313 416.323C295.313 416.323 266.867 379.774 234.21 337.922C185.002 357.838 142.135 375.279 142.135 375.279Z"
fill="#FCA326"/>
fill="#A78BFA"/>
<path d="M138.341 214.829C120.941 192.647 98.8514 174.589 73.6535 161.948L72.722 163.247C59.3272 181.723 52.3017 204.052 52.7049 226.869C53.1081 249.685 60.918 271.752 74.9572 289.743L75.1064 289.94L41.5 337.851L142.156 375.208C142.156 375.208 184.959 357.839 234.232 337.851L138.341 214.829Z"
fill="#FC6D26"/>
fill="#6C4FD1"/>
</g>
</svg>
-12
View File
@@ -1,12 +0,0 @@
[Desktop Entry]
Type=Application
Name=Mocktail
GenericName=Roblox Player
Comment=Play Roblox on Linux
Exec=mocktail %u
Icon=space.bigrat.mocktail
StartupWMClass=space.bigrat.mocktail
Categories=Game;
Terminal=false
MimeType=x-scheme-handler/roblox;x-scheme-handler/roblox-player;
X-Mocktail-Managed=true
+23 -40
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# SPDX-License-Identifier: Apache-2.0
@@ -9,8 +10,8 @@ readonly REPOSITORY="${1:?Flatpak repository path is required}"
readonly BUNDLE="${2:?Flatpak bundle path is required}"
readonly PUBLIC_KEY="${3:?GPG public key path is required}"
readonly OUTPUT="${4:?Pages output path is required}"
readonly NATIVE_REPOSITORIES="${5:?Native repositories path is required}"
readonly BASE_URL="https://mocktail.bigrat.space"
readonly BASE_URL="https://coderdayton.github.io/nightcap"
readonly APP_ID="io.github.CoderDayton.nightcap"
readonly SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
readonly PROJECT_DIR="$(dirname -- "${SCRIPT_DIR}")"
@@ -26,13 +27,6 @@ readonly PROJECT_DIR="$(dirname -- "${SCRIPT_DIR}")"
printf 'Flatpak public key is missing or unsafe: %s\n' "${PUBLIC_KEY}" >&2
exit 1
}
[[ -d "${NATIVE_REPOSITORIES}/apt" &&
-d "${NATIVE_REPOSITORIES}/rpm" &&
-d "${NATIVE_REPOSITORIES}/downloads" &&
-s "${NATIVE_REPOSITORIES}/mocktail-packages.gpg" ]] || {
printf 'Native repositories are missing: %s\n' "${NATIVE_REPOSITORIES}" >&2
exit 1
}
[[ ! -e "${OUTPUT}" ]] || {
printf 'Pages output already exists: %s\n' "${OUTPUT}" >&2
exit 1
@@ -40,50 +34,39 @@ readonly PROJECT_DIR="$(dirname -- "${SCRIPT_DIR}")"
mkdir -p -- "${OUTPUT}"
cp -a -- "${REPOSITORY}" "${OUTPUT}/repo"
install -m 0644 -- "${BUNDLE}" "${OUTPUT}/Mocktail-x86_64.flatpak"
install -m 0644 -- "${PUBLIC_KEY}" "${OUTPUT}/mocktail-flatpak.gpg"
install -m 0644 -- "${BUNDLE}" "${OUTPUT}/Nightcap-x86_64.flatpak"
install -m 0644 -- "${PUBLIC_KEY}" "${OUTPUT}/nightcap-flatpak.gpg"
install -m 0644 -- \
"${PROJECT_DIR}/packaging/space.bigrat.mocktail.svg" \
"${OUTPUT}/mocktail.svg"
install -m 0644 -- \
"${PROJECT_DIR}/packaging/discord-join.html" \
"${OUTPUT}/join.html"
install -m 0644 -- "${PROJECT_DIR}/site/index.html" "${OUTPUT}/index.html"
install -m 0644 -- "${PROJECT_DIR}/site/styles.css" "${OUTPUT}/styles.css"
install -d -- "${OUTPUT}/packaging"
install -m 0644 -- \
"${PROJECT_DIR}/packaging/space.bigrat.mocktail.svg" \
"${OUTPUT}/packaging/space.bigrat.mocktail.svg"
cp -a -- "${NATIVE_REPOSITORIES}/apt" "${OUTPUT}/apt"
cp -a -- "${NATIVE_REPOSITORIES}/rpm" "${OUTPUT}/rpm"
cp -a -- "${NATIVE_REPOSITORIES}/downloads" "${OUTPUT}/downloads"
install -m 0644 -- \
"${NATIVE_REPOSITORIES}/mocktail-packages.gpg" \
"${OUTPUT}/mocktail-packages.gpg"
"${PROJECT_DIR}/packaging/${APP_ID}.svg" \
"${OUTPUT}/nightcap.svg"
touch -- "${OUTPUT}/.nojekyll"
readonly GPG_KEY="$(base64 --wrap=0 "${PUBLIC_KEY}")"
cat >"${OUTPUT}/mocktail.flatpakrepo" <<EOF
cat >"${OUTPUT}/nightcap.flatpakrepo" <<EOF
[Flatpak Repo]
Title=Mocktail Nightly
Title=Nightcap
Url=${BASE_URL}/repo/
Homepage=https://github.com/komaruworld/mocktail
Comment=Nightly builds of Mocktail
Description=Signed x86_64 nightly builds published from the latest Mocktail main branch
Icon=${BASE_URL}/mocktail.svg
Homepage=https://github.com/CoderDayton/nightcap
Comment=Nightcap releases
Description=Signed x86_64 release builds of Nightcap
Icon=${BASE_URL}/nightcap.svg
GPGKey=${GPG_KEY}
EOF
cat >"${OUTPUT}/mocktail.flatpakref" <<EOF
cat >"${OUTPUT}/nightcap.flatpakref" <<EOF
[Flatpak Ref]
Title=Mocktail Nightly
Name=space.bigrat.mocktail
Title=Nightcap
Name=${APP_ID}
Branch=stable
Url=${BASE_URL}/repo/
RuntimeRepo=https://dl.flathub.org/repo/flathub.flatpakrepo
Homepage=https://github.com/komaruworld/mocktail
Comment=Nightly build from the latest main branch
Icon=${BASE_URL}/mocktail.svg
Homepage=https://github.com/CoderDayton/nightcap
Comment=Roblox on Linux, tuned for a real PC
Icon=${BASE_URL}/nightcap.svg
GPGKey=${GPG_KEY}
IsRuntime=false
EOF
install -m 0644 -- "${PROJECT_DIR}/site/index.html" "${OUTPUT}/index.html"
install -m 0644 -- "${PROJECT_DIR}/site/styles.css" "${OUTPUT}/styles.css"
+2 -1
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# SPDX-License-Identifier: Apache-2.0
@@ -8,7 +9,7 @@ readonly SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
readonly PROJECT_ROOT="$(cd -- "${SCRIPT_DIR}/.." && pwd -P)"
BUILD_DIR="${PROJECT_ROOT}/build-flatpak"
MANIFEST="${PROJECT_ROOT}/packaging/flatpak/space.bigrat.mocktail.json"
MANIFEST="${PROJECT_ROOT}/packaging/flatpak/io.github.CoderDayton.nightcap.json"
JOBS="${MOCKTAIL_FLATPAK_JOBS:-4}"
Usage() {
+3 -2
View File
@@ -1,13 +1,14 @@
#!/usr/bin/env bash
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# SPDX-License-Identifier: Apache-2.0
set -euo pipefail
readonly project_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
readonly source_icon="${project_root}/packaging/space.bigrat.mocktail.svg"
readonly source_icon="${project_root}/packaging/io.github.CoderDayton.nightcap.svg"
readonly output_root="${project_root}/packaging/icons/hicolor"
readonly icon_name="space.bigrat.mocktail.png"
readonly icon_name="io.github.CoderDayton.nightcap.png"
readonly icon_sizes=(16 22 24 32 36 48 64 72 96 128 192 256 512)
if ! command -v magick >/dev/null 2>&1; then
+3 -2
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# SPDX-License-Identifier: Apache-2.0
@@ -152,8 +153,8 @@ AnyLinuxDeploy() {
local -a deployment_environment=(
"APPDIR=${app_dir}" "MAIN_BIN=mocktail" "LIB_DIR=/usr/lib"
"TMPDIR=${ANYLINUX_WORK}/tmp"
"DESKTOP=/usr/share/applications/space.bigrat.mocktail.desktop"
"ICON=/usr/share/icons/hicolor/scalable/apps/space.bigrat.mocktail.svg"
"DESKTOP=/usr/share/applications/io.github.CoderDayton.nightcap.desktop"
"ICON=/usr/share/icons/hicolor/scalable/apps/io.github.CoderDayton.nightcap.svg"
"DEPLOY_DATADIR=0" "DEPLOY_LOCALE=0" "DEPLOY_VULKAN=0"
"STRACE_MODE=1" "STRACE_BINARY=mocktail" "STRACE_FLAGS=--help"
"STRACE_TIME=1"
+11 -10
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -920,25 +921,25 @@ BuildAppImage() {
ln -s "share/mocktail-bundle/run.sh" "${APPDIR}/usr/mocktail"
install -m 0755 -- "${PROJECT_ROOT}/packaging/AppRun" "${APPDIR}/AppRun"
install -m 0644 -- \
"${PROJECT_ROOT}/packaging/space.bigrat.mocktail.desktop" \
"${APPDIR}/space.bigrat.mocktail.desktop"
"${PROJECT_ROOT}/packaging/io.github.CoderDayton.nightcap.desktop" \
"${APPDIR}/io.github.CoderDayton.nightcap.desktop"
install -m 0644 -- \
"${PROJECT_ROOT}/packaging/space.bigrat.mocktail.desktop" \
"${APPDIR}/usr/share/applications/space.bigrat.mocktail.desktop"
"${PROJECT_ROOT}/packaging/io.github.CoderDayton.nightcap.desktop" \
"${APPDIR}/usr/share/applications/io.github.CoderDayton.nightcap.desktop"
install -m 0644 -- \
"${PROJECT_ROOT}/packaging/space.bigrat.mocktail.svg" \
"${APPDIR}/space.bigrat.mocktail.svg"
"${PROJECT_ROOT}/packaging/io.github.CoderDayton.nightcap.svg" \
"${APPDIR}/io.github.CoderDayton.nightcap.svg"
install -m 0644 -- \
"${PROJECT_ROOT}/packaging/space.bigrat.mocktail.svg" \
"${APPDIR}/usr/share/icons/hicolor/scalable/apps/space.bigrat.mocktail.svg"
"${PROJECT_ROOT}/packaging/io.github.CoderDayton.nightcap.svg" \
"${APPDIR}/usr/share/icons/hicolor/scalable/apps/io.github.CoderDayton.nightcap.svg"
for icon_path in \
"${PROJECT_ROOT}"/packaging/icons/hicolor/*x*/apps/space.bigrat.mocktail.png; do
"${PROJECT_ROOT}"/packaging/icons/hicolor/*x*/apps/io.github.CoderDayton.nightcap.png; do
[[ -f "${icon_path}" ]] || Die "hicolor icon set is incomplete"
icon_relative_path="${icon_path#"${PROJECT_ROOT}/packaging/icons/hicolor/"}"
install -D -m 0644 -- "${icon_path}" \
"${APPDIR}/usr/share/icons/hicolor/${icon_relative_path}"
done
ln -s space.bigrat.mocktail.svg "${APPDIR}/.DirIcon"
ln -s io.github.CoderDayton.nightcap.svg "${APPDIR}/.DirIcon"
mkdir -p -- "$(dirname -- "${APPIMAGE_OUTPUT}")"
ARCH=x86_64 appimagetool "${APPDIR}" "${APPIMAGE_OUTPUT}"
rm -rf -- "${APPDIR}"
+7 -4
View File
@@ -1,11 +1,12 @@
#!/usr/bin/env bash
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# SPDX-License-Identifier: Apache-2.0
set -Eeuo pipefail
umask 077
readonly DESKTOP_ID="space.bigrat.mocktail.desktop"
readonly DESKTOP_ID="io.github.CoderDayton.nightcap.desktop"
readonly ROBLOX_SCHEME="x-scheme-handler/roblox"
readonly ROBLOX_PLAYER_SCHEME="x-scheme-handler/roblox-player"
@@ -139,8 +140,9 @@ desktop_source="$(ResolveRegularFile "${desktop_source}" "desktop template")"
[[ "$(grep -Fxc '[Desktop Entry]' "${desktop_source}")" == 1 &&
"$(grep -Fxc 'Type=Application' "${desktop_source}")" == 1 &&
"$(grep -Fxc 'Icon=space.bigrat.mocktail' "${desktop_source}")" == 1 &&
"$(grep -Fxc 'Exec=mocktail %u' "${desktop_source}")" == 1 &&
"$(grep -Fxc 'Icon=io.github.CoderDayton.nightcap' "${desktop_source}")" == 1 &&
"$(grep -Fxc 'Exec=env SDL_VIDEODRIVER=wayland,x11 mocktail %u' \
"${desktop_source}")" == 1 &&
"$(grep -Fxc 'MimeType=x-scheme-handler/roblox;x-scheme-handler/roblox-player;' \
"${desktop_source}")" == 1 &&
"$(grep -Fxc 'X-Mocktail-Managed=true' "${desktop_source}")" == 1 &&
@@ -173,7 +175,8 @@ temporary="$(mktemp "${applications_dir}/.${DESKTOP_ID}.XXXXXX.desktop")"
trap 'rm -f -- "${temporary}"' EXIT
while IFS= read -r line || [[ -n "${line}" ]]; do
if [[ "${line}" == Exec=* ]]; then
printf 'Exec=%s %%u\n' "${mocktail_executable}"
printf 'Exec=env SDL_VIDEODRIVER=wayland,x11 %s %%u\n' \
"${mocktail_executable}"
if [[ -n "${launch_working_directory}" ]]; then
printf 'Path=%s\n' "${launch_working_directory}"
fi
+33 -54
View File
@@ -1,70 +1,49 @@
<!doctype html>
<!-- Modified by vii from komaruworld/mocktail. See README "About this fork". -->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="dark">
<title>Mocktail for Linux</title>
<title>Nightcap for Linux</title>
<link rel="icon" href="nightcap.svg" type="image/svg+xml">
<link rel="stylesheet" href="styles.css">
</head>
<body><main>
<img src="../packaging/space.bigrat.mocktail.svg" alt="Mocktail logo">
<h1>Mocktail</h1>
<p>Play Roblox on Linux. Use the stable Flathub release, or try the latest nightly build from main.</p>
<a class="button" href="https://flathub.org/apps/space.bigrat.mocktail">Stable on Flathub</a>
<a class="button secondary" href="https://mocktail.bigrat.space/mocktail.flatpakref">Nightly build</a>
<img src="nightcap.svg" alt="Nightcap logo">
<h1>Nightcap</h1>
<p>Play Roblox on Linux like it was made for your PC. Nightcap is Mocktail, tuned to feel fast and look sharp.</p>
<a class="button" href="https://github.com/CoderDayton/nightcap/releases/latest/download/Nightcap-x86_64.AppImage">Download AppImage</a>
<a class="button secondary" href="nightcap.flatpakref">Install with Flatpak</a>
<div class="commands">
<p>Stable</p>
<code>flatpak install flathub space.bigrat.mocktail</code>
<p>Nightly</p>
<code>flatpak install --user https://mocktail.bigrat.space/mocktail.flatpakref</code>
</div>
<h2>AUR packages</h2>
<p>Available from the AUR. Choose one package:</p>
<p class="links">
<a href="https://aur.archlinux.org/packages/mocktail">mocktail</a>
<a href="https://aur.archlinux.org/packages/mocktail-bin">mocktail-bin</a>
<a href="https://aur.archlinux.org/packages/mocktail-git">mocktail-git</a>
</p>
<code>yay -S mocktail
yay -S mocktail-bin
yay -S mocktail-git</code>
<h2>DNF repository</h2>
<p>Stable and nightly packages for Fedora 44. Choose one package.</p>
<code>sudo curl -fsSL https://mocktail.bigrat.space/rpm/mocktail.repo -o /etc/yum.repos.d/mocktail.repo</code>
<div class="commands">
<p>Stable</p>
<code>sudo dnf install mocktail</code>
<p>Nightly</p>
<code>sudo dnf install mocktail-nightly</code>
</div>
<h2>APT repository</h2>
<p>Stable and nightly packages for Ubuntu 26.04. Choose one package.</p>
<code>sudo install -d -m 0755 /etc/apt/keyrings
sudo curl -fsSL https://mocktail.bigrat.space/mocktail-packages.gpg -o /etc/apt/keyrings/mocktail.gpg
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/mocktail.gpg] https://mocktail.bigrat.space/apt mocktail main" | sudo tee /etc/apt/sources.list.d/mocktail.list &gt;/dev/null
sudo apt update</code>
<div class="commands">
<p>Stable</p>
<code>sudo apt install mocktail</code>
<p>Nightly</p>
<code>sudo apt install mocktail-nightly</code>
<p>AppImage</p>
<code>chmod +x Nightcap-x86_64.AppImage
./Nightcap-x86_64.AppImage</code>
<p>Flatpak</p>
<code>flatpak install --user https://coderdayton.github.io/nightcap/nightcap.flatpakref
flatpak run io.github.CoderDayton.nightcap</code>
<p>Build from source</p>
<code>git clone --recurse-submodules https://github.com/CoderDayton/nightcap.git
cd nightcap &amp;&amp; make build
./build/mocktail</code>
</div>
<h2>What's different</h2>
<ul>
<li>Lower input lag. Frames are shown as soon as they are ready.</li>
<li>Sharper textures, with your own PNG overrides if you want them.</li>
<li>ETC2 textures render correctly on desktop GPUs.</li>
<li>No more error 319 kicks after joining a server.</li>
<li>Roblox sees your real RAM and screen size.</li>
</ul>
<h2>Direct downloads</h2>
<p>Prebuilt packages for Linux x86_64.</p>
<p class="download-label">Stable</p>
<p>Prebuilt builds for Linux x86_64.</p>
<p class="links">
<a href="https://github.com/komaruworld/mocktail/releases/latest/download/Mocktail-x86_64.AppImage">AppImage</a>
<a href="https://mocktail.bigrat.space/downloads/mocktail.deb">DEB</a>
<a href="https://mocktail.bigrat.space/downloads/mocktail.rpm">RPM</a>
<a href="https://github.com/CoderDayton/nightcap/releases/latest/download/Nightcap-x86_64.AppImage">AppImage</a>
<a href="Nightcap-x86_64.flatpak">Flatpak bundle</a>
<a href="nightcap-flatpak.gpg">Signing key</a>
</p>
<p class="download-label">Nightly</p>
<p class="links">
<a href="https://github.com/komaruworld/mocktail/releases/download/continuous/mocktail-nightly.AppImage">AppImage</a>
<a href="https://github.com/komaruworld/mocktail/releases/download/continuous/mocktail-nightly.deb">DEB</a>
<a href="https://github.com/komaruworld/mocktail/releases/download/continuous/mocktail-nightly.rpm">RPM</a>
</p>
<p><a class="source" href="https://github.com/komaruworld/mocktail">Source code</a></p>
<p>Mocktail is an independent community project and is not affiliated with Roblox Corporation.</p>
<p><a class="source" href="https://github.com/CoderDayton/nightcap">Source code</a> ·
<a class="source" href="https://github.com/komaruworld/mocktail">Upstream Mocktail</a></p>
<p>Nightcap is an independent community project and is not affiliated with Roblox Corporation.</p>
</main></body>
</html>
+17 -11
View File
@@ -1,3 +1,4 @@
/* Modified by vii from komaruworld/mocktail. See README "About this fork". */
:root {
font: 17px/1.55 system-ui, sans-serif;
color-scheme: dark;
@@ -5,8 +6,8 @@
body {
margin: 0;
background: #0d1117;
color: #e6edf3;
background: #14122b;
color: #ece8ff;
}
main {
@@ -30,8 +31,13 @@ h2 {
font-size: 1.15rem;
}
p {
color: #9da7b3;
p,
li {
color: #b3aad6;
}
ul {
padding-left: 1.2rem;
}
a.button {
@@ -39,14 +45,14 @@ a.button {
margin: 16px 8px 16px 0;
padding: 12px 18px;
border-radius: 9px;
background: #238636;
background: #6c4fd1;
color: white;
font-weight: 700;
text-decoration: none;
}
a.secondary {
background: #21262d;
background: #2f2a6b;
}
.commands {
@@ -56,7 +62,7 @@ a.secondary {
.commands p,
.download-label {
margin: 14px 0 5px;
color: #e6edf3;
color: #ece8ff;
font-size: .82rem;
font-weight: 700;
letter-spacing: .04em;
@@ -67,9 +73,9 @@ code {
display: block;
padding: 14px;
overflow-wrap: anywhere;
border: 1px solid #30363d;
border: 1px solid #3a3470;
border-radius: 6px;
background: #161b22;
background: #1d1a3d;
white-space: pre-wrap;
}
@@ -80,9 +86,9 @@ code {
.links a {
display: inline-block;
margin: 0 14px 6px 0;
color: #e6edf3;
color: #a78bfa;
}
a.source {
color: #e6edf3;
color: #a78bfa;
}
+460 -5
View File
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
// Android Vulkan loader ABI -> host Vulkan loader + SDL3 WSI.
#include <dlfcn.h>
@@ -17,6 +18,7 @@
#include "mocktail/graphics/android_vulkan_wsi_adapter.h"
#include "mocktail/graphics/present_mode_policy.h"
#include "mocktail/graphics/vulkan_etc2_emulation.h"
#include "mocktail/graphics/vulkan_text_overlay_compositor.h"
#include "mocktail/platform/platform_runtime.h"
@@ -188,6 +190,7 @@ struct AdapterState {
VkInstance latest_instance = VK_NULL_HANDLE;
size_t active_instance_count = 0;
mocktail::graphics::VulkanTextOverlayCompositor text_overlay;
mocktail::graphics::VulkanEtc2Emulation etc2;
std::atomic<NotePresentFn> note_present{nullptr};
std::atomic<NoteHostPresentBeginFn> note_host_present_begin{nullptr};
std::atomic<NoteHostPresentEndFn> note_host_present_end{nullptr};
@@ -727,12 +730,92 @@ PFN_vkVoidFunction AdapterProc(const char* name) {
MOCKTAIL_VK_PROC(vkQueueWaitIdle)
MOCKTAIL_VK_PROC(vkDeviceWaitIdle)
MOCKTAIL_VK_PROC(vkQueuePresentKHR)
MOCKTAIL_VK_PROC(vkGetPhysicalDeviceFeatures)
MOCKTAIL_VK_PROC(vkGetPhysicalDeviceFeatures2)
MOCKTAIL_VK_PROC(vkGetPhysicalDeviceFormatProperties)
MOCKTAIL_VK_PROC(vkGetPhysicalDeviceFormatProperties2)
MOCKTAIL_VK_PROC(vkGetPhysicalDeviceImageFormatProperties)
MOCKTAIL_VK_PROC(vkGetPhysicalDeviceImageFormatProperties2)
MOCKTAIL_VK_PROC(vkCreateImage)
MOCKTAIL_VK_PROC(vkDestroyImage)
MOCKTAIL_VK_PROC(vkCreateImageView)
MOCKTAIL_VK_PROC(vkBindBufferMemory)
MOCKTAIL_VK_PROC(vkBindBufferMemory2)
MOCKTAIL_VK_PROC(vkMapMemory)
MOCKTAIL_VK_PROC(vkMapMemory2)
MOCKTAIL_VK_PROC(vkUnmapMemory)
MOCKTAIL_VK_PROC(vkUnmapMemory2)
MOCKTAIL_VK_PROC(vkFreeMemory)
MOCKTAIL_VK_PROC(vkDestroyBuffer)
MOCKTAIL_VK_PROC(vkCmdCopyBufferToImage)
MOCKTAIL_VK_PROC(vkCmdCopyImage)
MOCKTAIL_VK_PROC(vkCmdCopyImage2)
MOCKTAIL_VK_PROC(vkCmdCopyBufferToImage2)
MOCKTAIL_VK_PROC(vkCmdExecuteCommands)
#undef MOCKTAIL_VK_PROC
#define MOCKTAIL_VK_ALIAS(alias, function) \
if (std::strcmp(name, #alias) == 0) { \
return reinterpret_cast<PFN_vkVoidFunction>(function); \
}
MOCKTAIL_VK_ALIAS(vkGetPhysicalDeviceFeatures2KHR,
vkGetPhysicalDeviceFeatures2)
MOCKTAIL_VK_ALIAS(vkGetPhysicalDeviceFormatProperties2KHR,
vkGetPhysicalDeviceFormatProperties2)
MOCKTAIL_VK_ALIAS(vkGetPhysicalDeviceImageFormatProperties2KHR,
vkGetPhysicalDeviceImageFormatProperties2)
MOCKTAIL_VK_ALIAS(vkBindBufferMemory2KHR, vkBindBufferMemory2)
MOCKTAIL_VK_ALIAS(vkCmdCopyImage2KHR, vkCmdCopyImage2)
MOCKTAIL_VK_ALIAS(vkMapMemory2KHR, vkMapMemory2)
MOCKTAIL_VK_ALIAS(vkUnmapMemory2KHR, vkUnmapMemory2)
MOCKTAIL_VK_ALIAS(vkCmdCopyBufferToImage2KHR, vkCmdCopyBufferToImage2)
#undef MOCKTAIL_VK_ALIAS
return nullptr;
}
bool NameInList(const char* name, const char* const* names,
std::size_t count) {
return name != nullptr &&
std::any_of(names, names + count, [name](const char* candidate) {
return std::strcmp(name, candidate) == 0;
});
}
// Device commands wrapped for ETC2/EAC emulation.
bool IsEtc2DeviceProc(const char* name) {
static constexpr const char* kNames[] = {
"vkCreateImage", "vkDestroyImage",
"vkCreateImageView", "vkBindBufferMemory",
"vkBindBufferMemory2", "vkBindBufferMemory2KHR",
"vkMapMemory", "vkMapMemory2",
"vkMapMemory2KHR", "vkUnmapMemory",
"vkUnmapMemory2", "vkUnmapMemory2KHR",
"vkFreeMemory", "vkDestroyBuffer",
"vkCmdCopyBufferToImage", "vkCmdCopyBufferToImage2",
"vkCmdCopyImage", "vkCmdCopyImage2",
"vkCmdCopyImage2KHR",
"vkCmdCopyBufferToImage2KHR", "vkCmdExecuteCommands",
};
return NameInList(name, kNames, sizeof(kNames) / sizeof(kNames[0]));
}
// Physical-device queries that report emulated ETC2/EAC support.
bool IsEtc2PhysicalDeviceProc(const char* name) {
static constexpr const char* kNames[] = {
"vkGetPhysicalDeviceFeatures",
"vkGetPhysicalDeviceFeatures2",
"vkGetPhysicalDeviceFeatures2KHR",
"vkGetPhysicalDeviceFormatProperties",
"vkGetPhysicalDeviceFormatProperties2",
"vkGetPhysicalDeviceFormatProperties2KHR",
"vkGetPhysicalDeviceImageFormatProperties",
"vkGetPhysicalDeviceImageFormatProperties2",
"vkGetPhysicalDeviceImageFormatProperties2KHR",
};
return NameInList(name, kNames, sizeof(kNames) / sizeof(kNames[0]));
}
bool IsDeviceAdapterProc(const char* name) {
return name != nullptr && (std::strcmp(name, "vkDestroyDevice") == 0 ||
return name != nullptr && (IsEtc2DeviceProc(name) || std::strcmp(name, "vkDestroyDevice") == 0 ||
std::strcmp(name, "vkGetDeviceQueue") == 0 ||
std::strcmp(name, "vkGetDeviceQueue2") == 0 ||
std::strcmp(name, "vkCreateSwapchainKHR") == 0 ||
@@ -959,11 +1042,24 @@ struct FpsWaitTrace {
std::atomic<std::uint64_t> total_ns{0};
std::atomic<std::uint64_t> max_ns{0};
std::atomic<std::uint64_t> window_start_ns{0};
// Longest time between consecutive call starts; for present, a frame time.
std::atomic<std::uint64_t> max_gap_ns{0};
std::atomic<std::uint64_t> last_start_ns{0};
void Record(std::uint64_t start_ns) {
if (name == nullptr || start_ns == 0) {
return;
}
const std::uint64_t previous_start =
last_start_ns.exchange(start_ns, std::memory_order_relaxed);
if (previous_start != 0 && start_ns > previous_start) {
const std::uint64_t gap_ns = start_ns - previous_start;
std::uint64_t max_gap = max_gap_ns.load(std::memory_order_relaxed);
while (gap_ns > max_gap &&
!max_gap_ns.compare_exchange_weak(max_gap, gap_ns,
std::memory_order_relaxed)) {
}
}
const std::uint64_t wait_ns = MonotonicNanos() - start_ns;
total_ns.fetch_add(wait_ns, std::memory_order_relaxed);
std::uint64_t max_wait = max_ns.load(std::memory_order_relaxed);
@@ -984,14 +1080,18 @@ struct FpsWaitTrace {
const std::uint64_t total = total_ns.exchange(0, std::memory_order_relaxed);
const std::uint64_t peak = max_ns.exchange(0, std::memory_order_relaxed);
const std::uint64_t count = samples.exchange(0, std::memory_order_relaxed);
const std::uint64_t gap_peak =
max_gap_ns.exchange(0, std::memory_order_relaxed);
window_start_ns.store(start_ns, std::memory_order_relaxed);
if (count == 0) {
return;
}
std::fprintf(stderr, " [fps] %s n=%llu avg=%llu us max=%llu us\n", name,
static_cast<unsigned long long>(count),
std::fprintf(stderr,
" [fps] %s n=%llu avg=%llu us max=%llu us gap_max=%llu us\n",
name, static_cast<unsigned long long>(count),
static_cast<unsigned long long>(total / count / 1000ULL),
static_cast<unsigned long long>(peak / 1000ULL));
static_cast<unsigned long long>(peak / 1000ULL),
static_cast<unsigned long long>(gap_peak / 1000ULL));
}
};
@@ -1042,6 +1142,58 @@ ObservedHostQueuePresent(VkQueue queue, const VkPresentInfoKHR* present_info) {
return result;
}
template <typename Function>
Function HostPhysicalDeviceProc(const char* name, const char* alias) {
VkInstance instance = VK_NULL_HANDLE;
{
AdapterState& state = State();
std::lock_guard<std::mutex> lock(state.mutex);
instance = state.latest_instance;
}
PFN_vkVoidFunction proc = HostInstanceProc(instance, name);
if (proc == nullptr && alias != nullptr) {
proc = HostInstanceProc(instance, alias);
}
return reinterpret_cast<Function>(proc);
}
bool Etc2EmulatedPhysicalDevice(VkPhysicalDevice physical_device) {
return State().etc2.PhysicalDeviceNeedsEmulation(
physical_device, HostPhysicalDeviceProc<PFN_vkGetPhysicalDeviceFeatures>(
"vkGetPhysicalDeviceFeatures", nullptr));
}
void ReleaseEtc2PoolCommandBuffers(VkDevice device,
VkCommandPool command_pool) {
std::vector<VkCommandBuffer> command_buffers;
{
AdapterState& state = State();
std::lock_guard<std::mutex> lock(state.mutex);
for (const auto& binding : state.command_buffer_bindings) {
if (binding.device == device && binding.command_pool == command_pool) {
command_buffers.push_back(binding.command_buffer);
}
}
}
for (VkCommandBuffer command_buffer : command_buffers) {
State().etc2.ReleaseCommandBuffer(command_buffer);
}
}
void PrepareEtc2Submit2(std::uint32_t submit_count,
const VkSubmitInfo2* submits) {
if (submits == nullptr) {
return;
}
for (std::uint32_t index = 0; index < submit_count; ++index) {
for (std::uint32_t info = 0; info < submits[index].commandBufferInfoCount;
++info) {
State().etc2.PrepareSubmit(
&submits[index].pCommandBufferInfos[info].commandBuffer, 1);
}
}
}
} // namespace
extern "C" {
@@ -1247,7 +1399,7 @@ vkGetInstanceProcAddr(VkInstance instance, const char* name) {
}
if (const PFN_vkVoidFunction adapter = AdapterProc(name);
adapter != nullptr) {
if (IsDeviceAdapterProc(name) &&
if ((IsDeviceAdapterProc(name) || IsEtc2PhysicalDeviceProc(name)) &&
HostInstanceProc(instance, name) == nullptr) {
return nullptr;
}
@@ -1306,6 +1458,31 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(
VkDeviceCreateInfo host_info = *create_info;
EnabledDeviceFeatures enabled = InspectEnabledFeatures(*create_info);
const bool etc2_emulated = State().etc2.PhysicalDeviceNeedsEmulation(
physical_device, reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures>(
HostInstanceProc(instance,
"vkGetPhysicalDeviceFeatures")));
VkPhysicalDeviceFeatures host_enabled_features{};
VkPhysicalDeviceFeatures2* requested_features2 = nullptr;
VkBool32 requested_features2_etc2 = VK_FALSE;
if (etc2_emulated) {
enabled.root.features.textureCompressionETC2 = VK_FALSE;
if (create_info->pEnabledFeatures != nullptr) {
host_enabled_features = *create_info->pEnabledFeatures;
host_enabled_features.textureCompressionETC2 = VK_FALSE;
host_info.pEnabledFeatures = &host_enabled_features;
}
// The feature chain is caller-owned; clear the emulated bit only for the
// host call and restore it afterwards.
requested_features2 = const_cast<VkPhysicalDeviceFeatures2*>(
reinterpret_cast<const VkPhysicalDeviceFeatures2*>(FindFeature(
create_info->pNext, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2)));
if (requested_features2 != nullptr) {
requested_features2_etc2 =
requested_features2->features.textureCompressionETC2;
requested_features2->features.textureCompressionETC2 = VK_FALSE;
}
}
enabled.root.pNext = &enabled.vulkan11;
enabled.vulkan11.pNext = &enabled.vulkan12;
enabled.vulkan12.pNext = nullptr;
@@ -1341,11 +1518,25 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(
const VkResult result =
host_create(physical_device, &host_info, allocator, device);
if (requested_features2 != nullptr) {
requested_features2->features.textureCompressionETC2 =
requested_features2_etc2;
}
if (result != VK_SUCCESS) {
return result;
}
RegisterHostDeviceDispatch(*device, physical_device,
host_get_device_proc_addr);
VkPhysicalDeviceMemoryProperties memory_properties{};
if (const auto host_memory_properties =
reinterpret_cast<PFN_vkGetPhysicalDeviceMemoryProperties>(
HostInstanceProc(instance,
"vkGetPhysicalDeviceMemoryProperties"));
host_memory_properties != nullptr) {
host_memory_properties(physical_device, &memory_properties);
}
State().etc2.RegisterDevice(*device, physical_device, etc2_emulated,
memory_properties, host_get_device_proc_addr);
std::uint32_t queue_family_count = 0;
const auto host_get_queue_families =
@@ -1403,6 +1594,7 @@ vkDestroyDevice(VkDevice device, const VkAllocationCallbacks* allocator) {
const auto host_destroy = reinterpret_cast<PFN_vkDestroyDevice>(
HostDeviceProc(device, "vkDestroyDevice"));
State().text_overlay.DestroyDevice(device);
State().etc2.DestroyDevice(device);
if (host_destroy != nullptr) {
host_destroy(device, allocator);
}
@@ -1650,6 +1842,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(
observation.SetResult(VK_ERROR_INITIALIZATION_FAILED);
return VK_ERROR_INITIALIZATION_FAILED;
}
ReleaseEtc2PoolCommandBuffers(device, command_pool);
const VkResult result = host_reset(device, command_pool, flags);
observation.SetResult(result);
return result;
@@ -1706,6 +1899,11 @@ VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(
observation.SetResult(VK_ERROR_INITIALIZATION_FAILED);
return;
}
if (command_buffers != nullptr) {
for (std::uint32_t index = 0; index < command_buffer_count; ++index) {
State().etc2.ReleaseCommandBuffer(command_buffers[index]);
}
}
host_free(device, command_pool, command_buffer_count, command_buffers);
RemoveHostCommandBuffers(device, command_pool, command_buffer_count,
command_buffers);
@@ -1722,6 +1920,7 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(
observation.SetResult(VK_ERROR_INITIALIZATION_FAILED);
return;
}
ReleaseEtc2PoolCommandBuffers(device, command_pool);
host_destroy(device, command_pool, allocator);
RemoveHostCommandPoolBindings(device, command_pool);
observation.SetResult(VK_SUCCESS);
@@ -1737,6 +1936,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(
observation.SetResult(VK_ERROR_INITIALIZATION_FAILED);
return VK_ERROR_INITIALIZATION_FAILED;
}
State().etc2.ReleaseCommandBuffer(command_buffer);
const VkResult result = host_begin(command_buffer, begin_info);
observation.SetResult(result);
return result;
@@ -1765,6 +1965,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer(
observation.SetResult(VK_ERROR_INITIALIZATION_FAILED);
return VK_ERROR_INITIALIZATION_FAILED;
}
State().etc2.ReleaseCommandBuffer(command_buffer);
const VkResult result = host_reset(command_buffer, flags);
observation.SetResult(result);
return result;
@@ -1801,6 +2002,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(
observation.SetResult(VK_ERROR_INITIALIZATION_FAILED);
return VK_ERROR_INITIALIZATION_FAILED;
}
if (submits != nullptr) {
for (std::uint32_t index = 0; index < submit_count; ++index) {
State().etc2.PrepareSubmit(submits[index].pCommandBuffers,
submits[index].commandBufferCount);
}
}
const VkResult result = State().text_overlay.QueueSubmit(
queue, submit_count, submits, fence, host_submit);
observation.SetResult(result);
@@ -1817,6 +2024,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit2(
observation.SetResult(VK_ERROR_INITIALIZATION_FAILED);
return VK_ERROR_INITIALIZATION_FAILED;
}
PrepareEtc2Submit2(submit_count, submits);
const VkResult result = State().text_overlay.QueueSubmit2(
queue, submit_count, submits, fence, host_submit);
observation.SetResult(result);
@@ -1833,6 +2041,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit2KHR(
observation.SetResult(VK_ERROR_INITIALIZATION_FAILED);
return VK_ERROR_INITIALIZATION_FAILED;
}
PrepareEtc2Submit2(submit_count, submits);
const VkResult result = State().text_overlay.QueueSubmit2(
queue, submit_count, submits, fence,
reinterpret_cast<PFN_vkQueueSubmit2>(host_submit));
@@ -2025,4 +2234,250 @@ vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* present_info) {
return normalized_result;
}
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(
VkPhysicalDevice physical_device, VkPhysicalDeviceFeatures* features) {
const auto host = HostPhysicalDeviceProc<PFN_vkGetPhysicalDeviceFeatures>(
"vkGetPhysicalDeviceFeatures", nullptr);
if (host == nullptr || features == nullptr) {
return;
}
host(physical_device, features);
if (Etc2EmulatedPhysicalDevice(physical_device) &&
mocktail::graphics::Etc2SupportAdvertised()) {
features->textureCompressionETC2 = VK_TRUE;
}
}
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2(
VkPhysicalDevice physical_device, VkPhysicalDeviceFeatures2* features) {
const auto host = HostPhysicalDeviceProc<PFN_vkGetPhysicalDeviceFeatures2>(
"vkGetPhysicalDeviceFeatures2", "vkGetPhysicalDeviceFeatures2KHR");
if (host == nullptr || features == nullptr) {
return;
}
host(physical_device, features);
if (Etc2EmulatedPhysicalDevice(physical_device) &&
mocktail::graphics::Etc2SupportAdvertised()) {
features->features.textureCompressionETC2 = VK_TRUE;
}
}
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(
VkPhysicalDevice physical_device, VkFormat format,
VkFormatProperties* properties) {
const auto host =
HostPhysicalDeviceProc<PFN_vkGetPhysicalDeviceFormatProperties>(
"vkGetPhysicalDeviceFormatProperties", nullptr);
if (host == nullptr || properties == nullptr) {
return;
}
mocktail::graphics::Etc2EmulatedFormat mapped;
if (!mocktail::graphics::LookupEmulatedEtc2Format(format, &mapped) ||
!Etc2EmulatedPhysicalDevice(physical_device)) {
host(physical_device, format, properties);
return;
}
host(physical_device, mapped.host_format, properties);
properties->linearTilingFeatures = 0;
properties->optimalTilingFeatures =
mocktail::graphics::EmulatedEtc2FormatFeatures(
properties->optimalTilingFeatures);
properties->bufferFeatures = 0;
}
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2(
VkPhysicalDevice physical_device, VkFormat format,
VkFormatProperties2* properties) {
const auto host =
HostPhysicalDeviceProc<PFN_vkGetPhysicalDeviceFormatProperties2>(
"vkGetPhysicalDeviceFormatProperties2",
"vkGetPhysicalDeviceFormatProperties2KHR");
if (host == nullptr || properties == nullptr) {
return;
}
mocktail::graphics::Etc2EmulatedFormat mapped;
if (!mocktail::graphics::LookupEmulatedEtc2Format(format, &mapped) ||
!Etc2EmulatedPhysicalDevice(physical_device)) {
host(physical_device, format, properties);
return;
}
host(physical_device, mapped.host_format, properties);
VkFormatProperties& base = properties->formatProperties;
base.linearTilingFeatures = 0;
base.optimalTilingFeatures =
mocktail::graphics::EmulatedEtc2FormatFeatures(base.optimalTilingFeatures);
base.bufferFeatures = 0;
if (auto* extended = const_cast<VkFormatProperties3*>(
reinterpret_cast<const VkFormatProperties3*>(FindFeature(
properties->pNext, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3)));
extended != nullptr) {
extended->linearTilingFeatures = 0;
extended->optimalTilingFeatures =
mocktail::graphics::EmulatedEtc2FormatFeatures(
static_cast<VkFormatFeatureFlags>(
extended->optimalTilingFeatures));
extended->bufferFeatures = 0;
}
}
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(
VkPhysicalDevice physical_device, VkFormat format, VkImageType type,
VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
VkImageFormatProperties* properties) {
const auto host =
HostPhysicalDeviceProc<PFN_vkGetPhysicalDeviceImageFormatProperties>(
"vkGetPhysicalDeviceImageFormatProperties", nullptr);
if (host == nullptr) {
return VK_ERROR_INITIALIZATION_FAILED;
}
mocktail::graphics::Etc2EmulatedFormat mapped;
if (!mocktail::graphics::LookupEmulatedEtc2Format(format, &mapped) ||
!Etc2EmulatedPhysicalDevice(physical_device)) {
return host(physical_device, format, type, tiling, usage, flags,
properties);
}
if (tiling != VK_IMAGE_TILING_OPTIMAL || type != VK_IMAGE_TYPE_2D) {
return VK_ERROR_FORMAT_NOT_SUPPORTED;
}
return host(physical_device, mapped.host_format, type, tiling, usage,
flags & ~static_cast<VkImageCreateFlags>(
VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT),
properties);
}
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2(
VkPhysicalDevice physical_device,
const VkPhysicalDeviceImageFormatInfo2* info,
VkImageFormatProperties2* properties) {
const auto host =
HostPhysicalDeviceProc<PFN_vkGetPhysicalDeviceImageFormatProperties2>(
"vkGetPhysicalDeviceImageFormatProperties2",
"vkGetPhysicalDeviceImageFormatProperties2KHR");
if (host == nullptr || info == nullptr) {
return VK_ERROR_INITIALIZATION_FAILED;
}
mocktail::graphics::Etc2EmulatedFormat mapped;
if (!mocktail::graphics::LookupEmulatedEtc2Format(info->format, &mapped) ||
!Etc2EmulatedPhysicalDevice(physical_device)) {
return host(physical_device, info, properties);
}
if (info->tiling != VK_IMAGE_TILING_OPTIMAL ||
info->type != VK_IMAGE_TYPE_2D) {
return VK_ERROR_FORMAT_NOT_SUPPORTED;
}
VkPhysicalDeviceImageFormatInfo2 host_info = *info;
host_info.format = mapped.host_format;
host_info.flags &= ~static_cast<VkImageCreateFlags>(
VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT);
return host(physical_device, &host_info, properties);
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(
VkDevice device, const VkImageCreateInfo* create_info,
const VkAllocationCallbacks* allocator, VkImage* image) {
return State().etc2.CreateImage(device, create_info, allocator, image);
}
VKAPI_ATTR void VKAPI_CALL vkDestroyImage(
VkDevice device, VkImage image, const VkAllocationCallbacks* allocator) {
State().etc2.DestroyImage(device, image, allocator);
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(
VkDevice device, const VkImageViewCreateInfo* create_info,
const VkAllocationCallbacks* allocator, VkImageView* view) {
return State().etc2.CreateImageView(device, create_info, allocator, view);
}
VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device,
VkBuffer buffer,
VkDeviceMemory memory,
VkDeviceSize offset) {
return State().etc2.BindBufferMemory(device, buffer, memory, offset);
}
VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2(
VkDevice device, std::uint32_t count,
const VkBindBufferMemoryInfo* infos) {
return State().etc2.BindBufferMemory2(device, count, infos);
}
VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device,
VkDeviceMemory memory,
VkDeviceSize offset,
VkDeviceSize size,
VkMemoryMapFlags flags,
void** data) {
return State().etc2.MapMemory(device, memory, offset, size, flags, data);
}
VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory2(VkDevice device,
const VkMemoryMapInfo* info,
void** data) {
return State().etc2.MapMemory2(device, info, data);
}
VKAPI_ATTR void VKAPI_CALL vkUnmapMemory(VkDevice device,
VkDeviceMemory memory) {
State().etc2.UnmapMemory(device, memory);
}
VKAPI_ATTR VkResult VKAPI_CALL vkUnmapMemory2(VkDevice device,
const VkMemoryUnmapInfo* info) {
return State().etc2.UnmapMemory2(device, info);
}
VKAPI_ATTR void VKAPI_CALL vkFreeMemory(
VkDevice device, VkDeviceMemory memory,
const VkAllocationCallbacks* allocator) {
State().etc2.FreeMemory(device, memory, allocator);
}
VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(
VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* allocator) {
State().etc2.DestroyBuffer(device, buffer, allocator);
}
VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(
VkCommandBuffer command_buffer, VkBuffer source, VkImage destination,
VkImageLayout layout, std::uint32_t region_count,
const VkBufferImageCopy* regions) {
State().etc2.CmdCopyBufferToImage(
HostDispatchForCommandBuffer(command_buffer).device, command_buffer,
source, destination, layout, region_count, regions);
}
VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage2(
VkCommandBuffer command_buffer, const VkCopyBufferToImageInfo2* info) {
State().etc2.CmdCopyBufferToImage2(
HostDispatchForCommandBuffer(command_buffer).device, command_buffer,
info);
}
VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(
VkCommandBuffer command_buffer, VkImage source,
VkImageLayout source_layout, VkImage destination,
VkImageLayout destination_layout, std::uint32_t region_count,
const VkImageCopy* regions) {
State().etc2.CmdCopyImage(
HostDispatchForCommandBuffer(command_buffer).device, command_buffer,
source, source_layout, destination, destination_layout, region_count,
regions);
}
VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage2(VkCommandBuffer command_buffer,
const VkCopyImageInfo2* info) {
State().etc2.CmdCopyImage2(
HostDispatchForCommandBuffer(command_buffer).device, command_buffer,
info);
}
VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(
VkCommandBuffer command_buffer, std::uint32_t count,
const VkCommandBuffer* secondaries) {
State().etc2.CmdExecuteCommands(
HostDispatchForCommandBuffer(command_buffer).device, command_buffer,
count, secondaries);
}
} // extern "C"
+402
View File
@@ -0,0 +1,402 @@
#include "mocktail/graphics/etc2_decoder.h"
#include <algorithm>
#include <array>
#include <pthread.h>
#include <atomic>
#include <limits>
#include <vector>
namespace mocktail::graphics {
namespace {
constexpr std::array<int, 8> kDistance = {3, 6, 11, 16, 23, 32, 41, 64};
// Indexed by (msb << 1) | lsb.
constexpr int kEtc1Modifiers[8][4] = {
{2, 8, -2, -8}, {5, 17, -5, -17}, {9, 29, -9, -29},
{13, 42, -13, -42}, {18, 60, -18, -60}, {24, 80, -24, -80},
{33, 106, -33, -106}, {47, 183, -47, -183},
};
constexpr int kEacModifiers[16][8] = {
{-3, -6, -9, -15, 2, 5, 8, 14}, {-3, -7, -10, -13, 2, 6, 9, 12},
{-2, -5, -8, -13, 1, 4, 7, 12}, {-2, -4, -6, -13, 1, 3, 5, 12},
{-3, -6, -8, -12, 2, 5, 7, 11}, {-3, -7, -9, -11, 2, 6, 8, 10},
{-4, -7, -8, -11, 3, 6, 7, 10}, {-3, -5, -8, -11, 2, 4, 7, 10},
{-2, -6, -8, -10, 1, 5, 7, 9}, {-2, -5, -8, -10, 1, 4, 7, 9},
{-2, -4, -8, -10, 1, 3, 7, 9}, {-2, -5, -7, -10, 1, 4, 6, 9},
{-3, -4, -7, -10, 2, 3, 6, 9}, {-1, -2, -3, -10, 0, 1, 2, 9},
{-4, -6, -8, -9, 3, 5, 7, 8}, {-3, -5, -7, -9, 2, 4, 6, 8},
};
std::uint8_t Clamp255(int value) {
return static_cast<std::uint8_t>(std::clamp(value, 0, 255));
}
int Expand4(int value) { return (value << 4) | value; }
int Expand5(int value) { return (value << 3) | (value >> 2); }
int Expand6(int value) { return (value << 2) | (value >> 4); }
int Expand7(int value) { return (value << 1) | (value >> 6); }
// Decodes one ETC2 RGB block into 16 column-major RGBA texels (x * 4 + y).
void DecodeRgbBlock(const std::uint8_t* b, bool punchthrough,
std::array<std::uint8_t, 64>* out) {
static constexpr int kDelta[8] = {0, 1, 2, 3, -4, -3, -2, -1};
const bool diff_or_opaque = (b[3] & 2) != 0;
const bool opaque = !punchthrough || diff_or_opaque;
const int msb = (b[4] << 8) | b[5];
const int lsb = (b[6] << 8) | b[7];
auto index_of = [msb, lsb](int texel) {
return (((msb >> texel) & 1) << 1) | ((lsb >> texel) & 1);
};
auto write = [out](int texel, int r, int g, int bl, int a) {
const std::size_t o = static_cast<std::size_t>(texel) * 4;
(*out)[o] = Clamp255(r);
(*out)[o + 1] = Clamp255(g);
(*out)[o + 2] = Clamp255(bl);
(*out)[o + 3] = static_cast<std::uint8_t>(a);
};
const int r_sum = (b[0] >> 3) + kDelta[b[0] & 7];
const int g_sum = (b[1] >> 3) + kDelta[b[1] & 7];
const int b_sum = (b[2] >> 3) + kDelta[b[2] & 7];
const bool individual = !punchthrough && !diff_or_opaque;
if (!individual && (r_sum < 0 || r_sum > 31 || g_sum < 0 || g_sum > 31)) {
std::array<std::array<int, 3>, 4> paint{};
if (r_sum < 0 || r_sum > 31) {
const std::array<int, 3> c1 = {
Expand4((((b[0] >> 3) & 3) << 2) | (b[0] & 3)),
Expand4(b[1] >> 4), Expand4(b[1] & 15)};
const std::array<int, 3> c2 = {Expand4(b[2] >> 4), Expand4(b[2] & 15),
Expand4(b[3] >> 4)};
const int d = kDistance[(((b[3] >> 2) & 3) << 1) | (b[3] & 1)];
for (int c = 0; c < 3; ++c) {
paint[0][c] = c1[c];
paint[1][c] = c2[c] + d;
paint[2][c] = c2[c];
paint[3][c] = c2[c] - d;
}
} else {
const std::array<int, 3> c1 = {
Expand4((b[0] >> 3) & 15),
Expand4(((b[0] & 7) << 1) | ((b[1] >> 4) & 1)),
Expand4((b[1] & 8) | ((b[1] & 3) << 1) | (b[2] >> 7))};
const std::array<int, 3> c2 = {
Expand4((b[2] >> 3) & 15), Expand4(((b[2] & 7) << 1) | (b[3] >> 7)),
Expand4((b[3] >> 3) & 15)};
const int v1 = (c1[0] << 16) | (c1[1] << 8) | c1[2];
const int v2 = (c2[0] << 16) | (c2[1] << 8) | c2[2];
const int d =
kDistance[(b[3] & 4) | ((b[3] & 1) << 1) | (v1 >= v2 ? 1 : 0)];
for (int c = 0; c < 3; ++c) {
paint[0][c] = c1[c] + d;
paint[1][c] = c1[c] - d;
paint[2][c] = c2[c] + d;
paint[3][c] = c2[c] - d;
}
}
for (int texel = 0; texel < 16; ++texel) {
const int index = index_of(texel);
if (!opaque && index == 2) {
write(texel, 0, 0, 0, 0);
} else {
write(texel, paint[index][0], paint[index][1], paint[index][2], 255);
}
}
return;
}
if (!individual && (b_sum < 0 || b_sum > 31)) {
const int ro = Expand6((b[0] >> 1) & 63);
const int go = Expand7(((b[0] & 1) << 6) | ((b[1] >> 1) & 63));
const int bo = Expand6(((b[1] & 1) << 5) | (b[2] & 0x18) |
((b[2] & 3) << 1) | (b[3] >> 7));
const int rh = Expand6(((b[3] & 0x7c) >> 1) | (b[3] & 1));
const int gh = Expand7(b[4] >> 1);
const int bh = Expand6(((b[4] & 1) << 5) | (b[5] >> 3));
const int rv = Expand6(((b[5] & 7) << 3) | (b[6] >> 5));
const int gv = Expand7(((b[6] & 31) << 2) | (b[7] >> 6));
const int bv = Expand6(b[7] & 63);
for (int x = 0; x < 4; ++x) {
for (int y = 0; y < 4; ++y) {
write(x * 4 + y, (x * (rh - ro) + y * (rv - ro) + 4 * ro + 2) >> 2,
(x * (gh - go) + y * (gv - go) + 4 * go + 2) >> 2,
(x * (bh - bo) + y * (bv - bo) + 4 * bo + 2) >> 2, 255);
}
}
return;
}
std::array<std::array<int, 3>, 2> base{};
for (int c = 0; c < 3; ++c) {
if (individual) {
base[0][c] = Expand4(b[c] >> 4);
base[1][c] = Expand4(b[c] & 15);
} else {
base[0][c] = Expand5(b[c] >> 3);
base[1][c] = Expand5((b[c] >> 3) + kDelta[b[c] & 7]);
}
}
const int tables[2] = {b[3] >> 5, (b[3] >> 2) & 7};
const bool flipped = (b[3] & 1) != 0;
for (int x = 0; x < 4; ++x) {
for (int y = 0; y < 4; ++y) {
const int texel = x * 4 + y;
const int index = index_of(texel);
if (!opaque && index == 2) {
write(texel, 0, 0, 0, 0);
continue;
}
const int sub = flipped ? (y >= 2 ? 1 : 0) : (x >= 2 ? 1 : 0);
const int modifier =
(!opaque && index == 0) ? 0 : kEtc1Modifiers[tables[sub]][index];
write(texel, base[sub][0] + modifier, base[sub][1] + modifier,
base[sub][2] + modifier, 255);
}
}
}
// EAC 3-bit index for column-major texel (x * 4 + y).
int EacIndex(const std::uint8_t* b, int texel) {
std::uint64_t bits = 0;
for (int i = 2; i < 8; ++i) {
bits = (bits << 8) | b[i];
}
return static_cast<int>((bits >> (45 - texel * 3)) & 7);
}
int EacModifier(const std::uint8_t* b, int texel) {
return kEacModifiers[b[1] & 15][EacIndex(b, texel)];
}
std::uint16_t DecodeR11(const std::uint8_t* b, int texel, bool is_signed) {
const int multiplier = b[1] >> 4;
const int modifier = EacModifier(b, texel);
const int scaled = multiplier != 0 ? modifier * multiplier * 8 : modifier;
if (!is_signed) {
const int value = std::clamp(b[0] * 8 + 4 + scaled, 0, 2047);
return static_cast<std::uint16_t>((value << 5) | (value >> 6));
}
const int base = std::max(-127, static_cast<int>(static_cast<std::int8_t>(b[0])));
const int value = std::clamp(base * 8 + scaled, -1023, 1023);
const int magnitude = value < 0 ? -value : value;
const int expanded = (magnitude << 5) | (magnitude >> 5);
return static_cast<std::uint16_t>(
static_cast<std::int16_t>(value < 0 ? -expanded : expanded));
}
} // namespace
std::size_t EtcBlockBytes(EtcFormat format) {
switch (format) {
case EtcFormat::kEtc2Rgba8:
case EtcFormat::kEacRg11:
case EtcFormat::kEacRg11Signed:
return 16;
default:
return 8;
}
}
std::size_t EtcDecodedTexelBytes(EtcFormat format) {
switch (format) {
case EtcFormat::kEacR11:
case EtcFormat::kEacR11Signed:
return 2;
default:
return 4;
}
}
namespace {
// Blocks per band handed to one worker: about a 256x256 texel image.
constexpr std::uint64_t kBlocksPerBand = 16384;
// Batches smaller than a 1024x1024 texel image decode on the caller.
constexpr std::uint64_t kParallelMinimumBlocks = 65536;
bool ImageFits(EtcFormat format, const std::uint8_t* source,
std::size_t source_bytes, std::uint32_t width,
std::uint32_t height, const std::uint8_t* destination,
std::size_t destination_bytes) {
if (source == nullptr || destination == nullptr || width == 0 ||
height == 0) {
return false;
}
const std::uint64_t blocks_wide = (static_cast<std::uint64_t>(width) + 3) / 4;
const std::uint64_t blocks_high =
(static_cast<std::uint64_t>(height) + 3) / 4;
return blocks_wide * blocks_high * EtcBlockBytes(format) <= source_bytes &&
static_cast<std::uint64_t>(width) * height *
EtcDecodedTexelBytes(format) <=
destination_bytes;
}
} // namespace
bool DecodeEtcImage(EtcFormat format, const std::uint8_t* source,
std::size_t source_bytes, std::uint32_t width,
std::uint32_t height, std::uint8_t* destination,
std::size_t destination_bytes) {
return DecodeEtcImageBlockRows(format, source, source_bytes, width, height, 0,
(height + 3) / 4, destination,
destination_bytes);
}
namespace {
struct DecodeBand {
EtcDecodeJob* job;
std::uint32_t first_block_row;
std::uint32_t block_row_count;
};
struct DecodeBandQueue {
std::vector<DecodeBand> bands;
std::atomic<std::size_t> next{0};
void Run() {
for (;;) {
const std::size_t index = next.fetch_add(1, std::memory_order_relaxed);
if (index >= bands.size()) {
return;
}
const DecodeBand& band = bands[index];
const EtcDecodeJob& job = *band.job;
DecodeEtcImageBlockRows(job.format, job.source, job.source_bytes,
job.width, job.height, band.first_block_row,
band.block_row_count, job.destination,
job.destination_bytes);
}
}
};
void* RunDecodeBandQueue(void* queue) {
static_cast<DecodeBandQueue*>(queue)->Run();
return nullptr;
}
} // namespace
void DecodeEtcJobs(EtcDecodeJob* jobs, std::size_t count,
unsigned worker_count) {
if (jobs == nullptr) {
return;
}
DecodeBandQueue queue;
std::vector<DecodeBand>& bands = queue.bands;
std::uint64_t total_blocks = 0;
for (std::size_t index = 0; index < count; ++index) {
EtcDecodeJob& job = jobs[index];
job.ok = ImageFits(job.format, job.source, job.source_bytes, job.width,
job.height, job.destination, job.destination_bytes);
if (!job.ok) {
continue;
}
const std::uint32_t blocks_wide = (job.width + 3) / 4;
const std::uint32_t blocks_high = (job.height + 3) / 4;
const std::uint32_t rows_per_band = static_cast<std::uint32_t>(
std::max<std::uint64_t>(1, kBlocksPerBand / blocks_wide));
for (std::uint32_t row = 0; row < blocks_high; row += rows_per_band) {
bands.push_back(
{&job, row, std::min(rows_per_band, blocks_high - row)});
}
total_blocks += static_cast<std::uint64_t>(blocks_wide) * blocks_high;
}
const std::size_t threads =
total_blocks < kParallelMinimumBlocks
? 1
: std::min<std::size_t>(std::max(worker_count, 1U), bands.size());
std::vector<pthread_t> workers;
workers.reserve(threads > 0 ? threads - 1 : 0);
for (std::size_t index = 1; index < threads; ++index) {
pthread_t worker;
// The caller decodes whatever workers that failed to start leave behind.
if (pthread_create(&worker, nullptr, RunDecodeBandQueue, &queue) != 0) {
break;
}
workers.push_back(worker);
}
queue.Run();
for (pthread_t worker : workers) {
pthread_join(worker, nullptr);
}
}
bool DecodeEtcImageBlockRows(EtcFormat format, const std::uint8_t* source,
std::size_t source_bytes, std::uint32_t width,
std::uint32_t height,
std::uint32_t first_block_row,
std::uint32_t block_row_count,
std::uint8_t* destination,
std::size_t destination_bytes) {
if (!ImageFits(format, source, source_bytes, width, height, destination,
destination_bytes)) {
return false;
}
const std::uint64_t blocks_wide = (static_cast<std::uint64_t>(width) + 3) / 4;
const std::uint64_t blocks_high =
(static_cast<std::uint64_t>(height) + 3) / 4;
if (static_cast<std::uint64_t>(first_block_row) + block_row_count >
blocks_high) {
return false;
}
const std::size_t texel_bytes = EtcDecodedTexelBytes(format);
const std::size_t block_bytes = EtcBlockBytes(format);
std::array<std::uint8_t, 64> rgba{};
const std::uint64_t end_block_row =
static_cast<std::uint64_t>(first_block_row) + block_row_count;
for (std::uint64_t by = first_block_row; by < end_block_row; ++by) {
for (std::uint64_t bx = 0; bx < blocks_wide; ++bx) {
const std::uint8_t* block =
source + (by * blocks_wide + bx) * block_bytes;
if (format == EtcFormat::kEtc2Rgb8 || format == EtcFormat::kEtc2Rgb8A1) {
DecodeRgbBlock(block, format == EtcFormat::kEtc2Rgb8A1, &rgba);
} else if (format == EtcFormat::kEtc2Rgba8) {
DecodeRgbBlock(block + 8, false, &rgba);
}
for (std::uint32_t y = 0; y < 4 && by * 4 + y < height; ++y) {
for (std::uint32_t x = 0; x < 4 && bx * 4 + x < width; ++x) {
const int texel = static_cast<int>(x * 4 + y);
std::uint8_t* out =
destination + ((by * 4 + y) * width + bx * 4 + x) * texel_bytes;
switch (format) {
case EtcFormat::kEtc2Rgb8:
case EtcFormat::kEtc2Rgb8A1:
case EtcFormat::kEtc2Rgba8:
std::copy_n(rgba.data() + texel * 4, 4, out);
if (format == EtcFormat::kEtc2Rgba8) {
const int alpha =
block[0] + EacModifier(block, texel) * (block[1] >> 4);
out[3] = Clamp255(alpha);
}
break;
case EtcFormat::kEacR11:
case EtcFormat::kEacR11Signed:
case EtcFormat::kEacRg11:
case EtcFormat::kEacRg11Signed: {
const bool is_signed = format == EtcFormat::kEacR11Signed ||
format == EtcFormat::kEacRg11Signed;
const int channels = texel_bytes / 2;
for (int channel = 0; channel < channels; ++channel) {
const std::uint16_t value =
DecodeR11(block + channel * 8, texel, is_signed);
out[channel * 2] = static_cast<std::uint8_t>(value);
out[channel * 2 + 1] = static_cast<std::uint8_t>(value >> 8);
}
break;
}
}
}
}
}
}
return true;
}
} // namespace mocktail::graphics
+4 -4
View File
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#include "mocktail/graphics/present_mode_policy.h"
#include <algorithm>
@@ -28,10 +29,9 @@ PresentModePolicy ResolvePresentModePolicy(std::string_view vsync_value,
if (frame_rate_value == "unlimited") {
return PresentModePolicy::kUnthrottled;
}
if (frame_rate_value.empty() || frame_rate_value == "-1") {
return PresentModePolicy::kHostDefault;
}
// Display or any fixed scheduler target keeps synchronized presentation.
// Every synchronized target, including the unmanaged Roblox cap, presents
// through the lowest-latency vsync mode the host offers. Roblox's own FIFO
// request queues up to two rendered frames before they reach the display.
return PresentModePolicy::kVsync;
}
+182
View File
@@ -0,0 +1,182 @@
#include "mocktail/graphics/texture_override.h"
#include <png.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <filesystem>
namespace mocktail::graphics {
std::uint64_t HashBytes(const std::uint8_t* data, std::size_t size) {
std::uint64_t hash = 0xcbf29ce484222325ULL;
for (std::size_t index = 0; index < size; ++index) {
hash ^= data[index];
hash *= 0x100000001b3ULL;
}
return hash;
}
std::string HashName(std::uint64_t hash) {
char text[17];
std::snprintf(text, sizeof(text), "%016llx",
static_cast<unsigned long long>(hash));
return text;
}
bool ReadPngRgba(const std::string& path, RgbaImage* image) {
if (image == nullptr) {
return false;
}
png_image png{};
png.version = PNG_IMAGE_VERSION;
if (png_image_begin_read_from_file(&png, path.c_str()) == 0) {
return false;
}
png.format = PNG_FORMAT_RGBA;
RgbaImage result;
result.width = png.width;
result.height = png.height;
result.pixels.resize(PNG_IMAGE_SIZE(png));
if (png_image_finish_read(&png, nullptr, result.pixels.data(), 0,
nullptr) == 0) {
png_image_free(&png);
return false;
}
*image = std::move(result);
return true;
}
bool WritePngRgba(const std::string& path, const RgbaImage& image) {
if (image.width == 0 || image.height == 0 ||
image.pixels.size() !=
static_cast<std::size_t>(image.width) * image.height * 4) {
return false;
}
png_image png{};
png.version = PNG_IMAGE_VERSION;
png.width = image.width;
png.height = image.height;
png.format = PNG_FORMAT_RGBA;
const int written = png_image_write_to_file(&png, path.c_str(), 0,
image.pixels.data(), 0, nullptr);
png_image_free(&png);
return written != 0;
}
void ResampleRgba(const RgbaImage& source, std::uint32_t width,
std::uint32_t height, std::uint8_t* destination) {
if (source.pixels.size() <
static_cast<std::size_t>(source.width) * source.height * 4) {
return;
}
ResampleRgba(source.pixels.data(), source.width, source.height, width,
height, destination);
}
void ResampleRgba(const std::uint8_t* source, std::uint32_t source_width,
std::uint32_t source_height, std::uint32_t width,
std::uint32_t height, std::uint8_t* destination) {
if (source == nullptr || destination == nullptr || width == 0 ||
height == 0 || source_width == 0 || source_height == 0) {
return;
}
for (std::uint32_t y = 0; y < height; ++y) {
const std::uint64_t y0 = static_cast<std::uint64_t>(y) * source_height / height;
std::uint64_t y1 =
(static_cast<std::uint64_t>(y) + 1) * source_height / height;
if (y1 <= y0) {
y1 = y0 + 1;
}
for (std::uint32_t x = 0; x < width; ++x) {
const std::uint64_t x0 = static_cast<std::uint64_t>(x) * source_width / width;
std::uint64_t x1 =
(static_cast<std::uint64_t>(x) + 1) * source_width / width;
if (x1 <= x0) {
x1 = x0 + 1;
}
std::uint64_t sum[4] = {0, 0, 0, 0};
for (std::uint64_t sy = y0; sy < y1; ++sy) {
for (std::uint64_t sx = x0; sx < x1; ++sx) {
const std::uint8_t* pixel = source + (sy * source_width + sx) * 4;
for (int channel = 0; channel < 4; ++channel) {
sum[channel] += pixel[channel];
}
}
}
const std::uint64_t count = (y1 - y0) * (x1 - x0);
std::uint8_t* out = destination + (static_cast<std::size_t>(y) * width + x) * 4;
for (int channel = 0; channel < 4; ++channel) {
out[channel] =
static_cast<std::uint8_t>((sum[channel] + count / 2) / count);
}
}
}
}
namespace {
std::string EnvironmentString(const char* name) {
const char* value = std::getenv(name);
return value != nullptr ? value : "";
}
} // namespace
TextureOverrides::TextureOverrides(std::string override_dir,
std::string dump_dir)
: override_dir_(std::move(override_dir)), dump_dir_(std::move(dump_dir)) {}
TextureOverrides TextureOverrides::FromEnvironment() {
return TextureOverrides(EnvironmentString("MOCKTAIL_TEXTURE_OVERRIDE_DIR"),
EnvironmentString("MOCKTAIL_TEXTURE_DUMP_DIR"));
}
std::shared_ptr<const RgbaImage> TextureOverrides::Lookup(std::uint64_t hash) {
if (override_dir_.empty()) {
return nullptr;
}
std::lock_guard<std::mutex> lock(mutex_);
const auto cached = cache_.find(hash);
if (cached != cache_.end()) {
return cached->second;
}
std::shared_ptr<const RgbaImage> loaded;
RgbaImage image;
const std::string path = override_dir_ + "/" + HashName(hash) + ".png";
if (ReadPngRgba(path, &image) && image.width > 0 && image.height > 0) {
loaded = std::make_shared<const RgbaImage>(std::move(image));
std::fprintf(stderr, " [vulkan] texture override loaded: %s (%ux%u)\n",
path.c_str(), loaded->width, loaded->height);
}
cache_[hash] = loaded;
return loaded;
}
void TextureOverrides::Dump(std::uint64_t hash, std::uint32_t width,
std::uint32_t height, const std::uint8_t* rgba) {
if (dump_dir_.empty() || rgba == nullptr || width == 0 || height == 0) {
return;
}
{
std::lock_guard<std::mutex> lock(mutex_);
if (!dumped_.insert(hash).second) {
return;
}
}
std::error_code error;
std::filesystem::create_directories(dump_dir_, error);
RgbaImage image;
image.width = width;
image.height = height;
image.pixels.assign(rgba, rgba + static_cast<std::size_t>(width) * height * 4);
const std::string path = dump_dir_ + "/" + HashName(hash) + "_" +
std::to_string(width) + "x" +
std::to_string(height) + ".png";
if (!WritePngRgba(path, image)) {
std::fprintf(stderr, " [vulkan] texture dump failed: %s\n", path.c_str());
}
}
} // namespace mocktail::graphics
File diff suppressed because it is too large. Load diff
+75 -22
View File
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#include "jnivm/jnivm.h"
#include "mocktail/audio/fmod_thread_floating_point.h"
@@ -23,6 +24,8 @@
#include <unordered_set>
#include <vector>
#include "runtime/display_size.h"
namespace jnivm {
void Class::RegisterMethod(const std::string& method_name,
@@ -562,13 +565,25 @@ bool ResolvedDarkTheme() {
}
jint IntResultForName(const char* name) {
if (std::strcmp(name, "getScreenWidth") == 0 ||
std::strcmp(name, "getWidth") == 0) {
return 1280;
if (std::strcmp(name, "getScreenWidth") == 0) {
return mocktail::runtime::ParseDisplaySize(
std::getenv(mocktail::runtime::kDisplaySizeEnvironment))
.width;
}
if (std::strcmp(name, "getScreenHeight") == 0 ||
std::strcmp(name, "getHeight") == 0) {
return 720;
if (std::strcmp(name, "getScreenHeight") == 0) {
return mocktail::runtime::ParseDisplaySize(
std::getenv(mocktail::runtime::kDisplaySizeEnvironment))
.height;
}
if (std::strcmp(name, "getWidth") == 0) {
return mocktail::runtime::ParseDisplaySize(
std::getenv(mocktail::runtime::kWindowSizeEnvironment))
.width;
}
if (std::strcmp(name, "getHeight") == 0) {
return mocktail::runtime::ParseDisplaySize(
std::getenv(mocktail::runtime::kWindowSizeEnvironment))
.height;
}
if (std::strcmp(name, "getDensityDpi") == 0) {
return 160;
@@ -2275,8 +2290,11 @@ jobject MakeDeviceStaticParamsObject() {
pseudo_object->object_fields["soc_model"] =
MakeString(identity.soc_model.c_str());
pseudo_object->boolean_fields["cpu64Bit"] = JNI_TRUE;
pseudo_object->int_fields["screenWidth"] = 1280;
pseudo_object->int_fields["screenHeight"] = 720;
const mocktail::runtime::DisplaySize host_display =
mocktail::runtime::ParseDisplaySize(
std::getenv(mocktail::runtime::kDisplaySizeEnvironment));
pseudo_object->int_fields["screenWidth"] = host_display.width;
pseudo_object->int_fields["screenHeight"] = host_display.height;
pseudo_object->int_fields["screenDensityDpi"] = 160;
pseudo_object->int_fields["apiVersion"] = 33;
pseudo_object->int_fields["sdkVersion"] = 33;
@@ -2446,14 +2464,17 @@ void EnsureAndroidObjectGraph() {
SetObjectFieldRaw(decor_view, "holder", surface_holder);
SetObjectFieldRaw(decor_view, "surface", surface);
SetObjectFieldRaw(decor_view, "display", display);
SetIntFieldRaw(decor_view, "width", 1280);
SetIntFieldRaw(decor_view, "height", 720);
const mocktail::runtime::DisplaySize host_window =
mocktail::runtime::ParseDisplaySize(
std::getenv(mocktail::runtime::kWindowSizeEnvironment));
SetIntFieldRaw(decor_view, "width", host_window.width);
SetIntFieldRaw(decor_view, "height", host_window.height);
SetObjectFieldRaw(surface_view, "holder", surface_holder);
SetObjectFieldRaw(surface_view, "surface", surface);
SetObjectFieldRaw(surface_view, "rootView", root_view);
SetIntFieldRaw(surface_view, "width", 1280);
SetIntFieldRaw(surface_view, "height", 720);
SetIntFieldRaw(surface_view, "width", host_window.width);
SetIntFieldRaw(surface_view, "height", host_window.height);
SetObjectFieldRaw(surface_holder, "surface", surface);
SetObjectFieldRaw(surface_holder, "surfaceFrame",
@@ -2461,11 +2482,14 @@ void EnsureAndroidObjectGraph() {
SetBooleanFieldRaw(surface, "valid", JNI_TRUE);
SetBooleanFieldRaw(surface, "isValid", JNI_TRUE);
SetIntFieldRaw(display, "width", 1280);
SetIntFieldRaw(display, "height", 720);
const mocktail::runtime::DisplaySize host_display =
mocktail::runtime::ParseDisplaySize(
std::getenv(mocktail::runtime::kDisplaySizeEnvironment));
SetIntFieldRaw(display, "width", host_display.width);
SetIntFieldRaw(display, "height", host_display.height);
SetIntFieldRaw(display, "rotation", 0);
SetIntFieldRaw(display_metrics, "widthPixels", 1280);
SetIntFieldRaw(display_metrics, "heightPixels", 720);
SetIntFieldRaw(display_metrics, "widthPixels", host_display.width);
SetIntFieldRaw(display_metrics, "heightPixels", host_display.height);
SetIntFieldRaw(display_metrics, "densityDpi", 160);
SetFloatFieldRaw(display_metrics, "density", 1.0f);
SetFloatFieldRaw(display_metrics, "scaledDensity", 1.0f);
@@ -2476,9 +2500,11 @@ void EnsureAndroidObjectGraph() {
: PlatformIdentity{};
SetIntFieldRaw(configuration, "orientation", 2);
SetIntFieldRaw(configuration, "densityDpi", 160);
SetIntFieldRaw(configuration, "screenWidthDp", 1280);
SetIntFieldRaw(configuration, "screenHeightDp", 720);
SetIntFieldRaw(configuration, "smallestScreenWidthDp", 720);
// Density is 1.0, so dp equals window pixels.
SetIntFieldRaw(configuration, "screenWidthDp", host_window.width);
SetIntFieldRaw(configuration, "screenHeightDp", host_window.height);
SetIntFieldRaw(configuration, "smallestScreenWidthDp",
std::min(host_window.width, host_window.height));
SetIntFieldRaw(configuration, "touchscreen", identity.touch_enabled ? 3 : 1);
SetIntFieldRaw(configuration, "keyboard", identity.keyboard_enabled ? 2 : 1);
SetIntFieldRaw(configuration, "keyboardHidden",
@@ -3839,8 +3865,30 @@ jobjectArray MakeObjectArray(jsize len, jobject init) {
return ref;
}
// NativeQuoteInterface.requestResponse([B)[B reply when no Android Keystore
// exists: status byte 1, attestation-available byte 0, then the error text.
// A real device with a keystore answers [1, 1, chain] instead.
jbyteArray MakeQuoteUnavailableResponse() {
static const char kMessage[] =
"java.security.KeyStoreException: AndroidKeyStore is not available";
const std::size_t message_length = sizeof(kMessage) - 1;
jbyteArray result = MakeByteArray(static_cast<jsize>(2 + message_length));
PseudoArray* array = ArrayFromRef(result);
if (array == nullptr || array->bytes.size() != 2 + message_length) {
return nullptr;
}
array->bytes[0] = 1;
array->bytes[1] = 0;
std::memcpy(array->bytes.data() + 2, kMessage, message_length);
return result;
}
jobject StaticObjectResultForMethod(jmethodID method_id) {
const char* name = MethodName(method_id);
if (std::strcmp(name, "requestResponse") == 0 &&
std::strcmp(MethodSignature(method_id), "([B)[B") == 0) {
return MakeQuoteUnavailableResponse();
}
const PlatformIdentity identity = CurrentPlatformIdentity();
jobject android_object = AndroidObjectForMethod(name);
if (android_object) {
@@ -4952,10 +5000,15 @@ jobject CreateAndroidConfiguration(JNIEnv* env) {
SetIntFieldRaw(configuration, "navigation", 1);
SetIntFieldRaw(configuration, "navigationHidden", 1);
SetIntFieldRaw(configuration, "orientation", 2);
SetIntFieldRaw(configuration, "screenHeightDp", 720);
// Density is 1.0, so dp equals window pixels.
const mocktail::runtime::DisplaySize config_window =
mocktail::runtime::ParseDisplaySize(
std::getenv(mocktail::runtime::kWindowSizeEnvironment));
SetIntFieldRaw(configuration, "screenHeightDp", config_window.height);
SetIntFieldRaw(configuration, "screenLayout", 0);
SetIntFieldRaw(configuration, "screenWidthDp", 1280);
SetIntFieldRaw(configuration, "smallestScreenWidthDp", 720);
SetIntFieldRaw(configuration, "screenWidthDp", config_window.width);
SetIntFieldRaw(configuration, "smallestScreenWidthDp",
std::min(config_window.width, config_window.height));
SetIntFieldRaw(configuration, "touchscreen", identity.touch_enabled ? 3 : 1);
SetIntFieldRaw(configuration, "uiMode", 0);
return configuration;
+110 -27
View File
@@ -1,8 +1,10 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#include <algorithm>
#include <atomic>
#include <cctype>
#include <cerrno>
#include <chrono>
#include <cmath>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
@@ -56,6 +58,8 @@
#include "libc_shim/libc_shim.h"
#include "linker/linker.h"
#include "mocktail/graphics/bionic_egl_bridge.h"
#include "runtime/device_memory_profile.h"
#include "runtime/display_size.h"
#include "runtime/environment.h"
#include "runtime/discord_rpc.h"
#include "runtime/jnivm_platform_web_callbacks.h"
@@ -70,6 +74,7 @@
#include "runtime/roblox_text_input_jni_bridge.h"
#include "runtime/runtime_config.h"
#include "runtime/runtime_paths.h"
#include "runtime/texture_memory_policy.h"
#include "services/client_settings_service.h"
#include "services/http_client.h"
#include "window/window.h"
@@ -2393,6 +2398,23 @@ void InstallNativeGlJavaImplementation(JNIEnv* env, jclass native_gl_java_class)
jobject BuildPlatformParams(JNIEnv* env, jobject surface, bool is_headless);
mocktail::runtime::DisplaySize HostDisplaySize() {
return mocktail::runtime::ParseDisplaySize(
std::getenv(mocktail::runtime::kDisplaySizeEnvironment));
}
// Live window pixels once the host window exists; the initial window size
// handoff otherwise.
mocktail::runtime::DisplaySize HostWindowPixelSize() {
const mocktail::window::WindowViewportSnapshot viewport =
mocktail::window::GetWindowViewportSnapshot();
if (viewport.valid()) {
return {viewport.pixel_width, viewport.pixel_height};
}
return mocktail::runtime::ParseDisplaySize(
std::getenv(mocktail::runtime::kWindowSizeEnvironment));
}
jobject BuildDeviceParams(JNIEnv* env) {
jobject params = NewObject(env, "com/roblox/engine/jni/model/DeviceParams");
if (!params) {
@@ -2414,27 +2436,42 @@ jobject BuildDeviceParams(JNIEnv* env) {
SetStringField(env, params, "appVersion", app_version.c_str());
SetStringField(env, params, "country", "US");
SetStringField(env, params, "manufacturer", manufacturer.c_str());
SetStringField(env, params, "displayResolution", "1280x720");
const mocktail::runtime::DisplaySize display_size =
mocktail::runtime::ParseDisplaySize(
std::getenv(mocktail::runtime::kDisplaySizeEnvironment));
const std::string display_resolution = std::to_string(display_size.width) +
"x" +
std::to_string(display_size.height);
SetStringField(env, params, "displayResolution", display_resolution.c_str());
SetStringField(env, params, "networkType", "wifi");
SetStringField(env, params, "deviceSku", device_sku.c_str());
SetStringField(env, params, "socModel", soc_model.c_str());
SetStringField(env, params, "appBuildVariant", "googleProdRelease");
SetStringField(env, params, "testDeviceName", device_name.c_str());
const bool is_low_ram = !IsEnabled("MOCKTAIL_DISABLE_LOW_RAM_DEVICE");
SetIntField(env, params, "deviceTotalMemoryMB", is_low_ram ? 2048 : 4096);
SetIntField(env, params, "displayPhysicalWidthPixels", 1280);
SetIntField(env, params, "displayPhysicalHeightPixels", 720);
SetIntField(env, params, "memoryClass", is_low_ram ? 256 : 512);
SetIntField(env, params, "largeMemoryClass", is_low_ram ? 512 : 1024);
// MOCKTAIL_DISABLE_LOW_RAM_DEVICE forces the normal-RAM profile even when
// the host total cannot be read or is below 4 GiB.
std::uint64_t host_memory_bytes = mocktail::runtime::DetectHostMemoryBytes();
if (IsEnabled("MOCKTAIL_DISABLE_LOW_RAM_DEVICE")) {
host_memory_bytes =
std::max<std::uint64_t>(host_memory_bytes, 4096ULL * 1024ULL * 1024ULL);
}
const mocktail::runtime::DeviceMemoryProfile memory =
mocktail::runtime::BuildDeviceMemoryProfile(host_memory_bytes);
SetIntField(env, params, "deviceTotalMemoryMB", memory.total_memory_mb);
SetIntField(env, params, "displayPhysicalWidthPixels", display_size.width);
SetIntField(env, params, "displayPhysicalHeightPixels",
display_size.height);
SetIntField(env, params, "memoryClass", memory.memory_class_mb);
SetIntField(env, params, "largeMemoryClass", memory.large_memory_class_mb);
SetLongField(env, params, "lowMemoryKillerBackgroundAppThreshold",
is_low_ram ? 256 : 0);
memory.low_memory_killer_background_threshold);
SetLongField(env, params, "lowMemoryKillerForegroundAppThreshold",
is_low_ram ? 512 : 0);
memory.low_memory_killer_foreground_threshold);
SetBooleanField(env, params, "cpu64Bit", JNI_TRUE);
SetBooleanField(env, params, "isChrome", JNI_FALSE);
SetBooleanField(env, params, "isLowRamDevice",
is_low_ram ? JNI_TRUE : JNI_FALSE);
memory.low_ram_device ? JNI_TRUE : JNI_FALSE);
return params;
}
@@ -2534,8 +2571,9 @@ jobject BuildAppBridgeInitParams(JNIEnv* env, jstring client_settings,
SetStringField(env, params, "locale", "en_us");
SetRobloxServiceUrlFields(env, params);
SetIntField(env, params, "screenWidth", 1280);
SetIntField(env, params, "screenHeight", 720);
const mocktail::runtime::DisplaySize init_display = HostDisplaySize();
SetIntField(env, params, "screenWidth", init_display.width);
SetIntField(env, params, "screenHeight", init_display.height);
SetIntField(env, params, "densityDpi", 160);
SetIntField(env, params, "sdkVersion", 33);
jboolean headless = is_headless ? JNI_TRUE : JNI_FALSE;
@@ -2569,13 +2607,19 @@ jobject BuildPlatformParams(JNIEnv* env, jobject surface, bool is_headless) {
SetStringField(env, params, "deviceName", platform_device_name.c_str());
SetStringField(env, params, "locale", "en_us");
SetStringField(env, params, "assetFolderPath", DefaultAssetPath().c_str());
SetIntField(env, params, "width", 1280);
SetIntField(env, params, "height", 720);
SetIntField(env, params, "screenWidth", 1280);
SetIntField(env, params, "screenHeight", 720);
const mocktail::runtime::DisplaySize platform_window = HostWindowPixelSize();
const mocktail::runtime::DisplaySize platform_display = HostDisplaySize();
SetIntField(env, params, "width", platform_window.width);
SetIntField(env, params, "height", platform_window.height);
SetIntField(env, params, "screenWidth", platform_display.width);
SetIntField(env, params, "screenHeight", platform_display.height);
SetIntField(env, params, "densityDpi", 160);
SetIntField(env, params, "viewportWidthMm", 203);
SetIntField(env, params, "viewportHeightMm", 114);
SetIntField(env, params, "viewportWidthMm",
mocktail::runtime::PixelsToMillimetersAt160Dpi(
platform_window.width));
SetIntField(env, params, "viewportHeightMm",
mocktail::runtime::PixelsToMillimetersAt160Dpi(
platform_window.height));
const mocktail::window::WindowViewportSnapshot viewport =
mocktail::window::GetWindowViewportSnapshot();
SetFloatField(env, params, "dpiScale", viewport.dpi_scale);
@@ -2684,10 +2728,12 @@ jobject BuildStartAppParams(JNIEnv* env, jstring app_params,
SetStringField(env, params, "deviceName", start_device_name.c_str());
SetStringField(env, params, "locale", "en_us");
SetRobloxServiceUrlFields(env, params);
SetIntField(env, params, "width", 1280);
SetIntField(env, params, "height", 720);
SetIntField(env, params, "screenWidth", 1280);
SetIntField(env, params, "screenHeight", 720);
const mocktail::runtime::DisplaySize start_window = HostWindowPixelSize();
const mocktail::runtime::DisplaySize start_display = HostDisplaySize();
SetIntField(env, params, "width", start_window.width);
SetIntField(env, params, "height", start_window.height);
SetIntField(env, params, "screenWidth", start_display.width);
SetIntField(env, params, "screenHeight", start_display.height);
SetIntField(env, params, "densityDpi", 160);
SetIntField(env, params, "sdkVersion", 33);
SetIntField(env, params, "placeId", 0);
@@ -2815,8 +2861,9 @@ jobject BuildMockSurface(JNIEnv* env) {
if (!surface) {
return nullptr;
}
SetIntField(env, surface, "width", 1280);
SetIntField(env, surface, "height", 720);
const mocktail::runtime::DisplaySize surface_size = HostWindowPixelSize();
SetIntField(env, surface, "width", surface_size.width);
SetIntField(env, surface, "height", surface_size.height);
SetBooleanField(env, surface, "valid", JNI_TRUE);
SetBooleanField(env, surface, "isValid", JNI_TRUE);
return surface;
@@ -3913,7 +3960,10 @@ std::cerr << " [engine] nativeAppBridgeV2InitWithParams recovered\n"
on_surface_created(env, game_activity, handle, surface);
}
if (run_lifecycle_callbacks && on_surface_changed) {
on_surface_changed(env, game_activity, handle, surface, 4, 1280, 720);
const mocktail::runtime::DisplaySize changed_size =
HostWindowPixelSize();
on_surface_changed(env, game_activity, handle, surface, 4,
changed_size.width, changed_size.height);
}
if (run_lifecycle_callbacks && on_surface_redraw_needed) {
on_surface_redraw_needed(env, game_activity, handle, surface);
@@ -4084,8 +4134,9 @@ std::cerr << " [engine] nativeAppBridgeV2InitWithParams recovered\n"
ShouldRunStartupStep("MOCKTAIL_UPDATE_APP_UI_SIZES", false)) {
env = ensure_env();
std::cout << " [engine] updateAppUISizes\n" << std::flush;
context->native_update_app_ui_sizes(env, native_gl_class, 1280, 720, 0, 0,
0);
const mocktail::runtime::DisplaySize ui_size = HostWindowPixelSize();
context->native_update_app_ui_sizes(env, native_gl_class, ui_size.width,
ui_size.height, 0, 0, 0);
std::cout << " [engine] updateAppUISizes returned\n" << std::flush;
}
@@ -4726,6 +4777,38 @@ int mocktail::legacy::Run(const runtime::CommandLineOptions& options,
<< std::flush;
}
}
if (window_initialised) {
auto* sdl_window =
static_cast<SDL_Window*>(mocktail::window::GetBackendWindow());
const SDL_DisplayID display =
sdl_window != nullptr ? SDL_GetDisplayForWindow(sdl_window) : 0;
const SDL_DisplayMode* mode =
display != 0 ? SDL_GetCurrentDisplayMode(display) : nullptr;
if (mode != nullptr && mode->w > 0 && mode->h > 0) {
// SDL display modes are in desktop units; pixel_density maps them to
// physical pixels.
const float density = mode->pixel_density > 0.0f ? mode->pixel_density
: 1.0f;
const std::string display_size =
std::to_string(std::lround(mode->w * density)) + "x" +
std::to_string(std::lround(mode->h * density));
setenv(mocktail::runtime::kDisplaySizeEnvironment, display_size.c_str(),
1);
std::cout << " [window] host display " << display_size << " pixels\n"
<< std::flush;
}
}
if (window_initialised) {
const mocktail::window::WindowViewportSnapshot viewport =
mocktail::window::GetWindowViewportSnapshot();
if (viewport.valid()) {
const std::string window_size = std::to_string(viewport.pixel_width) +
"x" +
std::to_string(viewport.pixel_height);
setenv(mocktail::runtime::kWindowSizeEnvironment, window_size.c_str(),
1);
}
}
const SDL_SystemTheme system_theme =
window_initialised ? SDL_GetSystemTheme() : SDL_SYSTEM_THEME_UNKNOWN;
const bool system_dark_theme = system_theme == SDL_SYSTEM_THEME_DARK;
+35
View File
@@ -0,0 +1,35 @@
#include "runtime/device_memory_profile.h"
#include <algorithm>
#include <limits>
namespace mocktail {
namespace runtime {
namespace {
constexpr std::uint64_t kMebibyte = 1024U * 1024U;
constexpr std::uint64_t kMinimumNormalRamBytes = 4096U * kMebibyte;
} // namespace
DeviceMemoryProfile BuildDeviceMemoryProfile(std::uint64_t host_memory_bytes) {
DeviceMemoryProfile profile;
if (host_memory_bytes < kMinimumNormalRamBytes) {
profile.total_memory_mb = 2048;
profile.memory_class_mb = 256;
profile.large_memory_class_mb = 512;
profile.low_memory_killer_background_threshold = 256;
profile.low_memory_killer_foreground_threshold = 512;
profile.low_ram_device = true;
return profile;
}
profile.total_memory_mb = static_cast<std::int32_t>(std::min<std::uint64_t>(
host_memory_bytes / kMebibyte,
static_cast<std::uint64_t>(std::numeric_limits<std::int32_t>::max())));
profile.memory_class_mb = 512;
profile.large_memory_class_mb = 1024;
return profile;
}
} // namespace runtime
} // namespace mocktail
+4 -1
View File
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#include "runtime/runtime_config_bootstrap.h"
#include <fcntl.h>
@@ -64,7 +65,9 @@ graphics:
# display, unlimited, or any positive integer; fixed values are forwarded to
# DFIntTaskSchedulerTargetFps without a whitelist.
# frame_rate_limit: -1
# Optional presentation synchronization override: auto, on, or off.
# Optional presentation synchronization override: auto, on, or off. auto
# presents through the lowest-latency synchronized mode the driver offers
# unless frame_rate_limit is unlimited.
# vsync: off
performance:
+4 -1
View File
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#include "runtime/runtime_paths.h"
#define JSON_NOEXCEPTION 1
@@ -603,7 +604,9 @@ bool ExportRuntimePathEnvironment(const RuntimePaths& paths,
SetEnvironmentDefault("MOCKTAIL_ANDROID_CACHE_HOST_ROOT",
paths.android_cache_root(), error) &&
SetEnvironmentDefault("MOCKTAIL_VULKAN_SHADER_CACHE_HOST_PATH",
paths.vulkan_shader_cache_file(), error);
paths.vulkan_shader_cache_file(), error) &&
SetEnvironmentDefault("MOCKTAIL_TEXTURE_OVERRIDE_DIR",
paths.config_root() / "textures", error);
}
bool PrepareManagedPayloadWorkingDirectory(const RuntimePaths& paths,
+4 -3
View File
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#include <adwaita.h>
#include <glib-unix.h>
#include <sys/socket.h>
@@ -153,7 +154,7 @@ void InstallProgressStyle(GdkDisplay* display) {
}
bool InitializeUi(UiStyle style) {
g_set_application_name("Mocktail");
g_set_application_name("Nightcap");
if (!gtk_init_check()) {
return false;
}
@@ -169,7 +170,7 @@ bool InitializeUi(UiStyle style) {
if (display == nullptr) {
return false;
}
gtk_window_set_default_icon_name("space.bigrat.mocktail");
gtk_window_set_default_icon_name("io.github.CoderDayton.nightcap");
adw_style_manager_set_color_scheme(adw_style_manager_get_default(),
ADW_COLOR_SCHEME_FORCE_DARK);
adw_style_manager_set_color_scheme(adw_style_manager_get_for_display(display),
@@ -229,7 +230,7 @@ void PresentProgressWindow(ProgressState* state, std::string_view message) {
GtkWidget* window_widget = adw_window_new();
state->window = GTK_WINDOW(g_object_ref_sink(window_widget));
gtk_widget_add_css_class(window_widget, "mocktail-update-progress");
gtk_window_set_title(state->window, "Mocktail");
gtk_window_set_title(state->window, "Nightcap");
gtk_window_set_default_size(state->window, 470, 640);
GtkWidget* toolbar_widget = adw_toolbar_view_new();
+145 -123
View File
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#include "update/host_abi_deriver.h"
#define JSON_NOEXCEPTION 1
@@ -14,6 +15,7 @@
#include <array>
#include <cctype>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <filesystem>
#include <iterator>
@@ -1358,132 +1360,152 @@ std::optional<Json> DeriveRuntimeCompatibility(
*error = "reference FMOD string constructor contract changed";
return std::nullopt;
}
const auto string_constructor = FindUniqueSemanticSignatureMatch(
reference, candidate, disassembler,
{"fmod-string-constructor", old.string_constructor, 32, false, 3},
error);
const auto info_method = FindUniqueSemanticSignatureMatch(
reference, candidate, disassembler,
{"fmod-output-info", old.info_method, 18, false, 3}, error);
// A missing legacy selector is expected at the device-list ABI transition.
// The new layout is accepted only with its own complete selector contract.
std::string select_error;
const auto select_method = FindUniqueSemanticSignatureMatch(
reference, candidate, disassembler,
{"fmod-output-select", old.select_method, 18, false, 3}, &select_error);
if (!string_constructor.has_value() || !info_method.has_value()) {
return std::nullopt;
}
const auto count_matches = FindSignatureMatches(
reference, candidate, disassembler,
{"fmod-output-count", old.count_method, 24, false, 3}, true, error);
const auto current_matches = FindSignatureMatches(
reference, candidate, disassembler,
{"fmod-output-current", old.current_method, 24, false, 3}, true,
error);
if (!count_matches.has_value() || !current_matches.has_value()) {
return std::nullopt;
}
std::set<std::uint64_t> count_candidates;
std::set<std::uint64_t> current_candidates;
for (const SignatureMatch& match : *count_matches)
count_candidates.insert(match.rva);
for (const SignatureMatch& match : *current_matches)
current_candidates.insert(match.rva);
if (count_candidates.empty() || current_candidates.empty()) {
*error = "FMOD count/current method signatures have no candidates";
return std::nullopt;
}
const auto relocations = candidate.RelativeRelocations(error);
if (!relocations.has_value()) return std::nullopt;
std::vector<FmodRuntimeAnchors> candidates;
for (const auto& [offset, addend] : *relocations) {
if (addend != info_method->rva || offset < kInfoIndex * 8) continue;
const std::uint64_t vtable = offset - kInfoIndex * 8;
const auto count = relocations->find(vtable + kCountIndex * 8);
for (const int layout : {1, 2}) {
FmodRuntimeAnchors derived;
derived.layout_version = layout;
const auto current = relocations->find(vtable + derived.current_index() * 8);
const auto select = relocations->find(vtable + derived.select_index() * 8);
std::string relro_error;
if (vtable % 8 != 0 || count == relocations->end() ||
current == relocations->end() || select == relocations->end() ||
count_candidates.find(count->second) == count_candidates.end() ||
current_candidates.find(current->second) == current_candidates.end() ||
count->second == current->second ||
!candidate.RequireRelro(vtable, (derived.select_index() + 1) * 8,
&relro_error)) {
continue;
}
if (layout == 1) {
if (old.layout_version != 1 || !select_method.has_value() ||
select->second != select_method->rva) continue;
} else if (!HasFmodDeviceListsSelectContract(candidate, select->second)) {
continue;
}
candidates.push_back({vtable, string_constructor->rva, count->second,
info_method->rva, current->second, select->second,
layout});
// The FMOD output-device bridge is optional at runtime. A candidate whose
// FMOD output methods cannot be matched is derived without the bridge.
std::string fmod_error;
const auto bridge = [&]() -> std::optional<Json> {
const auto string_constructor = FindUniqueSemanticSignatureMatch(
reference, candidate, disassembler,
{"fmod-string-constructor", old.string_constructor, 32, false, 3},
&fmod_error);
const auto info_method = FindUniqueSemanticSignatureMatch(
reference, candidate, disassembler,
{"fmod-output-info", old.info_method, 18, false, 3}, &fmod_error);
// A missing legacy selector is expected at the device-list ABI
// transition. The new layout is accepted only with its own complete
// selector contract.
std::string select_error;
const auto select_method = FindUniqueSemanticSignatureMatch(
reference, candidate, disassembler,
{"fmod-output-select", old.select_method, 18, false, 3},
&select_error);
if (!string_constructor.has_value() || !info_method.has_value()) {
return std::nullopt;
}
}
if (candidates.size() != 1U) {
*error = "FMOD output vtable matched " +
std::to_string(candidates.size()) + " candidate locations";
return std::nullopt;
}
const FmodRuntimeAnchors& derived = candidates.front();
if (!HasFmodStringConstructorContract(candidate,
derived.string_constructor)) {
*error = "candidate FMOD string constructor contract changed";
return std::nullopt;
}
result["fmod_output_device_bridge"] = {
{"vtable_rva", FormatRva(derived.vtable)},
{"string_constructor_rva", FormatRva(derived.string_constructor)},
{"count_method_rva", FormatRva(derived.count_method)},
{"info_method_rva", FormatRva(derived.info_method)},
{"current_method_rva", FormatRva(derived.current_method)},
{"select_method_rva", FormatRva(derived.select_method)},
};
if (old.input_methods[0] != 0) {
constexpr std::array<std::string_view, 4> fields = {
"input_count_method_rva", "input_info_method_rva",
"input_current_method_rva", "input_select_method_rva"};
constexpr std::array<std::size_t, 4> lengths = {4, 16, 12, 16};
const auto old_slots = old.input_indexes();
const auto new_slots = derived.input_indexes();
for (std::size_t i = 0; i < fields.size(); ++i) {
const auto old_method =
reference_relocations->find(old.vtable + old_slots[i] * 8);
const auto new_method =
relocations->find(derived.vtable + new_slots[i] * 8);
if (old_method == reference_relocations->end() ||
old_method->second != old.input_methods[i] ||
new_method == relocations->end()) {
*error = "FMOD input vtable does not match its methods";
return std::nullopt;
}
const auto matches = FindSignatureMatches(
reference, candidate, disassembler,
{std::string(fields[i]), old.input_methods[i], lengths[i], false, 3},
true, error);
if (!matches || !std::any_of(matches->begin(), matches->end(),
[&](const auto &match) {
return match.rva == new_method->second;
})) {
if (error->empty())
*error = "candidate FMOD input contract changed";
return std::nullopt;
}
result["fmod_output_device_bridge"][fields[i]] =
FormatRva(new_method->second);
const auto count_matches = FindSignatureMatches(
reference, candidate, disassembler,
{"fmod-output-count", old.count_method, 24, false, 3}, true,
&fmod_error);
const auto current_matches = FindSignatureMatches(
reference, candidate, disassembler,
{"fmod-output-current", old.current_method, 24, false, 3}, true,
&fmod_error);
if (!count_matches.has_value() || !current_matches.has_value()) {
return std::nullopt;
}
std::set<std::uint64_t> count_candidates;
std::set<std::uint64_t> current_candidates;
for (const SignatureMatch& match : *count_matches)
count_candidates.insert(match.rva);
for (const SignatureMatch& match : *current_matches)
current_candidates.insert(match.rva);
if (count_candidates.empty() || current_candidates.empty()) {
fmod_error = "FMOD count/current method signatures have no candidates";
return std::nullopt;
}
const auto relocations = candidate.RelativeRelocations(&fmod_error);
if (!relocations.has_value()) return std::nullopt;
std::vector<FmodRuntimeAnchors> candidates;
for (const auto& [offset, addend] : *relocations) {
if (addend != info_method->rva || offset < kInfoIndex * 8) continue;
const std::uint64_t vtable = offset - kInfoIndex * 8;
const auto count = relocations->find(vtable + kCountIndex * 8);
for (const int layout : {1, 2}) {
FmodRuntimeAnchors derived;
derived.layout_version = layout;
const auto current =
relocations->find(vtable + derived.current_index() * 8);
const auto select =
relocations->find(vtable + derived.select_index() * 8);
std::string relro_error;
if (vtable % 8 != 0 || count == relocations->end() ||
current == relocations->end() || select == relocations->end() ||
count_candidates.find(count->second) == count_candidates.end() ||
current_candidates.find(current->second) ==
current_candidates.end() ||
count->second == current->second ||
!candidate.RequireRelro(vtable, (derived.select_index() + 1) * 8,
&relro_error)) {
continue;
}
if (layout == 1) {
if (old.layout_version != 1 || !select_method.has_value() ||
select->second != select_method->rva)
continue;
} else if (!HasFmodDeviceListsSelectContract(candidate,
select->second)) {
continue;
}
candidates.push_back({vtable, string_constructor->rva, count->second,
info_method->rva, current->second,
select->second, layout});
}
}
if (candidates.size() != 1U) {
fmod_error = "FMOD output vtable matched " +
std::to_string(candidates.size()) + " candidate locations";
return std::nullopt;
}
const FmodRuntimeAnchors& derived = candidates.front();
if (!HasFmodStringConstructorContract(candidate,
derived.string_constructor)) {
fmod_error = "candidate FMOD string constructor contract changed";
return std::nullopt;
}
Json bridge_json = {
{"vtable_rva", FormatRva(derived.vtable)},
{"string_constructor_rva", FormatRva(derived.string_constructor)},
{"count_method_rva", FormatRva(derived.count_method)},
{"info_method_rva", FormatRva(derived.info_method)},
{"current_method_rva", FormatRva(derived.current_method)},
{"select_method_rva", FormatRva(derived.select_method)},
};
if (old.input_methods[0] != 0) {
constexpr std::array<std::string_view, 4> fields = {
"input_count_method_rva", "input_info_method_rva",
"input_current_method_rva", "input_select_method_rva"};
constexpr std::array<std::size_t, 4> lengths = {4, 16, 12, 16};
const auto old_slots = old.input_indexes();
const auto new_slots = derived.input_indexes();
for (std::size_t i = 0; i < fields.size(); ++i) {
const auto old_method =
reference_relocations->find(old.vtable + old_slots[i] * 8);
const auto new_method =
relocations->find(derived.vtable + new_slots[i] * 8);
if (old_method == reference_relocations->end() ||
old_method->second != old.input_methods[i] ||
new_method == relocations->end()) {
fmod_error = "FMOD input vtable does not match its methods";
return std::nullopt;
}
const auto matches = FindSignatureMatches(
reference, candidate, disassembler,
{std::string(fields[i]), old.input_methods[i], lengths[i], false,
3},
true, &fmod_error);
if (!matches || !std::any_of(matches->begin(), matches->end(),
[&](const auto& match) {
return match.rva == new_method->second;
})) {
if (fmod_error.empty())
fmod_error = "candidate FMOD input contract changed";
return std::nullopt;
}
bridge_json[fields[i]] = FormatRva(new_method->second);
}
}
if (derived.layout_version != 1) {
bridge_json["vtable_layout_version"] = derived.layout_version;
}
return bridge_json;
}();
if (!bridge.has_value()) {
std::fprintf(stderr,
"[native-updater] FMOD output-device bridge omitted: %s\n",
fmod_error.c_str());
return result;
}
if (derived.layout_version != 1) {
result["fmod_output_device_bridge"]["vtable_layout_version"] =
derived.layout_version;
}
result["fmod_output_device_bridge"] = *bridge;
return result;
}
+7
View File
@@ -1,3 +1,4 @@
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# Licensed under the Apache License, Version 2.0.
@@ -106,13 +107,19 @@ target_link_libraries(stub_glesv2 PRIVATE dl)
add_library(stub_vulkan SHARED
${CMAKE_SOURCE_DIR}/src/graphics/bionic_vulkan_loader_adapter.cc
${CMAKE_SOURCE_DIR}/src/graphics/vulkan_text_overlay_compositor.cc
${CMAKE_SOURCE_DIR}/src/graphics/vulkan_etc2_emulation.cc
${CMAKE_SOURCE_DIR}/src/graphics/etc2_decoder.cc
${CMAKE_SOURCE_DIR}/src/graphics/texture_override.cc
)
configure_stub(stub_vulkan "libvulkan.so")
target_include_directories(stub_vulkan PRIVATE ${CMAKE_SOURCE_DIR}/include)
pkg_check_modules(LIBPLACEBO REQUIRED IMPORTED_TARGET libplacebo)
pkg_check_modules(LIBPNG REQUIRED IMPORTED_TARGET libpng)
target_link_libraries(stub_vulkan PRIVATE
Mocktail::SdlVulkanWsi
PkgConfig::LIBPLACEBO
PkgConfig::LIBPNG
Threads::Threads
dl
)
+54 -1
View File
@@ -1,3 +1,4 @@
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
#
# Licensed under the Apache License, Version 2.0 (the "License")
@@ -119,6 +120,18 @@ target_link_libraries(texture_memory_policy_test PRIVATE
GTest::gtest_main
)
add_executable(device_memory_profile_test device_memory_profile_test.cc)
target_link_libraries(device_memory_profile_test PRIVATE
Mocktail::Runtime
GTest::gtest_main
)
add_executable(display_size_test display_size_test.cc)
target_link_libraries(display_size_test PRIVATE
Mocktail::Runtime
GTest::gtest_main
)
add_executable(http_client_policy_test http_client_policy_test.cc)
target_link_libraries(http_client_policy_test PRIVATE
Mocktail::Runtime
@@ -477,6 +490,42 @@ target_link_libraries(vulkan_text_overlay_compositor_test PRIVATE
)
mocktail_apply_compile_options(vulkan_text_overlay_compositor_test)
add_executable(etc2_decoder_test
etc2_decoder_test.cc
${PROJECT_SOURCE_DIR}/src/graphics/etc2_decoder.cc
)
target_include_directories(etc2_decoder_test PRIVATE
${PROJECT_SOURCE_DIR}/include
)
target_link_libraries(etc2_decoder_test PRIVATE GTest::gtest_main Threads::Threads)
mocktail_apply_compile_options(etc2_decoder_test)
pkg_check_modules(LIBPNG REQUIRED IMPORTED_TARGET libpng)
add_executable(texture_override_test
texture_override_test.cc
${PROJECT_SOURCE_DIR}/src/graphics/texture_override.cc
)
target_include_directories(texture_override_test PRIVATE
${PROJECT_SOURCE_DIR}/include
)
target_link_libraries(texture_override_test PRIVATE GTest::gtest_main
PkgConfig::LIBPNG)
mocktail_apply_compile_options(texture_override_test)
add_executable(vulkan_etc2_emulation_test
vulkan_etc2_emulation_test.cc
${PROJECT_SOURCE_DIR}/src/graphics/vulkan_etc2_emulation.cc
${PROJECT_SOURCE_DIR}/src/graphics/etc2_decoder.cc
${PROJECT_SOURCE_DIR}/src/graphics/texture_override.cc
)
target_include_directories(vulkan_etc2_emulation_test PRIVATE
${PROJECT_SOURCE_DIR}/include
)
target_link_libraries(vulkan_etc2_emulation_test PRIVATE GTest::gtest_main
Threads::Threads PkgConfig::LIBPNG)
mocktail_apply_compile_options(vulkan_etc2_emulation_test)
add_executable(video_driver_policy_test
video_driver_policy_test.cc
)
@@ -894,6 +943,8 @@ gtest_discover_tests(failure_dialog_test)
gtest_discover_tests(frame_rate_policy_test)
gtest_discover_tests(performance_policy_test)
gtest_discover_tests(texture_memory_policy_test)
gtest_discover_tests(device_memory_profile_test)
gtest_discover_tests(display_size_test)
gtest_discover_tests(http_client_policy_test)
gtest_discover_tests(http_client_spin_guard_test)
gtest_discover_tests(crash_report_policy_test)
@@ -937,6 +988,8 @@ gtest_discover_tests(input_pump_pacer_test)
gtest_discover_tests(vulkan_surface_recovery_gate_test)
gtest_discover_tests(vulkan_present_progress_gate_test)
gtest_discover_tests(vulkan_text_overlay_compositor_test)
gtest_discover_tests(etc2_decoder_test)
gtest_discover_tests(vulkan_etc2_emulation_test)
gtest_discover_tests(video_driver_policy_test)
gtest_discover_tests(window_surface_lifecycle_test)
gtest_discover_tests(window_creation_policy_test)
@@ -1006,7 +1059,7 @@ add_test(
NAME UrlHandlerRegistrationTest.ExplicitPerUserDefault
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/url_handler_registration_test.sh
${CMAKE_SOURCE_DIR}/scripts/register_url_handler.sh
${CMAKE_SOURCE_DIR}/packaging/space.bigrat.mocktail.desktop
${CMAKE_SOURCE_DIR}/packaging/io.github.CoderDayton.nightcap.desktop
)
add_test(
+2 -1
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# SPDX-License-Identifier: Apache-2.0
@@ -86,7 +87,7 @@ fi
"$4" == /usr/lib/mocktail/mocktail_updater &&
"$5" == /usr/lib/mocktail && "$6" == /usr/share/mocktail &&
"$7" == /usr/bin/bash ]]
[[ "${DESKTOP}" == /usr/share/applications/space.bigrat.mocktail.desktop ]]
[[ "${DESKTOP}" == /usr/share/applications/io.github.CoderDayton.nightcap.desktop ]]
[[ "${MAIN_BIN}" == mocktail && "${STRACE_MODE}" == 1 ]]
[[ "${STRACE_BINARY}" == mocktail && "${STRACE_FLAGS}" == --help ]]
[[ -z "${NO_STRIP:-}" ]]
+56
View File
@@ -0,0 +1,56 @@
#include "runtime/device_memory_profile.h"
#include <gtest/gtest.h>
#include <cstdint>
#include <limits>
namespace mocktail {
namespace runtime {
namespace {
constexpr std::uint64_t kMebibyte = 1024U * 1024U;
void ExpectLowRamProfile(const DeviceMemoryProfile& profile) {
EXPECT_TRUE(profile.low_ram_device);
EXPECT_EQ(profile.total_memory_mb, 2048);
EXPECT_EQ(profile.memory_class_mb, 256);
EXPECT_EQ(profile.large_memory_class_mb, 512);
EXPECT_EQ(profile.low_memory_killer_background_threshold, 256);
EXPECT_EQ(profile.low_memory_killer_foreground_threshold, 512);
}
TEST(DeviceMemoryProfileTest, KeepsTheLowRamProfileOnSmallOrUnknownHosts) {
ExpectLowRamProfile(BuildDeviceMemoryProfile(0));
ExpectLowRamProfile(BuildDeviceMemoryProfile(2048U * kMebibyte));
ExpectLowRamProfile(BuildDeviceMemoryProfile(4095U * kMebibyte));
}
TEST(DeviceMemoryProfileTest, ReportsRealHostMemoryAsANormalRamDevice) {
const DeviceMemoryProfile profile =
BuildDeviceMemoryProfile(62951U * kMebibyte);
EXPECT_FALSE(profile.low_ram_device);
EXPECT_EQ(profile.total_memory_mb, 62951);
EXPECT_EQ(profile.memory_class_mb, 512);
EXPECT_EQ(profile.large_memory_class_mb, 1024);
EXPECT_EQ(profile.low_memory_killer_background_threshold, 0);
EXPECT_EQ(profile.low_memory_killer_foreground_threshold, 0);
}
TEST(DeviceMemoryProfileTest, StartsTheNormalRamProfileAtFourGibibytes) {
const DeviceMemoryProfile profile =
BuildDeviceMemoryProfile(4096U * kMebibyte);
EXPECT_FALSE(profile.low_ram_device);
EXPECT_EQ(profile.total_memory_mb, 4096);
}
TEST(DeviceMemoryProfileTest, ClampsTotalMemoryToTheJavaIntRange) {
const DeviceMemoryProfile profile =
BuildDeviceMemoryProfile(std::numeric_limits<std::uint64_t>::max());
EXPECT_FALSE(profile.low_ram_device);
EXPECT_EQ(profile.total_memory_mb, std::numeric_limits<std::int32_t>::max());
}
} // namespace
} // namespace runtime
} // namespace mocktail
+44
View File
@@ -0,0 +1,44 @@
#include "runtime/display_size.h"
#include <gtest/gtest.h>
namespace mocktail {
namespace runtime {
namespace {
void ExpectSize(const DisplaySize& size, int width, int height) {
EXPECT_EQ(size.width, width);
EXPECT_EQ(size.height, height);
}
TEST(DisplaySizeTest, ParsesHostDisplayPixels) {
ExpectSize(ParseDisplaySize("3440x1440"), 3440, 1440);
ExpectSize(ParseDisplaySize("1280x720"), 1280, 720);
}
TEST(DisplaySizeTest, FallsBackForMissingOrMalformedValues) {
ExpectSize(ParseDisplaySize(nullptr), 1920, 1080);
ExpectSize(ParseDisplaySize(""), 1920, 1080);
ExpectSize(ParseDisplaySize("3440"), 1920, 1080);
ExpectSize(ParseDisplaySize("3440x"), 1920, 1080);
ExpectSize(ParseDisplaySize("x1440"), 1920, 1080);
ExpectSize(ParseDisplaySize("3440x1440junk"), 1920, 1080);
ExpectSize(ParseDisplaySize("-3440x1440"), 1920, 1080);
ExpectSize(ParseDisplaySize("0x1440"), 1920, 1080);
}
TEST(DisplaySizeTest, FallsBackWhenAValueDoesNotFitAJavaInt) {
ExpectSize(ParseDisplaySize("2147483648x1440"), 1920, 1080);
ExpectSize(ParseDisplaySize("99999999999999999999x1440"), 1920, 1080);
}
TEST(DisplaySizeTest, ConvertsPixelsToMillimetersAt160Dpi) {
EXPECT_EQ(PixelsToMillimetersAt160Dpi(1280), 203);
EXPECT_EQ(PixelsToMillimetersAt160Dpi(720), 114);
EXPECT_EQ(PixelsToMillimetersAt160Dpi(3440), 546);
EXPECT_EQ(PixelsToMillimetersAt160Dpi(0), 0);
}
} // namespace
} // namespace runtime
} // namespace mocktail
+271
View File
@@ -0,0 +1,271 @@
#include "mocktail/graphics/etc2_decoder.h"
#include <gtest/gtest.h>
#include <array>
#include <cstdint>
#include <iterator>
#include <random>
#include <vector>
namespace mocktail::graphics {
namespace {
using Block8 = std::array<std::uint8_t, 8>;
struct Rgba {
int r;
int g;
int b;
int a;
};
std::vector<std::uint8_t> Decode(EtcFormat format,
const std::vector<std::uint8_t>& source,
std::uint32_t width, std::uint32_t height) {
std::vector<std::uint8_t> output(
static_cast<std::size_t>(width) * height * EtcDecodedTexelBytes(format),
0xAB);
EXPECT_TRUE(DecodeEtcImage(format, source.data(), source.size(), width,
height, output.data(), output.size()));
return output;
}
std::vector<std::uint8_t> Bytes(const Block8& block) {
return {block.begin(), block.end()};
}
void ExpectRgba(const std::vector<std::uint8_t>& texels, std::uint32_t width,
std::uint32_t x, std::uint32_t y, Rgba expected) {
const std::size_t offset = (static_cast<std::size_t>(y) * width + x) * 4;
ASSERT_LT(offset + 3, texels.size());
EXPECT_EQ(texels[offset], expected.r) << "x=" << x << " y=" << y;
EXPECT_EQ(texels[offset + 1], expected.g) << "x=" << x << " y=" << y;
EXPECT_EQ(texels[offset + 2], expected.b) << "x=" << x << " y=" << y;
EXPECT_EQ(texels[offset + 3], expected.a) << "x=" << x << " y=" << y;
}
std::uint16_t Unsigned16(const std::vector<std::uint8_t>& texels,
std::size_t index) {
return static_cast<std::uint16_t>(texels[index * 2] |
(texels[index * 2 + 1] << 8));
}
std::int16_t Signed16(const std::vector<std::uint8_t>& texels,
std::size_t index) {
return static_cast<std::int16_t>(Unsigned16(texels, index));
}
TEST(Etc2DecoderTest, ReportsBlockAndTexelSizes) {
EXPECT_EQ(EtcBlockBytes(EtcFormat::kEtc2Rgb8), 8U);
EXPECT_EQ(EtcBlockBytes(EtcFormat::kEtc2Rgb8A1), 8U);
EXPECT_EQ(EtcBlockBytes(EtcFormat::kEtc2Rgba8), 16U);
EXPECT_EQ(EtcBlockBytes(EtcFormat::kEacR11), 8U);
EXPECT_EQ(EtcBlockBytes(EtcFormat::kEacR11Signed), 8U);
EXPECT_EQ(EtcBlockBytes(EtcFormat::kEacRg11), 16U);
EXPECT_EQ(EtcBlockBytes(EtcFormat::kEacRg11Signed), 16U);
EXPECT_EQ(EtcDecodedTexelBytes(EtcFormat::kEtc2Rgb8), 4U);
EXPECT_EQ(EtcDecodedTexelBytes(EtcFormat::kEtc2Rgb8A1), 4U);
EXPECT_EQ(EtcDecodedTexelBytes(EtcFormat::kEtc2Rgba8), 4U);
EXPECT_EQ(EtcDecodedTexelBytes(EtcFormat::kEacR11), 2U);
EXPECT_EQ(EtcDecodedTexelBytes(EtcFormat::kEacRg11Signed), 4U);
}
TEST(Etc2DecoderTest, DecodesIndividualMode) {
// Base colours 8 (left sub-block) and 0 (right), codeword 0 (2/8).
// Pixel (0,0) index 1 (+8), pixels in column 1 index 2 (-2).
const Block8 block = {0x80, 0x80, 0x80, 0x00, 0x00, 0xF0, 0x00, 0x01};
const auto texels = Decode(EtcFormat::kEtc2Rgb8, Bytes(block), 4, 4);
ExpectRgba(texels, 4, 0, 0, {144, 144, 144, 255});
ExpectRgba(texels, 4, 0, 1, {138, 138, 138, 255});
ExpectRgba(texels, 4, 1, 0, {134, 134, 134, 255});
ExpectRgba(texels, 4, 2, 0, {2, 2, 2, 255});
}
TEST(Etc2DecoderTest, DecodesDifferentialMode) {
// R/G/B = 16 with delta +1: base colours 132 and 140, modifier +2.
const Block8 block = {0x81, 0x81, 0x81, 0x02, 0x00, 0x00, 0x00, 0x00};
const auto texels = Decode(EtcFormat::kEtc2Rgb8, Bytes(block), 4, 4);
ExpectRgba(texels, 4, 0, 0, {134, 134, 134, 255});
ExpectRgba(texels, 4, 2, 3, {142, 142, 142, 255});
}
TEST(Etc2DecoderTest, DecodesTMode) {
// Red overflows: colour 1 (0,255,0), colour 2 (0,255,136), distance 11.
const Block8 block = {0x04, 0xF0, 0x0F, 0x86, 0x00, 0x12, 0x00, 0x03};
const auto texels = Decode(EtcFormat::kEtc2Rgb8, Bytes(block), 4, 4);
ExpectRgba(texels, 4, 0, 0, {11, 255, 147, 255});
ExpectRgba(texels, 4, 0, 1, {0, 244, 125, 255});
ExpectRgba(texels, 4, 1, 0, {0, 255, 136, 255});
ExpectRgba(texels, 4, 1, 1, {0, 255, 0, 255});
}
TEST(Etc2DecoderTest, DecodesHMode) {
// Green overflows: colour 1 (0,0,0), colour 2 (255,17,255), distance 3.
const Block8 block = {0x00, 0x04, 0x78, 0xFA, 0x80, 0x01, 0x80, 0x00};
const auto texels = Decode(EtcFormat::kEtc2Rgb8, Bytes(block), 4, 4);
ExpectRgba(texels, 4, 0, 0, {255, 20, 255, 255});
ExpectRgba(texels, 4, 3, 3, {252, 14, 252, 255});
ExpectRgba(texels, 4, 1, 0, {3, 3, 3, 255});
}
TEST(Etc2DecoderTest, DecodesPlanarMode) {
// Blue overflows: O=(130,64,0), H=(0,255,0), V=(255,0,255).
const Block8 block = {0x40, 0x40, 0x04, 0x02, 0xFE, 0x07, 0xE0, 0x3F};
const auto texels = Decode(EtcFormat::kEtc2Rgb8, Bytes(block), 4, 4);
ExpectRgba(texels, 4, 0, 0, {130, 64, 0, 255});
ExpectRgba(texels, 4, 3, 0, {33, 207, 0, 255});
ExpectRgba(texels, 4, 0, 3, {224, 16, 191, 255});
ExpectRgba(texels, 4, 3, 3, {126, 159, 191, 255});
}
TEST(Etc2DecoderTest, DecodesPunchthroughAlpha) {
// Opaque bit clear: index 2 is transparent black, index 0 has no modifier.
const Block8 block = {0x81, 0x81, 0x81, 0x00, 0x00, 0x01, 0x00, 0x02};
const auto texels = Decode(EtcFormat::kEtc2Rgb8A1, Bytes(block), 4, 4);
ExpectRgba(texels, 4, 0, 0, {0, 0, 0, 0});
ExpectRgba(texels, 4, 0, 1, {140, 140, 140, 255});
ExpectRgba(texels, 4, 1, 0, {132, 132, 132, 255});
ExpectRgba(texels, 4, 2, 0, {140, 140, 140, 255});
}
TEST(Etc2DecoderTest, DecodesRgba8WithAlphaBlockFirst) {
// Alpha: base 100, multiplier 2, table 0; pixel (0,0) index 7 (+14).
const std::vector<std::uint8_t> block = {
100, 0x20, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x88, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const auto texels = Decode(EtcFormat::kEtc2Rgba8, block, 4, 4);
ExpectRgba(texels, 4, 0, 0, {138, 138, 138, 128});
ExpectRgba(texels, 4, 1, 0, {138, 138, 138, 94});
}
TEST(Etc2DecoderTest, DecodesUnsignedR11) {
const Block8 block = {128, 0x10, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00};
const auto texels = Decode(EtcFormat::kEacR11, Bytes(block), 4, 4);
EXPECT_EQ(Unsigned16(texels, 0), 36497);
EXPECT_EQ(Unsigned16(texels, 1), 32143);
const Block8 zero_multiplier = {0, 0x00, 0, 0, 0, 0, 0, 0};
const auto flat = Decode(EtcFormat::kEacR11, Bytes(zero_multiplier), 1, 1);
EXPECT_EQ(Unsigned16(flat, 0), 32);
}
TEST(Etc2DecoderTest, DecodesSignedR11) {
const Block8 block = {0x80, 0x10, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00};
const auto texels = Decode(EtcFormat::kEacR11Signed, Bytes(block), 4, 4);
EXPECT_EQ(Signed16(texels, 0), -28956);
EXPECT_EQ(Signed16(texels, 1), -32767);
}
TEST(Etc2DecoderTest, DecodesRg11AsTwoChannels) {
const std::vector<std::uint8_t> block = {
128, 0x10, 0xE0, 0, 0, 0, 0, 0,
0, 0x00, 0x00, 0, 0, 0, 0, 0,
};
const auto texels = Decode(EtcFormat::kEacRg11, block, 1, 1);
EXPECT_EQ(Unsigned16(texels, 0), 36497);
EXPECT_EQ(Unsigned16(texels, 1), 32);
}
TEST(Etc2DecoderTest, DecodesPartialAndMultipleBlocks) {
const Block8 t_mode = {0x04, 0xF0, 0x0F, 0x86, 0x00, 0x12, 0x00, 0x03};
const Block8 differential = {0x81, 0x81, 0x81, 0x02, 0, 0, 0, 0};
std::vector<std::uint8_t> source = Bytes(t_mode);
source.insert(source.end(), differential.begin(), differential.end());
const auto texels = Decode(EtcFormat::kEtc2Rgb8, source, 5, 1);
ExpectRgba(texels, 5, 0, 0, {11, 255, 147, 255});
ExpectRgba(texels, 5, 1, 0, {0, 255, 136, 255});
ExpectRgba(texels, 5, 4, 0, {134, 134, 134, 255});
}
std::vector<std::uint8_t> RandomBlocks(EtcFormat format, std::uint32_t width,
std::uint32_t height,
std::uint32_t seed) {
std::mt19937 rng(seed);
std::vector<std::uint8_t> source(((width + 3) / 4) * ((height + 3) / 4) *
EtcBlockBytes(format));
for (std::uint8_t& byte : source) {
byte = static_cast<std::uint8_t>(rng());
}
return source;
}
TEST(Etc2DecoderTest, DecodesBlockRowBandsLikeWholeImage) {
const std::uint32_t width = 13;
const std::uint32_t height = 10;
const auto source = RandomBlocks(EtcFormat::kEtc2Rgba8, width, height, 1);
const auto whole = Decode(EtcFormat::kEtc2Rgba8, source, width, height);
std::vector<std::uint8_t> banded(whole.size(), 0xAB);
ASSERT_TRUE(DecodeEtcImageBlockRows(EtcFormat::kEtc2Rgba8, source.data(),
source.size(), width, height, 1, 2,
banded.data(), banded.size()));
ASSERT_TRUE(DecodeEtcImageBlockRows(EtcFormat::kEtc2Rgba8, source.data(),
source.size(), width, height, 0, 1,
banded.data(), banded.size()));
EXPECT_EQ(banded, whole);
EXPECT_FALSE(DecodeEtcImageBlockRows(EtcFormat::kEtc2Rgba8, source.data(),
source.size(), width, height, 2, 2,
banded.data(), banded.size()));
}
TEST(Etc2DecoderTest, DecodesJobsOnWorkersLikeSerialDecode) {
struct Case {
EtcFormat format;
std::uint32_t width;
std::uint32_t height;
};
const Case cases[] = {{EtcFormat::kEtc2Rgb8, 1030, 770},
{EtcFormat::kEtc2Rgba8, 517, 1024},
{EtcFormat::kEacRg11, 300, 301},
{EtcFormat::kEtc2Rgb8A1, 3, 5}};
std::vector<std::vector<std::uint8_t>> sources;
std::vector<std::vector<std::uint8_t>> expected;
std::vector<std::vector<std::uint8_t>> outputs;
std::vector<EtcDecodeJob> jobs;
for (std::size_t index = 0; index < std::size(cases); ++index) {
const Case& c = cases[index];
sources.push_back(RandomBlocks(c.format, c.width, c.height,
static_cast<std::uint32_t>(index + 2)));
expected.push_back(Decode(c.format, sources.back(), c.width, c.height));
outputs.emplace_back(expected.back().size(), 0xAB);
}
for (std::size_t index = 0; index < std::size(cases); ++index) {
const Case& c = cases[index];
jobs.push_back({c.format, sources[index].data(), sources[index].size(),
c.width, c.height, outputs[index].data(),
outputs[index].size()});
}
std::vector<std::uint8_t> short_output(4 * 4 * 4 - 1, 0xAB);
jobs.push_back({EtcFormat::kEtc2Rgb8, sources[0].data(), sources[0].size(),
4, 4, short_output.data(), short_output.size()});
DecodeEtcJobs(jobs.data(), jobs.size(), 4);
for (std::size_t index = 0; index < std::size(cases); ++index) {
EXPECT_TRUE(jobs[index].ok) << index;
EXPECT_EQ(outputs[index], expected[index]) << index;
}
EXPECT_FALSE(jobs.back().ok);
EXPECT_EQ(short_output, std::vector<std::uint8_t>(4 * 4 * 4 - 1, 0xAB));
}
TEST(Etc2DecoderTest, RejectsShortBuffers) {
const std::vector<std::uint8_t> source(8, 0);
std::vector<std::uint8_t> output(4 * 4 * 4, 0);
EXPECT_FALSE(DecodeEtcImage(EtcFormat::kEtc2Rgb8, source.data(), 7, 4, 4,
output.data(), output.size()));
EXPECT_FALSE(DecodeEtcImage(EtcFormat::kEtc2Rgb8, source.data(),
source.size(), 4, 4, output.data(),
output.size() - 1));
EXPECT_FALSE(DecodeEtcImage(EtcFormat::kEtc2Rgb8, source.data(),
source.size(), 5, 4, output.data(),
output.size()));
EXPECT_FALSE(DecodeEtcImage(EtcFormat::kEtc2Rgb8, nullptr, 0, 0, 0,
output.data(), output.size()));
}
} // namespace
} // namespace mocktail::graphics
+21 -38
View File
@@ -1,11 +1,12 @@
#!/usr/bin/env bash
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# SPDX-License-Identifier: Apache-2.0
set -Eeuo pipefail
readonly ROOT="${1:?source root is required}"
readonly MANIFEST="${ROOT}/packaging/flatpak/space.bigrat.mocktail.json"
readonly MANIFEST="${ROOT}/packaging/flatpak/io.github.CoderDayton.nightcap.json"
readonly BUILD_HELPER="${ROOT}/scripts/build_flatpak.sh"
readonly PAGES_HELPER="${ROOT}/scripts/assemble_flatpak_pages.sh"
readonly GITHUB_CI="${ROOT}/.github/workflows/flatpak.yml"
@@ -25,7 +26,7 @@ import sys
with open(sys.argv[1], encoding="utf-8") as source:
manifest = json.load(source)
assert manifest["app-id"] == "space.bigrat.mocktail"
assert manifest["app-id"] == "io.github.CoderDayton.nightcap"
assert manifest["runtime"] == "org.gnome.Platform"
assert manifest["runtime-version"] == "50"
assert manifest["sdk"] == "org.gnome.Sdk"
@@ -129,24 +130,14 @@ grep -Fq 'CleanupStaleBuilderMounts' "${BUILD_HELPER}" ||
Fail 'obsolete GitLab CI configuration is still present'
grep -Fq 'name: Flatpak' "${GITHUB_CI}" ||
Fail 'GitHub Actions workflow has no stable display name'
validates_main=false
if grep -Fq 'branches: [main]' "${GITHUB_CI}"; then
validates_main=true
elif grep -Fq 'workflow_run:' "${GITHUB_CI}" &&
grep -Fq 'workflows: [Native packages]' "${GITHUB_CI}" &&
grep -Fq "head_branch == 'main'" "${GITHUB_CI}"; then
validates_main=true
fi
[[ "${validates_main}" == true ]] ||
Fail 'GitHub Actions does not validate the main branch'
grep -Fq "tags: ['v*']" "${GITHUB_CI}" ||
Fail 'GitHub Actions does not publish on release tags'
grep -Fq 'pull_request:' "${GITHUB_CI}" ||
Fail 'GitHub Actions does not validate pull requests'
grep -Fq 'workflow_dispatch:' "${GITHUB_CI}" ||
Fail 'GitHub Actions cannot be started manually'
grep -Fq "'assets/screenshots/**'" "${GITHUB_CI}" ||
Fail 'Flatpak workflow does not react to screenshot changes'
grep -Fq "'packaging/discord-join.html'" "${GITHUB_CI}" ||
Fail 'Flatpak workflow does not publish Discord join-page changes'
grep -Fq 'contents: read' "${GITHUB_CI}" ||
Fail 'GitHub Actions permissions are not read-only'
grep -Fq 'submodules: recursive' "${GITHUB_CI}" ||
@@ -159,7 +150,7 @@ grep -Fq -- '--install-deps-from=flathub' "${GITHUB_CI}" ||
Fail 'GitHub Actions does not install manifest dependencies from Flathub'
grep -Fq -- '--default-branch=stable' "${GITHUB_CI}" ||
Fail 'GitHub Actions does not produce the stable Flatpak branch'
grep -Fq 'Mocktail-x86_64.flatpak' "${GITHUB_CI}" ||
grep -Fq 'Nightcap-x86_64.flatpak' "${GITHUB_CI}" ||
Fail 'GitHub Actions does not build the installable Flatpak bundle'
grep -Fq 'actions/upload-artifact@' "${GITHUB_CI}" ||
Fail 'GitHub Actions does not publish the Flatpak artifact'
@@ -183,7 +174,7 @@ dry_run="$(
)"
grep -Fq './scripts/build_flatpak.sh' <<<"${dry_run}" ||
Fail 'make flatpak does not invoke the guarded Flatpak builder'
grep -Fq -- '--manifest packaging/flatpak/space.bigrat.mocktail.json' \
grep -Fq -- '--manifest packaging/flatpak/io.github.CoderDayton.nightcap.json' \
<<<"${dry_run}" || Fail 'make flatpak lost the canonical manifest'
grep -Fq -- '--jobs 4' <<<"${dry_run}" ||
Fail 'make flatpak does not cap local build parallelism'
@@ -210,33 +201,25 @@ grep -Fq 'flatpak-builder is unavailable' "${TEMP_DIR}/stderr" ||
Fail 'helper did not explain how to install flatpak-builder'
mkdir -p -- "${TEMP_DIR}/repo/objects"
mkdir -p -- \
"${TEMP_DIR}/native-repositories/apt" \
"${TEMP_DIR}/native-repositories/rpm" \
"${TEMP_DIR}/native-repositories/downloads"
printf 'bundle\n' >"${TEMP_DIR}/Mocktail-x86_64.flatpak"
printf 'public-key\n' >"${TEMP_DIR}/mocktail-flatpak.gpg"
printf 'public-key\n' \
>"${TEMP_DIR}/native-repositories/mocktail-packages.gpg"
printf 'bundle\n' >"${TEMP_DIR}/Nightcap-x86_64.flatpak"
printf 'public-key\n' >"${TEMP_DIR}/nightcap-flatpak.gpg"
"${PAGES_HELPER}" \
"${TEMP_DIR}/repo" \
"${TEMP_DIR}/Mocktail-x86_64.flatpak" \
"${TEMP_DIR}/mocktail-flatpak.gpg" \
"${TEMP_DIR}/public" \
"${TEMP_DIR}/native-repositories"
grep -Fq 'Url=https://mocktail.bigrat.space/repo/' \
"${TEMP_DIR}/public/mocktail.flatpakrepo" ||
"${TEMP_DIR}/Nightcap-x86_64.flatpak" \
"${TEMP_DIR}/nightcap-flatpak.gpg" \
"${TEMP_DIR}/public"
grep -Fq 'Url=https://coderdayton.github.io/nightcap/repo/' \
"${TEMP_DIR}/public/nightcap.flatpakrepo" ||
Fail 'published Flatpak repository URL is incorrect'
grep -Fq 'Name=space.bigrat.mocktail' \
"${TEMP_DIR}/public/mocktail.flatpakref" ||
grep -Fq 'Name=io.github.CoderDayton.nightcap' \
"${TEMP_DIR}/public/nightcap.flatpakref" ||
Fail 'published Flatpak ref has the wrong application ID'
grep -Fq 'GPGKey=' "${TEMP_DIR}/public/nightcap.flatpakref" ||
Fail 'published Flatpak ref is not pinned to the signing key'
grep -Fq 'flatpak install --user' "${TEMP_DIR}/public/index.html" ||
Fail 'Pages landing page has no direct installation command'
grep -Fq 'roblox://experiences/start' "${TEMP_DIR}/public/join.html" ||
Fail 'Pages output has no Discord join bridge'
[[ -d "${TEMP_DIR}/public/apt" &&
-d "${TEMP_DIR}/public/rpm" &&
-d "${TEMP_DIR}/public/downloads" ]] ||
Fail 'Pages output has no native package repositories'
[[ -f "${TEMP_DIR}/public/Nightcap-x86_64.flatpak" &&
-f "${TEMP_DIR}/public/.nojekyll" ]] ||
Fail 'Pages output is missing the bundle or the .nojekyll marker'
printf 'Flatpak packaging contract test passed\n'
+26
View File
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#include "jnivm/jnivm.h"
#include <gtest/gtest.h>
@@ -2675,5 +2676,30 @@ TEST_F(JniVmTest, MainGameActivityReturnsNativeHelperAndTracksCallbacks) {
EXPECT_EQ(env->GetBooleanField(helper, is_engine_initialized), JNI_TRUE);
}
TEST_F(JniVmTest, NativeQuoteInterfaceReportsKeystoreUnavailable) {
JNIEnv* env = vm_->GetJNIEnv();
jclass cls = env->FindClass("com/roblox/engine/jni/NativeQuoteInterface");
ASSERT_NE(cls, nullptr);
jmethodID method =
env->GetStaticMethodID(cls, "requestResponse", "([B)[B");
ASSERT_NE(method, nullptr);
jbyteArray challenge = env->NewByteArray(32);
ASSERT_NE(challenge, nullptr);
auto result = static_cast<jbyteArray>(
env->CallStaticObjectMethod(cls, method, challenge));
ASSERT_NE(result, nullptr);
const jsize length = env->GetArrayLength(result);
ASSERT_GT(length, 2);
std::vector<jbyte> bytes(static_cast<std::size_t>(length));
env->GetByteArrayRegion(result, 0, length, bytes.data());
EXPECT_EQ(bytes[0], 1);
EXPECT_EQ(bytes[1], 0);
const std::string message(reinterpret_cast<const char*>(bytes.data() + 2),
static_cast<std::size_t>(length - 2));
EXPECT_NE(message.find("AndroidKeyStore"), std::string::npos);
}
} // namespace
} // namespace jnivm
+1 -8
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# SPDX-License-Identifier: Apache-2.0
@@ -77,10 +78,6 @@ grep -Fq -- \
Fail 'AUR package embeds a build-tree compatibility manifest path'
grep -Fq 'pkgbase = mocktail-git' "${AUR_SRCINFO}" ||
Fail 'AUR package has no generated .SRCINFO metadata'
grep -Fq 'paru -S mocktail-git' "${README}" ||
Fail 'README has no AUR installation instructions'
grep -Fq 'yay -S mocktail-git' "${README}" ||
Fail 'README has no alternative AUR helper command'
grep -Fq 'LINKER:--no-as-needed' "${STUB_CMAKE}" ||
Fail 'system shims can lose their host libc dependencies'
grep -Fq 'MOCKTAIL_MINIZIP_HAS_STREAM_TELL' "${STUB_CMAKE}" ||
@@ -118,10 +115,6 @@ if grep -Fq "'site/**'" "${WORKFLOW}"; then
Fail 'native packages ignore website changes required by Pages publication'
fi
grep -Fq 'sudo dnf install mocktail-nightly' "${README}" ||
Fail 'README has no nightly DNF installation command'
grep -Fq 'sudo apt install mocktail-nightly' "${README}" ||
Fail 'README has no nightly APT installation command'
grep -Fq 'Ubuntu 26.04+' "${README}" ||
Fail 'README has no Ubuntu source dependency guide'
grep -Fq 'Arch Linux' "${README}" ||
+5 -1
View File
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#include "mocktail/graphics/present_mode_policy.h"
#include <gtest/gtest.h>
@@ -7,8 +8,11 @@ namespace graphics {
namespace {
TEST(PresentModePolicyTest, DerivesDisplayAndUnlimitedDefaults) {
// The unmanaged default keeps Roblox's frame cap but still selects the
// lowest-latency synchronized present mode instead of the engine's FIFO.
EXPECT_EQ(ResolvePresentModePolicy("auto", "-1"),
PresentModePolicy::kHostDefault);
PresentModePolicy::kVsync);
EXPECT_EQ(ResolvePresentModePolicy("auto", ""), PresentModePolicy::kVsync);
EXPECT_EQ(ResolvePresentModePolicy("auto", "display"),
PresentModePolicy::kVsync);
EXPECT_EQ(ResolvePresentModePolicy("auto", "60"),
+4 -1
View File
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#include "runtime/runtime_config_file.h"
#include <gtest/gtest.h>
@@ -139,7 +140,9 @@ TEST(RuntimeConfigBootstrapTest,
"# DFIntTaskSchedulerTargetFps without a whitelist.\n "
"# frame_rate_limit: -1",
"# Optional presentation synchronization override: auto, on, or "
"off.\n # vsync: off",
"off. auto\n # presents through the lowest-latency synchronized "
"mode the driver offers\n # unless frame_rate_limit is unlimited.\n"
" # vsync: off",
"# physical CPU core. A place's Lua/main thread can still remain "
"serial.\n multithreaded_rendering: false",
"# sizes and coalesces midphase work. Supported: auto, latency, "
+6
View File
@@ -1,3 +1,4 @@
// Modified by vii from komaruworld/mocktail. See README "About this fork".
#include "runtime/runtime_paths.h"
#include <gtest/gtest.h>
@@ -585,9 +586,12 @@ TEST(RuntimePathsTest, ExportsXdgBackedAndroidPathsAndCreatesParents) {
"MOCKTAIL_ANDROID_CACHE_HOST_ROOT");
const ScopedProcessEnvironment shader_cache(
"MOCKTAIL_VULKAN_SHADER_CACHE_HOST_PATH");
const ScopedProcessEnvironment texture_overrides(
"MOCKTAIL_TEXTURE_OVERRIDE_DIR");
ASSERT_EQ(unsetenv("MOCKTAIL_RUNTIME_ROOT"), 0);
ASSERT_EQ(unsetenv("MOCKTAIL_ANDROID_CACHE_HOST_ROOT"), 0);
ASSERT_EQ(unsetenv("MOCKTAIL_VULKAN_SHADER_CACHE_HOST_PATH"), 0);
ASSERT_EQ(unsetenv("MOCKTAIL_TEXTURE_OVERRIDE_DIR"), 0);
const MapEnvironment environment({
{"HOME", temporary.path().string()},
@@ -605,6 +609,8 @@ TEST(RuntimePathsTest, ExportsXdgBackedAndroidPathsAndCreatesParents) {
paths.android_cache_root().c_str());
EXPECT_STREQ(std::getenv("MOCKTAIL_VULKAN_SHADER_CACHE_HOST_PATH"),
paths.vulkan_shader_cache_file().c_str());
EXPECT_STREQ(std::getenv("MOCKTAIL_TEXTURE_OVERRIDE_DIR"),
(paths.config_root() / "textures").c_str());
EXPECT_TRUE(std::filesystem::is_directory(paths.android_runtime_root()));
EXPECT_TRUE(std::filesystem::is_directory(paths.android_cache_root()));
EXPECT_TRUE(std::filesystem::is_directory(
+9 -8
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# SPDX-License-Identifier: Apache-2.0
@@ -18,9 +19,9 @@ else
readonly runtime="${install_root}/usr/lib/mocktail"
fi
readonly data="${install_root}/usr/share/mocktail"
readonly desktop="${install_root}/usr/share/applications/space.bigrat.mocktail.desktop"
readonly metainfo="${install_root}/usr/share/metainfo/space.bigrat.mocktail.metainfo.xml"
readonly icon="${install_root}/usr/share/icons/hicolor/scalable/apps/space.bigrat.mocktail.svg"
readonly desktop="${install_root}/usr/share/applications/io.github.CoderDayton.nightcap.desktop"
readonly metainfo="${install_root}/usr/share/metainfo/io.github.CoderDayton.nightcap.metainfo.xml"
readonly icon="${install_root}/usr/share/icons/hicolor/scalable/apps/io.github.CoderDayton.nightcap.svg"
[[ -x "${binary}" ]]
[[ -x "${runtime}/mocktail_updater" ]]
@@ -47,14 +48,14 @@ if find "${install_root}/usr" -type f \( -name '*.py' -o -name '*.sh' \) \
fi
[[ -f "${desktop}" ]]
grep -Fq 'Name=Mocktail' "${desktop}"
grep -Fxq 'Exec=mocktail %u' "${desktop}"
grep -Fq 'Icon=space.bigrat.mocktail' "${desktop}"
grep -Fq 'Name=Nightcap' "${desktop}"
grep -Fxq 'Exec=env SDL_VIDEODRIVER=wayland,x11 /usr/bin/mocktail %u' "${desktop}"
grep -Fq 'Icon=io.github.CoderDayton.nightcap' "${desktop}"
[[ -f "${metainfo}" ]]
grep -Fq '<id>space.bigrat.mocktail</id>' "${metainfo}"
grep -Fq '<id>io.github.CoderDayton.nightcap</id>' "${metainfo}"
[[ -f "${icon}" ]]
for icon_size in 16 22 24 32 36 48 64 72 96 128 192 256 512; do
raster_icon="${install_root}/usr/share/icons/hicolor/${icon_size}x${icon_size}/apps/space.bigrat.mocktail.png"
raster_icon="${install_root}/usr/share/icons/hicolor/${icon_size}x${icon_size}/apps/io.github.CoderDayton.nightcap.png"
[[ -f "${raster_icon}" ]]
file "${raster_icon}" | grep -Fq "${icon_size} x ${icon_size}"
done
+145
View File
@@ -0,0 +1,145 @@
#include "mocktail/graphics/texture_override.h"
#include <gtest/gtest.h>
#include <cstdint>
#include <cstdio>
#include <filesystem>
#include <string>
#include <vector>
namespace mocktail::graphics {
namespace {
class TempDir {
public:
TempDir() {
char pattern[] = "/tmp/mocktail-texture-override-XXXXXX";
const char* made = mkdtemp(pattern);
path_ = made != nullptr ? made : "";
}
~TempDir() {
std::error_code error;
std::filesystem::remove_all(path_, error);
}
const std::string& path() const { return path_; }
private:
std::string path_;
};
RgbaImage Gradient(std::uint32_t width, std::uint32_t height) {
RgbaImage image;
image.width = width;
image.height = height;
image.pixels.resize(static_cast<std::size_t>(width) * height * 4);
for (std::uint32_t y = 0; y < height; ++y) {
for (std::uint32_t x = 0; x < width; ++x) {
std::uint8_t* pixel = image.pixels.data() + (y * width + x) * 4;
pixel[0] = static_cast<std::uint8_t>(x * 7);
pixel[1] = static_cast<std::uint8_t>(y * 11);
pixel[2] = static_cast<std::uint8_t>(x + y);
pixel[3] = static_cast<std::uint8_t>(255 - x);
}
}
return image;
}
TEST(TextureOverrideTest, HashIsStableAndDependsOnBytes) {
const std::uint8_t a[] = {1, 2, 3, 4};
const std::uint8_t b[] = {1, 2, 3, 5};
EXPECT_EQ(HashBytes(a, sizeof(a)), HashBytes(a, sizeof(a)));
EXPECT_NE(HashBytes(a, sizeof(a)), HashBytes(b, sizeof(b)));
EXPECT_EQ(HashName(0x0123456789abcdefULL), "0123456789abcdef");
}
TEST(TextureOverrideTest, PngRoundTripKeepsEveryPixel) {
TempDir dir;
ASSERT_FALSE(dir.path().empty());
const RgbaImage image = Gradient(9, 5);
const std::string path = dir.path() + "/image.png";
ASSERT_TRUE(WritePngRgba(path, image));
RgbaImage read;
ASSERT_TRUE(ReadPngRgba(path, &read));
EXPECT_EQ(read.width, image.width);
EXPECT_EQ(read.height, image.height);
EXPECT_EQ(read.pixels, image.pixels);
}
TEST(TextureOverrideTest, ReadPngFailsForMissingFile) {
RgbaImage read;
EXPECT_FALSE(ReadPngRgba("/nonexistent/mocktail.png", &read));
}
TEST(TextureOverrideTest, ResampleAveragesSourceBoxes) {
RgbaImage source;
source.width = 2;
source.height = 2;
source.pixels = {0, 0, 0, 0, 100, 100, 100, 100,
200, 200, 200, 200, 100, 100, 100, 100};
std::uint8_t one[4] = {};
ResampleRgba(source, 1, 1, one);
EXPECT_EQ(one[0], 100);
EXPECT_EQ(one[3], 100);
std::uint8_t four[16] = {};
ResampleRgba(source, 2, 2, four);
EXPECT_EQ(std::vector<std::uint8_t>(four, four + 16), source.pixels);
RgbaImage single;
single.width = 1;
single.height = 1;
single.pixels = {9, 8, 7, 6};
std::uint8_t grown[16] = {};
ResampleRgba(single, 2, 2, grown);
for (int pixel = 0; pixel < 4; ++pixel) {
EXPECT_EQ(grown[pixel * 4 + 0], 9);
EXPECT_EQ(grown[pixel * 4 + 3], 6);
}
}
TEST(TextureOverrideTest, LookupFindsPngNamedByHashAndCachesMisses) {
TempDir dir;
ASSERT_FALSE(dir.path().empty());
const RgbaImage image = Gradient(4, 4);
const std::uint64_t hash = 0xfeedfacecafebeefULL;
ASSERT_TRUE(WritePngRgba(dir.path() + "/" + HashName(hash) + ".png", image));
TextureOverrides overrides(dir.path(), "");
EXPECT_TRUE(overrides.enabled());
const auto found = overrides.Lookup(hash);
ASSERT_NE(found, nullptr);
EXPECT_EQ(found->pixels, image.pixels);
EXPECT_EQ(overrides.Lookup(hash), found);
EXPECT_EQ(overrides.Lookup(hash + 1), nullptr);
TextureOverrides disabled("", "");
EXPECT_FALSE(disabled.enabled());
EXPECT_EQ(disabled.Lookup(hash), nullptr);
}
TEST(TextureOverrideTest, DumpWritesOnePngPerHash) {
TempDir dir;
ASSERT_FALSE(dir.path().empty());
const RgbaImage image = Gradient(3, 2);
TextureOverrides overrides("", dir.path());
EXPECT_TRUE(overrides.enabled());
const std::uint64_t hash = 0x1234ULL;
overrides.Dump(hash, image.width, image.height, image.pixels.data());
overrides.Dump(hash, image.width, image.height, image.pixels.data());
const std::string expected =
dir.path() + "/" + HashName(hash) + "_3x2.png";
ASSERT_TRUE(std::filesystem::exists(expected));
RgbaImage read;
ASSERT_TRUE(ReadPngRgba(expected, &read));
EXPECT_EQ(read.pixels, image.pixels);
std::size_t files = 0;
for (const auto& entry : std::filesystem::directory_iterator(dir.path())) {
static_cast<void>(entry);
++files;
}
EXPECT_EQ(files, 1u);
}
} // namespace
} // namespace mocktail::graphics
+9 -6
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# Modified by vii from komaruworld/mocktail. See README "About this fork".
# Copyright 2026 Mocktail Project Authors
# SPDX-License-Identifier: Apache-2.0
@@ -32,14 +33,14 @@ cat >"${test_root}/bin/xdg-mime" <<'EOF'
case "${1:-}" in
default)
printf '%s\n' "$*" >>"${XDG_MIME_CALLS:?}"
[[ "$2" == space.bigrat.mocktail.desktop ]]
[[ "$2" == io.github.CoderDayton.nightcap.desktop ]]
[[ "$3" == x-scheme-handler/roblox ]]
[[ "$4" == x-scheme-handler/roblox-player ]]
touch "${XDG_MIME_SELECTED:?}"
;;
query)
[[ -f "${XDG_MIME_SELECTED:?}" ]] || exit 0
printf '%s\n' space.bigrat.mocktail.desktop
printf '%s\n' io.github.CoderDayton.nightcap.desktop
;;
*) exit 2 ;;
esac
@@ -57,9 +58,10 @@ export PATH="${test_root}/bin:${PATH}"
--executable "${mocktail_binary}" --desktop-file "${desktop_source}" \
>/dev/null
readonly installed_desktop="${XDG_DATA_HOME}/applications/space.bigrat.mocktail.desktop"
readonly installed_desktop="${XDG_DATA_HOME}/applications/io.github.CoderDayton.nightcap.desktop"
[[ -f "${installed_desktop}" && ! -L "${installed_desktop}" ]]
grep -Fxq "Exec=${mocktail_binary} %u" "${installed_desktop}"
grep -Fxq "Exec=env SDL_VIDEODRIVER=wayland,x11 ${mocktail_binary} %u" \
"${installed_desktop}"
grep -Fxq \
'MimeType=x-scheme-handler/roblox;x-scheme-handler/roblox-player;' \
"${installed_desktop}"
@@ -67,7 +69,7 @@ grep -Fxq 'X-Mocktail-Managed=true' "${installed_desktop}"
grep -Fxq -- "-q ${XDG_DATA_HOME}/applications" \
"${DESKTOP_DATABASE_CALLS}"
grep -Fxq \
'default space.bigrat.mocktail.desktop x-scheme-handler/roblox x-scheme-handler/roblox-player' \
'default io.github.CoderDayton.nightcap.desktop x-scheme-handler/roblox x-scheme-handler/roblox-player' \
"${XDG_MIME_CALLS}"
rm -f "${XDG_MIME_SELECTED}"
@@ -84,7 +86,8 @@ cp -- "${mocktail_binary}" "${fixture_project}/build/mocktail"
"${fixture_project}/scripts/register_url_handler.sh" --install-only \
--executable "${fixture_project}/build/mocktail" \
--desktop-file "${desktop_source}" >/dev/null
grep -Fxq "Exec=${fixture_project}/build/mocktail %u" \
grep -Fxq \
"Exec=env SDL_VIDEODRIVER=wayland,x11 ${fixture_project}/build/mocktail %u" \
"${installed_desktop}"
grep -Fxq "Path=${fixture_project}" "${installed_desktop}"
+595
View File
@@ -0,0 +1,595 @@
#include "mocktail/graphics/vulkan_etc2_emulation.h"
#include "mocktail/graphics/etc2_decoder.h"
#include "mocktail/graphics/texture_override.h"
#include <gtest/gtest.h>
#include <array>
#include <cstdint>
#include <cstring>
namespace mocktail::graphics {
namespace {
void ExpectMapping(VkFormat format, VkFormat host, EtcFormat etc) {
Etc2EmulatedFormat mapped;
ASSERT_TRUE(LookupEmulatedEtc2Format(format, &mapped)) << format;
EXPECT_EQ(mapped.host_format, host) << format;
EXPECT_EQ(mapped.etc_format, etc) << format;
}
TEST(VulkanEtc2EmulationTest, MapsEveryEtc2AndEacFormat) {
ExpectMapping(VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, VK_FORMAT_R8G8B8A8_UNORM,
EtcFormat::kEtc2Rgb8);
ExpectMapping(VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK, VK_FORMAT_R8G8B8A8_SRGB,
EtcFormat::kEtc2Rgb8);
ExpectMapping(VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK, VK_FORMAT_R8G8B8A8_UNORM,
EtcFormat::kEtc2Rgb8A1);
ExpectMapping(VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK, VK_FORMAT_R8G8B8A8_SRGB,
EtcFormat::kEtc2Rgb8A1);
ExpectMapping(VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, VK_FORMAT_R8G8B8A8_UNORM,
EtcFormat::kEtc2Rgba8);
ExpectMapping(VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK, VK_FORMAT_R8G8B8A8_SRGB,
EtcFormat::kEtc2Rgba8);
ExpectMapping(VK_FORMAT_EAC_R11_UNORM_BLOCK, VK_FORMAT_R16_UNORM,
EtcFormat::kEacR11);
ExpectMapping(VK_FORMAT_EAC_R11_SNORM_BLOCK, VK_FORMAT_R16_SNORM,
EtcFormat::kEacR11Signed);
ExpectMapping(VK_FORMAT_EAC_R11G11_UNORM_BLOCK, VK_FORMAT_R16G16_UNORM,
EtcFormat::kEacRg11);
ExpectMapping(VK_FORMAT_EAC_R11G11_SNORM_BLOCK, VK_FORMAT_R16G16_SNORM,
EtcFormat::kEacRg11Signed);
}
TEST(VulkanEtc2EmulationTest, AdvertisesEtc2UnlessSwitchedOff) {
EXPECT_TRUE(Etc2SupportAdvertised(nullptr));
EXPECT_TRUE(Etc2SupportAdvertised(""));
EXPECT_TRUE(Etc2SupportAdvertised("1"));
EXPECT_FALSE(Etc2SupportAdvertised("0"));
}
TEST(VulkanEtc2EmulationTest, ParsesSmallTextureUpscale) {
EXPECT_EQ(SmallTextureUpscale(nullptr), 4u);
EXPECT_EQ(SmallTextureUpscale(""), 4u);
EXPECT_EQ(SmallTextureUpscale("abc"), 4u);
EXPECT_EQ(SmallTextureUpscale("0"), 1u);
EXPECT_EQ(SmallTextureUpscale("1"), 1u);
EXPECT_EQ(SmallTextureUpscale("2"), 2u);
EXPECT_EQ(SmallTextureUpscale("99"), 8u);
}
TEST(VulkanEtc2EmulationTest, IgnoresOtherFormats) {
Etc2EmulatedFormat mapped;
EXPECT_FALSE(LookupEmulatedEtc2Format(VK_FORMAT_R8G8B8A8_UNORM, &mapped));
EXPECT_FALSE(LookupEmulatedEtc2Format(VK_FORMAT_BC7_UNORM_BLOCK, &mapped));
EXPECT_FALSE(
LookupEmulatedEtc2Format(VK_FORMAT_ASTC_4x4_UNORM_BLOCK, &mapped));
}
TEST(VulkanEtc2EmulationTest, KeepsOnlySamplingAndTransferFeatures) {
const VkFormatFeatureFlags host =
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT |
VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT |
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT |
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
EXPECT_EQ(EmulatedEtc2FormatFeatures(host),
static_cast<VkFormatFeatureFlags>(
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT |
VK_FORMAT_FEATURE_BLIT_SRC_BIT |
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
VK_FORMAT_FEATURE_TRANSFER_DST_BIT));
EXPECT_EQ(EmulatedEtc2FormatFeatures(VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT),
0U);
}
TEST(VulkanEtc2EmulationTest, CountsUploadBytesPerRegion) {
VkDeviceSize compressed = 0;
VkDeviceSize decoded = 0;
ASSERT_TRUE(Etc2UploadByteCounts(EtcFormat::kEtc2Rgba8, {5, 3, 1}, 2,
&compressed, &decoded));
EXPECT_EQ(compressed, 64U);
EXPECT_EQ(decoded, 120U);
ASSERT_TRUE(Etc2UploadByteCounts(EtcFormat::kEacR11, {1, 1, 1}, 1,
&compressed, &decoded));
EXPECT_EQ(compressed, 8U);
EXPECT_EQ(decoded, 2U);
}
TEST(VulkanEtc2EmulationTest, RejectsUnsupportedRegions) {
VkDeviceSize compressed = 0;
VkDeviceSize decoded = 0;
EXPECT_FALSE(Etc2UploadByteCounts(EtcFormat::kEtc2Rgb8, {4, 4, 2}, 1,
&compressed, &decoded));
EXPECT_FALSE(Etc2UploadByteCounts(EtcFormat::kEtc2Rgb8, {0, 4, 1}, 1,
&compressed, &decoded));
EXPECT_FALSE(Etc2UploadByteCounts(EtcFormat::kEtc2Rgb8, {4, 4, 1}, 0,
&compressed, &decoded));
}
template <typename Handle>
Handle FakeHandle(std::uintptr_t value) {
return reinterpret_cast<Handle>(value);
}
constexpr std::uintptr_t kSourceMemory = 0x300;
constexpr std::uintptr_t kStagingBuffer = 0x500;
constexpr std::uintptr_t kStagingMemory = 0x600;
std::array<std::uint8_t, 64> g_source{};
std::array<std::uint8_t, 512> g_staging{};
VkExtent3D g_created_extent{};
VkExtent3D g_copied_extent{};
VkDeviceSize g_created_buffer_size = 0;
std::uintptr_t g_next_image = 0x100;
std::uint32_t g_copy_image_calls = 0;
VkImageBlit g_blit{};
VkFilter g_blit_filter = VK_FILTER_NEAREST;
VKAPI_ATTR VkResult VKAPI_CALL FakeCreateImage(VkDevice,
const VkImageCreateInfo* info,
const VkAllocationCallbacks*,
VkImage* image) {
g_created_extent = info->extent;
*image = FakeHandle<VkImage>(g_next_image++);
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL FakeCopyImage(VkCommandBuffer, VkImage,
VkImageLayout, VkImage, VkImageLayout,
std::uint32_t, const VkImageCopy*) {
++g_copy_image_calls;
}
VKAPI_ATTR void VKAPI_CALL FakeBlitImage(VkCommandBuffer, VkImage,
VkImageLayout, VkImage, VkImageLayout,
std::uint32_t count,
const VkImageBlit* blits,
VkFilter filter) {
g_blit = count > 0 ? blits[0] : VkImageBlit{};
g_blit_filter = filter;
}
VKAPI_ATTR VkResult VKAPI_CALL FakeCreateBuffer(VkDevice,
const VkBufferCreateInfo* info,
const VkAllocationCallbacks*,
VkBuffer* buffer) {
g_created_buffer_size = info->size;
*buffer = FakeHandle<VkBuffer>(kStagingBuffer);
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL FakeBufferRequirements(
VkDevice, VkBuffer, VkMemoryRequirements* requirements) {
requirements->size = g_staging.size();
requirements->memoryTypeBits = 1;
}
VKAPI_ATTR VkResult VKAPI_CALL FakeAllocateMemory(
VkDevice, const VkMemoryAllocateInfo*, const VkAllocationCallbacks*,
VkDeviceMemory* memory) {
*memory = FakeHandle<VkDeviceMemory>(kStagingMemory);
return VK_SUCCESS;
}
VKAPI_ATTR VkResult VKAPI_CALL FakeBindBufferMemory(VkDevice, VkBuffer,
VkDeviceMemory,
VkDeviceSize) {
return VK_SUCCESS;
}
VKAPI_ATTR VkResult VKAPI_CALL FakeMapMemory(VkDevice, VkDeviceMemory memory,
VkDeviceSize offset, VkDeviceSize,
VkMemoryMapFlags, void** data) {
*data = memory == FakeHandle<VkDeviceMemory>(kSourceMemory)
? g_source.data() + offset
: g_staging.data() + offset;
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL FakeUnmapMemory(VkDevice, VkDeviceMemory) {}
VKAPI_ATTR void VKAPI_CALL FakeDestroyBuffer(VkDevice, VkBuffer,
const VkAllocationCallbacks*) {}
VKAPI_ATTR void VKAPI_CALL FakeFreeMemory(VkDevice, VkDeviceMemory,
const VkAllocationCallbacks*) {}
VKAPI_ATTR void VKAPI_CALL FakeCopyBufferToImage(
VkCommandBuffer, VkBuffer, VkImage, VkImageLayout, std::uint32_t count,
const VkBufferImageCopy* regions) {
g_copied_extent = count > 0 ? regions[0].imageExtent : VkExtent3D{};
}
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL FakeGetDeviceProcAddr(
VkDevice, const char* name) {
const auto is = [name](const char* candidate) {
return std::strcmp(name, candidate) == 0;
};
if (is("vkCreateImage")) return reinterpret_cast<PFN_vkVoidFunction>(FakeCreateImage);
if (is("vkCreateBuffer")) return reinterpret_cast<PFN_vkVoidFunction>(FakeCreateBuffer);
if (is("vkGetBufferMemoryRequirements"))
return reinterpret_cast<PFN_vkVoidFunction>(FakeBufferRequirements);
if (is("vkAllocateMemory")) return reinterpret_cast<PFN_vkVoidFunction>(FakeAllocateMemory);
if (is("vkBindBufferMemory")) return reinterpret_cast<PFN_vkVoidFunction>(FakeBindBufferMemory);
if (is("vkMapMemory")) return reinterpret_cast<PFN_vkVoidFunction>(FakeMapMemory);
if (is("vkUnmapMemory")) return reinterpret_cast<PFN_vkVoidFunction>(FakeUnmapMemory);
if (is("vkDestroyBuffer")) return reinterpret_cast<PFN_vkVoidFunction>(FakeDestroyBuffer);
if (is("vkFreeMemory")) return reinterpret_cast<PFN_vkVoidFunction>(FakeFreeMemory);
if (is("vkCmdCopyBufferToImage"))
return reinterpret_cast<PFN_vkVoidFunction>(FakeCopyBufferToImage);
if (is("vkCmdCopyImage")) return reinterpret_cast<PFN_vkVoidFunction>(FakeCopyImage);
if (is("vkCmdBlitImage")) return reinterpret_cast<PFN_vkVoidFunction>(FakeBlitImage);
return nullptr;
}
TEST(VulkanEtc2EmulationTest, SkipsUploadOutsideTheMappedWindow) {
const VkDevice device = FakeHandle<VkDevice>(0x10);
const VkBuffer source = FakeHandle<VkBuffer>(0x200);
const VkDeviceMemory source_memory = FakeHandle<VkDeviceMemory>(kSourceMemory);
const VkCommandBuffer command_buffer = FakeHandle<VkCommandBuffer>(0x700);
g_source.fill(0);
g_staging.fill(0xAA);
VkPhysicalDeviceMemoryProperties memory{};
memory.memoryTypeCount = 1;
memory.memoryTypes[0].propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
VulkanEtc2Emulation emulation;
emulation.RegisterDevice(device, FakeHandle<VkPhysicalDevice>(0x20), true,
memory, FakeGetDeviceProcAddr);
VkImageCreateInfo image_info{};
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
image_info.format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
image_info.extent = {4, 4, 1};
VkImage image = VK_NULL_HANDLE;
ASSERT_EQ(emulation.CreateImage(device, &image_info, nullptr, &image),
VK_SUCCESS);
// The 8-byte block sits at memory offset 16, but only [0, 8) is mapped.
ASSERT_EQ(emulation.BindBufferMemory(device, source, source_memory, 16),
VK_SUCCESS);
void* mapped = nullptr;
ASSERT_EQ(emulation.MapMemory(device, source_memory, 0, 8, 0, &mapped),
VK_SUCCESS);
VkBufferImageCopy region{};
region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
region.imageSubresource.layerCount = 1;
region.imageExtent = {4, 4, 1};
emulation.CmdCopyBufferToImage(device, command_buffer, source, image,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1,
&region);
emulation.PrepareSubmit(&command_buffer, 1);
EXPECT_EQ(g_staging[0], 0xAA);
emulation.ReleaseCommandBuffer(command_buffer);
}
TEST(VulkanEtc2EmulationTest, DecodesAgainOnEveryResubmit) {
const VkDevice device = FakeHandle<VkDevice>(0x11);
const VkBuffer source = FakeHandle<VkBuffer>(0x201);
const VkDeviceMemory source_memory = FakeHandle<VkDeviceMemory>(kSourceMemory);
const VkCommandBuffer command_buffer = FakeHandle<VkCommandBuffer>(0x701);
g_source.fill(0);
g_staging.fill(0xAA);
VkPhysicalDeviceMemoryProperties memory{};
memory.memoryTypeCount = 1;
memory.memoryTypes[0].propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
VulkanEtc2Emulation emulation;
emulation.RegisterDevice(device, FakeHandle<VkPhysicalDevice>(0x21), true,
memory, FakeGetDeviceProcAddr);
VkImageCreateInfo image_info{};
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
image_info.format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
image_info.extent = {4, 4, 1};
VkImage image = VK_NULL_HANDLE;
ASSERT_EQ(emulation.CreateImage(device, &image_info, nullptr, &image),
VK_SUCCESS);
ASSERT_EQ(emulation.BindBufferMemory(device, source, source_memory, 0),
VK_SUCCESS);
void* mapped = nullptr;
ASSERT_EQ(emulation.MapMemory(device, source_memory, 0, g_source.size(), 0,
&mapped),
VK_SUCCESS);
VkBufferImageCopy region{};
region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
region.imageSubresource.layerCount = 1;
region.imageExtent = {4, 4, 1};
emulation.CmdCopyBufferToImage(device, command_buffer, source, image,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1,
&region);
// Differential block: every texel decodes to 134.
const std::array<std::uint8_t, 8> first = {0x81, 0x81, 0x81, 0x02,
0, 0, 0, 0};
std::memcpy(g_source.data(), first.data(), first.size());
emulation.PrepareSubmit(&command_buffer, 1);
EXPECT_EQ(g_staging[0], 134);
// Individual block: every texel decodes to 138.
const std::array<std::uint8_t, 8> second = {0x88, 0x88, 0x88, 0x00,
0, 0, 0, 0};
std::memcpy(g_source.data(), second.data(), second.size());
emulation.PrepareSubmit(&command_buffer, 1);
EXPECT_EQ(g_staging[0], 138);
emulation.ReleaseCommandBuffer(command_buffer);
}
TEST(VulkanEtc2EmulationTest, UpscalesSmallTexturesAndTheirUploads) {
const VkDevice device = FakeHandle<VkDevice>(0x12);
const VkBuffer source = FakeHandle<VkBuffer>(0x202);
const VkDeviceMemory source_memory = FakeHandle<VkDeviceMemory>(kSourceMemory);
const VkCommandBuffer command_buffer = FakeHandle<VkCommandBuffer>(0x702);
g_source.fill(0);
g_staging.fill(0xAA);
ASSERT_EQ(setenv("MOCKTAIL_SMALL_TEXTURE_UPSCALE", "2", 1), 0);
VkPhysicalDeviceMemoryProperties memory{};
memory.memoryTypeCount = 1;
memory.memoryTypes[0].propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
VulkanEtc2Emulation emulation;
ASSERT_EQ(unsetenv("MOCKTAIL_SMALL_TEXTURE_UPSCALE"), 0);
emulation.RegisterDevice(device, FakeHandle<VkPhysicalDevice>(0x22), true,
memory, FakeGetDeviceProcAddr);
VkImageCreateInfo image_info{};
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
image_info.format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
image_info.imageType = VK_IMAGE_TYPE_2D;
image_info.extent = {4, 4, 1};
image_info.mipLevels = 1;
image_info.arrayLayers = 1;
VkImage image = VK_NULL_HANDLE;
ASSERT_EQ(emulation.CreateImage(device, &image_info, nullptr, &image),
VK_SUCCESS);
EXPECT_EQ(g_created_extent.width, 8u);
EXPECT_EQ(g_created_extent.height, 8u);
ASSERT_EQ(emulation.BindBufferMemory(device, source, source_memory, 0),
VK_SUCCESS);
void* mapped = nullptr;
ASSERT_EQ(emulation.MapMemory(device, source_memory, 0, g_source.size(), 0,
&mapped),
VK_SUCCESS);
VkBufferImageCopy region{};
region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
region.imageSubresource.layerCount = 1;
region.imageExtent = {4, 4, 1};
emulation.CmdCopyBufferToImage(device, command_buffer, source, image,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1,
&region);
EXPECT_EQ(g_copied_extent.width, 8u);
EXPECT_EQ(g_copied_extent.height, 8u);
const std::array<std::uint8_t, 8> block = {0x81, 0x81, 0x81, 0x02,
0, 0, 0, 0};
std::memcpy(g_source.data(), block.data(), block.size());
emulation.PrepareSubmit(&command_buffer, 1);
// The host region is 8x8: every 4x4 texel repeated 2x2.
std::array<std::uint8_t, 4 * 4 * 4> expected{};
ASSERT_TRUE(DecodeEtcImage(EtcFormat::kEtc2Rgb8, block.data(), block.size(),
4, 4, expected.data(), expected.size()));
for (std::size_t y = 0; y < 8; ++y) {
for (std::size_t x = 0; x < 8; ++x) {
for (std::size_t channel = 0; channel < 4; ++channel) {
ASSERT_EQ(g_staging[(y * 8 + x) * 4 + channel],
expected[((y / 2) * 4 + x / 2) * 4 + channel])
<< x << "," << y;
}
}
}
EXPECT_EQ(g_staging[8 * 8 * 4], 0xAA);
emulation.ReleaseCommandBuffer(command_buffer);
}
// Block-rounded uploads (a 1x1 mip sent as 4x4) must not scale past the
// host mip; the host region snaps to the host mip's edge instead.
TEST(VulkanEtc2EmulationTest, ClampsScaledUploadsToTheHostMip) {
const VkDevice device = FakeHandle<VkDevice>(0x14);
const VkBuffer source = FakeHandle<VkBuffer>(0x204);
const VkDeviceMemory source_memory = FakeHandle<VkDeviceMemory>(kSourceMemory);
const VkCommandBuffer command_buffer = FakeHandle<VkCommandBuffer>(0x704);
g_source.fill(0);
g_staging.fill(0xAA);
ASSERT_EQ(setenv("MOCKTAIL_SMALL_TEXTURE_UPSCALE", "2", 1), 0);
VkPhysicalDeviceMemoryProperties memory{};
memory.memoryTypeCount = 1;
memory.memoryTypes[0].propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
VulkanEtc2Emulation emulation;
ASSERT_EQ(unsetenv("MOCKTAIL_SMALL_TEXTURE_UPSCALE"), 0);
emulation.RegisterDevice(device, FakeHandle<VkPhysicalDevice>(0x24), true,
memory, FakeGetDeviceProcAddr);
VkImageCreateInfo image_info{};
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
image_info.format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
image_info.imageType = VK_IMAGE_TYPE_2D;
image_info.extent = {4, 4, 1};
image_info.mipLevels = 3;
image_info.arrayLayers = 1;
VkImage image = VK_NULL_HANDLE;
ASSERT_EQ(emulation.CreateImage(device, &image_info, nullptr, &image),
VK_SUCCESS);
ASSERT_EQ(emulation.BindBufferMemory(device, source, source_memory, 0),
VK_SUCCESS);
void* mapped = nullptr;
ASSERT_EQ(emulation.MapMemory(device, source_memory, 0, g_source.size(), 0,
&mapped),
VK_SUCCESS);
// Mip 2 is 1x1 for the application and 2x2 on the host.
VkBufferImageCopy region{};
region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
region.imageSubresource.mipLevel = 2;
region.imageSubresource.layerCount = 1;
region.imageExtent = {4, 4, 1};
g_copied_extent = {};
emulation.CmdCopyBufferToImage(device, command_buffer, source, image,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1,
&region);
EXPECT_EQ(g_copied_extent.width, 2u);
EXPECT_EQ(g_copied_extent.height, 2u);
EXPECT_EQ(g_created_buffer_size, 2u * 2u * 4u);
// Differential block: every texel decodes to 134.
const std::array<std::uint8_t, 8> block = {0x81, 0x81, 0x81, 0x02,
0, 0, 0, 0};
std::memcpy(g_source.data(), block.data(), block.size());
emulation.PrepareSubmit(&command_buffer, 1);
for (std::size_t index = 0; index < 2 * 2 * 4; ++index) {
ASSERT_EQ(g_staging[index], index % 4 == 3 ? 255 : 134) << index;
}
EXPECT_EQ(g_staging[2 * 2 * 4], 0xAA);
emulation.ReleaseCommandBuffer(command_buffer);
}
// Drawn at its own size, a scaled texture samples a smaller host mip, so
// every host mip carries level-0 detail rather than the application's mip.
TEST(VulkanEtc2EmulationTest, FillsScaledMipsFromLevelZero) {
const VkDevice device = FakeHandle<VkDevice>(0x15);
const VkBuffer source = FakeHandle<VkBuffer>(0x205);
const VkDeviceMemory source_memory = FakeHandle<VkDeviceMemory>(kSourceMemory);
const VkCommandBuffer command_buffer = FakeHandle<VkCommandBuffer>(0x705);
g_source.fill(0);
g_staging.fill(0xAA);
ASSERT_EQ(setenv("MOCKTAIL_SMALL_TEXTURE_UPSCALE", "2", 1), 0);
VkPhysicalDeviceMemoryProperties memory{};
memory.memoryTypeCount = 1;
memory.memoryTypes[0].propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
VulkanEtc2Emulation emulation;
ASSERT_EQ(unsetenv("MOCKTAIL_SMALL_TEXTURE_UPSCALE"), 0);
emulation.RegisterDevice(device, FakeHandle<VkPhysicalDevice>(0x25), true,
memory, FakeGetDeviceProcAddr);
VkImageCreateInfo image_info{};
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
image_info.format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
image_info.imageType = VK_IMAGE_TYPE_2D;
image_info.extent = {4, 4, 1};
image_info.mipLevels = 3;
image_info.arrayLayers = 1;
VkImage image = VK_NULL_HANDLE;
ASSERT_EQ(emulation.CreateImage(device, &image_info, nullptr, &image),
VK_SUCCESS);
ASSERT_EQ(emulation.BindBufferMemory(device, source, source_memory, 0),
VK_SUCCESS);
void* mapped = nullptr;
ASSERT_EQ(emulation.MapMemory(device, source_memory, 0, g_source.size(), 0,
&mapped),
VK_SUCCESS);
// Level 0 decodes to 134 everywhere, level 1 (at byte 8) to 138.
const std::array<std::uint8_t, 8> level0 = {0x81, 0x81, 0x81, 0x02,
0, 0, 0, 0};
const std::array<std::uint8_t, 8> level1 = {0x88, 0x88, 0x88, 0x00,
0, 0, 0, 0};
std::memcpy(g_source.data(), level0.data(), level0.size());
std::memcpy(g_source.data() + 8, level1.data(), level1.size());
std::array<VkBufferImageCopy, 2> regions{};
regions[0].imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
regions[0].imageSubresource.layerCount = 1;
regions[0].imageExtent = {4, 4, 1};
regions[1] = regions[0];
regions[1].bufferOffset = 8;
regions[1].imageSubresource.mipLevel = 1;
regions[1].imageExtent = {2, 2, 1};
emulation.CmdCopyBufferToImage(device, command_buffer, source, image,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 2,
regions.data());
emulation.PrepareSubmit(&command_buffer, 1);
// Host level 0 is 8x8 (256 bytes); host level 1 is 4x4 and follows it,
// holding level 0 itself rather than the 138 texels of level 1.
RgbaImage level0_texels;
level0_texels.width = 4;
level0_texels.height = 4;
level0_texels.pixels.resize(4 * 4 * 4);
ASSERT_TRUE(DecodeEtcImage(EtcFormat::kEtc2Rgb8, level0.data(),
level0.size(), 4, 4, level0_texels.pixels.data(),
level0_texels.pixels.size()));
std::array<std::uint8_t, 4 * 4 * 4> expected{};
ResampleRgba(level0_texels, 4, 4, expected.data());
for (std::size_t index = 0; index < expected.size(); ++index) {
ASSERT_EQ(g_staging[256 + index], expected[index]) << index;
}
emulation.ReleaseCommandBuffer(command_buffer);
}
// Copies out of a scaled image cover its host bounds and shrink back onto
// an unscaled destination, which a plain copy cannot do.
TEST(VulkanEtc2EmulationTest, BlitsCopiesThatTouchScaledImages) {
const VkDevice device = FakeHandle<VkDevice>(0x16);
const VkCommandBuffer command_buffer = FakeHandle<VkCommandBuffer>(0x706);
ASSERT_EQ(setenv("MOCKTAIL_SMALL_TEXTURE_UPSCALE", "2", 1), 0);
VkPhysicalDeviceMemoryProperties memory{};
memory.memoryTypeCount = 1;
memory.memoryTypes[0].propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
VulkanEtc2Emulation emulation;
ASSERT_EQ(unsetenv("MOCKTAIL_SMALL_TEXTURE_UPSCALE"), 0);
emulation.RegisterDevice(device, FakeHandle<VkPhysicalDevice>(0x26), true,
memory, FakeGetDeviceProcAddr);
VkImageCreateInfo image_info{};
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
image_info.format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
image_info.imageType = VK_IMAGE_TYPE_2D;
image_info.extent = {4, 4, 1};
image_info.mipLevels = 3;
image_info.arrayLayers = 1;
VkImage small = VK_NULL_HANDLE;
ASSERT_EQ(emulation.CreateImage(device, &image_info, nullptr, &small),
VK_SUCCESS);
image_info.extent = {128, 128, 1};
image_info.mipLevels = 8;
VkImage large = VK_NULL_HANDLE;
ASSERT_EQ(emulation.CreateImage(device, &image_info, nullptr, &large),
VK_SUCCESS);
// Mip 1 of the small image (2x2, block-rounded to 4x4) lands in mip 6 of
// the large one, 2x2 at offset (1, 1).
VkImageCopy region{};
region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
region.srcSubresource.mipLevel = 1;
region.srcSubresource.layerCount = 1;
region.dstSubresource = region.srcSubresource;
region.dstSubresource.mipLevel = 6;
region.dstOffset = {1, 1, 0};
region.extent = {4, 4, 1};
g_copy_image_calls = 0;
g_blit = {};
emulation.CmdCopyImage(device, command_buffer, small,
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, large,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &region);
EXPECT_EQ(g_copy_image_calls, 0u);
EXPECT_EQ(g_blit.srcSubresource.mipLevel, 1u);
EXPECT_EQ(g_blit.srcOffsets[1].x, 4);
EXPECT_EQ(g_blit.srcOffsets[1].y, 4);
EXPECT_EQ(g_blit.dstSubresource.mipLevel, 6u);
EXPECT_EQ(g_blit.dstOffsets[0].x, 1);
EXPECT_EQ(g_blit.dstOffsets[1].x, 5);
EXPECT_EQ(g_blit_filter, VK_FILTER_LINEAR);
// Copies between unscaled images pass through untouched.
emulation.CmdCopyImage(device, command_buffer, large,
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, large,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &region);
EXPECT_EQ(g_copy_image_calls, 1u);
}
} // namespace
} // namespace mocktail::graphics