PipeWire出力の解像度を設定可能にする
gamescopeはゲームの画面をPipeWireのVideo/Source
として出力する機能を備えている。これはアップスケール後の画面をキャプチャするようになっているので、ゲームのネイティブを画面をキャプチャできるようにするパッチを作成した。
- masterブランチへのパッチ: GitHub - atty303/gamescope at pipewire-output
- Bazzite 42にバンドルされているバージョンへのパッチ: GitHub - atty303/gamescope at pipewire-output-bazzite
以下のオプションを追加している。
--pipewire-source <output|source>
:output
を指定するとデフォルトと同じくアップスケール後のテクスチャをキャプチャする。source
を指定するとかわりにゲームのネイティブテクスチャをキャプチャする。--pipewire-width <w>, --pipewire-height <h>
: PipeWireに出力する解像度を指定する。指定しないとgamescopeの--output-width, --output-height
の指定と同じになる。--pipewire-source source
と組み合わせてゲームのネイティブ解像度を指定する。gamescopeの--nedted-width, --nested-height
と同じ値を指定することになるだろう。
FHDのゲームを4Kにアップスケールしている場合、gamescope -W 3840 -H 2160 -w 1920 -h 1080 --pipewire-source source --pipewire-width 1920 --pipewire-height 1080 -- game
と指定するとFHD画面をキャプチャできる。
なぜ必要か?
dj-kata氏のツールがゲーム画面の画像解析をするのに無劣化ネイティブ解像度のキャプチャが必要だった。4KをFHDにダウンスケールすると劣化のため解析に失敗する。ディスプレイをFHDに設定すればソフトウェア的には変更が必要ないが、ディスプレイ側アップスケールの遅延が大きく実質使用できなかった。
Bazziteにバンドルされているのと同じ設定でビルドする
ビルド用コンテナを準備する
toolbox create gamescope-build
toolbox enter gamescope-build
開発ツールをコンテナにインストールする
sudo dnf group install development-tools
sudo dnf install -y rpmdevtools rpm-build dnf-plugins-core spectool
rpmdev-setuptree
Bazziteのソースを取得してビルドする
git clone git@github.com:ublue-os/bazzite.git
cd bazzite/spec_files/gamescope
sudo dnf builddep --spec gamescope.spec
rpmbuild -ba gamescope.spec --define $"_topdir (pwd)" --define $"_sourcedir (pwd)" --define $"_specdir (pwd)"
以下のコマンドでrpmを展開できる。
rpm2cpio RPMS/x86_64/gamescope-123.c3310bbd-1.bazzite.x86_64.rpm | cpio -idmv
rpm2cpio RPMS/x86_64/gamescope-libs-123.c3310bbd-1.bazzite.x86_64.rpm | cpio -idmv
パッチを当ててビルドする
gamescope/masterをベースにしたパッチをビルドするためにspecファイルを編集する。
diff --git a/spec_files/gamescope/gamescope.spec b/spec_files/gamescope/gamescope.spec
index cc60c941..3cff30fe 100644
--- a/spec_files/gamescope/gamescope.spec
+++ b/spec_files/gamescope/gamescope.spec
@@ -3,7 +3,8 @@
%global _default_patch_fuzz 2
%global build_timestamp %(date +"%Y%m%d")
#global gamescope_tag 3.15.11
-%global gamescope_commit f873ec7868fe84d2850e91148bcbd6d6b19a7443
+%global gamescope_commit 7a3e5c938016e7fe3ecefbc4519bf81efdae82eb
%define short_commit %(echo %{gamescope_commit} | cut -c1-8)
Name: gamescope
@@ -13,13 +14,13 @@ Release: 1.bazzite
Summary: Micro-compositor for video games on Wayland
License: BSD
-URL: https://github.com/ValveSoftware/gamescope
+URL: https://github.com/atty303/gamescope
# Create stb.pc to satisfy dependency('stb')
Source0: stb.pc
Patch0: 0001-cstdint.patch
-Patch1: handheld.patch
+#Patch1: handheld.patch
BuildRequires: meson >= 0.54.0
BuildRequires: ninja-build
@@ -80,7 +81,7 @@ BuildRequires: git
Requires: libliftoff%{?_isa} >= %{libliftoff_minver}
Requires: xorg-x11-server-Xwayland
Requires: gamescope-libs = %{version}-%{release}
-Requires: gamescope-libs(x86-32) = %{version}-%{release}
+#Requires: gamescope-libs(x86-32) = %{version}-%{release}
Recommends: mesa-dri-drivers
Recommends: mesa-vulkan-drivers
@@ -109,7 +110,7 @@ sed -i 's^../thirdparty/SPIRV-Headers/include/spirv/^/usr/include/spirv/^' src/m
%build
cd gamescope
export PKG_CONFIG_PATH=pkgconfig
-%meson \
+%meson --wrap-mode=default \
--auto-features=enabled \
-Dforce_fallback_for=vkroots,wlroots,libliftoff,libdisplay-info
%meson_build
handheld.patch
は大きくmasterには当てられないため、自分は使っていないので無視する。
Bazziteにインストールする
ビルドしたgamescope-libsにVulkanのImplicit Loaderが含まれていて、これをビルドしたgamescopeのバージョンと合わせないとレンダリングがされない。
mkdir ~/.local/bin ~/.local/lib64
cp ./usr/bin/gamescope* ~/.local/bin
cp ./usr/lib64/libVkLayer_FROG_gamescope_wsi_x86_64.so ~/.local/lib64
cp ./usr/share/vulkan/implicit_layer.d/VkLayer_FROG_gamescope_wsi.x86_64.json ~/.config/vulkan/implicit_layer.d/
sed -i $"s#/usr/lib64/libVkLayer_FROG_gamescope_wsi_x86_64.so#(echo ~/.local/lib64/libVkLayer_FROG_gamescope_wsi_x86_64.so | path expand)#" ~/.config/vulkan/implicit_layer.d/VkLayer_FROG_gamescope_wsi.x86_64.json
rpm-ostreeでシステムのgamescopeをオーバーライドしたかったが上手くいかなかったので、いったんホームディレクトリにインストールしている。