Skip to content

feat(window): exclusive fullscreen option - #156

Merged
clansty merged 1 commit into
MuNET-OSS:mainfrom
Cleroth:feat/exclusive-fullscreen
Oct 9, 2026
Merged

clansty merged 1 commit into
MuNET-OSS:mainfrom
Cleroth:feat/exclusive-fullscreen

Conversation

@Cleroth

@Cleroth Cleroth commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Adds GameSystem.Window.ExclusiveFullscreen (default false). When the game isn't windowed, it requests FullScreenMode.ExclusiveFullScreen instead of FullScreenWindow in the existing Screen.SetResolution call. Nothing changes when the option is off.

Why

The stock fullscreen window is composed by DWM every frame. On my setup (PresentMon: Composed: Copy with GPU GDI), that costs extra visual lag. Worse, the lag isn't stable: it jumps by a whole frame and drifts slowly. True exclusive fullscreen presents with Hardware: Legacy Flip, so the lag is steady.

Measured on a laptop (Intel iGPU driving a 1080p60 HDMI monitor rotated 90°, RTX 4070 also present). Feedback-hidden, muted sight-tapping passes at fixed judge B, alternating window / exclusive / window:

Mode Implied B per pass
Fullscreen window +1.52, +1.92
Exclusive fullscreen +0.04, +0.50
Fullscreen window +1.93, +2.14

That's about 1.6 F (27 ms) less visual lag. In exclusive mode PresentMon showed no irregular frame intervals and no phase drift.

Requirements and caveats (in the option's description)

  • The game must render on the GPU that drives the display. On hybrid laptops, use the Windows graphics preference for Sinmai.exe. Otherwise exclusive mode isn't possible.
  • Windows "fullscreen optimizations" must be disabled for Sinmai.exe (Compatibility tab). Otherwise Windows emulates the request as a Composed: Flip window, which measured slower than the default window here (about 61 ms vs 50 ms frame start → scanout).
  • The game minimizes when it loses focus. A game launched from a background process starts minimized until it's focused.

Tested in game on SDEZ 1.70. checkSort.py passes.


新增 GameSystem.Window.ExclusiveFullscreen(默认 false):非窗口模式下,Screen.SetResolution 改用 FullScreenMode.ExclusiveFullScreen 而不是 FullScreenWindow。关闭时行为不变。

原因: 默认的全屏窗口每帧经过 DWM 合成,显示延迟更高,而且不稳定,会整帧跳变并缓慢漂移。真正的独占全屏(PresentMon 显示 Hardware: Legacy Flip)延迟稳定。在一台笔记本(Intel 核显驱动 HDMI 显示器)上交替测试“窗口 / 独占 / 窗口”,独占模式的视觉延迟约低 1.6 帧(27 ms)。

要求:

  • 游戏需在驱动该显示器的 GPU 上渲染(双显卡笔记本需在 Windows 图形设置中为 Sinmai.exe 选择对应 GPU)。
  • 需为 Sinmai.exe 禁用“全屏优化”(兼容性设置)。否则 Windows 会用合成窗口(Composed: Flip)模拟独占全屏,延迟反而比默认更高。
  • 游戏失去焦点时会最小化。

View guided diff

Sourcery 总结

新功能:

  • 添加可选配置设置,以使用独占全屏模式,从而降低并稳定显示延迟。
Original summary in English

Summary by Sourcery

New Features:

  • Add an opt-in configuration setting for using exclusive fullscreen mode to reduce and stabilize display latency.

GameSystem.Window.ExclusiveFullscreen requests ExclusiveFullScreen instead of
FullScreenWindow when not windowed. With the game rendering on the GPU that drives
the display and Windows fullscreen optimizations disabled for Sinmai.exe, frames are
presented by legacy flip instead of desktop composition: on a measured setup this
removed about 1.6 F of visual lag and its whole-frame variation. Without those two
Windows settings, Windows emulates the request as a composed flip window, which is
slower than the default. The game minimizes when it loses focus.
@sourcery-ai

sourcery-ai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
审查者指南(小型 PR 中折叠显示)

审查者指南

新增可选的 GameSystem.Window.ExclusiveFullscreen 设置,将现有的分辨率设置切换为 Unity 独占全屏模式,旨在降低并稳定显示延迟,同时默认保留当前的全屏窗口行为。该设置包含双语文档,涵盖 GPU 分配、Windows 全屏优化以及失去焦点时的注意事项。

独占全屏分辨率设置流程图

flowchart TD
    A[Window mode configuration] --> B{Game is windowed?}
    B -->|Yes| C[Keep windowed behavior]
    B -->|No| D{exclusiveFullscreen enabled?}
    D -->|No| E[Screen.SetResolution with FullScreenWindow]
    D -->|Yes| F[Screen.SetResolution with ExclusiveFullScreen]
Loading

文件级变更

变更 详情 文件
添加可配置的独占全屏模式,并记录平台和部署注意事项。
  • 引入默认禁用的 GameSystem.Window.ExclusiveFullscreen 配置项,并提供英文和中文说明。
  • 记录 GPU 选择、Windows 全屏优化要求以及最小化失去焦点行为的相关信息。
AquaMai.Mods/GameSystem/Window.cs
启用新选项时选择 Unity 的独占全屏模式,否则保持现有行为不变。
  • 对于启用该选项的非窗口配置,将 FullScreenMode.ExclusiveFullScreen 传递给 Screen.SetResolution。
  • 继续将 FullScreenMode.FullScreenWindow 作为默认回退模式。
AquaMai.Mods/GameSystem/Window.cs

提示和命令

与 Sourcery 交互

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 从该评论创建 issue。你也可以使用 @sourcery-ai issue 回复审查评论,从中创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,以随时生成或重新生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任意位置写入 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,以随时生成或重新生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时生成或重新生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,此功能会很有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想通过新的审查重新开始,这项功能尤其有用——别忘了评论 @sourcery-ai review 以触发新的审查!

自定义使用体验

访问你的 控制面板:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds an opt-in GameSystem.Window.ExclusiveFullscreen setting that switches the existing resolution setup to Unity exclusive fullscreen, aiming to reduce and stabilize display latency while preserving the current fullscreen-window behavior by default. The setting includes bilingual documentation covering GPU assignment, Windows fullscreen optimizations, and focus-loss caveats.

Flow diagram for exclusive fullscreen resolution setup

flowchart TD
    A[Window mode configuration] --> B{Game is windowed?}
    B -->|Yes| C[Keep windowed behavior]
    B -->|No| D{exclusiveFullscreen enabled?}
    D -->|No| E[Screen.SetResolution with FullScreenWindow]
    D -->|Yes| F[Screen.SetResolution with ExclusiveFullScreen]
Loading

File-Level Changes

Change Details Files
Add a configurable exclusive fullscreen mode with documented platform and deployment caveats.
  • Introduce the disabled-by-default GameSystem.Window.ExclusiveFullscreen config entry with English and Chinese guidance.
  • Document GPU selection, Windows fullscreen-optimization requirements, and focus-loss minimization behavior.
AquaMai.Mods/GameSystem/Window.cs
Select Unity’s exclusive fullscreen mode when the new option is enabled without changing existing behavior otherwise.
  • Pass FullScreenMode.ExclusiveFullScreen to Screen.SetResolution for non-windowed configurations when enabled.
  • Retain FullScreenMode.FullScreenWindow as the default fallback.
AquaMai.Mods/GameSystem/Window.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好——我已经审阅了你的更改,看起来很棒!

Sourcery 评估

已批准。


Sourcery 对开源项目免费提供服务——如果你喜欢我们的评审,请考虑分享它们 ✨
Original comment in English

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="AquaMai.Mods/GameSystem/Window.cs">

<violation number="1" location="AquaMai.Mods/GameSystem/Window.cs:104">
P2: Vulkan 图形 API 不支持 `FullScreenMode.ExclusiveFullScreen`,Unity 会静默回退为 `FullScreenMode.FullScreenWindow`,因此启用该选项时并不一定得到独占全屏。请检测 `SystemInfo.graphicsDeviceType`,在 Vulkan 下明确回退并记录警告,或在配置说明中注明该限制。</violation>
</file>

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

var width = Window.width == 0 ? Display.main.systemWidth : Window.width;
var height = Window.height == 0 ? Display.main.systemHeight : Window.height;
Screen.SetResolution(width, height, FullScreenMode.FullScreenWindow);
Screen.SetResolution(width, height, exclusiveFullscreen ? FullScreenMode.ExclusiveFullScreen : FullScreenMode.FullScreenWindow);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Vulkan 图形 API 不支持 FullScreenMode.ExclusiveFullScreen,Unity 会静默回退为 FullScreenMode.FullScreenWindow,因此启用该选项时并不一定得到独占全屏。请检测 SystemInfo.graphicsDeviceType,在 Vulkan 下明确回退并记录警告,或在配置说明中注明该限制。

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At AquaMai.Mods/GameSystem/Window.cs, line 104:

<comment>Vulkan 图形 API 不支持 `FullScreenMode.ExclusiveFullScreen`,Unity 会静默回退为 `FullScreenMode.FullScreenWindow`,因此启用该选项时并不一定得到独占全屏。请检测 `SystemInfo.graphicsDeviceType`,在 Vulkan 下明确回退并记录警告,或在配置说明中注明该限制。</comment>

<file context>
@@ -85,7 +101,7 @@ public static void OnBeforePatch()
             var width = Window.width == 0 ? Display.main.systemWidth : Window.width;
             var height = Window.height == 0 ? Display.main.systemHeight : Window.height;
-            Screen.SetResolution(width, height, FullScreenMode.FullScreenWindow);
+            Screen.SetResolution(width, height, exclusiveFullscreen ? FullScreenMode.ExclusiveFullScreen : FullScreenMode.FullScreenWindow);
         }
     }
</file context>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sinmai 应该是编译给dx的

@Starrah

Starrah commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

LGTM

@clansty
clansty merged commit 3c74586 into MuNET-OSS:main Oct 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants