Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion psprecomp/docs/GRAPHICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ scene snapshot and is left at paper white. The Vulkan swapchain asks for
`R16G16B16A16_SFLOAT` + `EXTENDED_SRGB_LINEAR` (scRGB, 1.0 = 80 nits) first and `A2B10G10R10` + `HDR10_ST2084` (PQ, encoded in the
shader) second; the default framebuffer becomes fp16 while HDR is live. Toggling the row rebuilds the swapchain at the next present.
HDR needs the system's HDR mode on and a compositor that exposes it (Windows, Wayland compositors with HDR, gamescope, Android
panels); X11 offers none, and the row then reads Unavailable with the reason.
panels); X11 offers none, and the row then reads Unavailable with the reason. SDL2 tries X11 before Wayland, so on a Wayland
desktop with X authorization (any session started from the desktop) the game opened through XWayland and never saw an HDR format.
With the Vulkan renderer `psp_runtime_init_sdl` therefore sets `SDL_HINT_VIDEODRIVER=wayland,x11` when `WAYLAND_DISPLAY` is set,
unless the user set `SDL_VIDEODRIVER` or the game runs under gamescope (which shows only X11 windows).

**HDR Scene (native HDR, opt-in).** With it on (and an HDR swapchain live, so the Vulkan renderer only) the scene targets
(`make_target`, the render-scale resize, the feedback / fx scratch copies, the screen-fx colour and effect buffers, the SMAA
Expand Down
15 changes: 15 additions & 0 deletions psprecomp/runtime/src/psp_event_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,21 @@ int psp_runtime_init_sdl() {
// Text input is only wanted while the on-screen keyboard is open, and SDL must not summon the
// Steam Deck keyboard by itself (SDL_StartTextInput does on a Deck): steam_keyboard() below does it.
SDL_SetHint("SDL_ENABLE_SCREEN_KEYBOARD", "0");
#if defined(__linux__) && !defined(__ANDROID__)
// SDL2 tries X11 before Wayland, so on a Wayland desktop (GNOME, KDE) the game opened through XWayland, which has no HDR: the surface
// offered no HDR format and HDR Output read "Unavailable" with HDR on in the system settings. With the Vulkan renderer ask for a
// native Wayland window first (X11 stays the fallback). Not under gamescope, which shows only X11 windows, and never over a
// SDL_VIDEODRIVER the user set. Reads PSPRECOMP_RENDERER (the settings file is already in the environment) instead of calling
// vk_renderer_requested(): its Vulkan probe starts SDL's video layer, which would pick X11 before this hint exists.
{
const char* wl = std::getenv("WAYLAND_DISPLAY");
const char* drv = std::getenv("SDL_VIDEODRIVER");
const char* rr = std::getenv("PSPRECOMP_RENDERER");
const bool want_vk = rr && (!std::strcmp(rr, "vulkan") || !std::strcmp(rr, "vk"));
if (want_vk && wl && wl[0] && !(drv && drv[0]) && !std::getenv("GAMESCOPE_WAYLAND_DISPLAY"))
SDL_SetHint(SDL_HINT_VIDEODRIVER, "wayland,x11");
}
#endif
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) != 0) {
std::fprintf(stderr,
"[RT] SDL_Init failed: %s\n", SDL_GetError());
Expand Down
9 changes: 7 additions & 2 deletions psprecomp/runtime/src/vk/psp_vk_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,13 @@ bool Context::create_swapchain(int w, int h, bool vsync, std::string* err) {
#endif
if (hdr_supported_) hdr_reason_.clear();
else if (!android_reason.empty()) hdr_reason_ = android_reason;
else hdr_reason_ = colorspace_ext_ ? "The display or the window system offers no HDR format. Turn HDR on in the system display settings, and use Wayland, Windows or gamescope (X11 has no HDR)."
: "The Vulkan driver has no VK_EXT_swapchain_colorspace.";
else if (!colorspace_ext_) hdr_reason_ = "The Vulkan driver has no VK_EXT_swapchain_colorspace.";
#if defined(__linux__) && !defined(__ANDROID__)
else if (window_ && std::getenv("WAYLAND_DISPLAY") && !std::getenv("GAMESCOPE_WAYLAND_DISPLAY") && SDL_GetCurrentVideoDriver() &&
!std::strcmp(SDL_GetCurrentVideoDriver(), "x11"))
hdr_reason_ = "The game window runs through XWayland (X11), which has no HDR. Start the game without SDL_VIDEODRIVER=x11 so it opens as a native Wayland window.";
#endif
else hdr_reason_ = "The display or the window system offers no HDR format. Turn HDR on in the system display settings, and use Wayland, Windows or gamescope (X11 has no HDR).";
if (hdr_wanted_ && hdr_supported_) {
// PSPRECOMP_HDR_FORMAT=hdr10|scrgb picks by hand; scRGB first otherwise.
const char* hf = std::getenv("PSPRECOMP_HDR_FORMAT");
Expand Down
Loading