ReStreet: FIFA Street (2012) recompiled for Windows PC, with online play, a launcher with friends, chat and rooms. Bring your own game.
ReStreet v1.3: offline release
SamuelitoDaViladf5f8efa4152
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d89b152..e50fb4c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,26 @@# ReStreet - FIFA Street 2012 Recompiled: changelog+## v1.3++True VSync on Direct3D 12 and Vulkan: no tearing, a new frame on every refresh at any refresh rate (also with Adaptive Sync / FreeSync), an FPS counter that matches GPU overlays, and clean stadium floors on every graphics card.++### New+- **True VSync.** With VSync on, the screen shows a new frame on every refresh, at whatever refresh rate you pick in the launcher (60, 120, 144, 165 Hz and beyond), with no tearing. Each refresh shows the game's newest frame, so motion is smooth: no more half-rate drops, uneven pacing or stutter when the game window has focus. Same on Direct3D 12 and Vulkan.+- **Works with Adaptive Sync / FreeSync.** With Adaptive Sync on, frames are handed to the display on an even clock, so the monitor refreshes exactly once per frame instead of holding frames for 2 or 3 refreshes.+- **The in-game FPS counter shows what you see.** With VSync on, it counts the frames that actually reach the screen, the same number AMD, NVIDIA and other overlays show.+- **VSync off = no frame limit.** With VSync on, the game is capped at twice the refresh rate so a fresh frame is always ready without wasting power.+- **The launcher's refresh rate change now sticks.** The chosen refresh rate is applied so Windows keeps it while the game is in front, and the refresh rate saved in Windows is restored when the game closes.++### Fixed+- **Graphical garbage on some court floors** (seen on slower graphics cards). The floor data the game reads back from the graphics card is always read for the current frame again.+- **Smoother render-to-texture images at higher internal resolutions** (for example player portraits drawn by the game): they are averaged instead of keeping one pixel out of each block when copied back at the original resolution.+- **Intro and cutscene videos** play at the correct speed with clean sound and steady frames, with VSync on or off.++### Notes+- With VSync on, the game cannot show more frames than it can produce: if a scene runs below your refresh rate, some frames stay on screen for two refreshes. 60 Hz is the safest choice for a perfectly steady match.+- The 3D portraits of players without a photo (generated World Tour squad players, created players) are drawn by the game at a small size; they look soft when stretched to large resolutions. This is how the game draws them.+- Installs over v1.2. Saves, game data and launcher settings are kept.+## v1.2Menus, cutscenes, goals and replays now run at your refresh rate, Vulkan replays are sharp, Direct3D 12 no longer drops to 1 FPS with VSync on, and updating over an online-patched install removes the online patch.diff --git a/Installer/FifaStreetSetupTool/FifaStreetSetupTool.csproj b/Installer/FifaStreetSetupTool/FifaStreetSetupTool.csprojindex cef0036..ed749f0 100644--- a/Installer/FifaStreetSetupTool/FifaStreetSetupTool.csproj+++ b/Installer/FifaStreetSetupTool/FifaStreetSetupTool.csproj@@ -5,7 +5,7 @@<TargetFramework>net8.0-windows</TargetFramework><UseWindowsForms>true</UseWindowsForms><ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>- <Version>1.2.0</Version>+ <Version>1.3.0</Version><AssemblyName>FifaStreetSetup</AssemblyName><ApplicationIcon>..\recomp-template\src\fifastreet.ico</ApplicationIcon><ImplicitUsings>enable</ImplicitUsings>diff --git a/Launcher/FifaStreetLauncher/FifaStreetLauncher.csproj b/Launcher/FifaStreetLauncher/FifaStreetLauncher.csprojindex 001125d..3ef4564 100644--- a/Launcher/FifaStreetLauncher/FifaStreetLauncher.csproj+++ b/Launcher/FifaStreetLauncher/FifaStreetLauncher.csproj@@ -6,7 +6,7 @@<Nullable>enable</Nullable><UseWindowsForms>true</UseWindowsForms><ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>- <Version>1.2.0</Version>+ <Version>1.3.0</Version><ApplicationIcon>fifastreet.ico</ApplicationIcon><ImplicitUsings>enable</ImplicitUsings></PropertyGroup>diff --git a/Launcher/FifaStreetLauncher/LauncherForm.cs b/Launcher/FifaStreetLauncher/LauncherForm.csindex adb57b5..47b2eaa 100644--- a/Launcher/FifaStreetLauncher/LauncherForm.cs+++ b/Launcher/FifaStreetLauncher/LauncherForm.cs@@ -159,7 +159,7 @@ public class LauncherForm : Form, ISceneHost, IUiScaledusing (var bar = new SolidBrush(StreetTheme.Yellow)) g.FillPolygon(bar, StreetTheme.Slant(tag, 12));using (var tagFont = new Font(StreetTheme.CondensedFamily, 18, FontStyle.Bold, GraphicsUnit.Pixel))using (var dark = new SolidBrush(StreetTheme.YellowDark))- StreetTheme.DrawSpaced(g, "V1.2 · OFFLINE", tagFont, dark, new PointF(Left + 14, 246), 2.8f);+ StreetTheme.DrawSpaced(g, "V1.3 · OFFLINE", tagFont, dark, new PointF(Left + 14, 246), 2.8f);using var name = new Font("Segoe UI", 15, FontStyle.Regular, GraphicsUnit.Pixel);StreetTheme.DrawLabelValue(g, "Ported by:", "SamuelitoDaVila", name, StreetTheme.Ink, StreetTheme.Ink, Left, 642);@@ -1106,23 +1106,25 @@ startInfo.Environment["REX_DRAW_RESOLUTION_SCALE_Y"] =startInfo.Environment["REX_WINDOW_HEIGHT"] = height.ToString();// Apply the selected rate to both the monitor and Xbox video timing.startInfo.Environment["REX_VIDEO_MODE_REFRESH_RATE"] = refresh;- // Lift the game's own 40 FPS replay/cutscene cap up to the chosen rate.- startInfo.Environment["REX_FRAME_LIMITER_MIN_HZ"] = "auto";- // No forced synchronous readbacks: they held goals and match setup at 30-40 FPS.- startInfo.Environment["REX_READBACK_SOME_SYNC_ADDRS"] = "00000000";+ // VSync on: lift the game's own 40 FPS replay/cutscene cap up to the chosen rate.+ // VSync off: no frame limit at all (the game's own limiter is raised out of the way).+ startInfo.Environment["REX_FRAME_LIMITER_MIN_HZ"] = vsyncBox.Checked ? "auto" : "1000";+ // Keep the one synchronous readback that keeps stadium floors clean (default 1282B000), drop the+ // other small-range ones that held goals, replays and match setup below the chosen rate.+ startInfo.Environment.Remove("REX_READBACK_SOME_SYNC_ADDRS");startInfo.Environment["REX_READBACK_SOME_SYNC_BELOW"] = "0";ApplyGameLanguage(startInfo);- // Disable the guest pacing limit together with display VSync.- startInfo.Environment["REX_GUEST_VBLANK_UNLOCKED"] =- vsyncBox.Checked ? "false" : "true";+ // The game keeps its own clock in both modes (True VSync shows its newest frame at each refresh).+ startInfo.Environment["REX_GUEST_VBLANK_UNLOCKED"] = "true";startInfo.Environment["REX_FULLSCREEN"] =fullscreen ? "true" : "false";startInfo.Environment["REX_MONITOR"] = (monitor + 1).ToString();startInfo.Environment["REX_LAUNCHER_MONITOR_DEVICE"] = Screen.AllScreens[monitor].DeviceName;- // "VSync" is implemented as paced presentation: the game clock stays locked to the refresh rate and- // frames are presented without blocking the graphics queue. The real blocking VSync of the host swap chain- // made every GPU wait cost two vblanks (a few FPS), and it does not tear because tearing is not requested.+ // "VSync" = True VSync: no tearing, the display shows the game's newest frame at every refresh of the+ // chosen rate (any rate), and the FPS counter shows displayed frames like GPU overlays do. The old+ // blocking host VSync (REX_VSYNC) stays off: it made every GPU wait cost two refreshes.startInfo.Environment["REX_VSYNC"] = "false";+ startInfo.Environment["REX_TRUE_VSYNC"] = vsyncBox.Checked ? "1" : "0";startInfo.Environment["REX_NATIVE_2X_MSAA"] =msaaBox.Checked ? "true" : "false";startInfo.Environment["REX_SWAP_POST_EFFECT"] = postEffect;@@ -1279,9 +1281,13 @@ startInfo.Environment["REX_DRAW_RESOLUTION_SCALE_Y"] =private static extern int ChangeDisplaySettingsEx(string deviceName, ref DEVMODE mode, IntPtr window, uint flags, IntPtr parameter);+ [DllImport("user32.dll", CharSet = CharSet.Ansi, EntryPoint = "ChangeDisplaySettingsEx")]+ private static extern int ChangeDisplaySettingsExToRegistry(+ string deviceName, IntPtr mode, IntPtr window, uint flags, IntPtr parameter);+private void ApplyMonitorRefresh(int monitor, string refresh, int width, int height){- const uint CDS_TEST = 2, CDS_FULLSCREEN = 4;+ const uint CDS_TEST = 2;const int DM_DISPLAYFREQUENCY = 0x00400000;if (monitor < 0 || monitor >= Screen.AllScreens.Length ||!int.TryParse(refresh, out int hz) || hz <= 1) {@@ -1308,7 +1314,10 @@ startInfo.Environment["REX_DRAW_RESOLUTION_SCALE_Y"] =throw new InvalidOperationException($"The selected resolution and {hz} Hz are not available on this monitor (Windows code {result}).");}- result = ChangeDisplaySettingsEx(device, ref requested, IntPtr.Zero, CDS_FULLSCREEN, IntPtr.Zero);+ // Dynamic change (not CDS_FULLSCREEN): a CDS_FULLSCREEN mode is tied to the launcher, and Windows dropped+ // it back to the desktop rate when the game window took focus (60 Hz chosen, 165 Hz measured in game).+ // It is not saved to the registry; RestoreMonitorRefresh puts the previous mode back after the game exits.+ result = ChangeDisplaySettingsEx(device, ref requested, IntPtr.Zero, 0, IntPtr.Zero);if (result != 0) {throw new InvalidOperationException($"Windows could not apply {hz} Hz (code {result}).");}@@ -1328,7 +1337,12 @@ startInfo.Environment["REX_DRAW_RESOLUTION_SCALE_Y"] =if (changedDisplay == null) return;string device = changedDisplay;changedDisplay = null;- int result = ChangeDisplaySettingsEx(device, ref previousDisplayMode, IntPtr.Zero, 0, IntPtr.Zero);+ // Back to the mode saved in Windows display settings (the change above is dynamic and never saved);+ // fall back to the mode read before the change.+ int result = ChangeDisplaySettingsExToRegistry(device, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero);+ if (result != 0) {+ result = ChangeDisplaySettingsEx(device, ref previousDisplayMode, IntPtr.Zero, 0, IntPtr.Zero);+ }if (result != 0) {ShowError($"Could not restore the monitor refresh rate (Windows code {result}). Check Windows display settings.");}diff --git a/README.md b/README.mdindex 4301829..b552816 100644--- a/README.md+++ b/README.md@@ -10,7 +10,7 @@[Download](https://github.com/samuelit0davila/fifa-street-pc-port/releases/latest) · [Changelog](CHANGELOG.md) · [Report a bug](https://github.com/samuelit0davila/fifa-street-pc-port/issues) · [Build from source](docs/BUILDING.md)-<img src="docs/images/start-screen.png" alt="ReStreet running on PC" width="1000">+<img src="docs/images/restreet-1.3-banner.png" alt="ReStreet 1.3: True VSync, smooth motion, honest FPS counter, Adaptive Sync, clean courts, uncapped when VSync is off" width="1000"></div>@@ -20,7 +20,18 @@ ReStreet is a Windows PC version of FIFA Street (2012) made by recompiling the XYou need your own copy of the game: an Xbox 360 ISO of FIFA Street (2012). The ISO and the game files are not included.-**v1.2 is offline only.** It has no online play.+**v1.3 is offline only.** It has no online play.++## What's new in v1.3++- **True VSync on Direct3D 12 and Vulkan:** no tearing and a new frame on every refresh, at any refresh rate you pick in the launcher (60, 120, 144, 165 Hz and beyond).+- **Smooth motion:** each refresh shows the game's newest frame, with no half-rate drops or stutter when the game window has focus. Works with **Adaptive Sync / FreeSync** on.+- **Honest FPS counter:** with VSync on, the in-game counter shows the frames that reach the screen, the same number as AMD, NVIDIA and other overlays.+- **VSync off = no frame limit.**+- **Clean stadium floors** on every graphics card, and a menu crash fixed.+- Installs over v1.2. Saves and settings are kept. See the full [changelog](CHANGELOG.md).++<img src="docs/images/start-screen.png" alt="ReStreet running on PC" width="1000">## What's new in v1.2diff --git a/docs/RELEASE-NOTES.md b/docs/RELEASE-NOTES.mdindex fe289fd..6519f12 100644--- a/docs/RELEASE-NOTES.md+++ b/docs/RELEASE-NOTES.md@@ -1,24 +1,28 @@-# ReStreet - FIFA Street 2012 Recompiled v1.2+# ReStreet - FIFA Street 2012 Recompiled v1.3-Smoother frame rate in the whole game, sharp Vulkan replays, and an update that removes the online patch. This version is offline only.+-## Improved in v1.2+True VSync on Direct3D 12 and Vulkan, an FPS counter that matches GPU overlays, and clean stadium floors on every graphics card. This version is offline only.-- **Cutscenes and goal replays are no longer capped at 40 FPS.** The game has its own frame limiter that held them at 40 FPS. It now follows the refresh rate chosen in the launcher.-- **Goals and match setup no longer drop to 30-40 FPS.** A forced wait for the graphics card on every frame was removed.-- **Menus run at 60 FPS** instead of 30.+## New in v1.3++- **True VSync.** With VSync on, the screen shows a new frame on every refresh, at whatever refresh rate you pick in the launcher (60, 120, 144, 165 Hz and beyond), with no tearing. Each refresh shows the game's newest frame: no half-rate drops, uneven pacing or stutter when the game window has focus. Same on Direct3D 12 and Vulkan.+- **Works with Adaptive Sync / FreeSync.** Frames are handed to the display on an even clock, so the monitor refreshes once per frame instead of holding frames for 2 or 3 refreshes.+- **Honest FPS counter.** With VSync on, the in-game counter counts the frames that reach the screen, the same number AMD, NVIDIA and other overlays show.+- **VSync off = no frame limit.** With VSync on, the game is capped at twice the refresh rate so a fresh frame is always ready without wasting power.+- **The launcher's refresh rate change sticks** while the game is in front, and the refresh rate saved in Windows is restored when the game closes.## Fixed-- **Vulkan: goal replays were blurred.** They are now as sharp as in Direct3D 12.-- **Direct3D 12 with VSync on could fall to 1 FPS** on some laptops. Measured on an RTX 4060 Laptop: 0.6 FPS to a steady 60 FPS in the same scene.-- **Updating works over v1.1 with or without the online patch.** If the online patch is installed, the update removes it (online.json, online-patch.json, the OnlinePatch folder, tools\ReStreetAssetExplorer.exe and the stadium pictures). A copy of the replaced files is kept in `.updates`. Saves, game data and launcher settings are kept.+- **Graphical garbage on some court floors** on slower graphics cards: the floor data is always read for the current frame.+- **A crash when opening some main menu options** with Direct3D 12.+- **Smoother render-to-texture images** at higher internal resolutions (for example the 3D portraits the game draws for players without a photo).+- **Intro and cutscene videos** play at the correct speed with clean sound, with VSync on or off.## Known limitations-- With VSync on above 60 Hz, some scenes can run at half the refresh rate (for example 50 FPS at 100 Hz). Turn VSync off (ideally with VRR) for an unlocked frame rate.-- With VSync on in Direct3D 12 you may see tearing in fullscreen.-- Vulkan still runs at 30 FPS outside menus on some PCs. Direct3D 12 is recommended.+- With VSync on, the game cannot show more frames than it produces: if a scene runs below your refresh rate, some frames stay on screen for two refreshes. 60 Hz is the safest choice for a perfectly steady match.+- The 3D portraits of players without a photo (generated World Tour squad players, created players) are drawn small by the game and look soft on large screens. This is how the game draws them.## How to installdiff --git a/docs/STATUS.md b/docs/STATUS.mdindex 716ac7a..084c114 100644--- a/docs/STATUS.md+++ b/docs/STATUS.md@@ -1,35 +1,35 @@# Validation and known limitations-Last updated: **11 October 2026**, for **ReStreet v1.2** (offline only). This page separates what was tested from what was not.+Last updated: **14 October 2026**, for **ReStreet v1.3** (offline only). This page separates what was tested from what was not.-## What was tested for v1.2+## What was tested for v1.3-All of this was tested by the developer on one Windows 11 PC with an AMD Radeon RX 9070 XT and a Ryzen 5 7600, at 100% display scale.+All of this was tested by the developer on one Windows 11 PC with an AMD Radeon RX 9070 XT, a Ryzen 5 7600 and a 165 Hz monitor with Adaptive Sync, at 100% display scale.| Check | Result ||---|---|-| Direct3D 12 at 60 Hz: menus, cutscenes, goals, replays and match setup at 60 FPS | Passed |-| Vulkan: goal replays sharp (no blur) | Passed |-| Vulkan: menus at 60 FPS, main menu not stretched | Passed |-| Update over v1.1 offline (installer `--update-test` on a copy) | Passed |-| Update over v1.1 with the online patch: files replaced, online patch removed, settings kept | Passed |+| Direct3D 12, VSync on at 60 Hz: menus, match, goals and replays at 60 FPS, one new image per refresh (DXGI frame statistics) | Passed |+| Same with Adaptive Sync / FreeSync on | Passed |+| Vulkan, VSync on at 60 Hz, Adaptive Sync on: smooth, 99% low about 57-58 FPS | Passed |+| In-game FPS counter equals the AMD overlay with VSync on | Passed |+| Court floors without graphical garbage in the two venues where it was seen | Passed |+| Main menu options open without the Direct3D 12 crash (Direct3D 12 and Vulkan) | Passed |+| Update over v1.2 (installer `--update-test` on a copy): all files replaced, settings kept | Passed |-**Not yet tested on v1.2:** a clean installation from the ISO, NVIDIA and Intel graphics, the update over an installation with the v1.0 online patch, a full play session from an updated installation.+**Not yet tested on v1.3:** NVIDIA and Intel graphics, refresh rates the game cannot sustain in a match (above about 90 FPS on the test PC), a long play session.-Known on v1.2: with VSync on above 60 Hz, some scenes run at half the refresh rate (for example 50 FPS at 100 Hz). Vulkan runs at 30 FPS outside menus on the test PC; Direct3D 12 is recommended.--The game module was rebuilt for v1.2 (the game's own 40 FPS limiter for replays and cutscenes now follows the refresh rate chosen in the launcher). World Tour and Practice were validated on earlier releases and not repeated.+The game module is unchanged from v1.2; only the runtime, the launcher and the installer changed. World Tour and Practice were validated on earlier releases and not repeated.## Graphics backendsThe package contains two validated backend folders, `Game/Backends/D3D12` and `Game/Backends/Vulkan`. The launcher copies the selected backend's `rexruntime.dll` and `rexgpu-xenos.dll` beside `fifastreet.exe` before launch. Direct3D 12 is the default.-### SHA-256 of the backend files in v1.2+### SHA-256 of the backend files in v1.3| Backend | `rexruntime.dll` | `rexgpu-xenos.dll` ||---|---|---|-| Direct3D 12 | `D572DF8FBCDB2B8972BBD0A4DA729260088873FF74FD40CB06D95E9568843CD3` | `E9E407D0EE59A8D6FBEE5AD5A98F49727314826687693C00A8FD68D8A9E0FB9F` |-| Vulkan | `870653C3AF20506413F5891A6C21C3E28491994B8691EA371B0D918BDCCBC7BF` | `C956E3B7701032851D46B17D5994A414B1C14C3C835B2EE6052C9F4421598085` |+| Direct3D 12 | `D74A137AC448D82381FF408AFDB92E4FCE449F3E96E8977A108AC3EA5AB4F041` | `D6068770C9644184B6BC9E0BE6DE3D2521EF542E36C5DF4DD527544FDA289D18` |+| Vulkan | `EF2E7F7AD33DDB950FC98CCDA238FEF40491D34D889BA7C57C5DBFE37523BC07` | `ADBF3CB83E5CB18C41C83E60ED59DD4DEC38A330E8E3D0B6127926F30460C5C3` |The installer checks its payload against the hashes in its own manifest before installing.@@ -55,7 +55,7 @@ Output resolution and internal rendering scale are independent. Internal resolut## Known limitations- No universal hardware, driver or frame-rate guarantee. 3x/4x internal rendering and 4K output are not guaranteed 60 FPS modes.-- No online play in v1.2.+- No online play in v1.3.- The window title of the game itself still reads "FIFA Street PC"; the launcher and installer use the ReStreet name.- The exit prompt only opens with the START + B (START + Circle) shortcut, not from the main menu.- The installer expands its details panel by 180 px, which does not fit on screens 768 px high or less.diff --git a/docs/images/restreet-1.3-banner.png b/docs/images/restreet-1.3-banner.pngnew file mode 100644index 0000000..7fb55c9Binary files /dev/null and b/docs/images/restreet-1.3-banner.png differdiff --git a/patches/rexglue-local-changes.patch b/patches/rexglue-local-changes.patchindex cb79a5b..980747b 100644--- a/patches/rexglue-local-changes.patch+++ b/patches/rexglue-local-changes.patch@@ -90,7 +90,7 @@ index da8e432..5ba6484 100644uint32_t primary_buffer_ptr_ = 0;uint32_t primary_buffer_size_ = 0;diff --git a/include/rex/graphics/d3d12/command_processor.h b/include/rex/graphics/d3d12/command_processor.h-index 96d362b..4f48975 100644+index 96d362b..3d26e54 100644--- a/include/rex/graphics/d3d12/command_processor.h+++ b/include/rex/graphics/d3d12/command_processor.h@@ -310,7 +310,7 @@ class D3D12CommandProcessor : public CommandProcessor {@@ -121,7 +121,15 @@ index 96d362b..4f48975 100644uint32_t current_index = 0;uint64_t last_used_frame = 0;};-@@ -615,6 +616,12 @@ class D3D12CommandProcessor : public CommandProcessor {+@@ -603,6 +604,7 @@ class D3D12CommandProcessor : public CommandProcessor {+ uint32_t pixel_size_log2;+ uint32_t tile_count;+ uint32_t half_pixel_offset;++ uint32_t average; // per-channel block average (8:8:8:8 color)+ };+ enum class ResolveDownscaleRootParameter : UINT {+ kConstants,+@@ -615,6 +617,12 @@ class D3D12CommandProcessor : public CommandProcessor {Microsoft::WRL::ComPtr<ID3D12PipelineState> resolve_downscale_pipeline_;Microsoft::WRL::ComPtr<ID3D12Resource> resolve_downscale_buffer_;uint32_t resolve_downscale_buffer_size_ = 0;@@ -173,7 +181,7 @@ index 4d845c7..6986efc 100644// Because on Direct3D 12 (at least on Windows 10 2004) typed SRV or UAV// creation fails for offsets above 4 GB, a single tiled 4.5 GB buffer can'tdiff --git a/include/rex/graphics/flags.h b/include/rex/graphics/flags.h-index 2cf24c4..24574c4 100644+index 2cf24c4..86fe5a1 100644--- a/include/rex/graphics/flags.h+++ b/include/rex/graphics/flags.h@@ -15,6 +15,7 @@@@ -184,6 +192,14 @@ index 2cf24c4..24574c4 100644REXCVAR_DECLARE(bool, clear_memory_page_state);REXCVAR_DECLARE(bool, half_pixel_offset);REXCVAR_DECLARE(bool, async_shader_compilation);+@@ -27,6 +28,7 @@ REXCVAR_DECLARE(bool, resolve_resolution_scale_fill_half_pixel_offset);+ REXCVAR_DECLARE(bool, draw_resolution_scaled_texture_offsets);+ REXCVAR_DECLARE(std::string, readback_resolve);+ REXCVAR_DECLARE(bool, readback_resolve_half_pixel_offset);++REXCVAR_DECLARE(bool, readback_resolve_average_color);+ REXCVAR_DECLARE(bool, readback_memexport);+ REXCVAR_DECLARE(bool, readback_memexport_fast);+ REXCVAR_DECLARE(bool, occlusion_query_enable);diff --git a/include/rex/graphics/pipeline/shader/dxbc_translator.h b/include/rex/graphics/pipeline/shader/dxbc_translator.hindex 3b0fd61..be2c144 100644--- a/include/rex/graphics/pipeline/shader/dxbc_translator.h@@ -230,7 +246,7 @@ index 4d85a2b..4a57875 100644void* memory_data_provider_handle_ = nullptr;diff --git a/include/rex/graphics/vulkan/command_processor.h b/include/rex/graphics/vulkan/command_processor.h-index 696ff48..a2bdd15 100644+index 696ff48..555a5e3 100644--- a/include/rex/graphics/vulkan/command_processor.h+++ b/include/rex/graphics/vulkan/command_processor.h@@ -149,6 +149,7 @@ class VulkanCommandProcessor : public CommandProcessor {@@ -276,6 +292,14 @@ index 696ff48..a2bdd15 100644return !submission_open_ && submissions_in_flight_fences_.empty();}// Keep primary-buffer-end submit behavior aligned with D3D12: only submit+@@ -480,6 +488,7 @@ class VulkanCommandProcessor : public CommandProcessor {+ uint32_t tile_count;+ uint32_t source_offset_bytes;+ uint32_t half_pixel_offset;++ uint32_t average; // per-channel block average (8:8:8:8 color)+ };+ bool EnsureSwapFxaaSourceImage(uint32_t width, uint32_t height);+ void DestroySwapFxaaSourceImage();diff --git a/include/rex/input/guide_capture.h b/include/rex/input/guide_capture.hnew file mode 100644index 0000000..4d908d5@@ -439,6 +463,32 @@ index 07eb5ea..ae8d43e 100644size_t Copy(uint8_t* dest_buffer, size_t num_bits);+diff --git a/include/rex/ui/d3d12/d3d12_presenter.h b/include/rex/ui/d3d12/d3d12_presenter.h+index 83d09f7..1058d82 100644+--- a/include/rex/ui/d3d12/d3d12_presenter.h++++ b/include/rex/ui/d3d12/d3d12_presenter.h+@@ -246,11 +246,21 @@ class D3D12Presenter final : public Presenter {+ guest_output_intermediate_textures;+ UINT64 guest_output_intermediate_texture_last_usage = 0;+++ // True VSync: painting and presenting use their own queue, so waiting for the display refresh never++ // holds the direct queue (and the guest's GPU readback waits behind it). Null otherwise.++ Microsoft::WRL::ComPtr<ID3D12CommandQueue> present_queue;++ Microsoft::WRL::ComPtr<ID3D12Fence> present_queue_direct_fence;++ UINT64 present_queue_direct_fence_value = 0;+++ // Connection-specific.++ uint32_t swap_chain_width = 0;+ uint32_t swap_chain_height = 0;+ bool swap_chain_allows_tearing = false;++ // True VSync: the swap chain is in DXGI exclusive fullscreen at the chosen refresh rate.++ bool swap_chain_exclusive = false;++ // True VSync: signaled when the swap chain can take a frame without blocking (null otherwise).++ HANDLE swap_chain_latency_waitable = nullptr;+ Microsoft::WRL::ComPtr<IDXGISwapChain3> swap_chain;+ std::array<Microsoft::WRL::ComPtr<ID3D12Resource>, kSwapChainBufferCount> swap_chain_buffers;+ };diff --git a/include/rex/ui/guide_font.h b/include/rex/ui/guide_font.hnew file mode 100644index 0000000..3a4c284@@ -1724,7 +1774,7 @@ index 4c57a18..c0d97c9 100644} else {return X_STATUS_END_OF_FILE;diff --git a/src/graphics/command_processor.cpp b/src/graphics/command_processor.cpp-index a744375..87bfab1 100644+index a744375..a4f27e1 100644--- a/src/graphics/command_processor.cpp+++ b/src/graphics/command_processor.cpp@@ -36,6 +36,15 @@@@ -1743,7 +1793,7 @@ index a744375..87bfab1 100644REXCVAR_DEFINE_BOOL(clear_memory_page_state, true, "GPU","Refresh page-valid state from GPU-written memory at frame end. "-@@ -54,6 +63,61 @@ REXCVAR_DEFINE_STRING(readback_resolve, "none", "GPU",+@@ -54,6 +63,67 @@ REXCVAR_DEFINE_STRING(readback_resolve, "none", "GPU",.allowed({"none", "fast", "some", "full"}).lifecycle(rex::cvar::Lifecycle::kHotReload);@@ -1801,11 +1851,17 @@ index a744375..87bfab1 100644+REXCVAR_DEFINE_BOOL(readback_some_log, false, "GPU",+ "Log the adaptive 'some' readback decisions and guest invalidations.")+ .lifecycle(rex::cvar::Lifecycle::kHotReload);++++REXCVAR_DEFINE_BOOL(readback_resolve_average_color, true, "GPU",++ "When draw resolution scaling is active, average each scaled block of 8:8:8:8 color resolves "++ "copied back to guest memory (smooth render-to-texture images such as player portraits) "++ "instead of picking one sample")++ .lifecycle(rex::cvar::Lifecycle::kHotReload);+REXCVAR_DEFINE_BOOL(readback_resolve_half_pixel_offset, false, "GPU","When draw resolution scaling is active, sample from the center of each ""scaled block during resolve readback downscale")-@@ -181,6 +245,144 @@ ReadbackResolveMode CommandProcessor::GetReadbackResolveMode(+@@ -181,6 +251,144 @@ ReadbackResolveMode CommandProcessor::GetReadbackResolveMode(: ReadbackResolveMode::kDisabled;}@@ -1950,7 +2006,7 @@ index a744375..87bfab1 100644bool CommandProcessor::IsReadbackMemexportEnabled(bool legacy_backend_flag) const {if (legacy_readback_memexport_cvar_name_ &&rex::cvar::HasNonDefaultValue(legacy_readback_memexport_cvar_name_)) {-@@ -930,6 +1132,33 @@ bool CommandProcessor::ExecutePacketType3_XE_SWAP(memory::RingBuffer* reader, ui+@@ -930,6 +1138,33 @@ bool CommandProcessor::ExecutePacketType3_XE_SWAP(memory::RingBuffer* reader, uiuint32_t count) {SCOPE_profile_cpu_f("gpu");@@ -1984,7 +2040,7 @@ index a744375..87bfab1 100644#ifdef REXGLUE_ENABLE_PERF_COUNTERS{static uint64_t last_frame_tick = 0;-@@ -943,6 +1172,7 @@ bool CommandProcessor::ExecutePacketType3_XE_SWAP(memory::RingBuffer* reader, ui+@@ -943,6 +1178,7 @@ bool CommandProcessor::ExecutePacketType3_XE_SWAP(memory::RingBuffer* reader, uilast_frame_tick = now;}#endif@@ -1993,7 +2049,7 @@ index a744375..87bfab1 100644// Xenia-specific VdSwap hook.diff --git a/src/graphics/d3d12/command_processor.cpp b/src/graphics/d3d12/command_processor.cpp-index 19874a5..a75c56d 100644+index 19874a5..f543162 100644--- a/src/graphics/d3d12/command_processor.cpp+++ b/src/graphics/d3d12/command_processor.cpp@@ -10,6 +10,7 @@@@ -2004,7 +2060,7 @@ index 19874a5..a75c56d 100644#include <cstdarg>#include <cstring>#include <sstream>-@@ -35,6 +36,18 @@+@@ -35,6 +36,41 @@REXCVAR_DEFINE_BOOL(d3d12_bindless, true, "GPU/D3D12", "Use bindless resources where available").lifecycle(rex::cvar::Lifecycle::kRequiresRestart);@@ -2016,6 +2072,29 @@ index 19874a5..a75c56d 100644++REXCVAR_DEFINE_UINT32(d3d12_readback_spin_us, 200, "GPU/D3D12",+ "Maximum CPU polling time before the blocking full-readback wait");++// Fence wait limit for the current CheckSubmissionFence (set only around the budgeted floor readback, on the++// command processor thread); INFINITE otherwise.++static thread_local DWORD g_fence_wait_timeout_ms = INFINITE;++++static void NoteReadbackBudget(bool fresh, double waited_us) {++ // Diagnostics for the budgeted floor readback: how often the GPU was done in time.++ static uint64_t fresh_count = 0, stale_count = 0;++ static double max_us = 0;++ static auto window = std::chrono::steady_clock::now();++ (fresh ? fresh_count : stale_count) += 1;++ max_us = std::max(max_us, waited_us);++ if (std::chrono::steady_clock::now() - window >= std::chrono::seconds(5)) {++ REXGPU_INFO("Readback sync budget: current_frame={} previous_frame={} max_wait_us={:.0f}", fresh_count,++ stale_count, max_us);++ fresh_count = stale_count = 0;++ max_us = 0;++ window = std::chrono::steady_clock::now();++ }++}++++REXCVAR_DEFINE_UINT32(d3d12_readback_sync_budget_us, 0, "GPU/D3D12",++ "'some' readback ranges read synchronously (readback_some_sync_*): wait at most this long "++ "for the GPU, then use the previous frame's copy instead (0 = always wait)");++REXCVAR_DEFINE_UINT32(d3d12_resolve_readback_max_bytes, 0, "GPU/D3D12",+ "Experimental CPU resolve readback size ceiling; zero preserves full readback");@@ -2023,7 +2102,7 @@ index 19874a5..a75c56d 100644REXCVAR_DEFINE_BOOL(d3d12_readback_memexport, false, "GPU/D3D12","Read data written by memory export in shaders on the CPU").lifecycle(rex::cvar::Lifecycle::kHotReload);-@@ -930,6 +943,8 @@ bool D3D12CommandProcessor::SetupContext() {+@@ -930,6 +966,8 @@ bool D3D12CommandProcessor::SetupContext() {REXGPU_ERROR("Failed to initialize shared memory");return false;}@@ -2032,7 +2111,7 @@ index 19874a5..a75c56d 100644// Initialize the render target cache before configuring binding - need to// know if using rasterizer-ordered views for the bindless root signature.-@@ -1672,6 +1687,11 @@ void D3D12CommandProcessor::ShutdownContext() {+@@ -1672,6 +1710,11 @@ void D3D12CommandProcessor::ShutdownContext() {scratch_buffer_size_ = 0;resolve_downscale_buffer_size_ = 0;resolve_downscale_buffer_.Reset();@@ -2044,7 +2123,7 @@ index 19874a5..a75c56d 100644for (const std::pair<uint64_t, ID3D12Resource*>& resource_for_deletion :resources_for_deletion_) {-@@ -1735,6 +1755,9 @@ void D3D12CommandProcessor::ShutdownContext() {+@@ -1735,6 +1778,9 @@ void D3D12CommandProcessor::ShutdownContext() {render_target_cache_.reset();@@ -2054,7 +2133,7 @@ index 19874a5..a75c56d 100644shared_memory_.reset();deferred_command_list_.Reset();-@@ -2784,6 +2807,11 @@ bool D3D12CommandProcessor::IssueDraw_MemexportReadbackFastPath(uint32_t total_s+@@ -2784,6 +2830,11 @@ bool D3D12CommandProcessor::IssueDraw_MemexportReadbackFastPath(uint32_t total_sMakeMemexportReadbackKey(memexport_ranges_.front().base_address_dwords, total_size);ReadbackBuffer& readback = memexport_readback_buffers_[readback_key];readback.last_used_frame = frame_current_;@@ -2066,7 +2145,7 @@ index 19874a5..a75c56d 100644auto ensure_readback_slot = [&](uint32_t index, uint32_t size) -> bool {if (readback.buffers[index] && readback.mapped_data[index] && size <= readback.sizes[index]) {-@@ -2847,11 +2875,13 @@ bool D3D12CommandProcessor::IssueDraw_MemexportReadbackFastPath(uint32_t total_s+@@ -2847,11 +2898,13 @@ bool D3D12CommandProcessor::IssueDraw_MemexportReadbackFastPath(uint32_t total_s}readback.submission_written[write_index] = submission_current_;readback.written_size[write_index] = total_size;@@ -2080,7 +2159,7 @@ index 19874a5..a75c56d 100644readback.submission_written[read_index] &&readback.submission_written[read_index] <= submission_completed_;if (!previous_slot_ready) {-@@ -2887,6 +2917,54 @@ bool D3D12CommandProcessor::IssueCopy() {+@@ -2887,6 +2940,54 @@ bool D3D12CommandProcessor::IssueCopy() {}bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {@@ -2135,7 +2214,7 @@ index 19874a5..a75c56d 100644uint32_t written_address, written_length;if (!render_target_cache_->Resolve(*memory_, *shared_memory_, *texture_cache_, written_address,written_length)) {-@@ -2897,14 +2975,39 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -2897,14 +2998,39 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {return true;}@@ -2175,7 +2254,7 @@ index 19874a5..a75c56d 100644uint32_t write_index = rb.current_index;uint32_t size = AlignReadbackBufferSize(written_length);-@@ -2922,6 +3025,10 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -2922,6 +3048,10 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {return true;}if (rb.buffers[write_index]) {@@ -2186,7 +2265,26 @@ index 19874a5..a75c56d 100644if (rb.mapped_data[write_index]) {rb.buffers[write_index]->Unmap(0, nullptr);rb.mapped_data[write_index] = nullptr;-@@ -3055,6 +3162,10 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -3042,6 +3172,18 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {+ (constants.scale_x > 1 || constants.scale_y > 1))+ ? 1u+ : 0u;++ // Color render-to-texture copies (player face portraits) are averaged; depth and other formats stay++ // point-sampled, an average of their bits would be meaningless.++ {++ const auto copy_control = register_file_->Get<reg::RB_COPY_CONTROL>();++ const auto dest_format = copy_dest_info.copy_dest_format;++ constants.average = (REXCVAR_GET(readback_resolve_average_color) && pixel_size_log2 == 2 &&++ copy_control.copy_src_select != 4 &&++ (dest_format == xenos::ColorFormat::k_8_8_8_8 ||++ dest_format == xenos::ColorFormat::k_8_8_8_8_A))++ ? 1u++ : 0u;++ }+ deferred_command_list_.D3DSetComputeRoot32BitConstants(+ UINT(ResolveDownscaleRootParameter::kConstants), sizeof(constants) / sizeof(uint32_t),+ &constants, 0);+@@ -3055,6 +3197,10 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {PushTransitionBarrier(resolve_downscale_buffer_.Get(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS,D3D12_RESOURCE_STATE_COPY_SOURCE);SubmitBarriers();@@ -2197,7 +2295,7 @@ index 19874a5..a75c56d 100644deferred_command_list_.D3DCopyBufferRegion(rb.buffers[write_index], 0,resolve_downscale_buffer_.Get(), 0, written_length);PushTransitionBarrier(resolve_downscale_buffer_.Get(), D3D12_RESOURCE_STATE_COPY_SOURCE,-@@ -3065,23 +3176,65 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -3065,23 +3211,88 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {shared_memory_->UseAsCopySource();SubmitBarriers();ID3D12Resource* shared_memory_buffer = shared_memory_->GetBuffer();@@ -2263,12 +2361,35 @@ index 19874a5..a75c56d 100644bool is_cache_miss = false;- if (use_delayed_sync && (!rb.buffers[read_index] || written_length > rb.sizes[read_index] ||- !rb.mapped_data[read_index])) {-+ if (use_delayed_sync && (some_decision.sync || !rb.buffers[read_index] ||-+ written_length > rb.sizes[read_index] || !rb.mapped_data[read_index])) {++ // A forced-synchronous range (e.g. the stadium floor data) normally stalls until the GPU is done, which++ // costs about a third of the frame rate. With a budget: if the GPU finishes within it, read this frame's++ // data; otherwise use last frame's copy (what the delayed path does), so fast GPUs keep current data++ // without a long stall and slow GPUs never wait more than the budget.++ const bool previous_copy_usable = rb.buffers[read_index] && written_length <= rb.sizes[read_index] &&++ rb.mapped_data[read_index] && rb.submission_written[read_index];++ const uint32_t sync_budget_us = REXCVAR_GET(d3d12_readback_sync_budget_us);++ bool budget_decided = false;++ if (use_delayed_sync && some_decision.sync && previous_copy_usable && sync_budget_us) {++ // The normal full wait (ends the submission, reclaims and downloads as usual), limited to the budget.++ const auto budget_start = std::chrono::steady_clock::now();++ g_fence_wait_timeout_ms = std::max<DWORD>(1, DWORD((sync_budget_us + 999) / 1000));++ const bool completed = AwaitAllQueueOperationsCompletion();++ g_fence_wait_timeout_ms = INFINITE;++ if (completed) {++ is_cache_miss = true;++ read_index = write_index;++ }++ NoteReadbackBudget(completed, std::chrono::duration<double, std::micro>(++ std::chrono::steady_clock::now() - budget_start).count());++ budget_decided = true;++ }++ if (!budget_decided && use_delayed_sync &&++ (some_decision.sync || !rb.buffers[read_index] || written_length > rb.sizes[read_index] ||++ !rb.mapped_data[read_index])) {is_cache_miss = true;read_index = write_index;if (!AwaitAllQueueOperationsCompletion()) {-@@ -3089,7 +3242,16 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -3089,7 +3300,16 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {}}@@ -2286,7 +2407,7 @@ index 19874a5..a75c56d 100644if (should_copy && rb.buffers[read_index] && written_length <= rb.sizes[read_index] &&rb.mapped_data[read_index]) {uint8_t* destination = memory_->TranslatePhysical(written_address);-@@ -3097,12 +3259,76 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -3097,12 +3317,76 @@ bool D3D12CommandProcessor::IssueCopy_ReadbackResolvePath() {std::memcpy(destination, static_cast<uint8_t*>(rb.mapped_data[read_index]), written_length);}}@@ -2364,7 +2485,7 @@ index 19874a5..a75c56d 100644if (await_submission >= submission_current_) {if (submission_open_) {EndSubmission(false);-@@ -3114,9 +3340,9 @@ void D3D12CommandProcessor::CheckSubmissionFence(uint64_t await_submission) {+@@ -3114,9 +3398,9 @@ void D3D12CommandProcessor::CheckSubmissionFence(uint64_t await_submission) {if (queue_operations_done_since_submission_signal_) {UINT64 fence_value = ++queue_operations_since_submission_fence_last_;ID3D12CommandQueue* direct_queue = GetD3D12Provider().GetDirectQueue();@@ -2377,7 +2498,7 @@ index 19874a5..a75c56d 100644PROFILE_CMD_BUFFER_STALL();WaitForSingleObject(fence_completion_event_, INFINITE);queue_operations_done_since_submission_signal_ = false;-@@ -3131,8 +3357,22 @@ void D3D12CommandProcessor::CheckSubmissionFence(uint64_t await_submission) {+@@ -3131,19 +3415,50 @@ void D3D12CommandProcessor::CheckSubmissionFence(uint64_t await_submission) {await_submission = submission_current_ - 1;}@@ -2400,8 +2521,14 @@ index 19874a5..a75c56d 100644if (submission_completed_ < await_submission) {if (SUCCEEDED(submission_fence_->SetEventOnCompletion(await_submission, fence_completion_event_))) {-@@ -3144,6 +3384,23 @@ void D3D12CommandProcessor::CheckSubmissionFence(uint64_t await_submission) {- if (submission_completed_ < await_submission) {+ PROFILE_CMD_BUFFER_STALL();+- WaitForSingleObject(fence_completion_event_, INFINITE);++ WaitForSingleObject(fence_completion_event_, g_fence_wait_timeout_ms);+ submission_completed_ = submission_fence_->GetCompletedValue();+ }+ }+- if (submission_completed_ < await_submission) {++ if (submission_completed_ < await_submission && g_fence_wait_timeout_ms == INFINITE) {REXGPU_ERROR("Failed to await a submission completion Direct3D 12 fence");}+ const auto wait_finished = measure_readback ? WaitClock::now() : WaitClock::time_point{};@@ -2424,7 +2551,7 @@ index 19874a5..a75c56d 100644if (submission_completed_ <= submission_completed_before) {// Not updated - no need to reclaim or download things.return;-@@ -3302,6 +3559,12 @@ bool D3D12CommandProcessor::BeginSubmission(bool is_guest_command) {+@@ -3302,6 +3617,12 @@ bool D3D12CommandProcessor::BeginSubmission(bool is_guest_command) {// end of the submission (when async pipeline creation requests are// fulfilled).deferred_command_list_.Reset();@@ -2437,7 +2564,7 @@ index 19874a5..a75c56d 100644// Reset cached state of the command list.ff_viewport_update_needed_ = true;-@@ -4432,7 +4695,7 @@ bool D3D12CommandProcessor::UpdateBindings(const D3D12Shader* vertex_shader,+@@ -4432,7 +4753,7 @@ bool D3D12CommandProcessor::UpdateBindings(const D3D12Shader* vertex_shader,for (size_t i = 0; i < texture_count_pixel; ++i) {const D3D12Shader::TextureBinding& texture = (*textures_pixel)[i];descriptor_indices[texture.bindless_descriptor_index] =@@ -2446,7 +2573,7 @@ index 19874a5..a75c56d 100644uint32_t(SystemBindlessView::kUnboundedSRVsStart);}current_texture_layout_uid_pixel_ = texture_layout_uid_pixel;-@@ -4755,7 +5018,10 @@ void D3D12CommandProcessor::EvictOldReadbackBuffers(+@@ -4755,7 +5076,10 @@ void D3D12CommandProcessor::EvictOldReadbackBuffers(ReadbackBuffer& readback = it->second;bool evict =buffer_map.size() > kMaxReadbackBuffers || readback.last_used_frame < eviction_frame_floor;@@ -3406,6 +3533,1708 @@ index 0000000..fb3ad69+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,+ 0, 0, 0, 0,+};+diff --git a/src/graphics/shaders/bytecode/d3d12_5_1/resolve_downscale_cs.h b/src/graphics/shaders/bytecode/d3d12_5_1/resolve_downscale_cs.h+index da071c5..ed8e52e 100644+--- a/src/graphics/shaders/bytecode/d3d12_5_1/resolve_downscale_cs.h++++ b/src/graphics/shaders/bytecode/d3d12_5_1/resolve_downscale_cs.h+@@ -1,6 +1,31 @@+ #if 0+ //+-// Generated by Microsoft (R) D3D Shader Disassembler++// Generated by Microsoft (R) HLSL Shader Compiler 10.1++//++//++// Buffer Definitions:++//++// cbuffer XeResolveDownscaleConstants++// {++//++// uint xe_downscale_scale_x; // Offset: 0 Size: 4++// uint xe_downscale_scale_y; // Offset: 4 Size: 4++// uint xe_downscale_pixel_size_log2; // Offset: 8 Size: 4++// uint xe_downscale_tile_count; // Offset: 12 Size: 4++// uint xe_downscale_half_pixel_offset;// Offset: 16 Size: 4++// uint xe_downscale_average; // Offset: 20 Size: 4++//++// }++//++//++// Resource Bindings:++//++// Name Type Format Dim ID HLSL Bind Count++// ------------------------------ ---------- ------- ----------- ------- -------------- ------++// xe_resolve_source texture byte r/o T0 t0 1++// xe_resolve_dest UAV byte r/w U0 u0 1++// XeResolveDownscaleConstants cbuffer NA NA CB0 cb0 1++//+ //+ //+ // Input signature:+@@ -15,19 +40,19 @@+ // -------------------- ----- ------ -------- -------- ------- ------+ // no Output+ cs_5_1+-dcl_globalFlags refactoringAllowed | allResourcesBound++dcl_globalFlags refactoringAllowed+ dcl_constantbuffer CB0[0:0][2], immediateIndexed, space=0+ dcl_resource_raw T0[0:0], space=0+ dcl_uav_raw U0[0:0], space=0+ dcl_input vThreadGroupID.x+ dcl_input vThreadIDInGroup.xy+-dcl_temps 2++dcl_temps 4+ dcl_tgsm_structured g0, 4, 1024+ dcl_thread_group 32, 32, 1+ uge r0.x, vThreadGroupID.x, CB0[0][0].w+ if_nz r0.x+- ret+-endif++ ret++endif+ imad r0.x, vThreadIDInGroup.y, l(32), vThreadIDInGroup.x+ ishl r0.yz, l(0, 1, 1024, 0), CB0[0][0].zzzz+ imul null, r0.w, CB0[0][0].y, CB0[0][0].x+@@ -35,193 +60,743 @@ ine r1.y, CB0[0][1].x, l(0)+ ult r1.z, l(1), r0.w+ and r1.y, r1.z, r1.y+ if_nz r1.y+- ushr r1.yz, CB0[0][0].xxyx, l(0, 1, 1, 0)+- imad r1.y, r1.z, CB0[0][0].x, r1.y+-else++ ushr r1.yw, CB0[0][0].xxxy, l(0, 1, 0, 1)++ imad r1.y, r1.w, CB0[0][0].x, r1.y++else+ mov r1.y, l(0)+-endif+-imul null, r1.xz, r0.wwyw, r0.zzxz+-imul null, r0.w, r0.w, r1.z+-imad r0.w, vThreadGroupID.x, r1.x, r0.w+-imad r0.y, r1.y, r0.y, r0.w+-ult r0.w, CB0[0][0].z, l(2)+-if_nz r0.w++endif++imul null, r1.xw, r0.wwwy, r0.zzzx++imul null, r2.x, r0.w, r1.w++imad r1.x, vThreadGroupID.x, r1.x, r2.x++imad r0.y, r1.y, r0.y, r1.x++ult r1.y, CB0[0][0].z, l(2)++if_nz r1.y+ if_z CB0[0][0].z+- and r0.w, r0.y, l(-4)+- ld_raw r0.w, r0.w, T0[0].xxxx+- bfi r1.xw, l(2, 0, 0, 2), l(3, 0, 0, 3), r0.yyyx, l(0, 0, 0, 0)+- ushr r0.w, r0.w, r1.x+- ushr r1.x, r0.x, l(2)+- and r1.z, r0.x, l(3)+- bfi r0.w, l(8), r1.w, r0.w, l(0)+- if_z r1.z+- store_structured g0.x, r1.x, l(0), r0.w+- endif++ and r1.y, r0.y, l(-4)++ ld_raw r1.y, r1.y, T0[0].xxxx++ bfi r1.w, l(2), l(3), r0.y, l(0)++ ushr r1.y, r1.y, r1.w++ ushr r2.x, r0.x, l(2)++ and r1.w, r0.x, l(3)++ bfi r2.z, l(2), l(3), r0.x, l(0)++ bfi r1.y, l(8), r2.z, r1.y, l(0)++ if_z r1.w++ store_structured g0.x, r2.x, l(0), r1.y++ endif+ sync_g_t+- if_nz r1.z+- mov r1.y, l(0)+- atomic_or g0, r1.xyxx, r0.w+- endif++ if_nz r1.w++ mov r2.y, l(0)++ atomic_or g0, r2.xyxx, r1.y++ endif+ sync_g_t+- if_z r1.z+- and r0.w, r0.x, l(1020)+- imad r0.w, vThreadGroupID.x, l(1024), r0.w+- ld_structured r1.x, r1.x, l(0), g0.xxxx+- store_raw U0[0].x, r0.w, r1.x+- endif+- else+- and r0.w, r0.y, l(-4)+- ld_raw r0.w, r0.w, T0[0].xxxx+- ishl r1.x, r0.y, l(3)+- and r1.x, r1.x, l(16)+- ushr r0.w, r0.w, r1.x+- ushr r1.x, r0.x, l(1)+- and r1.z, r0.x, l(1)++ if_z r1.w++ and r1.y, r0.x, l(1020)++ imad r1.y, vThreadGroupID.x, l(1024), r1.y++ ld_structured r1.w, r2.x, l(0), g0.xxxx++ store_raw U0[0].x, r1.y, r1.w++ endif++ else++ and r1.y, r0.y, l(-4)++ ld_raw r1.y, r1.y, T0[0].xxxx++ ishl r1.w, r0.y, l(3)++ and r1.w, r1.w, l(16)++ ushr r1.y, r1.y, r1.w++ ushr r2.x, r0.x, l(1)++ and r1.w, r0.x, l(1)+ bfi r0.x, l(1), l(4), r0.x, l(0)+- bfi r0.x, l(16), r0.x, r0.w, l(0)+- if_z r1.z+- store_structured g0.x, r1.x, l(0), r0.x+- endif++ bfi r0.x, l(16), r0.x, r1.y, l(0)++ if_z r1.w++ store_structured g0.x, r2.x, l(0), r0.x++ endif+ sync_g_t+- if_nz r1.z+- mov r1.y, l(0)+- atomic_or g0, r1.xyxx, r0.x+- endif++ if_nz r1.w++ mov r2.y, l(0)++ atomic_or g0, r2.xyxx, r0.x++ endif+ sync_g_t+- if_z r1.z+- ishl r0.x, r1.x, l(2)++ if_z r1.w++ ishl r0.x, r2.x, l(2)+ imad r0.x, vThreadGroupID.x, l(2048), r0.x+- ld_structured r0.w, r1.x, l(0), g0.xxxx+- store_raw U0[0].x, r0.x, r0.w+- endif+- endif+-else+- imad r0.z, vThreadGroupID.x, r0.z, r1.z++ ld_structured r1.y, r2.x, l(0), g0.xxxx++ store_raw U0[0].x, r0.x, r1.y++ endif++ endif++else++ imad r0.z, vThreadGroupID.x, r0.z, r1.w+ ieq r0.x, CB0[0][0].z, l(2)+ if_nz r0.x+- ld_raw r0.x, r0.y, T0[0].xxxx++ ine r0.x, CB0[0][1].y, l(0)++ and r0.x, r1.z, r0.x++ if_nz r0.x++ mov r2.xyzw, l(0,0,0,0)++ mov r0.x, l(0)++ loop++ uge r1.y, r0.x, r0.w++ breakc_nz r1.y++ ishl r1.y, r0.x, l(2)++ iadd r1.y, r1.y, r1.x++ ld_raw r1.y, r1.y, T0[0].xxxx++ and r3.x, r1.y, l(255)++ ubfe r3.yz, l(0, 8, 8, 0), l(0, 8, 16, 0), r1.yyyy++ ushr r3.w, r1.y, l(24)++ iadd r2.xyzw, r2.xyzw, r3.xyzw++ iadd r0.x, r0.x, l(1)++ endloop++ ushr r0.x, r0.w, l(1)++ iadd r1.xyzw, r0.xxxx, r2.xyzw++ udiv r1.xyzw, null, r1.xyzw, r0.wwww++ ishl r1.yzw, r1.yyzw, l(0, 8, 16, 24)++ or r0.x, r1.y, r1.x++ or r0.x, r1.z, r0.x++ or r0.x, r1.w, r0.x++ else++ ld_raw r0.x, r0.y, T0[0].xxxx++ endif+ store_raw U0[0].x, r0.z, r0.x+- else++ else+ ieq r0.x, CB0[0][0].z, l(3)+ if_nz r0.x+ ld_raw r0.xy, r0.y, T0[0].xyxx+ store_raw U0[0].xy, r0.z, r0.xyxx+- endif+- endif+-endif+-ret+-// Approximately 0 instruction slots used++ endif++ endif++endif++ret++// Approximately 113 instruction slots used+ #endif++-const BYTE resolve_downscale_cs[] = {+- 68, 88, 66, 67, 235, 139, 102, 94, 189, 150, 220, 235, 94, 229, 59, 205, 74, 78, 159, 167,+- 1, 0, 0, 0, 164, 8, 0, 0, 3, 0, 0, 0, 44, 0, 0, 0, 60, 0, 0, 0,+- 76, 0, 0, 0, 73, 83, 71, 78, 8, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0,+- 79, 83, 71, 78, 8, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 83, 72, 69, 88,+- 80, 8, 0, 0, 81, 0, 5, 0, 20, 2, 0, 0, 106, 8, 8, 1, 89, 0, 0, 7,+- 70, 142, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,+- 0, 0, 0, 0, 161, 0, 0, 6, 70, 126, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0,+- 0, 0, 0, 0, 0, 0, 0, 0, 157, 0, 0, 6, 70, 238, 49, 0, 0, 0, 0, 0,+- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, 2, 18, 16, 2, 0,+- 95, 0, 0, 2, 50, 32, 2, 0, 104, 0, 0, 2, 2, 0, 0, 0, 160, 0, 0, 5,+- 0, 240, 17, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 4, 0, 0, 155, 0, 0, 4,+- 32, 0, 0, 0, 32, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 8, 18, 0, 16, 0,+- 0, 0, 0, 0, 10, 16, 2, 0, 58, 128, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0,+- 0, 0, 0, 0, 31, 0, 4, 3, 10, 0, 16, 0, 0, 0, 0, 0, 62, 0, 0, 1,+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, 18, 0, 0, 1, 35, 0, 0, 8,+- 66, 0, 16, 0, 0, 0, 0, 0, 10, 16, 2, 0, 42, 0, 16, 0, 0, 0, 0, 0,+- 42, 0, 16, 0, 1, 0, 0, 0, 32, 0, 0, 9, 18, 0, 16, 0, 0, 0, 0, 0,+- 42, 128, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 64, 0, 0,+- 2, 0, 0, 0, 31, 0, 4, 3, 10, 0, 16, 0, 0, 0, 0, 0, 165, 0, 0, 8,+- 18, 0, 16, 0, 0, 0, 0, 0, 26, 0, 16, 0, 0, 0, 0, 0, 6, 112, 32, 0,+- 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 8, 18, 224, 33, 0, 0, 0, 0, 0,+- 0, 0, 0, 0, 42, 0, 16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 0, 0, 0, 0,+- 18, 0, 0, 1, 32, 0, 0, 9, 18, 0, 16, 0, 0, 0, 0, 0, 42, 128, 48, 0,+- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 64, 0, 0, 3, 0, 0, 0,+- 31, 0, 4, 3, 10, 0, 16, 0, 0, 0, 0, 0, 165, 0, 0, 8, 50, 0, 16, 0,+- 0, 0, 0, 0, 26, 0, 16, 0, 0, 0, 0, 0, 70, 112, 32, 0, 0, 0, 0, 0,+- 0, 0, 0, 0, 166, 0, 0, 8, 50, 224, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0,+- 42, 0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 21, 0, 0, 1,+- 21, 0, 0, 1, 21, 0, 0, 1, 62, 0, 0, 1};++const BYTE resolve_downscale_cs[] =++{++ 68, 88, 66, 67, 132, 194,++ 134, 149, 211, 248, 31, 125,++ 111, 222, 59, 55, 141, 27,++ 121, 240, 1, 0, 0, 0,++ 204, 14, 0, 0, 5, 0,++ 0, 0, 52, 0, 0, 0,++ 32, 3, 0, 0, 48, 3,++ 0, 0, 64, 3, 0, 0,++ 48, 14, 0, 0, 82, 68,++ 69, 70, 228, 2, 0, 0,++ 1, 0, 0, 0, 244, 0,++ 0, 0, 3, 0, 0, 0,++ 60, 0, 0, 0, 1, 5,++ 83, 67, 0, 133, 0, 0,++ 186, 2, 0, 0, 19, 19,++ 68, 37, 60, 0, 0, 0,++ 24, 0, 0, 0, 40, 0,++ 0, 0, 40, 0, 0, 0,++ 36, 0, 0, 0, 12, 0,++ 0, 0, 0, 0, 0, 0,++ 180, 0, 0, 0, 7, 0,++ 0, 0, 6, 0, 0, 0,++ 1, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 1, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 198, 0,++ 0, 0, 8, 0, 0, 0,++ 6, 0, 0, 0, 1, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 1, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 214, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 1, 0, 0, 0,++ 1, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 120, 101, 95, 114, 101, 115,++ 111, 108, 118, 101, 95, 115,++ 111, 117, 114, 99, 101, 0,++ 120, 101, 95, 114, 101, 115,++ 111, 108, 118, 101, 95, 100,++ 101, 115, 116, 0, 88, 101,++ 82, 101, 115, 111, 108, 118,++ 101, 68, 111, 119, 110, 115,++ 99, 97, 108, 101, 67, 111,++ 110, 115, 116, 97, 110, 116,++ 115, 0, 171, 171, 214, 0,++ 0, 0, 6, 0, 0, 0,++ 12, 1, 0, 0, 32, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 252, 1,++ 0, 0, 0, 0, 0, 0,++ 4, 0, 0, 0, 2, 0,++ 0, 0, 24, 2, 0, 0,++ 0, 0, 0, 0, 255, 255,++ 255, 255, 0, 0, 0, 0,++ 255, 255, 255, 255, 0, 0,++ 0, 0, 60, 2, 0, 0,++ 4, 0, 0, 0, 4, 0,++ 0, 0, 2, 0, 0, 0,++ 24, 2, 0, 0, 0, 0,++ 0, 0, 255, 255, 255, 255,++ 0, 0, 0, 0, 255, 255,++ 255, 255, 0, 0, 0, 0,++ 81, 2, 0, 0, 8, 0,++ 0, 0, 4, 0, 0, 0,++ 2, 0, 0, 0, 24, 2,++ 0, 0, 0, 0, 0, 0,++ 255, 255, 255, 255, 0, 0,++ 0, 0, 255, 255, 255, 255,++ 0, 0, 0, 0, 110, 2,++ 0, 0, 12, 0, 0, 0,++ 4, 0, 0, 0, 2, 0,++ 0, 0, 24, 2, 0, 0,++ 0, 0, 0, 0, 255, 255,++ 255, 255, 0, 0, 0, 0,++ 255, 255, 255, 255, 0, 0,++ 0, 0, 134, 2, 0, 0,++ 16, 0, 0, 0, 4, 0,++ 0, 0, 2, 0, 0, 0,++ 24, 2, 0, 0, 0, 0,++ 0, 0, 255, 255, 255, 255,++ 0, 0, 0, 0, 255, 255,++ 255, 255, 0, 0, 0, 0,++ 165, 2, 0, 0, 20, 0,++ 0, 0, 4, 0, 0, 0,++ 2, 0, 0, 0, 24, 2,++ 0, 0, 0, 0, 0, 0,++ 255, 255, 255, 255, 0, 0,++ 0, 0, 255, 255, 255, 255,++ 0, 0, 0, 0, 120, 101,++ 95, 100, 111, 119, 110, 115,++ 99, 97, 108, 101, 95, 115,++ 99, 97, 108, 101, 95, 120,++ 0, 100, 119, 111, 114, 100,++ 0, 171, 0, 0, 19, 0,++ 1, 0, 1, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 17, 2,++ 0, 0, 120, 101, 95, 100,++ 111, 119, 110, 115, 99, 97,++ 108, 101, 95, 115, 99, 97,++ 108, 101, 95, 121, 0, 120,++ 101, 95, 100, 111, 119, 110,++ 115, 99, 97, 108, 101, 95,++ 112, 105, 120, 101, 108, 95,++ 115, 105, 122, 101, 95, 108,++ 111, 103, 50, 0, 120, 101,++ 95, 100, 111, 119, 110, 115,++ 99, 97, 108, 101, 95, 116,++ 105, 108, 101, 95, 99, 111,++ 117, 110, 116, 0, 120, 101,++ 95, 100, 111, 119, 110, 115,++ 99, 97, 108, 101, 95, 104,++ 97, 108, 102, 95, 112, 105,++ 120, 101, 108, 95, 111, 102,++ 102, 115, 101, 116, 0, 120,++ 101, 95, 100, 111, 119, 110,++ 115, 99, 97, 108, 101, 95,++ 97, 118, 101, 114, 97, 103,++ 101, 0, 77, 105, 99, 114,++ 111, 115, 111, 102, 116, 32,++ 40, 82, 41, 32, 72, 76,++ 83, 76, 32, 83, 104, 97,++ 100, 101, 114, 32, 67, 111,++ 109, 112, 105, 108, 101, 114,++ 32, 49, 48, 46, 49, 0,++ 171, 171, 73, 83, 71, 78,++ 8, 0, 0, 0, 0, 0,++ 0, 0, 8, 0, 0, 0,++ 79, 83, 71, 78, 8, 0,++ 0, 0, 0, 0, 0, 0,++ 8, 0, 0, 0, 83, 72,++ 69, 88, 232, 10, 0, 0,++ 81, 0, 5, 0, 186, 2,++ 0, 0, 106, 8, 0, 1,++ 89, 0, 0, 7, 70, 142,++ 48, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 2, 0, 0, 0,++ 0, 0, 0, 0, 161, 0,++ 0, 6, 70, 126, 48, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 157, 0,++ 0, 6, 70, 238, 49, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 95, 0,++ 0, 2, 18, 16, 2, 0,++ 95, 0, 0, 2, 50, 32,++ 2, 0, 104, 0, 0, 2,++ 4, 0, 0, 0, 160, 0,++ 0, 5, 0, 240, 17, 0,++ 0, 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 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 0, 0, 0, 0,++ 0, 0, 4, 0, 0, 0,++ 2, 0, 0, 0, 4, 0,++ 0, 0++};+diff --git a/src/graphics/shaders/resolve_downscale.cs.glsl b/src/graphics/shaders/resolve_downscale.cs.glsl+index a3c8c12..f52ea66 100644+--- a/src/graphics/shaders/resolve_downscale.cs.glsl++++ b/src/graphics/shaders/resolve_downscale.cs.glsl+@@ -32,6 +32,8 @@ layout(push_constant) uniform ResolveDownscaleConstants {+ // games, which at Nx resolution scaling shifts rendered content by+ // (N/2, N/2) host pixels.+ uint xe_downscale_half_pixel_offset;++ // Non-zero (32-bit 8:8:8:8 color only): per-channel average of the scaled block (see the HLSL version).++ uint xe_downscale_average;+ };++ // Source buffer (scaled resolve data)+@@ -146,8 +148,20 @@ void main() {+ }+ break;+ }+- case 2u: { // 32-bit - direct copy+- xe_resolve_dest.data[dst_offset] = xe_resolve_source.data[src_offset];++ case 2u: { // 32-bit - direct copy, or the per-channel block average for 8:8:8:8 color++ if (xe_downscale_average != 0u && scale_xy > 1u) {++ uint block_base = (xe_downscale_source_offset_bytes + tile_index * tile_size_scaled +++ pixel_index * pixel_size * scale_xy) >> 2u;++ uvec4 sum = uvec4(0u);++ for (uint s = 0u; s < scale_xy; ++s) {++ uint texel = xe_resolve_source.data[block_base + s];++ sum += uvec4(texel & 0xFFu, (texel >> 8u) & 0xFFu, (texel >> 16u) & 0xFFu, texel >> 24u);++ }++ sum = (sum + uvec4(scale_xy >> 1u)) / uvec4(scale_xy);++ xe_resolve_dest.data[dst_offset] = sum.x | (sum.y << 8u) | (sum.z << 16u) | (sum.w << 24u);++ } else {++ xe_resolve_dest.data[dst_offset] = xe_resolve_source.data[src_offset];++ }+ break;+ }+ case 3u: { // 64-bit - direct copy (2 uints)+diff --git a/src/graphics/shaders/resolve_downscale.cs.hlsl b/src/graphics/shaders/resolve_downscale.cs.hlsl+index 91c2f95..5b07640 100644+--- a/src/graphics/shaders/resolve_downscale.cs.hlsl++++ b/src/graphics/shaders/resolve_downscale.cs.hlsl+@@ -27,6 +27,10 @@ cbuffer XeResolveDownscaleConstants : register(b0) {+ // games, which at Nx resolution scaling shifts rendered content by+ // (N/2, N/2) host pixels.+ uint xe_downscale_half_pixel_offset;++ // When non-zero (32-bit 8:8:8:8 color only), average the whole scaled block per byte channel instead of++ // picking one sample: point picking left render-to-texture images (player face portraits) aliased and++ // pixelated after the copy back to guest memory.++ uint xe_downscale_average;+ };++ ByteAddressBuffer xe_resolve_source : register(t0);+@@ -135,8 +139,19 @@ void main(uint3 xe_group_id : SV_GroupID,+ }+ break;+ }+- case 2: { // 32-bit - direct copy+- xe_resolve_dest.Store(dst_offset, xe_resolve_source.Load(src_offset));++ case 2: { // 32-bit - direct copy, or the per-channel block average for 8:8:8:8 color++ [branch] if (xe_downscale_average != 0u && scale_xy > 1u) {++ uint block_base = tile_index * tile_size_scaled + pixel_index * pixel_size * scale_xy;++ uint4 sum = uint4(0u, 0u, 0u, 0u);++ for (uint s = 0u; s < scale_xy; ++s) {++ uint texel = xe_resolve_source.Load(block_base + s * 4u);++ sum += uint4(texel & 0xFFu, (texel >> 8u) & 0xFFu, (texel >> 16u) & 0xFFu, texel >> 24u);++ }++ sum = (sum + (scale_xy >> 1u)) / scale_xy;++ xe_resolve_dest.Store(dst_offset, sum.x | (sum.y << 8u) | (sum.z << 16u) | (sum.w << 24u));++ } else {++ xe_resolve_dest.Store(dst_offset, xe_resolve_source.Load(src_offset));++ }+ break;+ }+ case 3: { // 64-bit - direct copy+diff --git a/src/graphics/shaders/vulkan_spirv/resolve_downscale_cs.h b/src/graphics/shaders/vulkan_spirv/resolve_downscale_cs.h+index fd9d6a7..0d87d0d 100644+--- a/src/graphics/shaders/vulkan_spirv/resolve_downscale_cs.h++++ b/src/graphics/shaders/vulkan_spirv/resolve_downscale_cs.h+@@ -1,376 +1,272 @@+-// Generated with `xb buildshaders`.+-#if 0+-; SPIR-V+-; Version: 1.0+-; Generator: Khronos Glslang Reference Front End; 11+-; Bound: 25190+-; Schema: 0+- OpCapability Shader+- %1 = OpExtInstImport "GLSL.std.450"+- OpMemoryModel Logical GLSL450+- OpEntryPoint GLCompute %5663 "main" %gl_WorkGroupID %gl_LocalInvocationID+- OpExecutionMode %5663 LocalSize 32 32 1+- OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId+- OpDecorate %_struct_1056 Block+- OpMemberDecorate %_struct_1056 0 Offset 0+- OpMemberDecorate %_struct_1056 1 Offset 4+- OpMemberDecorate %_struct_1056 2 Offset 8+- OpMemberDecorate %_struct_1056 3 Offset 12+- OpMemberDecorate %_struct_1056 4 Offset 16+- OpMemberDecorate %_struct_1056 5 Offset 20+- OpDecorate %gl_LocalInvocationID BuiltIn LocalInvocationId+- OpDecorate %_runtimearr_uint ArrayStride 4+- OpDecorate %_struct_1948 BufferBlock+- OpMemberDecorate %_struct_1948 0 NonWritable+- OpMemberDecorate %_struct_1948 0 Offset 0+- OpDecorate %3152 NonWritable+- OpDecorate %3152 Binding 0+- OpDecorate %3152 DescriptorSet 0+- OpDecorate %_runtimearr_uint_0 ArrayStride 4+- OpDecorate %_struct_1949 BufferBlock+- OpMemberDecorate %_struct_1949 0 NonReadable+- OpMemberDecorate %_struct_1949 0 Offset 0+- OpDecorate %5522 NonReadable+- OpDecorate %5522 Binding 1+- OpDecorate %5522 DescriptorSet 0+- OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize+- %void = OpTypeVoid+- %1282 = OpTypeFunction %void+- %uint = OpTypeInt 32 0+- %v3uint = OpTypeVector %uint 3+-%_ptr_Input_v3uint = OpTypePointer Input %v3uint+-%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input+- %uint_0 = OpConstant %uint 0+-%_ptr_Input_uint = OpTypePointer Input %uint+-%_struct_1056 = OpTypeStruct %uint %uint %uint %uint %uint %uint+-%_ptr_PushConstant__struct_1056 = OpTypePointer PushConstant %_struct_1056+- %4930 = OpVariable %_ptr_PushConstant__struct_1056 PushConstant+- %int = OpTypeInt 32 1+- %int_3 = OpConstant %int 3+-%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint+- %bool = OpTypeBool+-%gl_LocalInvocationID = OpVariable %_ptr_Input_v3uint Input+- %uint_1 = OpConstant %uint 1+- %uint_32 = OpConstant %uint 32+- %int_2 = OpConstant %int 2+- %uint_1024 = OpConstant %uint 1024+- %int_0 = OpConstant %int 0+- %int_1 = OpConstant %int 1+- %int_5 = OpConstant %int 5+- %int_4 = OpConstant %int 4+- %uint_2 = OpConstant %uint 2+-%_runtimearr_uint = OpTypeRuntimeArray %uint+-%_struct_1948 = OpTypeStruct %_runtimearr_uint+-%_ptr_Uniform__struct_1948 = OpTypePointer Uniform %_struct_1948+- %3152 = OpVariable %_ptr_Uniform__struct_1948 Uniform+-%_ptr_Uniform_uint = OpTypePointer Uniform %uint+- %uint_3 = OpConstant %uint 3+- %uint_8 = OpConstant %uint 8+- %uint_255 = OpConstant %uint 255+-%_arr_uint_uint_1024 = OpTypeArray %uint %uint_1024+-%_ptr_Workgroup__arr_uint_uint_1024 = OpTypePointer Workgroup %_arr_uint_uint_1024+- %4017 = OpVariable %_ptr_Workgroup__arr_uint_uint_1024 Workgroup+-%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint+- %uint_264 = OpConstant %uint 264+-%_runtimearr_uint_0 = OpTypeRuntimeArray %uint+-%_struct_1949 = OpTypeStruct %_runtimearr_uint_0+-%_ptr_Uniform__struct_1949 = OpTypePointer Uniform %_struct_1949+- %5522 = OpVariable %_ptr_Uniform__struct_1949 Uniform+- %uint_256 = OpConstant %uint 256+- %uint_65535 = OpConstant %uint 65535+- %uint_16 = OpConstant %uint 16+- %uint_512 = OpConstant %uint 512+-%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_32 %uint_1+- %5663 = OpFunction %void None %1282+- %15110 = OpLabel+- OpSelectionMerge %14903 None+- OpSwitch %uint_0 %11880+- %11880 = OpLabel+- %22245 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0+- %15627 = OpLoad %uint %22245+- %22225 = OpAccessChain %_ptr_PushConstant_uint %4930 %int_3+- %7085 = OpLoad %uint %22225+- %7405 = OpUGreaterThanEqual %bool %15627 %7085+- OpSelectionMerge %16413 None+- OpBranchConditional %7405 %21992 %16413+- %21992 = OpLabel+- OpBranch %14903+- %16413 = OpLabel+- %20632 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_1+- %15628 = OpLoad %uint %20632+- %21427 = OpAccessChain %_ptr_Input_uint %gl_LocalInvocationID %uint_0+- %12090 = OpLoad %uint %21427+- %6234 = OpIMul %uint %15628 %uint_32+- %8353 = OpIAdd %uint %6234 %12090+- %16525 = OpAccessChain %_ptr_PushConstant_uint %4930 %int_2+- %13159 = OpLoad %uint %16525+- %15178 = OpShiftLeftLogical %uint %uint_1 %13159+- %21815 = OpIMul %uint %uint_1024 %15178+- %13000 = OpAccessChain %_ptr_PushConstant_uint %4930 %int_0+- %18628 = OpLoad %uint %13000+- %21428 = OpAccessChain %_ptr_PushConstant_uint %4930 %int_1+- %12166 = OpLoad %uint %21428+- %24613 = OpIMul %uint %18628 %12166+- %13723 = OpIMul %uint %21815 %24613+- %8597 = OpAccessChain %_ptr_PushConstant_uint %4930 %int_5+- %21470 = OpLoad %uint %8597+- %24311 = OpINotEqual %bool %21470 %uint_0+- %23629 = OpUGreaterThan %bool %24613 %uint_1+- %11037 = OpLogicalAnd %bool %24311 %23629+- OpSelectionMerge %23266 None+- OpBranchConditional %11037 %11410 %23266+- %11410 = OpLabel+- %20167 = OpShiftRightLogical %uint %18628 %uint_1+- %24779 = OpShiftRightLogical %uint %12166 %uint_1+- %16010 = OpIMul %uint %24779 %18628+- %19240 = OpIAdd %uint %20167 %16010+- OpBranch %23266+- %23266 = OpLabel+- %19748 = OpPhi %uint %uint_0 %16413 %19240 %11410+- %25074 = OpAccessChain %_ptr_PushConstant_uint %4930 %int_4+- %25189 = OpLoad %uint %25074+- %7507 = OpIMul %uint %15627 %13723+- %17182 = OpIAdd %uint %25189 %7507+- %19692 = OpIMul %uint %8353 %15178+- %16238 = OpIMul %uint %19692 %24613+- %6869 = OpIAdd %uint %17182 %16238+- %21638 = OpIMul %uint %19748 %15178+- %18521 = OpIAdd %uint %6869 %21638+- %7572 = OpShiftRightLogical %uint %18521 %uint_2+- %6935 = OpIMul %uint %15627 %21815+- %9665 = OpIAdd %uint %6935 %19692+- %9085 = OpShiftRightLogical %uint %9665 %uint_2+- OpSelectionMerge %18023 None+- OpSwitch %13159 %18023 0 %11881 1 %16414 2 %16415 3 %8158+- %11881 = OpLabel+- %24791 = OpAccessChain %_ptr_Uniform_uint %3152 %int_0 %7572+- %12865 = OpLoad %uint %24791+- %12121 = OpBitwiseAnd %uint %18521 %uint_3+- %13987 = OpIMul %uint %12121 %uint_8+- %14461 = OpShiftRightLogical %uint %12865 %13987+- %15580 = OpBitwiseAnd %uint %14461 %uint_255+- %19824 = OpShiftRightLogical %uint %8353 %uint_2+- %19243 = OpBitwiseAnd %uint %8353 %uint_3+- %14114 = OpIMul %uint %19243 %uint_8+- %23170 = OpShiftLeftLogical %uint %15580 %14114+- %15629 = OpIEqual %bool %19243 %uint_0+- OpSelectionMerge %20883 None+- OpBranchConditional %15629 %12148 %20883+- %12148 = OpLabel+- %21533 = OpAccessChain %_ptr_Workgroup_uint %4017 %19824+- OpStore %21533 %23170+- OpBranch %20883+- %20883 = OpLabel+- OpControlBarrier %uint_2 %uint_2 %uint_264+- %15932 = OpINotEqual %bool %19243 %uint_0+- OpSelectionMerge %9094 None+- OpBranchConditional %15932 %15549 %9094+- %15549 = OpLabel+- %9637 = OpAccessChain %_ptr_Workgroup_uint %4017 %19824+- %6303 = OpAtomicOr %uint %9637 %uint_1 %uint_0 %23170+- OpBranch %9094+- %9094 = OpLabel+- OpControlBarrier %uint_2 %uint_2 %uint_264+- OpSelectionMerge %18021 None+- OpBranchConditional %15629 %20882 %18021+- %20882 = OpLabel+- %10747 = OpIMul %uint %15627 %uint_256+- %14186 = OpIAdd %uint %10747 %19824+- %14036 = OpAccessChain %_ptr_Workgroup_uint %4017 %19824+- %15421 = OpLoad %uint %14036+- %23477 = OpAccessChain %_ptr_Uniform_uint %5522 %int_0 %14186+- OpStore %23477 %15421+- OpBranch %18021+- %18021 = OpLabel+- OpBranch %18023+- %16414 = OpLabel+- %23178 = OpAccessChain %_ptr_Uniform_uint %3152 %int_0 %7572+- %12866 = OpLoad %uint %23178+- %12122 = OpBitwiseAnd %uint %18521 %uint_2+- %13988 = OpIMul %uint %12122 %uint_8+- %14462 = OpShiftRightLogical %uint %12866 %13988+- %15581 = OpBitwiseAnd %uint %14462 %uint_65535+- %19825 = OpShiftRightLogical %uint %8353 %uint_1+- %19244 = OpBitwiseAnd %uint %8353 %uint_1+- %14115 = OpIMul %uint %19244 %uint_16+- %23171 = OpShiftLeftLogical %uint %15581 %14115+- %15630 = OpIEqual %bool %19244 %uint_0+- OpSelectionMerge %20884 None+- OpBranchConditional %15630 %12149 %20884+- %12149 = OpLabel+- %21534 = OpAccessChain %_ptr_Workgroup_uint %4017 %19825+- OpStore %21534 %23171+- OpBranch %20884+- %20884 = OpLabel+- OpControlBarrier %uint_2 %uint_2 %uint_264+- %15933 = OpINotEqual %bool %19244 %uint_0+- OpSelectionMerge %9095 None+- OpBranchConditional %15933 %15550 %9095+- %15550 = OpLabel+- %9638 = OpAccessChain %_ptr_Workgroup_uint %4017 %19825+- %6304 = OpAtomicOr %uint %9638 %uint_1 %uint_0 %23171+- OpBranch %9095+- %9095 = OpLabel+- OpControlBarrier %uint_2 %uint_2 %uint_264+- OpSelectionMerge %18022 None+- OpBranchConditional %15630 %20885 %18022+- %20885 = OpLabel+- %10748 = OpIMul %uint %15627 %uint_512+- %14187 = OpIAdd %uint %10748 %19825+- %14037 = OpAccessChain %_ptr_Workgroup_uint %4017 %19825+- %15422 = OpLoad %uint %14037+- %23478 = OpAccessChain %_ptr_Uniform_uint %5522 %int_0 %14187+- OpStore %23478 %15422+- OpBranch %18022+- %18022 = OpLabel+- OpBranch %18023+- %16415 = OpLabel+- %20633 = OpAccessChain %_ptr_Uniform_uint %3152 %int_0 %7572+- %15646 = OpLoad %uint %20633+- %23479 = OpAccessChain %_ptr_Uniform_uint %5522 %int_0 %9085+- OpStore %23479 %15646+- OpBranch %18023+- %8158 = OpLabel+- %20634 = OpAccessChain %_ptr_Uniform_uint %3152 %int_0 %7572+- %15647 = OpLoad %uint %20634+- %21178 = OpAccessChain %_ptr_Uniform_uint %5522 %int_0 %9085+- OpStore %21178 %15647+- %19686 = OpIAdd %uint %9085 %uint_1+- %13384 = OpIAdd %uint %7572 %uint_1+- %10810 = OpAccessChain %_ptr_Uniform_uint %3152 %int_0 %13384+- %15423 = OpLoad %uint %10810+- %23480 = OpAccessChain %_ptr_Uniform_uint %5522 %int_0 %19686+- OpStore %23480 %15423+- OpBranch %18023+- %18023 = OpLabel+- OpBranch %14903+- %14903 = OpLabel+- OpReturn+- OpFunctionEnd+-#endif+-++// Generated with glslangValidator -S comp -V --target-env vulkan1.0 from resolve_downscale.cs.glsl (ReStreet 1.3).+ const uint32_t resolve_downscale_cs[] = {+- 0x07230203, 0x00010000, 0x0008000B, 0x00006266, 0x00000000, 0x00020011, 0x00000001, 0x0006000B,+- 0x00000001, 0x4C534C47, 0x6474732E, 0x3035342E, 0x00000000, 0x0003000E, 0x00000000, 0x00000001,+- 0x0007000F, 0x00000005, 0x0000161F, 0x6E69616D, 0x00000000, 0x00000BEF, 0x00000DA3, 0x00060010,+- 0x0000161F, 0x00000011, 0x00000020, 0x00000020, 0x00000001, 0x00040047, 0x00000BEF, 0x0000000B,+- 0x0000001A, 0x00030047, 0x00000420, 0x00000002, 0x00050048, 0x00000420, 0x00000000, 0x00000023,+- 0x00000000, 0x00050048, 0x00000420, 0x00000001, 0x00000023, 0x00000004, 0x00050048, 0x00000420,+- 0x00000002, 0x00000023, 0x00000008, 0x00050048, 0x00000420, 0x00000003, 0x00000023, 0x0000000C,+- 0x00050048, 0x00000420, 0x00000004, 0x00000023, 0x00000010, 0x00050048, 0x00000420, 0x00000005,+- 0x00000023, 0x00000014, 0x00040047, 0x00000DA3, 0x0000000B, 0x0000001B, 0x00040047, 0x000007D0,+- 0x00000006, 0x00000004, 0x00030047, 0x0000079C, 0x00000003, 0x00040048, 0x0000079C, 0x00000000,+- 0x00000018, 0x00050048, 0x0000079C, 0x00000000, 0x00000023, 0x00000000, 0x00030047, 0x00000C50,+- 0x00000018, 0x00040047, 0x00000C50, 0x00000021, 0x00000000, 0x00040047, 0x00000C50, 0x00000022,+- 0x00000000, 0x00040047, 0x000007D1, 0x00000006, 0x00000004, 0x00030047, 0x0000079D, 0x00000003,+- 0x00040048, 0x0000079D, 0x00000000, 0x00000019, 0x00050048, 0x0000079D, 0x00000000, 0x00000023,+- 0x00000000, 0x00030047, 0x00001592, 0x00000019, 0x00040047, 0x00001592, 0x00000021, 0x00000001,+- 0x00040047, 0x00001592, 0x00000022, 0x00000000, 0x00040047, 0x000000FC, 0x0000000B, 0x00000019,+- 0x00020013, 0x00000008, 0x00030021, 0x00000502, 0x00000008, 0x00040015, 0x0000000B, 0x00000020,+- 0x00000000, 0x00040017, 0x00000014, 0x0000000B, 0x00000003, 0x00040020, 0x00000291, 0x00000001,+- 0x00000014, 0x0004003B, 0x00000291, 0x00000BEF, 0x00000001, 0x0004002B, 0x0000000B, 0x00000A0A,+- 0x00000000, 0x00040020, 0x00000288, 0x00000001, 0x0000000B, 0x0008001E, 0x00000420, 0x0000000B,+- 0x0000000B, 0x0000000B, 0x0000000B, 0x0000000B, 0x0000000B, 0x00040020, 0x0000069D, 0x00000009,+- 0x00000420, 0x0004003B, 0x0000069D, 0x00001342, 0x00000009, 0x00040015, 0x0000000C, 0x00000020,+- 0x00000001, 0x0004002B, 0x0000000C, 0x00000A14, 0x00000003, 0x00040020, 0x00000289, 0x00000009,+- 0x0000000B, 0x00020014, 0x00000009, 0x0004003B, 0x00000291, 0x00000DA3, 0x00000001, 0x0004002B,+- 0x0000000B, 0x00000A0D, 0x00000001, 0x0004002B, 0x0000000B, 0x00000A6A, 0x00000020, 0x0004002B,+- 0x0000000C, 0x00000A11, 0x00000002, 0x0004002B, 0x0000000B, 0x00000A47, 0x00000400, 0x0004002B,+- 0x0000000C, 0x00000A0B, 0x00000000, 0x0004002B, 0x0000000C, 0x00000A0E, 0x00000001, 0x0004002B,+- 0x0000000C, 0x00000A1A, 0x00000005, 0x0004002B, 0x0000000C, 0x00000A17, 0x00000004, 0x0004002B,+- 0x0000000B, 0x00000A10, 0x00000002, 0x0003001D, 0x000007D0, 0x0000000B, 0x0003001E, 0x0000079C,+- 0x000007D0, 0x00040020, 0x00000A19, 0x00000002, 0x0000079C, 0x0004003B, 0x00000A19, 0x00000C50,+- 0x00000002, 0x00040020, 0x0000028A, 0x00000002, 0x0000000B, 0x0004002B, 0x0000000B, 0x00000A13,+- 0x00000003, 0x0004002B, 0x0000000B, 0x00000A22, 0x00000008, 0x0004002B, 0x0000000B, 0x00000144,+- 0x000000FF, 0x0004001C, 0x00000293, 0x0000000B, 0x00000A47, 0x00040020, 0x00000510, 0x00000004,+- 0x00000293, 0x0004003B, 0x00000510, 0x00000FB1, 0x00000004, 0x00040020, 0x0000028B, 0x00000004,+- 0x0000000B, 0x0004002B, 0x0000000B, 0x0000015F, 0x00000108, 0x0003001D, 0x000007D1, 0x0000000B,+- 0x0003001E, 0x0000079D, 0x000007D1, 0x00040020, 0x00000A1B, 0x00000002, 0x0000079D, 0x0004003B,+- 0x00000A1B, 0x00001592, 0x00000002, 0x0004002B, 0x0000000B, 0x00000147, 0x00000100, 0x0004002B,+- 0x0000000B, 0x000001C1, 0x0000FFFF, 0x0004002B, 0x0000000B, 0x00000A3A, 0x00000010, 0x0004002B,+- 0x0000000B, 0x00000447, 0x00000200, 0x0006002C, 0x00000014, 0x000000FC, 0x00000A6A, 0x00000A6A,+- 0x00000A0D, 0x00050036, 0x00000008, 0x0000161F, 0x00000000, 0x00000502, 0x000200F8, 0x00003B06,+- 0x000300F7, 0x00003A37, 0x00000000, 0x000300FB, 0x00000A0A, 0x00002E68, 0x000200F8, 0x00002E68,+- 0x00050041, 0x00000288, 0x000056E5, 0x00000BEF, 0x00000A0A, 0x0004003D, 0x0000000B, 0x00003D0B,+- 0x000056E5, 0x00050041, 0x00000289, 0x000056D1, 0x00001342, 0x00000A14, 0x0004003D, 0x0000000B,+- 0x00001BAD, 0x000056D1, 0x000500AE, 0x00000009, 0x00001CED, 0x00003D0B, 0x00001BAD, 0x000300F7,+- 0x0000401D, 0x00000000, 0x000400FA, 0x00001CED, 0x000055E8, 0x0000401D, 0x000200F8, 0x000055E8,+- 0x000200F9, 0x00003A37, 0x000200F8, 0x0000401D, 0x00050041, 0x00000288, 0x00005098, 0x00000DA3,+- 0x00000A0D, 0x0004003D, 0x0000000B, 0x00003D0C, 0x00005098, 0x00050041, 0x00000288, 0x000053B3,+- 0x00000DA3, 0x00000A0A, 0x0004003D, 0x0000000B, 0x00002F3A, 0x000053B3, 0x00050084, 0x0000000B,+- 0x0000185A, 0x00003D0C, 0x00000A6A, 0x00050080, 0x0000000B, 0x000020A1, 0x0000185A, 0x00002F3A,+- 0x00050041, 0x00000289, 0x0000408D, 0x00001342, 0x00000A11, 0x0004003D, 0x0000000B, 0x00003367,+- 0x0000408D, 0x000500C4, 0x0000000B, 0x00003B4A, 0x00000A0D, 0x00003367, 0x00050084, 0x0000000B,+- 0x00005537, 0x00000A47, 0x00003B4A, 0x00050041, 0x00000289, 0x000032C8, 0x00001342, 0x00000A0B,+- 0x0004003D, 0x0000000B, 0x000048C4, 0x000032C8, 0x00050041, 0x00000289, 0x000053B4, 0x00001342,+- 0x00000A0E, 0x0004003D, 0x0000000B, 0x00002F86, 0x000053B4, 0x00050084, 0x0000000B, 0x00006025,+- 0x000048C4, 0x00002F86, 0x00050084, 0x0000000B, 0x0000359B, 0x00005537, 0x00006025, 0x00050041,+- 0x00000289, 0x00002195, 0x00001342, 0x00000A1A, 0x0004003D, 0x0000000B, 0x000053DE, 0x00002195,+- 0x000500AB, 0x00000009, 0x00005EF7, 0x000053DE, 0x00000A0A, 0x000500AC, 0x00000009, 0x00005C4D,+- 0x00006025, 0x00000A0D, 0x000500A7, 0x00000009, 0x00002B1D, 0x00005EF7, 0x00005C4D, 0x000300F7,+- 0x00005AE2, 0x00000000, 0x000400FA, 0x00002B1D, 0x00002C92, 0x00005AE2, 0x000200F8, 0x00002C92,+- 0x000500C2, 0x0000000B, 0x00004EC7, 0x000048C4, 0x00000A0D, 0x000500C2, 0x0000000B, 0x000060CB,+- 0x00002F86, 0x00000A0D, 0x00050084, 0x0000000B, 0x00003E8A, 0x000060CB, 0x000048C4, 0x00050080,+- 0x0000000B, 0x00004B28, 0x00004EC7, 0x00003E8A, 0x000200F9, 0x00005AE2, 0x000200F8, 0x00005AE2,+- 0x000700F5, 0x0000000B, 0x00004D24, 0x00000A0A, 0x0000401D, 0x00004B28, 0x00002C92, 0x00050041,+- 0x00000289, 0x000061F2, 0x00001342, 0x00000A17, 0x0004003D, 0x0000000B, 0x00006265, 0x000061F2,+- 0x00050084, 0x0000000B, 0x00001D53, 0x00003D0B, 0x0000359B, 0x00050080, 0x0000000B, 0x0000431E,+- 0x00006265, 0x00001D53, 0x00050084, 0x0000000B, 0x00004CEC, 0x000020A1, 0x00003B4A, 0x00050084,+- 0x0000000B, 0x00003F6E, 0x00004CEC, 0x00006025, 0x00050080, 0x0000000B, 0x00001AD5, 0x0000431E,+- 0x00003F6E, 0x00050084, 0x0000000B, 0x00005486, 0x00004D24, 0x00003B4A, 0x00050080, 0x0000000B,+- 0x00004859, 0x00001AD5, 0x00005486, 0x000500C2, 0x0000000B, 0x00001D94, 0x00004859, 0x00000A10,+- 0x00050084, 0x0000000B, 0x00001B17, 0x00003D0B, 0x00005537, 0x00050080, 0x0000000B, 0x000025C1,+- 0x00001B17, 0x00004CEC, 0x000500C2, 0x0000000B, 0x0000237D, 0x000025C1, 0x00000A10, 0x000300F7,+- 0x00004667, 0x00000000, 0x000B00FB, 0x00003367, 0x00004667, 0x00000000, 0x00002E69, 0x00000001,+- 0x0000401E, 0x00000002, 0x0000401F, 0x00000003, 0x00001FDE, 0x000200F8, 0x00002E69, 0x00060041,+- 0x0000028A, 0x000060D7, 0x00000C50, 0x00000A0B, 0x00001D94, 0x0004003D, 0x0000000B, 0x00003241,+- 0x000060D7, 0x000500C7, 0x0000000B, 0x00002F59, 0x00004859, 0x00000A13, 0x00050084, 0x0000000B,+- 0x000036A3, 0x00002F59, 0x00000A22, 0x000500C2, 0x0000000B, 0x0000387D, 0x00003241, 0x000036A3,+- 0x000500C7, 0x0000000B, 0x00003CDC, 0x0000387D, 0x00000144, 0x000500C2, 0x0000000B, 0x00004D70,+- 0x000020A1, 0x00000A10, 0x000500C7, 0x0000000B, 0x00004B2B, 0x000020A1, 0x00000A13, 0x00050084,+- 0x0000000B, 0x00003722, 0x00004B2B, 0x00000A22, 0x000500C4, 0x0000000B, 0x00005A82, 0x00003CDC,+- 0x00003722, 0x000500AA, 0x00000009, 0x00003D0D, 0x00004B2B, 0x00000A0A, 0x000300F7, 0x00005193,+- 0x00000000, 0x000400FA, 0x00003D0D, 0x00002F74, 0x00005193, 0x000200F8, 0x00002F74, 0x00050041,+- 0x0000028B, 0x0000541D, 0x00000FB1, 0x00004D70, 0x0003003E, 0x0000541D, 0x00005A82, 0x000200F9,+- 0x00005193, 0x000200F8, 0x00005193, 0x000400E0, 0x00000A10, 0x00000A10, 0x0000015F, 0x000500AB,+- 0x00000009, 0x00003E3C, 0x00004B2B, 0x00000A0A, 0x000300F7, 0x00002386, 0x00000000, 0x000400FA,+- 0x00003E3C, 0x00003CBD, 0x00002386, 0x000200F8, 0x00003CBD, 0x00050041, 0x0000028B, 0x000025A5,+- 0x00000FB1, 0x00004D70, 0x000700F1, 0x0000000B, 0x0000189F, 0x000025A5, 0x00000A0D, 0x00000A0A,+- 0x00005A82, 0x000200F9, 0x00002386, 0x000200F8, 0x00002386, 0x000400E0, 0x00000A10, 0x00000A10,+- 0x0000015F, 0x000300F7, 0x00004665, 0x00000000, 0x000400FA, 0x00003D0D, 0x00005192, 0x00004665,+- 0x000200F8, 0x00005192, 0x00050084, 0x0000000B, 0x000029FB, 0x00003D0B, 0x00000147, 0x00050080,+- 0x0000000B, 0x0000376A, 0x000029FB, 0x00004D70, 0x00050041, 0x0000028B, 0x000036D4, 0x00000FB1,+- 0x00004D70, 0x0004003D, 0x0000000B, 0x00003C3D, 0x000036D4, 0x00060041, 0x0000028A, 0x00005BB5,+- 0x00001592, 0x00000A0B, 0x0000376A, 0x0003003E, 0x00005BB5, 0x00003C3D, 0x000200F9, 0x00004665,+- 0x000200F8, 0x00004665, 0x000200F9, 0x00004667, 0x000200F8, 0x0000401E, 0x00060041, 0x0000028A,+- 0x00005A8A, 0x00000C50, 0x00000A0B, 0x00001D94, 0x0004003D, 0x0000000B, 0x00003242, 0x00005A8A,+- 0x000500C7, 0x0000000B, 0x00002F5A, 0x00004859, 0x00000A10, 0x00050084, 0x0000000B, 0x000036A4,+- 0x00002F5A, 0x00000A22, 0x000500C2, 0x0000000B, 0x0000387E, 0x00003242, 0x000036A4, 0x000500C7,+- 0x0000000B, 0x00003CDD, 0x0000387E, 0x000001C1, 0x000500C2, 0x0000000B, 0x00004D71, 0x000020A1,+- 0x00000A0D, 0x000500C7, 0x0000000B, 0x00004B2C, 0x000020A1, 0x00000A0D, 0x00050084, 0x0000000B,+- 0x00003723, 0x00004B2C, 0x00000A3A, 0x000500C4, 0x0000000B, 0x00005A83, 0x00003CDD, 0x00003723,+- 0x000500AA, 0x00000009, 0x00003D0E, 0x00004B2C, 0x00000A0A, 0x000300F7, 0x00005194, 0x00000000,+- 0x000400FA, 0x00003D0E, 0x00002F75, 0x00005194, 0x000200F8, 0x00002F75, 0x00050041, 0x0000028B,+- 0x0000541E, 0x00000FB1, 0x00004D71, 0x0003003E, 0x0000541E, 0x00005A83, 0x000200F9, 0x00005194,+- 0x000200F8, 0x00005194, 0x000400E0, 0x00000A10, 0x00000A10, 0x0000015F, 0x000500AB, 0x00000009,+- 0x00003E3D, 0x00004B2C, 0x00000A0A, 0x000300F7, 0x00002387, 0x00000000, 0x000400FA, 0x00003E3D,+- 0x00003CBE, 0x00002387, 0x000200F8, 0x00003CBE, 0x00050041, 0x0000028B, 0x000025A6, 0x00000FB1,+- 0x00004D71, 0x000700F1, 0x0000000B, 0x000018A0, 0x000025A6, 0x00000A0D, 0x00000A0A, 0x00005A83,+- 0x000200F9, 0x00002387, 0x000200F8, 0x00002387, 0x000400E0, 0x00000A10, 0x00000A10, 0x0000015F,+- 0x000300F7, 0x00004666, 0x00000000, 0x000400FA, 0x00003D0E, 0x00005195, 0x00004666, 0x000200F8,+- 0x00005195, 0x00050084, 0x0000000B, 0x000029FC, 0x00003D0B, 0x00000447, 0x00050080, 0x0000000B,+- 0x0000376B, 0x000029FC, 0x00004D71, 0x00050041, 0x0000028B, 0x000036D5, 0x00000FB1, 0x00004D71,+- 0x0004003D, 0x0000000B, 0x00003C3E, 0x000036D5, 0x00060041, 0x0000028A, 0x00005BB6, 0x00001592,+- 0x00000A0B, 0x0000376B, 0x0003003E, 0x00005BB6, 0x00003C3E, 0x000200F9, 0x00004666, 0x000200F8,+- 0x00004666, 0x000200F9, 0x00004667, 0x000200F8, 0x0000401F, 0x00060041, 0x0000028A, 0x00005099,+- 0x00000C50, 0x00000A0B, 0x00001D94, 0x0004003D, 0x0000000B, 0x00003D1E, 0x00005099, 0x00060041,+- 0x0000028A, 0x00005BB7, 0x00001592, 0x00000A0B, 0x0000237D, 0x0003003E, 0x00005BB7, 0x00003D1E,+- 0x000200F9, 0x00004667, 0x000200F8, 0x00001FDE, 0x00060041, 0x0000028A, 0x0000509A, 0x00000C50,+- 0x00000A0B, 0x00001D94, 0x0004003D, 0x0000000B, 0x00003D1F, 0x0000509A, 0x00060041, 0x0000028A,+- 0x000052BA, 0x00001592, 0x00000A0B, 0x0000237D, 0x0003003E, 0x000052BA, 0x00003D1F, 0x00050080,+- 0x0000000B, 0x00004CE6, 0x0000237D, 0x00000A0D, 0x00050080, 0x0000000B, 0x00003448, 0x00001D94,+- 0x00000A0D, 0x00060041, 0x0000028A, 0x00002A3A, 0x00000C50, 0x00000A0B, 0x00003448, 0x0004003D,+- 0x0000000B, 0x00003C3F, 0x00002A3A, 0x00060041, 0x0000028A, 0x00005BB8, 0x00001592, 0x00000A0B,+- 0x00004CE6, 0x0003003E, 0x00005BB8, 0x00003C3F, 0x000200F9, 0x00004667, 0x000200F8, 0x00004667,+- 0x000200F9, 0x00003A37, 0x000200F8, 0x00003A37, 0x000100FD, 0x00010038,++ 0x07230203,0x00010000,0x0008000a,0x00000162,0x00000000,0x00020011,0x00000001,0x0006000b,++ 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,++ 0x0007000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000001f,0x00060010,++ 0x00000004,0x00000011,0x00000020,0x00000020,0x00000001,0x00030003,0x00000002,0x000001cc,++ 0x00040005,0x00000004,0x6e69616d,0x00000000,0x00050005,0x00000008,0x656c6974,0x646e695f,++ 0x00007865,0x00060005,0x0000000b,0x575f6c67,0x476b726f,0x70756f72,0x00004449,0x00090005,++ 0x00000011,0x6f736552,0x4465766c,0x736e776f,0x656c6163,0x736e6f43,0x746e6174,0x00000073,++ 0x00090006,0x00000011,0x00000000,0x645f6578,0x736e776f,0x656c6163,0x6163735f,0x785f656c,++ 0x00000000,0x00090006,0x00000011,0x00000001,0x645f6578,0x736e776f,0x656c6163,0x6163735f,++ 0x795f656c,0x00000000,0x000b0006,0x00000011,0x00000002,0x645f6578,0x736e776f,0x656c6163,++ 0x7869705f,0x735f6c65,0x5f657a69,0x32676f6c,0x00000000,0x00090006,0x00000011,0x00000003,++ 0x645f6578,0x736e776f,0x656c6163,0x6c69745f,0x6f635f65,0x00746e75,0x000c0006,0x00000011,++ 0x00000004,0x645f6578,0x736e776f,0x656c6163,0x756f735f,0x5f656372,0x7366666f,0x625f7465,++ 0x73657479,0x00000000,0x000b0006,0x00000011,0x00000005,0x645f6578,0x736e776f,0x656c6163,++ 0x6c61685f,0x69705f66,0x5f6c6578,0x7366666f,0x00007465,0x00090006,0x00000011,0x00000006,++ 0x645f6578,0x736e776f,0x656c6163,0x6576615f,0x65676172,0x00000000,0x00030005,0x00000013,++ 0x00000000,0x00030005,0x0000001e,0x00776f72,0x00080005,0x0000001f,0x4c5f6c67,0x6c61636f,++ 0x6f766e49,0x69746163,0x44496e6f,0x00000000,0x00040005,0x00000023,0x756c6f63,0x00006e6d,++ 0x00050005,0x00000026,0x65786970,0x6e695f6c,0x00786564,0x00050005,0x0000002c,0x65786970,++ 0x69735f6c,0x0000657a,0x00060005,0x00000031,0x656c6974,0x7a69735f,0x78315f65,0x00000000,++ 0x00050005,0x00000035,0x6c616373,0x79785f65,0x00000000,0x00070005,0x0000003d,0x656c6974,++ 0x7a69735f,0x63735f65,0x64656c61,0x00000000,0x00070005,0x00000041,0x636f6c62,0x61735f6b,++ 0x656c706d,0x66666f5f,0x00746573,0x00050005,0x0000004b,0x7366666f,0x785f7465,0x00000000,++ 0x00050005,0x0000004f,0x7366666f,0x795f7465,0x00000000,0x00060005,0x00000059,0x5f637273,++ 0x65747962,0x66666f5f,0x00746573,0x00050005,0x0000006b,0x5f637273,0x7366666f,0x00007465,++ 0x00060005,0x0000006f,0x5f747364,0x65747962,0x66666f5f,0x00746573,0x00050005,0x00000077,++ 0x5f747364,0x7366666f,0x00007465,0x00050005,0x00000081,0x5f637273,0x64726f77,0x00000000,++ 0x00060005,0x00000083,0x72756f53,0x75426563,0x72656666,0x00000000,0x00050006,0x00000083,++ 0x00000000,0x61746164,0x00000000,0x00070005,0x00000085,0x725f6578,0x6c6f7365,0x735f6576,++ 0x6372756f,0x00000065,0x00050005,0x0000008a,0x65747962,0x6c61765f,0x00000000,0x00050005,++ 0x00000094,0x6b636170,0x646e695f,0x00007865,0x00050005,0x00000097,0x65747962,0x736f705f,++ 0x00000000,0x00060005,0x0000009a,0x746e6f63,0x75626972,0x6e6f6974,0x00000000,0x00060005,++ 0x000000a5,0x745f7367,0x5f656c69,0x61746164,0x00000000,0x00050005,0x000000b8,0x74736544,++ 0x66667542,0x00007265,0x00050006,0x000000b8,0x00000000,0x61746164,0x00000000,0x00060005,++ 0x000000ba,0x725f6578,0x6c6f7365,0x645f6576,0x00747365,0x00050005,0x000000c5,0x5f637273,++ 0x64726f77,0x00000000,0x00050005,0x000000c9,0x726f6873,0x61765f74,0x0000006c,0x00050005,++ 0x000000d1,0x6b636170,0x646e695f,0x00007865,0x00050005,0x000000d4,0x726f6873,0x6f705f74,++ 0x00000073,0x00060005,0x000000d7,0x746e6f63,0x75626972,0x6e6f6974,0x00000000,0x00050005,++ 0x00000103,0x636f6c62,0x61625f6b,0x00006573,0x00030005,0x00000113,0x006d7573,0x00030005,++ 0x00000115,0x00000073,0x00040005,0x0000011e,0x65786574,0x0000006c,0x00040047,0x0000000b,++ 0x0000000b,0x0000001a,0x00050048,0x00000011,0x00000000,0x00000023,0x00000000,0x00050048,++ 0x00000011,0x00000001,0x00000023,0x00000004,0x00050048,0x00000011,0x00000002,0x00000023,++ 0x00000008,0x00050048,0x00000011,0x00000003,0x00000023,0x0000000c,0x00050048,0x00000011,++ 0x00000004,0x00000023,0x00000010,0x00050048,0x00000011,0x00000005,0x00000023,0x00000014,++ 0x00050048,0x00000011,0x00000006,0x00000023,0x00000018,0x00030047,0x00000011,0x00000002,++ 0x00040047,0x0000001f,0x0000000b,0x0000001b,0x00040047,0x00000082,0x00000006,0x00000004,++ 0x00040048,0x00000083,0x00000000,0x00000018,0x00050048,0x00000083,0x00000000,0x00000023,++ 0x00000000,0x00030047,0x00000083,0x00000003,0x00040047,0x00000085,0x00000022,0x00000000,++ 0x00040047,0x00000085,0x00000021,0x00000000,0x00040047,0x000000b7,0x00000006,0x00000004,++ 0x00040048,0x000000b8,0x00000000,0x00000019,0x00050048,0x000000b8,0x00000000,0x00000023,++ 0x00000000,0x00030047,0x000000b8,0x00000003,0x00040047,0x000000ba,0x00000022,0x00000000,++ 0x00040047,0x000000ba,0x00000021,0x00000001,0x00040047,0x00000161,0x0000000b,0x00000019,++ 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,++ 0x00000000,0x00040020,0x00000007,0x00000007,0x00000006,0x00040017,0x00000009,0x00000006,++ 0x00000003,0x00040020,0x0000000a,0x00000001,0x00000009,0x0004003b,0x0000000a,0x0000000b,++ 0x00000001,0x0004002b,0x00000006,0x0000000c,0x00000000,0x00040020,0x0000000d,0x00000001,++ 0x00000006,0x0009001e,0x00000011,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,++ 0x00000006,0x00000006,0x00040020,0x00000012,0x00000009,0x00000011,0x0004003b,0x00000012,++ 0x00000013,0x00000009,0x00040015,0x00000014,0x00000020,0x00000001,0x0004002b,0x00000014,++ 0x00000015,0x00000003,0x00040020,0x00000016,0x00000009,0x00000006,0x00020014,0x00000019,++ 0x0004003b,0x0000000a,0x0000001f,0x00000001,0x0004002b,0x00000006,0x00000020,0x00000001,++ 0x0004002b,0x00000006,0x00000028,0x00000020,0x0004002b,0x00000014,0x0000002d,0x00000002,++ 0x0004002b,0x00000006,0x00000032,0x00000400,0x0004002b,0x00000014,0x00000036,0x00000000,++ 0x0004002b,0x00000014,0x00000039,0x00000001,0x0004002b,0x00000014,0x00000042,0x00000005,++ 0x0004002b,0x00000014,0x0000005a,0x00000004,0x0004002b,0x00000006,0x0000006d,0x00000002,++ 0x0003001d,0x00000082,0x00000006,0x0003001e,0x00000083,0x00000082,0x00040020,0x00000084,++ 0x00000002,0x00000083,0x0004003b,0x00000084,0x00000085,0x00000002,0x00040020,0x00000087,++ 0x00000002,0x00000006,0x0004002b,0x00000006,0x0000008d,0x00000003,0x0004002b,0x00000006,++ 0x0000008f,0x00000008,0x0004002b,0x00000006,0x00000092,0x000000ff,0x0004001c,0x000000a3,++ 0x00000006,0x00000032,0x00040020,0x000000a4,0x00000004,0x000000a3,0x0004003b,0x000000a4,++ 0x000000a5,0x00000004,0x00040020,0x000000a8,0x00000004,0x00000006,0x0004002b,0x00000006,++ 0x000000aa,0x00000108,0x0003001d,0x000000b7,0x00000006,0x0003001e,0x000000b8,0x000000b7,++ 0x00040020,0x000000b9,0x00000002,0x000000b8,0x0004003b,0x000000b9,0x000000ba,0x00000002,++ 0x0004002b,0x00000006,0x000000bc,0x00000100,0x0004002b,0x00000006,0x000000cf,0x0000ffff,++ 0x0004002b,0x00000006,0x000000da,0x00000010,0x0004002b,0x00000006,0x000000f1,0x00000200,++ 0x0004002b,0x00000014,0x000000fa,0x00000006,0x00040017,0x00000111,0x00000006,0x00000004,++ 0x00040020,0x00000112,0x00000007,0x00000111,0x0007002c,0x00000111,0x00000114,0x0000000c,++ 0x0000000c,0x0000000c,0x0000000c,0x0004002b,0x00000006,0x0000012d,0x00000018,0x0006002c,++ 0x00000009,0x00000161,0x00000028,0x00000028,0x00000020,0x00050036,0x00000002,0x00000004,++ 0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000007,0x00000008,0x00000007,++ 0x0004003b,0x00000007,0x0000001e,0x00000007,0x0004003b,0x00000007,0x00000023,0x00000007,++ 0x0004003b,0x00000007,0x00000026,0x00000007,0x0004003b,0x00000007,0x0000002c,0x00000007,++ 0x0004003b,0x00000007,0x00000031,0x00000007,0x0004003b,0x00000007,0x00000035,0x00000007,++ 0x0004003b,0x00000007,0x0000003d,0x00000007,0x0004003b,0x00000007,0x00000041,0x00000007,++ 0x0004003b,0x00000007,0x0000004b,0x00000007,0x0004003b,0x00000007,0x0000004f,0x00000007,++ 0x0004003b,0x00000007,0x00000059,0x00000007,0x0004003b,0x00000007,0x0000006b,0x00000007,++ 0x0004003b,0x00000007,0x0000006f,0x00000007,0x0004003b,0x00000007,0x00000077,0x00000007,++ 0x0004003b,0x00000007,0x00000081,0x00000007,0x0004003b,0x00000007,0x0000008a,0x00000007,++ 0x0004003b,0x00000007,0x00000094,0x00000007,0x0004003b,0x00000007,0x00000097,0x00000007,++ 0x0004003b,0x00000007,0x0000009a,0x00000007,0x0004003b,0x00000007,0x000000c5,0x00000007,++ 0x0004003b,0x00000007,0x000000c9,0x00000007,0x0004003b,0x00000007,0x000000d1,0x00000007,++ 0x0004003b,0x00000007,0x000000d4,0x00000007,0x0004003b,0x00000007,0x000000d7,0x00000007,++ 0x0004003b,0x00000007,0x00000103,0x00000007,0x0004003b,0x00000112,0x00000113,0x00000007,++ 0x0004003b,0x00000007,0x00000115,0x00000007,0x0004003b,0x00000007,0x0000011e,0x00000007,++ 0x00050041,0x0000000d,0x0000000e,0x0000000b,0x0000000c,0x0004003d,0x00000006,0x0000000f,++ 0x0000000e,0x0003003e,0x00000008,0x0000000f,0x0004003d,0x00000006,0x00000010,0x00000008,++ 0x00050041,0x00000016,0x00000017,0x00000013,0x00000015,0x0004003d,0x00000006,0x00000018,++ 0x00000017,0x000500ae,0x00000019,0x0000001a,0x00000010,0x00000018,0x000300f7,0x0000001c,++ 0x00000000,0x000400fa,0x0000001a,0x0000001b,0x0000001c,0x000200f8,0x0000001b,0x000100fd,++ 0x000200f8,0x0000001c,0x00050041,0x0000000d,0x00000021,0x0000001f,0x00000020,0x0004003d,++ 0x00000006,0x00000022,0x00000021,0x0003003e,0x0000001e,0x00000022,0x00050041,0x0000000d,++ 0x00000024,0x0000001f,0x0000000c,0x0004003d,0x00000006,0x00000025,0x00000024,0x0003003e,++ 0x00000023,0x00000025,0x0004003d,0x00000006,0x00000027,0x0000001e,0x00050084,0x00000006,++ 0x00000029,0x00000027,0x00000028,0x0004003d,0x00000006,0x0000002a,0x00000023,0x00050080,++ 0x00000006,0x0000002b,0x00000029,0x0000002a,0x0003003e,0x00000026,0x0000002b,0x00050041,++ 0x00000016,0x0000002e,0x00000013,0x0000002d,0x0004003d,0x00000006,0x0000002f,0x0000002e,++ 0x000500c4,0x00000006,0x00000030,0x00000020,0x0000002f,0x0003003e,0x0000002c,0x00000030,++ 0x0004003d,0x00000006,0x00000033,0x0000002c,0x00050084,0x00000006,0x00000034,0x00000032,++ 0x00000033,0x0003003e,0x00000031,0x00000034,0x00050041,0x00000016,0x00000037,0x00000013,++ 0x00000036,0x0004003d,0x00000006,0x00000038,0x00000037,0x00050041,0x00000016,0x0000003a,++ 0x00000013,0x00000039,0x0004003d,0x00000006,0x0000003b,0x0000003a,0x00050084,0x00000006,++ 0x0000003c,0x00000038,0x0000003b,0x0003003e,0x00000035,0x0000003c,0x0004003d,0x00000006,++ 0x0000003e,0x00000031,0x0004003d,0x00000006,0x0000003f,0x00000035,0x00050084,0x00000006,++ 0x00000040,0x0000003e,0x0000003f,0x0003003e,0x0000003d,0x00000040,0x0003003e,0x00000041,++ 0x0000000c,0x00050041,0x00000016,0x00000043,0x00000013,0x00000042,0x0004003d,0x00000006,++ 0x00000044,0x00000043,0x000500ab,0x00000019,0x00000045,0x00000044,0x0000000c,0x0004003d,++ 0x00000006,0x00000046,0x00000035,0x000500ac,0x00000019,0x00000047,0x00000046,0x00000020,++ 0x000500a7,0x00000019,0x00000048,0x00000045,0x00000047,0x000300f7,0x0000004a,0x00000000,++ 0x000400fa,0x00000048,0x00000049,0x0000004a,0x000200f8,0x00000049,0x00050041,0x00000016,++ 0x0000004c,0x00000013,0x00000036,0x0004003d,0x00000006,0x0000004d,0x0000004c,0x000500c2,++ 0x00000006,0x0000004e,0x0000004d,0x00000020,0x0003003e,0x0000004b,0x0000004e,0x00050041,++ 0x00000016,0x00000050,0x00000013,0x00000039,0x0004003d,0x00000006,0x00000051,0x00000050,++ 0x000500c2,0x00000006,0x00000052,0x00000051,0x00000020,0x0003003e,0x0000004f,0x00000052,++ 0x0004003d,0x00000006,0x00000053,0x0000004b,0x0004003d,0x00000006,0x00000054,0x0000004f,++ 0x00050041,0x00000016,0x00000055,0x00000013,0x00000036,0x0004003d,0x00000006,0x00000056,++ 0x00000055,0x00050084,0x00000006,0x00000057,0x00000054,0x00000056,0x00050080,0x00000006,++ 0x00000058,0x00000053,0x00000057,0x0003003e,0x00000041,0x00000058,0x000200f9,0x0000004a,++ 0x000200f8,0x0000004a,0x00050041,0x00000016,0x0000005b,0x00000013,0x0000005a,0x0004003d,++ 0x00000006,0x0000005c,0x0000005b,0x0004003d,0x00000006,0x0000005d,0x00000008,0x0004003d,++ 0x00000006,0x0000005e,0x0000003d,0x00050084,0x00000006,0x0000005f,0x0000005d,0x0000005e,++ 0x00050080,0x00000006,0x00000060,0x0000005c,0x0000005f,0x0004003d,0x00000006,0x00000061,++ 0x00000026,0x0004003d,0x00000006,0x00000062,0x0000002c,0x00050084,0x00000006,0x00000063,++ 0x00000061,0x00000062,0x0004003d,0x00000006,0x00000064,0x00000035,0x00050084,0x00000006,++ 0x00000065,0x00000063,0x00000064,0x00050080,0x00000006,0x00000066,0x00000060,0x00000065,++ 0x0004003d,0x00000006,0x00000067,0x00000041,0x0004003d,0x00000006,0x00000068,0x0000002c,++ 0x00050084,0x00000006,0x00000069,0x00000067,0x00000068,0x00050080,0x00000006,0x0000006a,++ 0x00000066,0x00000069,0x0003003e,0x00000059,0x0000006a,0x0004003d,0x00000006,0x0000006c,++ 0x00000059,0x000500c2,0x00000006,0x0000006e,0x0000006c,0x0000006d,0x0003003e,0x0000006b,++ 0x0000006e,0x0004003d,0x00000006,0x00000070,0x00000008,0x0004003d,0x00000006,0x00000071,++ 0x00000031,0x00050084,0x00000006,0x00000072,0x00000070,0x00000071,0x0004003d,0x00000006,++ 0x00000073,0x00000026,0x0004003d,0x00000006,0x00000074,0x0000002c,0x00050084,0x00000006,++ 0x00000075,0x00000073,0x00000074,0x00050080,0x00000006,0x00000076,0x00000072,0x00000075,++ 0x0003003e,0x0000006f,0x00000076,0x0004003d,0x00000006,0x00000078,0x0000006f,0x000500c2,++ 0x00000006,0x00000079,0x00000078,0x0000006d,0x0003003e,0x00000077,0x00000079,0x00050041,++ 0x00000016,0x0000007a,0x00000013,0x0000002d,0x0004003d,0x00000006,0x0000007b,0x0000007a,++ 0x000300f7,0x00000080,0x00000000,0x000b00fb,0x0000007b,0x00000080,0x00000000,0x0000007c,++ 0x00000001,0x0000007d,0x00000002,0x0000007e,0x00000003,0x0000007f,0x000200f8,0x0000007c,++ 0x0004003d,0x00000006,0x00000086,0x0000006b,0x00060041,0x00000087,0x00000088,0x00000085,++ 0x00000036,0x00000086,0x0004003d,0x00000006,0x00000089,0x00000088,0x0003003e,0x00000081,++ 0x00000089,0x0004003d,0x00000006,0x0000008b,0x00000081,0x0004003d,0x00000006,0x0000008c,++ 0x00000059,0x000500c7,0x00000006,0x0000008e,0x0000008c,0x0000008d,0x00050084,0x00000006,++ 0x00000090,0x0000008e,0x0000008f,0x000500c2,0x00000006,0x00000091,0x0000008b,0x00000090,++ 0x000500c7,0x00000006,0x00000093,0x00000091,0x00000092,0x0003003e,0x0000008a,0x00000093,++ 0x0004003d,0x00000006,0x00000095,0x00000026,0x000500c2,0x00000006,0x00000096,0x00000095,++ 0x0000006d,0x0003003e,0x00000094,0x00000096,0x0004003d,0x00000006,0x00000098,0x00000026,++ 0x000500c7,0x00000006,0x00000099,0x00000098,0x0000008d,0x0003003e,0x00000097,0x00000099,++ 0x0004003d,0x00000006,0x0000009b,0x0000008a,0x0004003d,0x00000006,0x0000009c,0x00000097,++ 0x00050084,0x00000006,0x0000009d,0x0000009c,0x0000008f,0x000500c4,0x00000006,0x0000009e,++ 0x0000009b,0x0000009d,0x0003003e,0x0000009a,0x0000009e,0x0004003d,0x00000006,0x0000009f,++ 0x00000097,0x000500aa,0x00000019,0x000000a0,0x0000009f,0x0000000c,0x000300f7,0x000000a2,++ 0x00000000,0x000400fa,0x000000a0,0x000000a1,0x000000a2,0x000200f8,0x000000a1,0x0004003d,++ 0x00000006,0x000000a6,0x00000094,0x0004003d,0x00000006,0x000000a7,0x0000009a,0x00050041,++ 0x000000a8,0x000000a9,0x000000a5,0x000000a6,0x0003003e,0x000000a9,0x000000a7,0x000200f9,++ 0x000000a2,0x000200f8,0x000000a2,0x000400e0,0x0000006d,0x0000006d,0x000000aa,0x0004003d,++ 0x00000006,0x000000ab,0x00000097,0x000500ab,0x00000019,0x000000ac,0x000000ab,0x0000000c,++ 0x000300f7,0x000000ae,0x00000000,0x000400fa,0x000000ac,0x000000ad,0x000000ae,0x000200f8,++ 0x000000ad,0x0004003d,0x00000006,0x000000af,0x00000094,0x00050041,0x000000a8,0x000000b0,++ 0x000000a5,0x000000af,0x0004003d,0x00000006,0x000000b1,0x0000009a,0x000700f1,0x00000006,++ 0x000000b2,0x000000b0,0x00000020,0x0000000c,0x000000b1,0x000200f9,0x000000ae,0x000200f8,++ 0x000000ae,0x000400e0,0x0000006d,0x0000006d,0x000000aa,0x0004003d,0x00000006,0x000000b3,++ 0x00000097,0x000500aa,0x00000019,0x000000b4,0x000000b3,0x0000000c,0x000300f7,0x000000b6,++ 0x00000000,0x000400fa,0x000000b4,0x000000b5,0x000000b6,0x000200f8,0x000000b5,0x0004003d,++ 0x00000006,0x000000bb,0x00000008,0x00050084,0x00000006,0x000000bd,0x000000bb,0x000000bc,++ 0x0004003d,0x00000006,0x000000be,0x00000094,0x00050080,0x00000006,0x000000bf,0x000000bd,++ 0x000000be,0x0004003d,0x00000006,0x000000c0,0x00000094,0x00050041,0x000000a8,0x000000c1,++ 0x000000a5,0x000000c0,0x0004003d,0x00000006,0x000000c2,0x000000c1,0x00060041,0x00000087,++ 0x000000c3,0x000000ba,0x00000036,0x000000bf,0x0003003e,0x000000c3,0x000000c2,0x000200f9,++ 0x000000b6,0x000200f8,0x000000b6,0x000200f9,0x00000080,0x000200f8,0x0000007d,0x0004003d,++ 0x00000006,0x000000c6,0x0000006b,0x00060041,0x00000087,0x000000c7,0x00000085,0x00000036,++ 0x000000c6,0x0004003d,0x00000006,0x000000c8,0x000000c7,0x0003003e,0x000000c5,0x000000c8,++ 0x0004003d,0x00000006,0x000000ca,0x000000c5,0x0004003d,0x00000006,0x000000cb,0x00000059,++ 0x000500c7,0x00000006,0x000000cc,0x000000cb,0x0000006d,0x00050084,0x00000006,0x000000cd,++ 0x000000cc,0x0000008f,0x000500c2,0x00000006,0x000000ce,0x000000ca,0x000000cd,0x000500c7,++ 0x00000006,0x000000d0,0x000000ce,0x000000cf,0x0003003e,0x000000c9,0x000000d0,0x0004003d,++ 0x00000006,0x000000d2,0x00000026,0x000500c2,0x00000006,0x000000d3,0x000000d2,0x00000020,++ 0x0003003e,0x000000d1,0x000000d3,0x0004003d,0x00000006,0x000000d5,0x00000026,0x000500c7,++ 0x00000006,0x000000d6,0x000000d5,0x00000020,0x0003003e,0x000000d4,0x000000d6,0x0004003d,++ 0x00000006,0x000000d8,0x000000c9,0x0004003d,0x00000006,0x000000d9,0x000000d4,0x00050084,++ 0x00000006,0x000000db,0x000000d9,0x000000da,0x000500c4,0x00000006,0x000000dc,0x000000d8,++ 0x000000db,0x0003003e,0x000000d7,0x000000dc,0x0004003d,0x00000006,0x000000dd,0x000000d4,++ 0x000500aa,0x00000019,0x000000de,0x000000dd,0x0000000c,0x000300f7,0x000000e0,0x00000000,++ 0x000400fa,0x000000de,0x000000df,0x000000e0,0x000200f8,0x000000df,0x0004003d,0x00000006,++ 0x000000e1,0x000000d1,0x0004003d,0x00000006,0x000000e2,0x000000d7,0x00050041,0x000000a8,++ 0x000000e3,0x000000a5,0x000000e1,0x0003003e,0x000000e3,0x000000e2,0x000200f9,0x000000e0,++ 0x000200f8,0x000000e0,0x000400e0,0x0000006d,0x0000006d,0x000000aa,0x0004003d,0x00000006,++ 0x000000e4,0x000000d4,0x000500ab,0x00000019,0x000000e5,0x000000e4,0x0000000c,0x000300f7,++ 0x000000e7,0x00000000,0x000400fa,0x000000e5,0x000000e6,0x000000e7,0x000200f8,0x000000e6,++ 0x0004003d,0x00000006,0x000000e8,0x000000d1,0x00050041,0x000000a8,0x000000e9,0x000000a5,++ 0x000000e8,0x0004003d,0x00000006,0x000000ea,0x000000d7,0x000700f1,0x00000006,0x000000eb,++ 0x000000e9,0x00000020,0x0000000c,0x000000ea,0x000200f9,0x000000e7,0x000200f8,0x000000e7,++ 0x000400e0,0x0000006d,0x0000006d,0x000000aa,0x0004003d,0x00000006,0x000000ec,0x000000d4,++ 0x000500aa,0x00000019,0x000000ed,0x000000ec,0x0000000c,0x000300f7,0x000000ef,0x00000000,++ 0x000400fa,0x000000ed,0x000000ee,0x000000ef,0x000200f8,0x000000ee,0x0004003d,0x00000006,++ 0x000000f0,0x00000008,0x00050084,0x00000006,0x000000f2,0x000000f0,0x000000f1,0x0004003d,++ 0x00000006,0x000000f3,0x000000d1,0x00050080,0x00000006,0x000000f4,0x000000f2,0x000000f3,++ 0x0004003d,0x00000006,0x000000f5,0x000000d1,0x00050041,0x000000a8,0x000000f6,0x000000a5,++ 0x000000f5,0x0004003d,0x00000006,0x000000f7,0x000000f6,0x00060041,0x00000087,0x000000f8,++ 0x000000ba,0x00000036,0x000000f4,0x0003003e,0x000000f8,0x000000f7,0x000200f9,0x000000ef,++ 0x000200f8,0x000000ef,0x000200f9,0x00000080,0x000200f8,0x0000007e,0x00050041,0x00000016,++ 0x000000fb,0x00000013,0x000000fa,0x0004003d,0x00000006,0x000000fc,0x000000fb,0x000500ab,++ 0x00000019,0x000000fd,0x000000fc,0x0000000c,0x0004003d,0x00000006,0x000000fe,0x00000035,++ 0x000500ac,0x00000019,0x000000ff,0x000000fe,0x00000020,0x000500a7,0x00000019,0x00000100,++ 0x000000fd,0x000000ff,0x000300f7,0x00000102,0x00000000,0x000400fa,0x00000100,0x00000101,++ 0x0000014c,0x000200f8,0x00000101,0x00050041,0x00000016,0x00000104,0x00000013,0x0000005a,++ 0x0004003d,0x00000006,0x00000105,0x00000104,0x0004003d,0x00000006,0x00000106,0x00000008,++ 0x0004003d,0x00000006,0x00000107,0x0000003d,0x00050084,0x00000006,0x00000108,0x00000106,++ 0x00000107,0x00050080,0x00000006,0x00000109,0x00000105,0x00000108,0x0004003d,0x00000006,++ 0x0000010a,0x00000026,0x0004003d,0x00000006,0x0000010b,0x0000002c,0x00050084,0x00000006,++ 0x0000010c,0x0000010a,0x0000010b,0x0004003d,0x00000006,0x0000010d,0x00000035,0x00050084,++ 0x00000006,0x0000010e,0x0000010c,0x0000010d,0x00050080,0x00000006,0x0000010f,0x00000109,++ 0x0000010e,0x000500c2,0x00000006,0x00000110,0x0000010f,0x0000006d,0x0003003e,0x00000103,++ 0x00000110,0x0003003e,0x00000113,0x00000114,0x0003003e,0x00000115,0x0000000c,0x000200f9,++ 0x00000116,0x000200f8,0x00000116,0x000400f6,0x00000118,0x00000119,0x00000000,0x000200f9,++ 0x0000011a,0x000200f8,0x0000011a,0x0004003d,0x00000006,0x0000011b,0x00000115,0x0004003d,++ 0x00000006,0x0000011c,0x00000035,0x000500b0,0x00000019,0x0000011d,0x0000011b,0x0000011c,++ 0x000400fa,0x0000011d,0x00000117,0x00000118,0x000200f8,0x00000117,0x0004003d,0x00000006,++ 0x0000011f,0x00000103,0x0004003d,0x00000006,0x00000120,0x00000115,0x00050080,0x00000006,++ 0x00000121,0x0000011f,0x00000120,0x00060041,0x00000087,0x00000122,0x00000085,0x00000036,++ 0x00000121,0x0004003d,0x00000006,0x00000123,0x00000122,0x0003003e,0x0000011e,0x00000123,++ 0x0004003d,0x00000006,0x00000124,0x0000011e,0x000500c7,0x00000006,0x00000125,0x00000124,++ 0x00000092,0x0004003d,0x00000006,0x00000126,0x0000011e,0x000500c2,0x00000006,0x00000127,++ 0x00000126,0x0000008f,0x000500c7,0x00000006,0x00000128,0x00000127,0x00000092,0x0004003d,++ 0x00000006,0x00000129,0x0000011e,0x000500c2,0x00000006,0x0000012a,0x00000129,0x000000da,++ 0x000500c7,0x00000006,0x0000012b,0x0000012a,0x00000092,0x0004003d,0x00000006,0x0000012c,++ 0x0000011e,0x000500c2,0x00000006,0x0000012e,0x0000012c,0x0000012d,0x00070050,0x00000111,++ 0x0000012f,0x00000125,0x00000128,0x0000012b,0x0000012e,0x0004003d,0x00000111,0x00000130,++ 0x00000113,0x00050080,0x00000111,0x00000131,0x00000130,0x0000012f,0x0003003e,0x00000113,++ 0x00000131,0x000200f9,0x00000119,0x000200f8,0x00000119,0x0004003d,0x00000006,0x00000132,++ 0x00000115,0x00050080,0x00000006,0x00000133,0x00000132,0x00000039,0x0003003e,0x00000115,++ 0x00000133,0x000200f9,0x00000116,0x000200f8,0x00000118,0x0004003d,0x00000111,0x00000134,++ 0x00000113,0x0004003d,0x00000006,0x00000135,0x00000035,0x000500c2,0x00000006,0x00000136,++ 0x00000135,0x00000020,0x00070050,0x00000111,0x00000137,0x00000136,0x00000136,0x00000136,++ 0x00000136,0x00050080,0x00000111,0x00000138,0x00000134,0x00000137,0x0004003d,0x00000006,++ 0x00000139,0x00000035,0x00070050,0x00000111,0x0000013a,0x00000139,0x00000139,0x00000139,++ 0x00000139,0x00050086,0x00000111,0x0000013b,0x00000138,0x0000013a,0x0003003e,0x00000113,++ 0x0000013b,0x0004003d,0x00000006,0x0000013c,0x00000077,0x00050041,0x00000007,0x0000013d,++ 0x00000113,0x0000000c,0x0004003d,0x00000006,0x0000013e,0x0000013d,0x00050041,0x00000007,++ 0x0000013f,0x00000113,0x00000020,0x0004003d,0x00000006,0x00000140,0x0000013f,0x000500c4,++ 0x00000006,0x00000141,0x00000140,0x0000008f,0x000500c5,0x00000006,0x00000142,0x0000013e,++ 0x00000141,0x00050041,0x00000007,0x00000143,0x00000113,0x0000006d,0x0004003d,0x00000006,++ 0x00000144,0x00000143,0x000500c4,0x00000006,0x00000145,0x00000144,0x000000da,0x000500c5,++ 0x00000006,0x00000146,0x00000142,0x00000145,0x00050041,0x00000007,0x00000147,0x00000113,++ 0x0000008d,0x0004003d,0x00000006,0x00000148,0x00000147,0x000500c4,0x00000006,0x00000149,++ 0x00000148,0x0000012d,0x000500c5,0x00000006,0x0000014a,0x00000146,0x00000149,0x00060041,++ 0x00000087,0x0000014b,0x000000ba,0x00000036,0x0000013c,0x0003003e,0x0000014b,0x0000014a,++ 0x000200f9,0x00000102,0x000200f8,0x0000014c,0x0004003d,0x00000006,0x0000014d,0x00000077,++ 0x0004003d,0x00000006,0x0000014e,0x0000006b,0x00060041,0x00000087,0x0000014f,0x00000085,++ 0x00000036,0x0000014e,0x0004003d,0x00000006,0x00000150,0x0000014f,0x00060041,0x00000087,++ 0x00000151,0x000000ba,0x00000036,0x0000014d,0x0003003e,0x00000151,0x00000150,0x000200f9,++ 0x00000102,0x000200f8,0x00000102,0x000200f9,0x00000080,0x000200f8,0x0000007f,0x0004003d,++ 0x00000006,0x00000153,0x00000077,0x0004003d,0x00000006,0x00000154,0x0000006b,0x00060041,++ 0x00000087,0x00000155,0x00000085,0x00000036,0x00000154,0x0004003d,0x00000006,0x00000156,++ 0x00000155,0x00060041,0x00000087,0x00000157,0x000000ba,0x00000036,0x00000153,0x0003003e,++ 0x00000157,0x00000156,0x0004003d,0x00000006,0x00000158,0x00000077,0x00050080,0x00000006,++ 0x00000159,0x00000158,0x00000020,0x0004003d,0x00000006,0x0000015a,0x0000006b,0x00050080,++ 0x00000006,0x0000015b,0x0000015a,0x00000020,0x00060041,0x00000087,0x0000015c,0x00000085,++ 0x00000036,0x0000015b,0x0004003d,0x00000006,0x0000015d,0x0000015c,0x00060041,0x00000087,++ 0x0000015e,0x000000ba,0x00000036,0x00000159,0x0003003e,0x0000015e,0x0000015d,0x000200f9,++ 0x00000080,0x000200f8,0x00000080,0x000100fd,0x00010038+ };diff --git a/src/graphics/shared_memory.cpp b/src/graphics/shared_memory.cppindex ec0df7c..2ac72b9 100644--- a/src/graphics/shared_memory.cpp@@ -3436,7 +5265,7 @@ index 3027dc8..54f77a9 100644REXCVAR_DEFINE_BOOL(execute_unclipped_draw_vs_on_cpu_with_scissor, false, "GPU",diff --git a/src/graphics/vulkan/command_processor.cpp b/src/graphics/vulkan/command_processor.cpp-index 001f36b..71fee31 100644+index 001f36b..f2af0d9 100644--- a/src/graphics/vulkan/command_processor.cpp+++ b/src/graphics/vulkan/command_processor.cpp@@ -11,6 +11,7 @@@@ -3455,7 +5284,7 @@ index 001f36b..71fee31 100644#include <rex/math.h>#include <rex/graphics/util/draw.h>#include <rex/graphics/flags.h>-@@ -44,9 +46,21 @@+@@ -44,9 +46,41 @@#include <rex/memory/utils.h>#include <rex/ui/flags.h>#include <rex/ui/vulkan/presenter.h>@@ -3465,6 +5294,26 @@ index 001f36b..71fee31 100644// Legacy backend compatibility aliases for shared readback controls.+REXCVAR_DEFINE_BOOL(vulkan_readback_short_wait, false, "GPU/Vulkan",+ "Poll the final resolve fence briefly before the blocking wait");++REXCVAR_DEFINE_UINT32(vulkan_readback_sync_budget_us, 0, "GPU/Vulkan",++ "'some' readback ranges read synchronously (readback_some_sync_*): wait at most this long "++ "for the GPU, then use the previous frame's copy instead (0 = always wait)");++static void NoteReadbackBudget(bool fresh, double waited_us) {++ // Diagnostics for the budgeted floor readback: how often the GPU was done in time.++ static uint64_t fresh_count = 0, stale_count = 0;++ static double max_us = 0;++ static auto window = std::chrono::steady_clock::now();++ (fresh ? fresh_count : stale_count) += 1;++ max_us = std::max(max_us, waited_us);++ if (std::chrono::steady_clock::now() - window >= std::chrono::seconds(5)) {++ REXGPU_INFO("Readback sync budget: current_frame={} previous_frame={} max_wait_us={:.0f}", fresh_count,++ stale_count, max_us);++ fresh_count = stale_count = 0;++ max_us = 0;++ window = std::chrono::steady_clock::now();++ }++}++// Fence wait limit for the current resolve wait (set only around a budgeted readback, command processor thread).++static thread_local uint64_t g_resolve_wait_timeout_ns = UINT64_MAX;+REXCVAR_DEFINE_UINT32(vulkan_readback_spin_us, 200, "GPU/Vulkan",+ "Maximum CPU polling time before the blocking full-readback wait");+@@ -3477,7 +5326,7 @@ index 001f36b..71fee31 100644REXCVAR_DEFINE_BOOL(vulkan_readback_resolve, false, "GPU/Vulkan","Read render-to-texture results on the CPU").lifecycle(rex::cvar::Lifecycle::kHotReload);-@@ -896,6 +910,8 @@ bool VulkanCommandProcessor::SetupContext() {+@@ -896,6 +930,8 @@ bool VulkanCommandProcessor::SetupContext() {REXGPU_ERROR("Failed to initialize shared memory");return false;}@@ -3486,7 +5335,7 @@ index 001f36b..71fee31 100644primitive_processor_ =std::make_unique<VulkanPrimitiveProcessor>(*register_file_, *memory_, *shared_memory_, *this);-@@ -2026,6 +2042,9 @@ void VulkanCommandProcessor::ShutdownContext() {+@@ -2026,6 +2062,9 @@ void VulkanCommandProcessor::ShutdownContext() {primitive_processor_.reset();@@ -3496,7 +5345,7 @@ index 001f36b..71fee31 100644shared_memory_.reset();ClearTransientDescriptorPools();-@@ -2059,10 +2078,16 @@ void VulkanCommandProcessor::ShutdownContext() {+@@ -2059,10 +2098,16 @@ void VulkanCommandProcessor::ShutdownContext() {deferred_command_buffer_.Reset();for (const auto& command_buffer_pair : command_buffers_submitted_) {@@ -3513,7 +5362,7 @@ index 001f36b..71fee31 100644dfn.vkDestroyCommandPool(device, command_buffer.pool, nullptr);}command_buffers_writable_.clear();-@@ -3822,7 +3847,7 @@ bool VulkanCommandProcessor::IssueDraw(xenos::PrimitiveType prim_type, uint32_t+@@ -3822,7 +3867,7 @@ bool VulkanCommandProcessor::IssueDraw(xenos::PrimitiveType prim_type, uint32_tuint64_t sampler_overflow_await_submission =texture_cache_->GetSubmissionToAwaitOnSamplerOverflow(samplers_overflowed_count);assert_true(sampler_overflow_await_submission <= GetCurrentSubmission());@@ -3522,7 +5371,7 @@ index 001f36b..71fee31 100644}uint32_t normalized_color_mask =-@@ -4154,6 +4179,8 @@ bool VulkanCommandProcessor::IssueDraw(xenos::PrimitiveType prim_type, uint32_t+@@ -4154,6 +4199,8 @@ bool VulkanCommandProcessor::IssueDraw(xenos::PrimitiveType prim_type, uint32_t0, 0, 0);}@@ -3531,7 +5380,7 @@ index 001f36b..71fee31 100644// Invalidate textures in memexported memory and watch for changes.if (!memexport_ranges_.empty()) {for (const draw_util::MemExportRange& memexport_range : memexport_ranges_) {-@@ -4222,7 +4249,7 @@ bool VulkanCommandProcessor::IssueDraw_MemexportReadbackFullPath(uint32_t total_+@@ -4222,7 +4269,7 @@ bool VulkanCommandProcessor::IssueDraw_MemexportReadbackFullPath(uint32_t total_VK_PIPELINE_STAGE_HOST_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,VK_ACCESS_HOST_READ_BIT);@@ -3540,7 +5389,7 @@ index 001f36b..71fee31 100644REXGPU_ERROR("Failed to await completion of Vulkan memexport readback");dfn.vkDestroyBuffer(device, readback_buffer, nullptr);dfn.vkFreeMemory(device, readback_memory, nullptr);-@@ -4297,7 +4324,7 @@ bool VulkanCommandProcessor::IssueDraw_MemexportReadbackFastPath(uint32_t total_+@@ -4297,7 +4344,7 @@ bool VulkanCommandProcessor::IssueDraw_MemexportReadbackFastPath(uint32_t total_}if (readback.buffers[index] != VK_NULL_HANDLE || readback.memories[index] != VK_NULL_HANDLE) {@@ -3549,7 +5398,7 @@ index 001f36b..71fee31 100644dfn.vkUnmapMemory(device, new_memory);dfn.vkDestroyBuffer(device, new_buffer, nullptr);dfn.vkFreeMemory(device, new_memory, nullptr);-@@ -4381,6 +4408,11 @@ bool VulkanCommandProcessor::IssueDraw_MemexportReadbackFastPath(uint32_t total_+@@ -4381,6 +4428,11 @@ bool VulkanCommandProcessor::IssueDraw_MemexportReadbackFastPath(uint32_t total_return true;}@@ -3561,7 +5410,7 @@ index 001f36b..71fee31 100644bool VulkanCommandProcessor::IssueCopy() {#if XE_GPU_FINE_GRAINED_DRAW_SCOPESSCOPE_profile_cpu_f("gpu");-@@ -4448,7 +4480,7 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -4448,7 +4500,7 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {}if (readback.buffers[index] != VK_NULL_HANDLE || readback.memories[index] != VK_NULL_HANDLE) {@@ -3570,7 +5419,7 @@ index 001f36b..71fee31 100644dfn.vkUnmapMemory(device, new_memory);dfn.vkDestroyBuffer(device, new_buffer, nullptr);dfn.vkFreeMemory(device, new_memory, nullptr);-@@ -4476,6 +4508,10 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -4476,6 +4528,10 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {uint64_t resolve_key = MakeReadbackResolveKey(written_address, written_length);ReadbackBuffer& readback = readback_buffers_[resolve_key];readback.last_used_frame = frame_current_;@@ -3581,7 +5430,7 @@ index 001f36b..71fee31 100644uint32_t write_index = readback.current_index;uint32_t readback_size = AlignReadbackBufferSize(written_length);if (!ensure_readback_slot(readback, write_index, readback_size)) {-@@ -4515,7 +4551,20 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -4515,7 +4571,20 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {}VkBuffer scaled_resolve_buffer = texture_cache_->scaled_resolve_buffer();@@ -3603,7 +5452,7 @@ index 001f36b..71fee31 100644return true;}-@@ -4533,7 +4582,7 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -4533,7 +4602,7 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {}if (resolve_downscale_buffer_ != VK_NULL_HANDLE ||resolve_downscale_buffer_memory_ != VK_NULL_HANDLE) {@@ -3612,7 +5461,7 @@ index 001f36b..71fee31 100644dfn.vkDestroyBuffer(device, new_buffer, nullptr);dfn.vkFreeMemory(device, new_memory, nullptr);return true;-@@ -4561,8 +4610,8 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -4561,8 +4630,8 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {VkDescriptorBufferInfo buffer_infos[2] = {};buffer_infos[0].buffer = scaled_resolve_buffer;@@ -3623,7 +5472,7 @@ index 001f36b..71fee31 100644buffer_infos[1].buffer = resolve_downscale_buffer_;buffer_infos[1].offset = 0;buffer_infos[1].range = written_length;-@@ -4601,7 +4650,7 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -4601,11 +4670,23 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {constants.scale_y = texture_cache_->draw_resolution_scale_y();constants.pixel_size_log2 = pixel_size_log2;constants.tile_count = tile_count;@@ -3632,7 +5481,23 @@ index 001f36b..71fee31 100644constants.half_pixel_offset = (REXCVAR_GET(readback_resolve_half_pixel_offset) &&(constants.scale_x > 1 || constants.scale_y > 1))? 1u-@@ -4649,27 +4698,67 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {+ : 0u;++ // Color render-to-texture copies (player face portraits) are averaged; depth and other formats stay++ // point-sampled, an average of their bits would be meaningless.++ {++ const auto copy_control = register_file_->Get<reg::RB_COPY_CONTROL>();++ const auto dest_format = copy_dest_info.copy_dest_format;++ constants.average = (REXCVAR_GET(readback_resolve_average_color) && pixel_size_log2 == 2 &&++ copy_control.copy_src_select != 4 &&++ (dest_format == xenos::ColorFormat::k_8_8_8_8 ||++ dest_format == xenos::ColorFormat::k_8_8_8_8_A))++ ? 1u++ : 0u;++ }+ deferred_command_buffer_.CmdVkPushConstants(resolve_downscale_pipeline_layout_,+ VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(constants),+ &constants);+@@ -4649,27 +4730,89 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT,VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_HOST_READ_BIT);@@ -3652,9 +5517,33 @@ index 001f36b..71fee31 100644bool is_cache_miss = false;- if (use_delayed_sync && (readback.buffers[read_index] == VK_NULL_HANDLE ||-+ if (use_delayed_sync && (some_decision.sync || readback.buffers[read_index] == VK_NULL_HANDLE ||- written_length > readback.sizes[read_index] ||- readback.mapped_data[read_index] == nullptr)) {+- written_length > readback.sizes[read_index] ||+- readback.mapped_data[read_index] == nullptr)) {++ // Same budget as D3D12: a forced-synchronous range waits at most the budget for the GPU, then uses last++ // frame's copy (the full stall cost about a third of the frame rate).++ const uint32_t sync_budget_us = REXCVAR_GET(vulkan_readback_sync_budget_us);++ bool budget_decided = false;++ if (use_delayed_sync && some_decision.sync && sync_budget_us &&++ readback.buffers[read_index] != VK_NULL_HANDLE && written_length <= readback.sizes[read_index] &&++ readback.mapped_data[read_index] != nullptr) {++ const auto budget_start = std::chrono::steady_clock::now();++ g_resolve_wait_timeout_ns = uint64_t(sync_budget_us) * 1000;++ const bool completed = AwaitAllQueueOperationsCompletion("resolve");++ g_resolve_wait_timeout_ns = UINT64_MAX;++ if (device_lost_) {++ return true;++ }++ if (completed) {++ is_cache_miss = true;++ read_index = write_index;++ }++ NoteReadbackBudget(completed, std::chrono::duration<double, std::micro>(++ std::chrono::steady_clock::now() - budget_start).count());++ budget_decided = true;++ }++ if (!budget_decided && use_delayed_sync &&++ (some_decision.sync || readback.buffers[read_index] == VK_NULL_HANDLE ||++ written_length > readback.sizes[read_index] || readback.mapped_data[read_index] == nullptr)) {is_cache_miss = true;read_index = write_index;- if (!AwaitAllQueueOperationsCompletion()) {@@ -3704,7 +5593,7 @@ index 001f36b..71fee31 100644if (should_copy && readback.buffers[read_index] != VK_NULL_HANDLE &&written_length <= readback.sizes[read_index] && readback.mapped_data[read_index] != nullptr) {VkMappedMemoryRange readback_memory_range = {};-@@ -4682,6 +4771,28 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {+@@ -4682,6 +4825,28 @@ bool VulkanCommandProcessor::IssueCopy_ReadbackResolvePath() {uint8_t* destination = memory_->TranslatePhysical(written_address);if (destination) {std::memcpy(destination, readback.mapped_data[read_index], written_length);@@ -3733,7 +5622,7 @@ index 001f36b..71fee31 100644}}-@@ -4886,7 +4997,7 @@ bool VulkanCommandProcessor::EndGuestOcclusionQuery(uint32_t sample_count_addres+@@ -4886,7 +5051,7 @@ bool VulkanCommandProcessor::EndGuestOcclusionQuery(uint32_t sample_count_addresif (!EndSubmission(false)) {return false;}@@ -3742,7 +5631,7 @@ index 001f36b..71fee31 100644return false;}-@@ -4943,7 +5054,8 @@ void VulkanCommandProcessor::WriteGuestOcclusionResult(uint32_t sample_count_add+@@ -4943,7 +5108,8 @@ void VulkanCommandProcessor::WriteGuestOcclusionResult(uint32_t sample_count_addsample_counts->StencilFail_B = 0;}@@ -3752,7 +5641,7 @@ index 001f36b..71fee31 100644// Only report once, no need to retry a wait that won't succeed anyway.if (device_lost_) {return;-@@ -4951,7 +5063,12 @@ void VulkanCommandProcessor::CheckSubmissionFenceAndDeviceLoss(uint64_t await_su+@@ -4951,7 +5117,12 @@ void VulkanCommandProcessor::CheckSubmissionFenceAndDeviceLoss(uint64_t await_suif (await_submission >= GetCurrentSubmission()) {if (submission_open_) {@@ -3765,7 +5654,7 @@ index 001f36b..71fee31 100644}// A submission won't be ended if it hasn't been started, or if ending// has failed - clamp the index.-@@ -4965,14 +5082,40 @@ void VulkanCommandProcessor::CheckSubmissionFenceAndDeviceLoss(uint64_t await_su+@@ -4965,17 +5136,43 @@ void VulkanCommandProcessor::CheckSubmissionFenceAndDeviceLoss(uint64_t await_susize_t fences_total = submissions_in_flight_fences_.size();size_t fences_awaited = 0;if (await_submission > submission_completed_) {@@ -3804,7 +5693,7 @@ index 001f36b..71fee31 100644+ } while (wait_result == VK_NOT_READY && std::chrono::steady_clock::now() < deadline);+ }+ if (wait_result == VK_NOT_READY) {-+ wait_result = dfn.vkWaitForFences(device, 1, &target_fence, VK_TRUE, UINT64_MAX);++ wait_result = dfn.vkWaitForFences(device, 1, &target_fence, VK_TRUE, g_resolve_wait_timeout_ns);+ }+ }+ if (measure) {@@ -3813,8 +5702,12 @@ index 001f36b..71fee31 100644+ }if (wait_result == VK_SUCCESS) {fences_awaited += await_submission - submission_completed_;- } else {-@@ -5032,11 +5175,35 @@ void VulkanCommandProcessor::CheckSubmissionFenceAndDeviceLoss(uint64_t await_su+- } else {++ } else if (wait_result != VK_TIMEOUT) { // VK_TIMEOUT: budgeted resolve wait, GPU not done yet+ REXGPU_ERROR("Failed to await submission completion Vulkan fences");+ if (wait_result == VK_ERROR_DEVICE_LOST) {+ device_lost_ = true;+@@ -5032,11 +5229,35 @@ void VulkanCommandProcessor::CheckSubmissionFenceAndDeviceLoss(uint64_t await_suif (command_buffer_pair.first > submission_completed_) {break;}@@ -3850,7 +5743,7 @@ index 001f36b..71fee31 100644primitive_processor_->CompletedSubmissionUpdated();-@@ -5111,7 +5278,7 @@ bool VulkanCommandProcessor::BeginSubmission(bool is_guest_command) {+@@ -5111,7 +5332,7 @@ bool VulkanCommandProcessor::BeginSubmission(bool is_guest_command) {// is still available, and whether the await was successful.uint64_t await_submission =is_opening_frame ? closed_frame_submissions_[frame_current_ % kMaxFramesInFlight] : 0;@@ -3859,7 +5752,7 @@ index 001f36b..71fee31 100644if (device_lost_ || submission_completed_ < await_submission) {return false;}-@@ -5284,6 +5451,9 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {+@@ -5284,6 +5505,9 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {if (dfn.vkAllocateCommandBuffers(device, &command_buffer_allocate_info,&command_buffer.buffer) != VK_SUCCESS) {REXGPU_ERROR("Failed to allocate a Vulkan command buffer");@@ -3869,7 +5762,7 @@ index 001f36b..71fee31 100644dfn.vkDestroyCommandPool(device, command_buffer.pool, nullptr);return false;}-@@ -5372,6 +5542,32 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {+@@ -5372,6 +5596,32 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {assert_false(command_buffers_writable_.empty());CommandBuffer command_buffer = command_buffers_writable_.back();@@ -3902,7 +5795,7 @@ index 001f36b..71fee31 100644if (dfn.vkResetCommandPool(device, command_buffer.pool, 0) != VK_SUCCESS) {REXGPU_ERROR("Failed to reset a Vulkan command pool");return false;-@@ -5385,7 +5581,14 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {+@@ -5385,7 +5635,14 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {REXGPU_ERROR("Failed to begin a Vulkan command buffer");return false;}@@ -3917,7 +5810,7 @@ index 001f36b..71fee31 100644if (dfn.vkEndCommandBuffer(command_buffer.buffer) != VK_SUCCESS) {REXGPU_ERROR("Failed to end a Vulkan command buffer");return false;-@@ -5452,7 +5655,7 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {+@@ -5452,7 +5709,7 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {// Submission already closed now, so minus 1.closed_frame_submissions_[(frame_current_++) % kMaxFramesInFlight] = GetCurrentSubmission() - 1;@@ -3926,7 +5819,7 @@ index 001f36b..71fee31 100644cache_clear_requested_ = false;DestroyScratchBuffer();-@@ -5464,6 +5667,9 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {+@@ -5464,6 +5721,9 @@ bool VulkanCommandProcessor::EndSubmission(bool is_swap) {assert_true(command_buffers_submitted_.empty());for (const CommandBuffer& command_buffer : command_buffers_writable_) {@@ -4829,8 +6722,102 @@ index 8b862fc..bc6d50a 100644}if (rex::thread::atomic_inc(&cs->lock_count) != 0) {+diff --git a/src/kernel/xboxkrnl/xboxkrnl_video.cpp b/src/kernel/xboxkrnl/xboxkrnl_video.cpp+index 1254710..fb641aa 100644+--- a/src/kernel/xboxkrnl/xboxkrnl_video.cpp++++ b/src/kernel/xboxkrnl/xboxkrnl_video.cpp+@@ -14,6 +14,10 @@++ #include <algorithm>+ #include <atomic>++#include <chrono>++#include <cstring>++#include <cstdlib>++#include <thread>+ #include <string>++ #include <rex/cvar.h>+@@ -33,6 +37,10 @@+ #include <rex/system/xtypes.h>+ #include <rex/ui/flags.h>+++#if REX_PLATFORM_WIN32++#include <windows.h>++#endif+++ namespace {+ // Display gamma type: 0 - linear, 1 - sRGB (CRT), 2 - BT.709 (HDTV), 3 - power+ constexpr uint32_t kDisplayGammaType = 2;+@@ -437,6 +445,59 @@ u32 VdRetrainEDRAM_entry(u32 unk0, u32 unk1, u32 unk2, u32 unk3, u32 unk4, u32 u+ return 0;+ }+++// True VSync (REX_TRUE_VSYNC=1): hold the game's render thread to the chosen refresh rate at its own++// swap, so the game runs at exactly the display rate. Pacing in the swap callback instead slowed videos/audio.++static void PaceTrueVsyncSwap() {++ using Clock = std::chrono::steady_clock;++ static const double hz = [] {++ const char* on = std::getenv("REX_TRUE_VSYNC");++ if (!on || on[0] != '1') return 0.0;++ // REX_TRUE_VSYNC_FPS: displayed frame rate when it is a divisor of the refresh rate (30 at 60 Hz).++ const char* value = std::getenv("REX_TRUE_VSYNC_FPS");++ if (!value) value = std::getenv("REX_VIDEO_MODE_REFRESH_RATE");++ const double parsed = value ? std::strtod(value, nullptr) : 0.0;++ if (parsed < 20.0 || parsed > 1000.0) return 0.0;++ // Default ("newest"): the game runs on its own clock and each refresh shows its newest frame; the game++ // simulates on a separate thread, so holding rendering to the display made motion uneven. It is only++ // capped at twice the displayed rate so a fresh frame is always ready without wasting power.++ // REX_TRUE_VSYNC_MODE=locked: rendering held to the display (smooth only if the game's clock agrees).++ const char* mode = std::getenv("REX_TRUE_VSYNC_MODE");++ return (mode && std::strcmp(mode, "locked") == 0) ? parsed : -parsed * 2.0;++ }();++ if (hz == 0.0) return;++ const bool locked = hz > 0.0;++ const double rate = locked ? hz : -hz;++#if REX_PLATFORM_WIN32++ // D3D12 publishes its swap chain latency waitable: waiting on it clocks the game by the real display++ // refresh (no drift against a CPU timer, so no skipped or doubled frames). The timer below then only++ // stops the game from outrunning the chosen rate on a faster monitor.++ char handle_text[32];++ const bool display_paced =++ locked && GetEnvironmentVariableA("REX_TRUE_VSYNC_WAITABLE", handle_text, sizeof(handle_text)) > 0;++ if (display_paced) {++ const HANDLE waitable = HANDLE(uintptr_t(std::strtoull(handle_text, nullptr, 16)));++ // Presents that are not game frames (window repaints) also release the semaphore: take every pending++ // release at once (no surplus builds up, so the game never runs ahead of the display and drops frames),++ // and only wait when the display has not taken a frame since the last swap.++ int released = 0;++ while (WaitForSingleObject(waitable, 0) == WAIT_OBJECT_0) ++released;++ if (released == 0) WaitForSingleObject(waitable, 100);++ }++#else++ const bool display_paced = false;++#endif++ static Clock::time_point next{};++ const auto period = std::chrono::duration_cast<Clock::duration>(++ std::chrono::duration<double>(1.0 / (display_paced ? rate * 1.05 : rate)));++ auto now = Clock::now();++ if (next == Clock::time_point{} || now - next > period * 2) next = now; // late or first: no catch-up burst++ if (now < next) {++ if (next - now > std::chrono::milliseconds(2)) std::this_thread::sleep_for(next - now - std::chrono::milliseconds(1));++ while (Clock::now() < next) std::this_thread::yield();++ }++ next += period;++}+++ void VdSwap_entry(mapped_void buffer_ptr, // ptr into primary ringbuffer+ mapped_void fetch_ptr, // frontbuffer Direct3D 9 texture header fetch+ mapped_void unk2, // system writeback ptr+@@ -445,6 +506,7 @@ void VdSwap_entry(mapped_void buffer_ptr, // ptr into primary ringbuffer+ mapped_u32 frontbuffer_ptr, // ptr to frontbuffer address+ mapped_u32 texture_format_ptr, mapped_u32 color_space_ptr, mapped_u32 width,+ mapped_u32 height) {++ PaceTrueVsyncSwap();+ // All of these parameters are REQUIRED.+ assert(buffer_ptr);+ assert(fetch_ptr);diff --git a/src/system/function_dispatcher.cpp b/src/system/function_dispatcher.cpp-index bd43109..c5f952b 100644+index bd43109..8a47e13 100644--- a/src/system/function_dispatcher.cpp+++ b/src/system/function_dispatcher.cpp@@ -13,7 +13,18 @@@@ -4869,7 +6856,7 @@ index bd43109..c5f952b 100644namespace rex::runtime {namespace {-@@ -32,9 +53,123 @@ FunctionDispatcher* GetBoundFunctionDispatcher() {+@@ -32,9 +53,118 @@ FunctionDispatcher* GetBoundFunctionDispatcher() {return runtime ? runtime->function_dispatcher() : nullptr;}@@ -4895,12 +6882,7 @@ index bd43109..c5f952b 100644++void LimitFrameRate() {+ double hz = FrameLimitHz();-+ if (hz <= 0.0 && REXCVAR_QUERY(bool, true_vsync)) {-+ // True VSync: the frame rate is capped at the refresh rate chosen in the launcher.-+ const char* refresh = std::getenv("REX_VIDEO_MODE_REFRESH_RATE");-+ const double parsed = refresh ? std::strtod(refresh, nullptr) : 0.0;-+ if (parsed >= 20.0 && parsed <= 1000.0) hz = parsed;-+ }++ // No automatic cap for True VSync: sleeping in the swap callback slowed videos and audio to slow motion.+ if (hz <= 0.0) return;+ using Clock = std::chrono::steady_clock;+ static Clock::time_point next{};@@ -4993,7 +6975,7 @@ index bd43109..c5f952b 100644REX_FATAL("Call to invalid or unregistered function at guest address 0x{:08X}",ctx.last_indirect_target);}-@@ -61,29 +196,52 @@ bool FunctionDispatcher::Execute(ThreadState* thread_state, uint32_t address) {+@@ -61,29 +191,52 @@ bool FunctionDispatcher::Execute(ThreadState* thread_state, uint32_t address) {SCOPE_profile_cpu_f("cpu");PROFILE_FUNCTION_DISPATCHED();@@ -5055,7 +7037,7 @@ index bd43109..c5f952b 100644return true;}-@@ -130,13 +288,16 @@ uint64_t FunctionDispatcher::Execute(ThreadState* thread_state, uint32_t address+@@ -130,13 +283,16 @@ uint64_t FunctionDispatcher::Execute(ThreadState* thread_state, uint32_t addressuint64_t FunctionDispatcher::ExecuteTrap(ThreadState* thread_state, uint32_t address,uint64_t args[], size_t arg_count) {auto* ctx = thread_state->context();@@ -5078,7 +7060,7 @@ index bd43109..c5f952b 100644}uint64_t FunctionDispatcher::ExecuteInterrupt(ThreadState* thread_state, uint32_t address,-@@ -166,49 +327,77 @@ uint64_t FunctionDispatcher::ExecuteInterrupt(ThreadState* thread_state, uint32_+@@ -166,49 +322,77 @@ uint64_t FunctionDispatcher::ExecuteInterrupt(ThreadState* thread_state, uint32_auto pcr_address = memory_->TranslateVirtual(static_cast<uint32_t>(ctx->r13.u64));uint32_t old_tls_ptr = memory::load_and_swap<uint32_t>(pcr_address);memory::store_and_swap<uint32_t>(pcr_address, 0);@@ -5172,7 +7154,7 @@ index bd43109..c5f952b 100644REXLOG_ERROR("Failed to initialize guest memory function table");return false;}-@@ -226,11 +415,13 @@ bool FunctionDispatcher::InitializeFunctionTable(uint32_t code_base, uint32_t co+@@ -226,11 +410,13 @@ bool FunctionDispatcher::InitializeFunctionTable(uint32_t code_base, uint32_t coentrypoint_code_base_ = code_base;}@@ -5189,7 +7171,7 @@ index bd43109..c5f952b 100644FunctionDispatcher::ModuleTableInfo* FunctionDispatcher::FindModuleByAddress(uint32_t guest_address) {for (auto& mod : module_tables_) {-@@ -253,6 +444,11 @@ bool FunctionDispatcher::SetFunction(uint32_t guest_address, ::PPCFunc* func) {+@@ -253,6 +439,11 @@ bool FunctionDispatcher::SetFunction(uint32_t guest_address, ::PPCFunc* func) {std::lock_guard<std::recursive_mutex> lock(dispatch_mutex_);assert_true(!module_tables_.empty());@@ -5201,7 +7183,7 @@ index bd43109..c5f952b 100644if (!FindModuleByAddress(guest_address)) {REXLOG_ERROR("SetFunction: address {:08X} outside all registered module ranges", guest_address);return false;-@@ -343,6 +539,7 @@ void FunctionDispatcher::RegisterModule(const std::string& module_id, uint32_t c+@@ -343,6 +534,7 @@ void FunctionDispatcher::RegisterModule(const std::string& module_id, uint32_t c} guard{this};register_func(this);@@ -5448,10 +7430,31 @@ index 5bd3dc5..e573a94 100644keybinds.cppmenu_item.cppdiff --git a/src/ui/d3d12/d3d12_presenter.cpp b/src/ui/d3d12/d3d12_presenter.cpp-index 306118e..66febc7 100644+index 306118e..04cce26 100644--- a/src/ui/d3d12/d3d12_presenter.cpp+++ b/src/ui/d3d12/d3d12_presenter.cpp-@@ -33,6 +33,13 @@+@@ -11,7 +11,10 @@++ #include <algorithm>+ #include <climits>++#include <atomic>+ #include <cmath>++#include <thread>++#include <chrono>+ #include <memory>+ #include <utility>++@@ -20,6 +23,9 @@+ #include <rex/logging.h>+ #include <rex/math.h>+ #include <rex/ui/d3d12/d3d12_presenter.h>++++#include <cmath>++#include <vector>+ #include <rex/ui/d3d12/d3d12_provider.h>+ #include <rex/ui/d3d12/d3d12_util.h>+ #include <rex/ui/surface_win.h>+@@ -33,10 +39,19 @@REXCVAR_DEFINE_BOOL(d3d12_allow_variable_refresh_rate_and_tearing, true, "UI/D3D12","Allow variable refresh rate and tearing");@@ -5465,40 +7468,419 @@ index 306118e..66febc7 100644namespace rex::ui::d3d12 {// Generated with `xb buildshaders`.-@@ -408,7 +415,9 @@ D3D12Presenter::ConnectOrReconnectPaintingToSurfaceFromUIThread(Surface& new_sur+ namespace shaders {+++++ #include "ui/shaders/bytecode/d3d12_5_1/guest_output_bilinear_dither_ps.h"+ #include "ui/shaders/bytecode/d3d12_5_1/guest_output_bilinear_ps.h"+ #if defined(REX_HAS_FIDELITYFX_SDK)+@@ -51,6 +66,50 @@ namespace shaders {+ #include "ui/shaders/bytecode/d3d12_5_1/guest_output_triangle_strip_rect_vs.h"+ } // namespace shaders+++namespace {++// True VSync flavour: "newest" (default) lets the game run free and shows its newest frame at each displayed++// refresh; "locked" holds the game to the display in VdSwap (xboxkrnl_video.cpp).++bool TrueVsyncNewest() {++ static const bool newest = [] {++ const char* mode = std::getenv("REX_TRUE_VSYNC_MODE");++ return !(mode && std::strcmp(mode, "locked") == 0);++ }();++ return newest;++}++// True VSync in fullscreen uses DXGI exclusive fullscreen at the chosen refresh rate: with Adaptive Sync /++// FreeSync on, a borderless window covering the monitor made the panel run at its maximum rate (~165 refreshes/s++// with 60 Hz chosen) so frames stayed on screen for 2 or 3 refreshes. REX_TRUE_VSYNC_EXCLUSIVE=0 disables it.++// Set when the display behaves as Adaptive Sync / FreeSync: it refreshes on its own fast grid (~165 Hz) while the++// game shows 60 images, so a refresh-synchronized present lands on that grid (12/18 ms holds = judder). From then++// on, True VSync presents immediately (tearing allowed) at the even clock rate: a VRR display starts a refresh when++// the image arrives, so every image stays exactly one period on screen and nothing tears.++std::atomic<bool> g_true_vsync_vrr{false};++DXGI_MODE_DESC& TrueVsyncExclusiveMode() {++ static DXGI_MODE_DESC mode = {};++ return mode;++}++bool TrueVsyncExclusive() {++ static const bool exclusive = [] {++ const char* fullscreen = std::getenv("REX_FULLSCREEN");++ const char* knob = std::getenv("REX_TRUE_VSYNC_EXCLUSIVE");++ return fullscreen && std::strcmp(fullscreen, "true") == 0 && knob && knob[0] == '1'; // opt-in test knob++ }();++ return exclusive && REXCVAR_QUERY(bool, true_vsync);++}++// Refreshes each displayed image stays on screen: refresh rate / REX_TRUE_VSYNC_FPS (30 at 60 Hz = 2).++UINT TrueVsyncInterval() {++ static const UINT interval = [] {++ const char* refresh_text = std::getenv("REX_VIDEO_MODE_REFRESH_RATE");++ const char* fps_text = std::getenv("REX_TRUE_VSYNC_FPS");++ const double refresh = refresh_text ? std::strtod(refresh_text, nullptr) : 0.0;++ const double fps = fps_text ? std::strtod(fps_text, nullptr) : 0.0;++ if (refresh <= 0.0 || fps <= 0.0) return UINT(1);++ return UINT(std::clamp(std::lround(refresh / fps), 1L, 4L));++ }();++ return interval;++}++} // namespace+++ D3D12Presenter::~D3D12Presenter() {+ // Await completion of the usage of everything before destroying anything.+ // From most likely the latest to most likely the earliest to be signaled, so+@@ -363,7 +422,9 @@ D3D12Presenter::ConnectOrReconnectPaintingToSurfaceFromUIThread(Surface& new_sur+ }+ bool swap_chain_resized = SUCCEEDED(paint_context_.swap_chain->ResizeBuffers(+ 0, UINT(new_swap_chain_width), UINT(new_swap_chain_height), DXGI_FORMAT_UNKNOWN,+- paint_context_.swap_chain_allows_tearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0));++ (paint_context_.swap_chain_allows_tearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0) |++ (paint_context_.swap_chain_latency_waitable++ ? DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT : 0)));+ if (swap_chain_resized) {+ for (uint32_t i = 0; i < PaintContext::kSwapChainBufferCount; ++i) {+ if (FAILED(paint_context_.swap_chain->GetBuffer(+@@ -408,13 +469,20 @@ D3D12Presenter::ConnectOrReconnectPaintingToSurfaceFromUIThread(Surface& new_surswap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;swap_chain_desc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;swap_chain_desc.Flags = 0;- if (REXCVAR_GET(d3d12_allow_variable_refresh_rate_and_tearing) && dxgi_supports_tearing_) {+ if ((REXCVAR_GET(d3d12_allow_variable_refresh_rate_and_tearing) ||-+ REXCVAR_GET(d3d12_paced_present_tearing)) &&++ REXCVAR_GET(d3d12_paced_present_tearing) || REXCVAR_QUERY(bool, true_vsync)) &&+ dxgi_supports_tearing_) {// Allow tearing in borderless fullscreen to support variable refresh// rate.swap_chain_desc.Flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;-@@ -478,7 +487,7 @@ D3D12Presenter::ConnectOrReconnectPaintingToSurfaceFromUIThread(Surface& new_sur+ }++ if (REXCVAR_QUERY(bool, true_vsync)) {++ swap_chain_desc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;++ }+ IDXGIFactory2* dxgi_factory = provider_.GetDXGIFactory();+- ID3D12CommandQueue* direct_queue = provider_.GetDirectQueue();++ ID3D12CommandQueue* direct_queue = paint_context_.present_queue++ ? paint_context_.present_queue.Get()++ : provider_.GetDirectQueue();+ Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain_1;+ switch (surface_type) {+ #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_GAMES)+@@ -450,6 +518,76 @@ D3D12Presenter::ConnectOrReconnectPaintingToSurfaceFromUIThread(Surface& new_sur+ paint_context_.swap_chain_height = new_swap_chain_height;+ paint_context_.swap_chain_allows_tearing =+ (swap_chain_desc.Flags & DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING) != 0;++ if (swap_chain_desc.Flags & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT) {++ paint_context_.swap_chain->SetMaximumFrameLatency(1);++ paint_context_.swap_chain_latency_waitable =++ paint_context_.swap_chain->GetFrameLatencyWaitableObject();++ // VdSwap waits on it so the game is clocked by the display refresh (see xboxkrnl_video.cpp).++ char handle_text[32];++ snprintf(handle_text, sizeof(handle_text), "%llx",++ (unsigned long long)(uintptr_t)paint_context_.swap_chain_latency_waitable);++ SetEnvironmentVariableA("REX_TRUE_VSYNC_WAITABLE", handle_text);++ }++ if (TrueVsyncExclusive()) {++ Microsoft::WRL::ComPtr<IDXGIOutput> output;++ const char* refresh_text = std::getenv("REX_VIDEO_MODE_REFRESH_RATE");++ const UINT refresh = refresh_text ? UINT(std::strtoul(refresh_text, nullptr, 10)) : 0;++ if (refresh && SUCCEEDED(paint_context_.swap_chain->GetContainingOutput(&output))) {++ DXGI_MODE_DESC wanted = {};++ wanted.Width = UINT(new_swap_chain_width);++ wanted.Height = UINT(new_swap_chain_height);++ wanted.RefreshRate = {refresh, 1};++ wanted.Format = kSwapChainFormat;++ // Pick the monitor's own mode with this size and the refresh rate closest to the chosen one.++ DXGI_MODE_DESC mode = {};++ UINT mode_count = 0;++ HRESULT hr = output->GetDisplayModeList(wanted.Format, 0, &mode_count, nullptr);++ std::vector<DXGI_MODE_DESC> modes(mode_count);++ if (SUCCEEDED(hr) && mode_count) hr = output->GetDisplayModeList(wanted.Format, 0, &mode_count, modes.data());++ double best_error = 1e9;++ for (UINT m = 0; SUCCEEDED(hr) && m < mode_count; ++m) {++ const DXGI_MODE_DESC& candidate = modes[m];++ if (candidate.Width != wanted.Width || candidate.Height != wanted.Height || !candidate.RefreshRate.Denominator) {++ continue;++ }++ const double error = std::abs(double(candidate.RefreshRate.Numerator) / candidate.RefreshRate.Denominator -++ double(refresh));++ if (error < best_error) {++ best_error = error;++ mode = candidate;++ }++ }++ if (SUCCEEDED(hr) && best_error > 1.0) hr = DXGI_ERROR_NOT_FOUND;++ // Enter exclusive fullscreen first, then set the mode: ResizeTarget before it only resizes the window.++ // Windows only grants it to the foreground window (DXGI_ERROR_NOT_CURRENTLY_AVAILABLE while the game++ // window is still coming up): bring it to the front and retry for up to 3 s.++ HWND hwnd = nullptr;++ paint_context_.swap_chain->GetHwnd(&hwnd);++ for (int attempt = 0; SUCCEEDED(hr) && attempt < 30; ++attempt) {++ const HRESULT fullscreen_hr = paint_context_.swap_chain->SetFullscreenState(TRUE, output.Get());++ if (fullscreen_hr != DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) {++ hr = fullscreen_hr;++ break;++ }++ hr = fullscreen_hr;++ if (hwnd) SetForegroundWindow(hwnd);++ Sleep(100);++ hr = S_OK;++ if (attempt == 29) hr = fullscreen_hr;++ }++ if (SUCCEEDED(hr)) hr = paint_context_.swap_chain->ResizeTarget(&mode);++ if (SUCCEEDED(hr)) TrueVsyncExclusiveMode() = mode;++ if (SUCCEEDED(hr)) {++ hr = paint_context_.swap_chain->ResizeBuffers(0, UINT(new_swap_chain_width), UINT(new_swap_chain_height),++ DXGI_FORMAT_UNKNOWN, swap_chain_desc.Flags);++ }++ paint_context_.swap_chain_exclusive = SUCCEEDED(hr);++ REXLOG_INFO("D3D12Presenter: True VSync exclusive fullscreen {}x{} @ {:.2f} Hz: {}", mode.Width, mode.Height,++ mode.RefreshRate.Denominator ? double(mode.RefreshRate.Numerator) / mode.RefreshRate.Denominator : 0.0,++ SUCCEEDED(hr) ? "on" : "failed");++ if (FAILED(hr)) REXLOG_WARN("D3D12Presenter: exclusive fullscreen error 0x{:08X} ({} modes)", uint32_t(hr), mode_count);++ }++ }+ for (uint32_t i = 0; i < PaintContext::kSwapChainBufferCount; ++i) {+ if (FAILED(paint_context_.swap_chain->GetBuffer(+ i, IID_PPV_ARGS(&paint_context_.swap_chain_buffers[i])))) {+@@ -478,7 +616,11 @@ D3D12Presenter::ConnectOrReconnectPaintingToSurfaceFromUIThread(Surface& new_surprovider_.OffsetRTVDescriptor(rtv_heap_start, PaintContext::kRTVIndexSwapChainBuffer0 + i));}- is_vsync_implicit_out = false;-+ is_vsync_implicit_out = (REXCVAR_QUERY(bool, vsync) || REXCVAR_QUERY(bool, true_vsync));++ // True VSync presents with interval 0 (no CPU wait), so it must keep painting from the guest output thread.++ // True VSync paints on the UI thread, once per display refresh, the newest guest frame (triple buffering):++ // the GPU thread and the game never wait for the display.++ is_vsync_implicit_out =++ REXCVAR_QUERY(bool, vsync) || (REXCVAR_QUERY(bool, true_vsync) && TrueVsyncNewest());return SurfacePaintConnectResult::kSuccess;}-@@ -1155,9 +1164,11 @@ Presenter::PaintResult D3D12Presenter::PaintAndPresentImpl(bool execute_ui_drawe+@@ -548,13 +690,66 @@ void D3D12Presenter::PaintContext::DestroySwapChain() {+ for (Microsoft::WRL::ComPtr<ID3D12Resource>& swap_chain_buffer_ref : swap_chain_buffers) {+ swap_chain_buffer_ref.Reset();+ }++ if (swap_chain_exclusive) {++ swap_chain->SetFullscreenState(FALSE, nullptr); // a swap chain must leave exclusive fullscreen before release++ swap_chain_exclusive = false;++ }+ swap_chain.Reset();+ swap_chain_allows_tearing = false;++ if (swap_chain_latency_waitable) {++ SetEnvironmentVariableA("REX_TRUE_VSYNC_WAITABLE", nullptr);++ CloseHandle(swap_chain_latency_waitable);++ swap_chain_latency_waitable = nullptr;++ }+ swap_chain_height = 0;+ swap_chain_width = 0;+ }++ Presenter::PaintResult D3D12Presenter::PaintAndPresentImpl(bool execute_ui_drawers) {++ // True VSync: wait (on the UI thread) until the display has taken the previous frame, then paint whatever++ // guest frame is newest at that moment, so each refresh shows the latest image and none is queued stale.++ // Exclusive fullscreen is left on Alt+Tab: take it back once the game window is in front again.++ if (paint_context_.swap_chain_exclusive) {++ static uint32_t paint_count = 0;++ if (++paint_count % 60 == 0) {++ BOOL fullscreen = FALSE;++ HWND hwnd = nullptr;++ paint_context_.swap_chain->GetHwnd(&hwnd);++ if (SUCCEEDED(paint_context_.swap_chain->GetFullscreenState(&fullscreen, nullptr)) && !fullscreen && hwnd &&++ GetForegroundWindow() == hwnd && !IsIconic(hwnd) &&++ SUCCEEDED(paint_context_.swap_chain->SetFullscreenState(TRUE, nullptr))) {++ paint_context_.swap_chain->ResizeTarget(&TrueVsyncExclusiveMode());++ REXLOG_INFO("D3D12Presenter: True VSync exclusive fullscreen restored");++ }++ }++ }++ if (paint_context_.swap_chain_latency_waitable && TrueVsyncNewest()) {++ WaitForSingleObject(paint_context_.swap_chain_latency_waitable, 100);++ // Also present on an even clock at the chosen rate: with Adaptive Sync / FreeSync the display shows each++ // frame as soon as it arrives, so uneven present times (18-23 ms gaps measured) were visible as judder.++ // On a fixed-refresh display the refresh wait above dominates and this changes nothing.++ static const double present_hz = [] {++ const char* refresh_text = std::getenv("REX_VIDEO_MODE_REFRESH_RATE");++ const double refresh = refresh_text ? std::strtod(refresh_text, nullptr) : 0.0;++ return refresh > 0.0 ? refresh / double(TrueVsyncInterval()) : 0.0;++ }();++ if (present_hz > 0.0) {++ using Clock = std::chrono::steady_clock;++ static Clock::time_point next{};++ const auto period = std::chrono::duration_cast<Clock::duration>(std::chrono::duration<double>(1.0 / present_hz));++ auto now = Clock::now();++ if (next == Clock::time_point{} || now - next > period * 2) next = now;++ if (now < next) {++ if (next - now > std::chrono::milliseconds(2)) {++ std::this_thread::sleep_for(next - now - std::chrono::milliseconds(1));++ }++ while (Clock::now() < next) YieldProcessor();++ }++ next += period;++ }++ }++ // True VSync: when the display has not taken the queued frames yet, skip this paint (the next one shows++ // the newest guest frame) instead of waiting; also keeps the back buffer written here off the screen.+ // Begin the command list with the command allocator not currently potentially+ // used on the GPU.+ UINT64 current_paint_submission = paint_context_.paint_submission_tracker.GetCurrentSubmission();+@@ -1142,7 +1337,15 @@ Presenter::PaintResult D3D12Presenter::PaintAndPresentImpl(bool execute_ui_drawe+ // Execute and present.+ command_list->Close();+ ID3D12CommandList* execute_command_list = command_list;+- provider_.GetDirectQueue()->ExecuteCommandLists(1, &execute_command_list);++ if (paint_context_.present_queue) {++ // The guest output was written on the direct queue: paint only after that work is done.++ const UINT64 fence_value = ++paint_context_.present_queue_direct_fence_value;++ provider_.GetDirectQueue()->Signal(paint_context_.present_queue_direct_fence.Get(), fence_value);++ paint_context_.present_queue->Wait(paint_context_.present_queue_direct_fence.Get(), fence_value);++ paint_context_.present_queue->ExecuteCommandLists(1, &execute_command_list);++ } else {++ provider_.GetDirectQueue()->ExecuteCommandLists(1, &execute_command_list);++ }+ if (execute_ui_drawers) {+ ui_submission_tracker_.NextSubmission();+ }+@@ -1155,13 +1358,80 @@ Presenter::PaintResult D3D12Presenter::PaintAndPresentImpl(bool execute_ui_drawe// fullscreen is ever used in, the allow tearing flag must not be passed in// fullscreen, but DXGI fullscreen is largely unneeded with the flip// presentation model used in Direct3D 12).-+ const bool presentation_vsync = (REXCVAR_QUERY(bool, vsync) || REXCVAR_QUERY(bool, true_vsync));- HRESULT present_result = paint_context_.swap_chain->Present(+- HRESULT present_result = paint_context_.swap_chain->Present(- 0, DXGI_PRESENT_RESTART |- (paint_context_.swap_chain_allows_tearing ? DXGI_PRESENT_ALLOW_TEARING : 0));-+ presentation_vsync ? 1 : 0,-+ presentation_vsync ? 0 : (DXGI_PRESENT_RESTART |-+ (paint_context_.swap_chain_allows_tearing ? DXGI_PRESENT_ALLOW_TEARING : 0)));++ // True VSync: sync interval 0 without ALLOW_TEARING on a flip swap chain shows the newest frame at the next++ // refresh without tearing and without blocking the queue (Present(1) blocked it and dropped the game to 1-3 FPS).++ // True VSync presents with sync interval 1 on its own present queue: every frame is shown exactly once++ // (interval 0 discarded about one frame per second = visible jumps), and the refresh wait stays on that queue.++ const bool presentation_vsync =++ REXCVAR_QUERY(bool, true_vsync) ? paint_context_.present_queue != nullptr : REXCVAR_QUERY(bool, vsync);++ const bool vrr_present = REXCVAR_QUERY(bool, true_vsync) && paint_context_.swap_chain_allows_tearing &&++ !paint_context_.swap_chain_exclusive && g_true_vsync_vrr.load(std::memory_order_relaxed);++ const bool allow_tearing =++ paint_context_.swap_chain_allows_tearing && (!REXCVAR_QUERY(bool, true_vsync) || vrr_present);++ HRESULT present_result = vrr_present++ ? paint_context_.swap_chain->Present(0, DXGI_PRESENT_ALLOW_TEARING)++ : paint_context_.swap_chain->Present(++ presentation_vsync ? (REXCVAR_QUERY(bool, true_vsync) ? TrueVsyncInterval() : 1) : 0,++ presentation_vsync ? 0 : (DXGI_PRESENT_RESTART | (allow_tearing ? DXGI_PRESENT_ALLOW_TEARING : 0)));// Even if presentation has failed, work might have been enqueued anyway// internally before the failure according to Jesse Natalie from the DirectX// Discord server.+ paint_context_.present_submission_tracker.NextSubmission();++ if (FAILED(present_result)) {++ REXLOG_ERROR("D3D12Presenter: Present failed with 0x{:08X} (true_vsync={}, interval={})",++ uint32_t(present_result), REXCVAR_QUERY(bool, true_vsync), TrueVsyncInterval());++ }++ if (REXCVAR_QUERY(bool, true_vsync)) {++ // Diagnostics: what the display really showed, once per second. "refreshes" = vblanks that passed,++ // "shown" = new images flipped on screen, "repeats" = refreshes that showed an old image again (stutter).++ static uint64_t window_start_ms = 0, presents = 0, stats_fail = 0;++ static UINT first_present_count = 0, first_refresh_count = 0;++ static bool have_first = false;++ static uint64_t last_qpc_shown = 0, max_gap_us = 0;++ static UINT last_present_count = 0;++ ++presents;++ DXGI_FRAME_STATISTICS st = {};++ LARGE_INTEGER freq;++ QueryPerformanceFrequency(&freq);++ if (SUCCEEDED(paint_context_.swap_chain->GetFrameStatistics(&st))) {++ if (!have_first) {++ first_present_count = st.PresentCount;++ first_refresh_count = st.SyncRefreshCount;++ have_first = true;++ }++ if (st.PresentCount != last_present_count) {++ const uint64_t qpc = uint64_t(st.SyncQPCTime.QuadPart);++ if (last_qpc_shown && qpc > last_qpc_shown) {++ max_gap_us = std::max(max_gap_us, (qpc - last_qpc_shown) * 1000000ull / uint64_t(freq.QuadPart));++ }++ last_qpc_shown = qpc;++ last_present_count = st.PresentCount;++ }++ } else {++ ++stats_fail;++ }++ const uint64_t now_ms = GetTickCount64();++ if (!window_start_ms) window_start_ms = now_ms;++ if (now_ms - window_start_ms >= 1000) {++ const UINT shown = have_first ? st.PresentCount - first_present_count : 0;++ const UINT refreshes = have_first ? st.SyncRefreshCount - first_refresh_count : 0;++ REXLOG_INFO("TrueVsyncDisplay: presents={} refreshes={} shown={} repeats={} max_gap_ms={:.1f} stats_fail={} vrr={}",++ presents, refreshes, shown, refreshes > shown ? refreshes - shown : 0,++ double(max_gap_us) / 1000.0, stats_fail, g_true_vsync_vrr.load());++ // Two windows in a row where the display refreshed far more often than it got images, none lost:++ // Adaptive Sync / FreeSync grid (see g_true_vsync_vrr).++ static int vrr_windows = 0;++ const bool vrr_like = presents >= 20 && stats_fail == 0 && shown + 2 >= presents &&++ refreshes * 2 >= shown * 3;++ vrr_windows = vrr_like ? vrr_windows + 1 : 0;++ if (vrr_windows >= 2 && !g_true_vsync_vrr.exchange(true)) {++ REXLOG_INFO("True VSync: Adaptive Sync / FreeSync display detected, presenting on the even clock");++ }++ window_start_ms = now_ms;++ presents = stats_fail = max_gap_us = 0;++ have_first = false;++ }++ }+ switch (present_result) {+ case DXGI_ERROR_DEVICE_REMOVED:+ return PaintResult::kGpuLostExternally;+@@ -1442,6 +1712,20 @@ bool D3D12Presenter::InitializeSurfaceIndependent() {+ // Initialize connection-independent parts of the painting context.++ ID3D12CommandQueue* direct_queue = provider_.GetDirectQueue();++ if (REXCVAR_QUERY(bool, true_vsync)) {++ D3D12_COMMAND_QUEUE_DESC present_queue_desc = {};++ present_queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;++ if (SUCCEEDED(device->CreateCommandQueue(&present_queue_desc,++ IID_PPV_ARGS(&paint_context_.present_queue))) &&++ SUCCEEDED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE,++ IID_PPV_ARGS(&paint_context_.present_queue_direct_fence)))) {++ direct_queue = paint_context_.present_queue.Get();++ REXLOG_INFO("D3D12Presenter: True VSync uses a separate presentation queue");++ } else {++ paint_context_.present_queue.Reset();++ paint_context_.present_queue_direct_fence.Reset();++ }++ }++ // Paint submission trackers.+ if (!paint_context_.paint_submission_tracker.Initialize(device, direct_queue) ||+@@ -1501,7 +1785,7 @@ bool D3D12Presenter::InitializeSurfaceIndependent() {+ return false;+ }++- if (!guest_output_resource_refresher_submission_tracker_.Initialize(device, direct_queue)) {++ if (!guest_output_resource_refresher_submission_tracker_.Initialize(device, provider_.GetDirectQueue())) {+ return false;+ }++diff --git a/src/ui/d3d12/d3d12_provider.cpp b/src/ui/d3d12/d3d12_provider.cpp+index bf8252b..8175193 100644+--- a/src/ui/d3d12/d3d12_provider.cpp++++ b/src/ui/d3d12/d3d12_provider.cpp+@@ -19,6 +19,7 @@+ #include <rex/ui/d3d12/d3d12_provider.h>++ #include <malloc.h>++#include <wrl/client.h>++ REXCVAR_DEFINE_BOOL(d3d12_debug, false, "UI/D3D12", "Enable Direct3D 12 and DXGI debug layer")+ .lifecycle(rex::cvar::Lifecycle::kInitOnly);+@@ -351,6 +352,21 @@ bool D3D12Provider::Initialize() {+ if (REXCVAR_GET(d3d12_break_on_warning)) {+ d3d12_info_queue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_WARNING, TRUE);+ }++ // With the debug layer on, write its warnings and errors to the game log (no debugger needed).++ Microsoft::WRL::ComPtr<ID3D12InfoQueue1> d3d12_info_queue_1;++ if (debug && SUCCEEDED(d3d12_info_queue->QueryInterface(IID_PPV_ARGS(&d3d12_info_queue_1)))) {++ DWORD cookie = 0;++ d3d12_info_queue_1->RegisterMessageCallback(++ [](D3D12_MESSAGE_CATEGORY, D3D12_MESSAGE_SEVERITY severity, D3D12_MESSAGE_ID id,++ LPCSTR description, void*) {++ if (severity <= D3D12_MESSAGE_SEVERITY_WARNING) {++ REXLOG_ERROR("D3D12 debug layer (severity {}, id {}): {}", int(severity), int(id),++ description ? description : "");++ }++ },++ D3D12_MESSAGE_CALLBACK_FLAG_NONE, nullptr, &cookie);++ REXLOG_INFO("D3D12 debug layer messages are written to this log");++ }+ d3d12_info_queue->Release();+ }+diff --git a/src/ui/game_ui_fonts.cpp b/src/ui/game_ui_fonts.cppnew file mode 100644index 0000000..e637829@@ -5740,10 +8122,10 @@ index 9822f3b..604936b 100644for (auto& entry : g_binds) {if (!entry.callback)diff --git a/src/ui/overlay/debug_overlay.cpp b/src/ui/overlay/debug_overlay.cpp-index 43d6c06..5a24828 100644+index 43d6c06..f133df8 100644--- a/src/ui/overlay/debug_overlay.cpp+++ b/src/ui/overlay/debug_overlay.cpp-@@ -10,8 +10,11 @@+@@ -10,8 +10,13 @@* See LICENSE file in the project root for full license text.*/#include <rex/ui/overlay/debug_overlay.h>@@ -5751,11 +8133,13 @@ index 43d6c06..5a24828 100644#include <rex/version.h>#include <imgui.h>+#include <algorithm>++#include <chrono>+#include <cstdio>++#include <cstdlib>#ifdef REXGLUE_ENABLE_PERF_COUNTERS#include <rex/perf/counter.h>#include <cinttypes>-@@ -25,84 +28,82 @@ DebugOverlayDialog::DebugOverlayDialog(ImGuiDrawer* imgui_drawer, FrameStatsProv+@@ -25,84 +30,102 @@ DebugOverlayDialog::DebugOverlayDialog(ImGuiDrawer* imgui_drawer, FrameStatsProvDebugOverlayDialog::~DebugOverlayDialog() {}void DebugOverlayDialog::OnDraw(ImGuiIO& io) {@@ -5768,7 +8152,20 @@ index 43d6c06..5a24828 100644- ImGui::SetNextWindowSize(ImVec2(280, 280), ImGuiCond_FirstUseEver);-#else- ImGui::SetNextWindowSize(ImVec2(220, 60), ImGuiCond_FirstUseEver);--#endif++ // Recent average over the last guest frames (same source the old statistics panel used).++ const auto frame_time_us = rex::perf::GetSnapshotCounter(rex::perf::CounterId::kFrameTimeUs);++ const float frame_time_ms = static_cast<float>(frame_time_us) / 1000.0f;++ const auto guest_frame = rex::perf::GetSnapshotCounter(rex::perf::CounterId::kFrameNumber);++ if (guest_frame != last_guest_frame_ && frame_time_ms > 0.0f) {++ last_guest_frame_ = guest_frame;++ frame_time_history_[frame_history_idx_] = frame_time_ms;++ frame_history_idx_ = (frame_history_idx_ + 1) % kFrameHistorySize;++ frame_history_count_ = std::min(frame_history_count_ + 1, kFrameHistorySize);++ }++ float total_ms = 0.0f;++ for (size_t i = 0; i < frame_history_count_; ++i) total_ms += frame_time_history_[i];++ if (total_ms > 0.0f) fps = 1000.0 * frame_history_count_ / total_ms;+ #endif- ImGui::SetNextWindowBgAlpha(0.5f);- if (ImGui::Begin("Debug##overlay", nullptr, ImGuiWindowFlags_NoCollapse)) {- if (stats_provider_) {@@ -5776,7 +8173,24 @@ index 43d6c06..5a24828 100644- if (stats.frame_count > 0) {- ImGui::Text("Guest: %.1f FPS (%.2f ms)", stats.fps, stats.frame_time_ms);- }-- }++ // True VSync: the game renders more images than the display shows; count displayed ones (this overlay is++ // drawn once per displayed image), the same number GPU driver overlays (AMD, NVIDIA) report.++ static const bool true_vsync = [] {++ const char* on = std::getenv("REX_TRUE_VSYNC");++ return on && on[0] == '1';++ }();++ if (true_vsync) {++ using Clock = std::chrono::steady_clock;++ static Clock::time_point window_start = Clock::now();++ static uint32_t draws = 0;++ static double shown_fps = 0.0;++ ++draws;++ const double elapsed = std::chrono::duration<double>(Clock::now() - window_start).count();++ if (elapsed >= 0.5) {++ shown_fps = draws / elapsed;++ draws = 0;++ window_start = Clock::now();+ }-#ifdef REXGLUE_ENABLE_PERF_COUNTERS- ImGui::Separator();-@@ -5784,14 +8198,7 @@ index 43d6c06..5a24828 100644- auto ft_us = rex::perf::GetSnapshotCounter(rex::perf::CounterId::kFrameTimeUs);- float ft_ms = static_cast<float>(ft_us) / 1000.0f;- frame_time_history_[frame_history_idx_] = ft_ms;-+ // Recent average over the last guest frames (same source the old statistics panel used).-+ const auto frame_time_us = rex::perf::GetSnapshotCounter(rex::perf::CounterId::kFrameTimeUs);-+ const float frame_time_ms = static_cast<float>(frame_time_us) / 1000.0f;-+ const auto guest_frame = rex::perf::GetSnapshotCounter(rex::perf::CounterId::kFrameNumber);-+ if (guest_frame != last_guest_frame_ && frame_time_ms > 0.0f) {-+ last_guest_frame_ = guest_frame;-+ frame_time_history_[frame_history_idx_] = frame_time_ms;- frame_history_idx_ = (frame_history_idx_ + 1) % kFrameHistorySize;+- frame_history_idx_ = (frame_history_idx_ + 1) % kFrameHistorySize;- ImGui::PlotLines("##ft", frame_time_history_.data(), kFrameHistorySize,- static_cast<int>(frame_history_idx_), "Frame (ms)", 0.0f, 50.0f,- ImVec2(200, 40));@@ -5814,12 +8221,8 @@ index 43d6c06..5a24828 100644- ImGui::Text("Dispatch: %" PRId64 " IRQ: %" PRId64,- rex::perf::GetSnapshotCounter(rex::perf::CounterId::kFunctionsDispatched),- rex::perf::GetSnapshotCounter(rex::perf::CounterId::kInterruptDispatches));-+ frame_history_count_ = std::min(frame_history_count_ + 1, kFrameHistorySize);++ fps = shown_fps;+ }-+ float total_ms = 0.0f;-+ for (size_t i = 0; i < frame_history_count_; ++i) total_ms += frame_time_history_[i];-+ if (total_ms > 0.0f) fps = 1000.0 * frame_history_count_ / total_ms;-+#endif+ if (fps <= 0.0 && stats_provider_) {+ const auto stats = stats_provider_();+ if (stats.frame_count > 0) fps = stats.fps;@@ -6021,10 +8424,10 @@ index b94fe9e..756b89a 100644debug_overlay_.reset();} else {diff --git a/src/ui/vulkan/vulkan_presenter.cpp b/src/ui/vulkan/vulkan_presenter.cpp-index 23645ef..1dc0ba8 100644+index 23645ef..39ddbfe 100644--- a/src/ui/vulkan/vulkan_presenter.cpp+++ b/src/ui/vulkan/vulkan_presenter.cpp-@@ -11,6 +11,8 @@+@@ -11,12 +11,16 @@#include <algorithm>#include <atomic>@@ -6033,7 +8436,15 @@ index 23645ef..1dc0ba8 100644#include <cstddef>#include <cstdint>#include <cmath>-@@ -58,10 +60,101 @@ REXCVAR_DEFINE_BOOL(vulkan_allow_present_mode_mailbox, true, "UI/Vulkan",+ #include <cstring>+ #include <memory>+ #include <utility>++#include <thread>++#include <cstdlib>+ #include <vector>++ #include <rex/assert.h>+@@ -58,10 +62,101 @@ REXCVAR_DEFINE_BOOL(vulkan_allow_present_mode_mailbox, true, "UI/Vulkan",REXCVAR_DEFINE_BOOL(vulkan_allow_present_mode_fifo_relaxed, true, "UI/Vulkan","Allow FIFO relaxed present mode");@@ -6135,7 +8546,7 @@ index 23645ef..1dc0ba8 100644#if defined(REX_HAS_FIDELITYFX_RUNTIME) && REX_HAS_FIDELITYFX_RUNTIMEnamespace {-@@ -129,12 +222,12 @@ VulkanPresenter::PaintContext::Submission::~Submission() {+@@ -129,12 +224,12 @@ VulkanPresenter::PaintContext::Submission::~Submission() {dfn.vkDestroyCommandPool(device, draw_command_pool_, nullptr);}@@ -6151,7 +8562,7 @@ index 23645ef..1dc0ba8 100644}bool VulkanPresenter::PaintContext::Submission::Initialize() {-@@ -152,11 +245,11 @@ bool VulkanPresenter::PaintContext::Submission::Initialize() {+@@ -152,11 +247,11 @@ bool VulkanPresenter::PaintContext::Submission::Initialize() {"semaphore");return false;}@@ -6168,7 +8579,7 @@ index 23645ef..1dc0ba8 100644return false;}-@@ -988,6 +1081,21 @@ VulkanPresenter::ConnectOrReconnectPaintingToSurfaceFromUIThread(Surface& new_su+@@ -988,6 +1083,21 @@ VulkanPresenter::ConnectOrReconnectPaintingToSurfaceFromUIThread(Surface& new_sureturn SurfacePaintConnectResult::kFailure;}@@ -6190,7 +8601,7 @@ index 23645ef..1dc0ba8 100644// Create the image views and the framebuffers.assert_true(paint_context_.swapchain_framebuffers.empty());paint_context_.swapchain_framebuffers.reserve(paint_context_.swapchain_images.size());-@@ -1061,7 +1169,7 @@ bool VulkanPresenter::RefreshGuestOutputImpl(+@@ -1061,7 +1171,7 @@ bool VulkanPresenter::RefreshGuestOutputImpl(if (image_instance.image && (image_instance.image->extent().width != frontbuffer_width ||image_instance.image->extent().height != frontbuffer_height)) {guest_output_image_refresher_submission_tracker_.AwaitSubmissionCompletion(@@ -6199,13 +8610,18 @@ index 23645ef..1dc0ba8 100644image_instance.image.reset();}if (!image_instance.image) {-@@ -1381,19 +1489,20 @@ VkSwapchainKHR VulkanPresenter::PaintContext::CreateSwapchainForVulkanSurface(+@@ -1381,19 +1491,25 @@ VkSwapchainKHR VulkanPresenter::PaintContext::CreateSwapchainForVulkanSurface(// interfering with GPU command processing, and also to allow tearing so// variable refresh rate may be used where it's available.// Note: If the priorities here are changes, update the cvar descriptions.- if (REXCVAR_GET(vulkan_allow_present_mode_immediate) &&+ const bool presentation_vsync = (REXCVAR_QUERY(bool, vsync) || REXCVAR_QUERY(bool, true_vsync));-+ if (!presentation_vsync && REXCVAR_GET(vulkan_allow_present_mode_immediate) &&++ if (REXCVAR_QUERY(bool, true_vsync)) {++ // True VSync (same as D3D12): FIFO makes painting move to the UI thread (implicit vsync), which waits++ // for each refresh and then shows the newest guest frame; the game and the GPU thread never wait, and++ // the FPS overlay counts exactly the displayed frames. FIFO exists on every Vulkan driver.++ swapchain_create_info.presentMode = VK_PRESENT_MODE_FIFO_KHR;++ } else if (!presentation_vsync && REXCVAR_GET(vulkan_allow_present_mode_immediate) &&std::find(present_modes.cbegin(), present_modes.cend(), VK_PRESENT_MODE_IMMEDIATE_KHR) !=present_modes.cend()) {// Allowing tearing to reduce latency, and possibly variable refresh rate@@ -6223,7 +8639,7 @@ index 23645ef..1dc0ba8 100644std::find(present_modes.cbegin(), present_modes.cend(),VK_PRESENT_MODE_FIFO_RELAXED_KHR) != present_modes.cend()) {// Limiting the frame rate, but lets too long frames cause tearing not to-@@ -1428,6 +1537,13 @@ VkSwapchainKHR VulkanPresenter::PaintContext::CreateSwapchainForVulkanSurface(+@@ -1428,6 +1544,13 @@ VkSwapchainKHR VulkanPresenter::PaintContext::CreateSwapchainForVulkanSurface(VkSwapchainKHR VulkanPresenter::PaintContext::PrepareForSwapchainRetirement() {if (swapchain != VK_NULL_HANDLE) {submission_tracker.AwaitAllSubmissionsCompletion();@@ -6237,7 +8653,7 @@ index 23645ef..1dc0ba8 100644}const VulkanDevice::Functions& dfn = vulkan_device->functions();const VkDevice device = vulkan_device->device();-@@ -1436,6 +1552,12 @@ VkSwapchainKHR VulkanPresenter::PaintContext::PrepareForSwapchainRetirement() {+@@ -1436,6 +1559,12 @@ VkSwapchainKHR VulkanPresenter::PaintContext::PrepareForSwapchainRetirement() {dfn.vkDestroyImageView(device, framebuffer.image_view, nullptr);}swapchain_framebuffers.clear();@@ -6250,15 +8666,37 @@ index 23645ef..1dc0ba8 100644swapchain_images.clear();swapchain_extent.width = 0;swapchain_extent.height = 0;-@@ -1529,6 +1651,7 @@ bool VulkanPresenter::GuestOutputImage::Initialize() {+@@ -1529,6 +1658,29 @@ bool VulkanPresenter::GuestOutputImage::Initialize() {}Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_drawers) {++ // True VSync (same as D3D12): present on an even clock at the chosen rate. With Adaptive Sync / FreeSync the++ // display shows each image when it arrives, so uneven present times were visible as judder (99% low ~55).++ if (REXCVAR_QUERY(bool, true_vsync)) {++ static const double present_hz = [] {++ const char* refresh_text = std::getenv("REX_VIDEO_MODE_REFRESH_RATE");++ return refresh_text ? std::strtod(refresh_text, nullptr) : 0.0;++ }();++ if (present_hz > 0.0) {++ using Clock = std::chrono::steady_clock;++ static Clock::time_point next{};++ const auto period = std::chrono::duration_cast<Clock::duration>(std::chrono::duration<double>(1.0 / present_hz));++ auto now = Clock::now();++ if (next == Clock::time_point{} || now - next > period * 2) next = now;++ if (now < next) {++ if (next - now > std::chrono::milliseconds(2)) {++ std::this_thread::sleep_for(next - now - std::chrono::milliseconds(1));++ }++ while (Clock::now() < next) std::this_thread::yield();++ }++ next += period;++ }++ }+ PresentTiming timing;// Begin the submission in place of the one not currently potentially used on// the GPU.uint64_t current_paint_submission_index =-@@ -1536,8 +1659,9 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw+@@ -1536,8 +1688,9 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_drawuint64_t paint_submission_count = uint64_t(paint_context_.submissions.size());if (current_paint_submission_index >= paint_submission_count) {paint_context_.submission_tracker.AwaitSubmissionCompletion(current_paint_submission_index -@@ -6269,7 +8707,7 @@ index 23645ef..1dc0ba8 100644const PaintContext::Submission& paint_submission =*paint_context_.submissions[current_paint_submission_index % paint_submission_count];-@@ -1568,11 +1692,27 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw+@@ -1568,11 +1721,27 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw// safe to return early from this function in case of an error.VkSemaphore acquire_semaphore = paint_submission.acquire_semaphore();@@ -6299,7 +8737,7 @@ index 23645ef..1dc0ba8 100644case VK_SUCCESS:case VK_SUBOPTIMAL_KHR:break;-@@ -1595,6 +1735,18 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw+@@ -1595,6 +1764,18 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_drawreturn PaintResult::kNotPresented;}@@ -6318,7 +8756,7 @@ index 23645ef..1dc0ba8 100644// Non-zero extents needed for both the viewport (width must not be zero) and// the guest output rectangle.assert_not_zero(paint_context_.swapchain_extent.width);-@@ -1688,7 +1840,7 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw+@@ -1688,7 +1869,7 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw// its descriptors.paint_context_.submission_tracker.AwaitSubmissionCompletion(paint_context_.guest_output_image_paint_refs[guest_output_image_paint_ref_new_index]@@ -6327,7 +8765,7 @@ index 23645ef..1dc0ba8 100644}guest_output_image_paint_ref_index = guest_output_image_paint_ref_new_index;// The actual submission index will be set if the image is actually-@@ -1736,7 +1888,8 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw+@@ -1736,7 +1917,8 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw// size is needed.if (intermediate_image_ptr_ref) {paint_context_.submission_tracker.AwaitSubmissionCompletion(@@ -6337,7 +8775,7 @@ index 23645ef..1dc0ba8 100644intermediate_image_ptr_ref.reset();util::DestroyAndNullHandle(dfn.vkDestroyFramebuffer, device,paint_context_.guest_output_intermediate_framebuffers[i]);-@@ -1829,7 +1982,8 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw+@@ -1829,7 +2011,8 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_drawswapchain_effect_pipeline.swapchain_format !=paint_context_.swapchain_render_pass_format) {paint_context_.submission_tracker.AwaitSubmissionCompletion(@@ -6347,7 +8785,7 @@ index 23645ef..1dc0ba8 100644util::DestroyAndNullHandle(dfn.vkDestroyPipeline, device,swapchain_effect_pipeline.swapchain_pipeline);}-@@ -1840,6 +1994,9 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw+@@ -1840,6 +2023,9 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_drawswapchain_effect, paint_context_.swapchain_render_pass);if (swapchain_effect_pipeline.swapchain_pipeline == VK_NULL_HANDLE) {guest_output_flow.effect_count = 0;@@ -6357,7 +8795,7 @@ index 23645ef..1dc0ba8 100644}}}-@@ -2174,7 +2331,9 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw+@@ -2174,7 +2360,9 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_drawpaint_context_.ui_setup_command_buffer_current_index = SIZE_MAX;}command_buffers[command_buffer_count++] = draw_command_buffer;@@ -6368,7 +8806,7 @@ index 23645ef..1dc0ba8 100644VkSubmitInfo submit_info;submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;submit_info.pNext = nullptr;-@@ -2227,6 +2386,7 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw+@@ -2227,6 +2415,7 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw}}@@ -6376,7 +8814,7 @@ index 23645ef..1dc0ba8 100644VkPresentInfoKHR present_info;present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;present_info.pNext = nullptr;-@@ -2242,6 +2402,10 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_draw+@@ -2242,6 +2431,10 @@ Presenter::PaintResult VulkanPresenter::PaintAndPresentImpl(bool execute_ui_drawvulkan_device_->AcquireQueue(paint_context_.present_queue_family, 0);present_result = dfn.vkQueuePresentKHR(queue_acquisition.queue(), &present_info);}@@ -6433,10 +8871,20 @@ index 07a07b2..610c9b0 100644}}diff --git a/src/ui/window_sdl.cpp b/src/ui/window_sdl.cpp-index 2251429..29b1e8b 100644+index 2251429..c813d31 100644--- a/src/ui/window_sdl.cpp+++ b/src/ui/window_sdl.cpp-@@ -40,6 +40,9 @@+@@ -15,7 +15,9 @@++ #include <algorithm>+ #include <cmath>++#include <cstdlib>+ #include <cstring>++#include <string>+ #include <filesystem>++ #define UTF_CPP_CPLUSPLUS 201703L // -fno-char8_t+@@ -40,8 +42,116 @@#include <rex/ui/surface_gnulinux.h>#endif@@ -6445,8 +8893,115 @@ index 2251429..29b1e8b 100644+namespace rex::ui {++namespace {++// True VSync (REX_TRUE_VSYNC=1) needs the desktop compositor to show the frames: with a window exactly covering++// the monitor, Windows lets the game flip straight to the display, and with FreeSync/VRR the panel then runs at++// its maximum rate instead of the chosen one (60 Hz chosen, ~162 refreshes/s measured), so frames stay on screen++// for 2 or 3 refreshes. A borderless window one pixel taller than the monitor looks the same but stays composed.++// Test knob REX_TRUE_VSYNC_COMPOSE: taller (default) | overlay | both | none.++const char* ComposeMode() {++ const char* mode = std::getenv("REX_TRUE_VSYNC_COMPOSE");++ return mode ? mode : "none"; // D3D12 uses exclusive fullscreen instead (d3d12_presenter.cpp)++}++++#if REX_PLATFORM_WIN32++// A 1x1, almost transparent, click-through window above the game: Windows cannot flip the game straight to the++// display while another window covers part of it, so the desktop compositor keeps presenting it.++void PlaceCompositionGuard(SDL_Window* window, const SDL_Rect& bounds) {++ static HWND guard = nullptr;++ HWND owner = HWND(SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER,++ nullptr));++ if (!guard) {++ guard = CreateWindowExW(WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE,++ L"STATIC", L"", WS_POPUP, bounds.x, bounds.y, 1, 1, owner, nullptr, nullptr, nullptr);++ if (guard) SetLayeredWindowAttributes(guard, 0, 1, LWA_ALPHA);++ }++ if (guard) {++ SetWindowPos(guard, HWND_TOPMOST, bounds.x, bounds.y, 1, 1, SWP_NOACTIVATE | SWP_SHOWWINDOW);++ }++ REXLOG_INFO("True VSync: composition guard window {}", guard ? "placed" : "failed");++}++#endif++++bool UseComposedFullscreen() {++ static const bool composed = [] {++ const char* on = std::getenv("REX_TRUE_VSYNC");++ return on && on[0] == '1';++ }();++ return composed;++}++++void SetWindowFullscreenState(SDL_Window* window, bool fullscreen) {++ static SDL_Rect windowed_rect{};++ static bool composed_active = false;++ if (!UseComposedFullscreen()) {++ SDL_SetWindowFullscreen(window, fullscreen);++ return;++ }++ SDL_Rect bounds{};++ if (fullscreen) {++ if (!SDL_GetDisplayBounds(SDL_GetDisplayForWindow(window), &bounds)) {++ SDL_SetWindowFullscreen(window, true);++ return;++ }++ if (!composed_active) {++ SDL_GetWindowPosition(window, &windowed_rect.x, &windowed_rect.y);++ SDL_GetWindowSize(window, &windowed_rect.w, &windowed_rect.h);++ }++ const std::string mode = ComposeMode();++ if (mode == "none") {++ SDL_SetWindowFullscreen(window, true);++ return;++ }++ if (mode == "overlay" || mode == "region" || mode == "layered") {++ SDL_SetWindowFullscreen(window, true);++ } else {++ SDL_SetWindowFullscreen(window, false);++ SDL_SetWindowBordered(window, false);++ SDL_SetWindowSize(window, bounds.w, bounds.h + 1);++ SDL_SetWindowPosition(window, bounds.x, bounds.y);++ }++#if REX_PLATFORM_WIN32++ if (mode == "overlay" || mode == "both") PlaceCompositionGuard(window, bounds);++ HWND hwnd = HWND(SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER,++ nullptr));++ if (hwnd && mode == "region") {++ // Clip one corner pixel off the window: its visible area no longer covers the whole monitor.++ int cw = 0, ch = 0;++ SDL_GetWindowSize(window, &cw, &ch);++ HRGN full = CreateRectRgn(0, 0, cw, ch);++ HRGN corner = CreateRectRgn(cw - 1, ch - 1, cw, ch);++ CombineRgn(full, full, corner, RGN_DIFF);++ DeleteObject(corner);++ SetWindowRgn(hwnd, full, TRUE); // the system owns the region now++ }++ if (hwnd && mode == "layered") {++ SetWindowLongW(hwnd, GWL_EXSTYLE, GetWindowLongW(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);++ SetLayeredWindowAttributes(hwnd, 0, 255, LWA_ALPHA);++ }++#endif++ int ww = 0, wh = 0;++ SDL_GetWindowSize(window, &ww, &wh);++ REXLOG_INFO("True VSync fullscreen ({}): display {}x{}, window {}x{}", mode, bounds.w, bounds.h, ww, wh);++ composed_active = true;++ } else {++ SDL_SetWindowFullscreen(window, false);++ if (composed_active) {++ SDL_SetWindowBordered(window, true);++ if (windowed_rect.w > 0 && windowed_rect.h > 0) {++ SDL_SetWindowSize(window, windowed_rect.w, windowed_rect.h);++ SDL_SetWindowPosition(window, windowed_rect.x, windowed_rect.y);++ }++ composed_active = false;++ }++ }++}++} // namespace++namespace {-@@ -170,6 +173,34 @@ bool WindowSDL::OpenImpl() {++ uint32_t ResolveWindowWidth(uint32_t requested_width) {+@@ -170,9 +280,37 @@ bool WindowSDL::OpenImpl() {}}@@ -6480,8 +9035,31 @@ index 2251429..29b1e8b 100644+if (IsFullscreen()) {// Borderless desktop fullscreen (a NULL display mode is SDL3's default).- SDL_SetWindowFullscreen(sdl_window_, true);-@@ -484,11 +515,28 @@ void WindowSDL::HandleWindowEvent(SDL_Event& event) {+- SDL_SetWindowFullscreen(sdl_window_, true);++ SetWindowFullscreenState(sdl_window_, true);+ }+ #if REX_PLATFORM_MAC+ CFPreferencesSetAppValue(CFSTR("ApplePressAndHoldEnabled"), kCFBooleanFalse,+@@ -295,7 +433,7 @@ void WindowSDL::ApplyNewFullscreen() {+ if (!sdl_window_) {+ return;+ }+- SDL_SetWindowFullscreen(sdl_window_, IsFullscreen());++ SetWindowFullscreenState(sdl_window_, IsFullscreen());+ }++ void WindowSDL::ApplyNewTitle() {+@@ -450,7 +588,8 @@ void WindowSDL::HandleWindowEvent(SDL_Event& event) {+ // Track the user-driven size as the desired size for the normal state+ // only (mirrors the Win32 WM_SIZE handling).+ SDL_WindowFlags flags = SDL_GetWindowFlags(sdl_window_);+- if (!(flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MINIMIZED))) {++ if (!(flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MINIMIZED)) &&++ !IsFullscreen()) {+ #if REX_PLATFORM_MAC+ // Cocoa reports the client size in logical points. Converting it from+ // the backing DPI a second time would halve the desired size on Retina+@@ -484,11 +623,28 @@ void WindowSDL::HandleWindowEvent(SDL_Event& event) {OnPaint(true);break;case SDL_EVENT_WINDOW_MINIMIZED: