Use a software Gamescope swapchain without scan-out texture exports

This commit is contained in:
xXJsonDeruloXx committed 2026-10-03 14:24:24 -04:00
1 parent 5f3112fb4b
commit 423c5388ee
2 files changed
+30 -4

No files matched your search

@@ -1,5 +1,5 @@
diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp
index 54e4efc..226f9b7 100644
index 54e4efc..43239d8 100644
--- a/src/rendervulkan.cpp
+++ b/src/rendervulkan.cpp
@@ -349,6 +349,25 @@ bool CVulkanDevice::selectPhysDev(VkSurfaceKHR surface)
@@ -88,7 +88,17 @@ index 54e4efc..226f9b7 100644
}
else
vulkan_remake_swapchain();
@@ -3662,7 +3693,7 @@ bool vulkan_init( VkInstance instance, VkSurfaceKHR surface )
@@ -3161,7 +3192,8 @@ gamescope::Rc<CVulkanTexture> vulkan_get_hacky_blank_texture()
gamescope::OwningRc<CVulkanTexture> vulkan_create_flat_texture( uint32_t width, uint32_t height, uint8_t r, uint8_t g, uint8_t b, uint8_t a )
{
CVulkanTexture::createFlags flags;
- flags.bFlippable = true;
+ // A swapchain backend samples this texture locally; it never scans it out.
+ flags.bFlippable = !GetBackend()->UsesVulkanSwapchain();
flags.bSampled = true;
flags.bTransferDst = true;
@@ -3662,7 +3694,7 @@ bool vulkan_init( VkInstance instance, VkSurfaceKHR surface )
if (!init_nis_data())
return false;
@@ -73,6 +73,15 @@ if [ -n "${BL_VK_DRIVER:-}" ]; then
fi
unset bl_icd_lib
fi
# Compatibility mode: the Android presenter still uses its selected Vulkan driver, while the
# Linux session renders on the CPU. Gamescope's SDL swapchain can carry these frames as wl_shm;
# its Wayland backend requires exportable dma-bufs even for its dummy black texture.
if [ "${BL_STEAM_SOFTWARE:-0}" = 1 ]; then
export VK_DRIVER_FILES=/usr/share/vulkan/icd.d/lvp_icd.json
export VK_ICD_FILENAMES=$VK_DRIVER_FILES
export LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe MESA_LOADER_DRIVER_OVERRIDE=swrast
echo "== linux graphics: software rendering requested (Lavapipe/llvmpipe)"
fi
# The app's gamescope build (tools/gamescope) asks for realtime-priority Vulkan queues on this
# switch instead of on CAP_SYS_NICE, which proot never has; it falls back to normal priority
# where the driver refuses, and the runtime's own build ignores it. On KGSL Turnip (Mesa 26.2) it
@@ -148,7 +157,13 @@ if [ -z "${BL_INSIDE:-}" ]; then
echo "== gamescope: games at ${nested}x${height} stretched to the ${width}x${height} output"
fi
fi
args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$height")
backend=wayland
if [ "${BL_STEAM_SOFTWARE:-0}" = 1 ]; then
backend=sdl
export SDL_VIDEODRIVER=wayland
echo "== gamescope: SDL Wayland swapchain for software rendering"
fi
args=(--backend "$backend" --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$height")
[ "$nested" != "$width" ] && args+=(-S stretch)
# -r is what gamescope advertises as the refresh rate, and what a game reads as the display's.
# Left unset it defaults to 60, so a 120 Hz panel offers only 60 Hz in game settings. The FPS
@@ -179,7 +194,8 @@ if [ -z "${BL_INSIDE:-}" ]; then
# MANGOHUD_CONFIGFILE. The apk stages Valve's aarch64 build (tools/mangoapp) - without it the menu
# still offers the levels and nothing appears. Starts hidden until the client writes a level.
# BL_MANGOAPP=0 turns it off (one community build found Valve's mangoapp crashing on Turnip).
if [ "$mode" = steam ] && [ "${BL_STEAMDECK:-0}" = 1 ] && [ "${BL_MANGOAPP:-1}" = 1 ] \
if [ "$mode" = steam ] && [ "${BL_STEAM_SOFTWARE:-0}" != 1 ] \
&& [ "${BL_STEAMDECK:-0}" = 1 ] && [ "${BL_MANGOAPP:-1}" = 1 ] \
&& [ "${BL_STEAM_UI:-}" != desktop ] && command -v mangoapp >/dev/null 2>&1; then
MANGOHUD_CONFIGFILE=$(mktemp /tmp/mangohud.XXXXXXXX)
echo no_display > "$MANGOHUD_CONFIGFILE"