Magpie Documentation

A general-purpose window upscaler for Windows 10/11.

16,663 stars HLSL 1 file · ~18,165 tokens #anime4k#capture#cppwinrt#fluent-design#fsr#hlsl#magnifier#magpie
RAW Doc

Technical Documentation: Blinue/Magpie

ℹ️ Provenance: Multi-Tier Ingestion · CodeWiki Reference

Overview (`README.md`)

Magpie

🌍 English | 简体中文

Magpie is a lightweight window upscaling tool that comes equipped with a variety of efficient scaling algorithms and filters.

👉 Download

👉 FAQ

👉 Built-in effects

👉 Compilation guide

Features

  • Supports both fullscreen and windowed scaling
  • Includes a variety of built-in algorithms and filters, including Anime4K, FSR, CRT shaders, and more
  • WinUI-based user interface with support for light and dark themes
  • Multi-monitor support

Screenshots

Hints

  1. If you have set DPI scaling and the window you want to scale does not support high DPI (which is common in older games), it is recommended to first enter the program's compatibility settings and set "High DPI scaling override" to "Application".

  2. Some games support zooming the window, but with extremely naive algorithms. Please set the resolution to the built-in (best) option.

System requirements

  1. Windows 10 v1903+ or Windows 11
  2. DirectX feature level 11

Localization

Thanks to Weblate for hosting! Click the image below to visit the translation page.

Acknowledgement

Thanks go to these wonderful people:

Xu🚧 hooke007📖 💬 📓 💻 Pal Lockheart📓 Steve Donaghy💻 🌍 gyro永不抽风💻 ButtERRbrod🌍 NightFox🌍
Tzugimaa💻 WHMHammer🌍 kato-megumi💻 Mike Wang📓 Sammy Hori🌍 NeilTohno🌍 a0193143🌍
soulset001🌍 WluhWluh🎨 Serdar Sağlam🌍 Andrus Diaz German🌍 Kefir2105🌍 animeojisan🌍 MuscularPuky🌍
Zoommod🌍 fil08🌍 攸羚💻 OHaiiBuzzle🌍 Rastadu23🌍 hauuau💻 nellydocs🌍
funnyplanter💻 Erich Yu💻 தமிழ் நேரம்🌍 mhtvsSFrpHdE📖 Krzysztof🌍 Howard Wu💻 Arif Budiman🌍
Raphael🌍 Pate L🌍 Carlo_Mava🌍 XIONG PEILIN💻

This project follows the all-contributors specification. Contributions of any kind are welcome!

License

This project is licensed under GPLv3.


Overview (`tools/MPVHookTextureParser/README.md`)

MPVHookTextureParser

用于将 mpv hook 中的 TEXTURE 块转换为 DDS 格式。

使用说明

以下面的格式将 TEXTURE 块的文本复制到文件中:

text
{WIDTH} {HEIGHT}
{TEXTURE DATA}

如

text
45 2592
00000000000000000000000000000000a164deb9bc0290ba6a16...

假设该文件名为 TEXTURE.txt,要将结果输出到 weights.dds 中,执行以下命令

bash
> .\MPVHookTextureParser TEXTURE.txt weights.dds

About Touch Support (`docs/About touch support.md`)

Due to OS security restrictions, Magpie requires UIAccess privileges to support touch input. Obtaining this privilege necessitates meeting two conditions:

  1. The application must possess a digital signature, and this signature must be verified by a certificate associated with a trusted root certificate authority store on the local machine.
  2. The application must reside in a "secure location", such as the Program Files or System32 folders.

When enabling touch support, Magpie performs the following actions:

  1. Adds a self-signed certificate to the trusted root certificate authority store.
  2. Copies the TouchHelper.exe to System32\Magpie. During scaling, Magpie runs this program to enable touch support.

Both of these actions constitute significant changes to the OS, thus requiring administrator privileges. If touch support is no longer needed, this option should be disabled. Magpie will then revert these changes, leaving no traces in the OS.

Touch support may fail for various reasons, such as when TouchHelper.exe requires an update. In such cases, Magpie will request administrator privileges before scaling to resolve the issue.


Built In Effects (`docs/Built-in effects.md`)

Magpie ships with a handful of effects that can be used in combinations. Most of the effects have parameters that can be customized. All effects are stored in the effects folder. You can easily add effects if you are familiar with HLSL. Check the MagpieFX page.

Introduction to shipped effects

  • ACNet: Port of ACNetGLSL. Suitable for anime-style images. Strong denoise effects.

    • Output size: twice that of the input
  • AdaptiveSharpen: Self-adaptive sharpening algorithm. This algorithm focuses on sharpening the blurry edges in the images. Hence it has less image noise, ringing artifacts, and stripes compared to the common sharpening algorithms.

    • Output size: the same as the input
    • Parameter
      • Sharpness
  • Ani4Kv2_ArtCNN_C4F32_i:Port of Ani4K-v2

    • Output size: twice that of the input
  • Anime4K_3D_AA_Upscale_US and Anime4K_3D_Upscale_US: 3D game scaling algorithms provided by Anime4K. The AA variant supports anti-aliasing.

    • Output size: twice that of the input
  • Anime4K_Denoise_Bilateral_Mean, Anime4K_Denoise_Bilateral_Median, and Anime4K_Denoise_Bilateral_Mode: Denoise algorithms provided by Anime4K. Uses mean, median, and mode, respectively.

    • Output size: the same as the input
    • Parameter:
      • Strength: Denoise magnitude
  • Anime4K_Restore family: Algorithms to restore the lines in animations. In increasing order of demand for computing power. The Soft variants are more conservative in sharpening.

    • Output size: the same as the input
  • Anime4K_Thin_HQ: Algorithm to clarify lines in animations provided by Anime4K.

    • Output size: the same as the input
    • Parameters
      • Strength: The strength in each iteration.
      • Iterations: The number of iterations. Decreasing strength and increasing iterations improves the quality of the images, but will lower the processing speed.
  • Anime4K_Upscale family: Anime-style scaling algorithms provided by Anime4K. The denoise variant includes denoise functionality. The GAN variant, which keeps more details, is still under experiment.

    • Output size: twice that of the input
  • Bicubic: Interpolation algorithms. The lite variant is fast, but at the cost of quality degradation, Suitable for users will weak graphics cards.

    • Output size: determined by scale configuration
    • Parameters
      • B: Too large values will result in blurry images.
      • C: Too large values will result in ring artifacts.
    • Note: Different combinations of parameters will lead to different variants of the algorithm. For example: Mitchell(B=C≈0.333333), Catmull-Rom(B=0 C=0.5), bicubic Photoshop(B=0 C=0.75), Spline(B=1 C=0)
  • Bilinear:Bilinear interpolation

    • Output size: determined by scale configuration
  • CAS: Port of FidelityFX-CAS. Lightweight sharpening effects.

    • Output size: the same as the input
    • Parameter
      • Sharpness
  • CAS_Scaling:Port of FidelityFX-CAS. Supports scaling

    • Output size: the same as the input
    • Parameter
      • Sharpness
  • CRT_Easymode: Easy-to-configure lightweight CRT shader.

    • Output size: determined by scale configuration
    • Parameters
      • Sharpness Horizontal
      • Sharpness Vertical
      • Mask Strength
      • Mask Dot Width
      • Mask Dot Height
      • Mask Stagger
      • Mask Size
      • Scanline Strength
      • Scanline Beam Width Min
      • Scanline Beam Width Max
      • Scanline Brightness Min
      • Scanline Brightness Max
      • Scanline Cutoff
      • Gamma Input
      • Gamma Output
      • Brightness Boost
      • Dilation
  • CRT_Geom: One of the most popular CRT shaders, designed to emulate the look of Arcade-machine. This implementation does not support interlacing simulation. Check Emulation General Wiki.

    • Output size: determined by scale configuration
    • Parameters
      • Target Gamma
      • Monitor Gamma
      • Distance
      • Curvature: Whether to emulate the screen curvature
      • Curvature Radius
      • Corner Size
      • Corner Smoothness
      • Horizontal Tilt
      • Vertical Tilt
      • Horizontal Overscan
      • Vertical Overscan
      • Dot Mask
      • Sharpness: The larger the value is, the clear the image becomes
      • Scanline Weight
      • Luminance Boost
  • CRT_Hyllian: Provides sharp and clear outputs with slight rims. Similar to Sony BVM displays.

    • Output size: determined by scale configuration
    • Parameters
      • Phosphor
      • Vertical Scanlines
      • Input Gamma
      • Output Gamma
      • Sharpness
      • Color Boost
      • Red Boost
      • Green Boost
      • Blue Boost
      • Scanline Strength
      • Min Beam Width
      • Max Beam Width
      • Anti-Ringing
  • CRT_Lottes: Provides multiple masks emulating Bloom and Halation effects. Similar to CGA arcade displays.

    • Output size: determined by scale configuration
    • Parameters
      • Scanline Hardness
      • Pixel Hardness
      • Horizontal Display Warp
      • Vertical Display Warp
      • Mask Dark
      • Mask Light
      • Shadow Mask
      • Brightness Boost
      • Bloom-X Soft
      • Bloom-Y Soft
      • Bloom Amount
      • Filter Kernel Shape
  • CuNNy family:Suitable for visual novel-style images. The DS variants offer a subtle denoise effect. Provided by CuNNy

    • Output size: twice that of the input
  • CuNNy2 family: An enhanced version of CuNNy

    • Output size: twice that of the input
  • Deband

    • Output size: the same as the input
    • Parameters
      • Threshold:The threshold of difference below which a pixel is considered to be part of a gradient.
      • Range:The range (in source pixels) at which to sample for neighbours.
      • Iterations:The number of debanding iterations to perform. Each iteration samples from random positions, so increasing the number of iterations is likely to increase the debanding quality. Conversely, it slows the shader down.
      • Grain:Add some extra noise to the image. This significantly helps cover up remaining banding and blocking artifacts, at comparatively little visual quality.
  • FineSharp: High-quality sharpening. The earliest version was the AviSynth script.

    • Output size: the same as the input
    • Parameters
      • sstr: Sharpening strength. If you change this parameter, you will have to also change cstr. Check the note below.
      • cstr: Balancing strength.
      • xstr: The sharpening strength in the final step of the XSharpen style.
      • xrep: To fix the artifacts in the last step of sharpening.
    • Note: mapping between sstr and cstr (sstr->cstr): 0->0, 0.5->0.1, 1.0->0.6, 2.0->0.9, 2.5->1.00, 3.0->1.09, 3.5->1.15, 4.0->1.19, 8.0->1.249, 255.0->1.5
  • FSR_EASU: Port of the scaling step in FidelityFX-FSR. The DX10 variant works on graphics cards supporting DirectX feature level, but will be slower.

    • Output size: determined by scale configuration
  • FSR_RCAS: Port of the sharpening step in FidelityFX-FSR.

    • Output size: the same as the input
    • Parameter
      • sharpness
  • FSRCNNX: Port of FSRCNNX_x2_8-0-4-1

    • Output size: twice that of the input
  • FSRCNNX_LineArt: Port of FSRCNNX_x2_8-0-4-1_LineArt

    • Output size: twice that of the input
  • FXAA_Medium, FXAA_High, FXAA_Ultra: Fast anti-aliasing by approximation. In increasing order of demand to computing power.

    • Output size: the same as the input
  • GTU_v050: Aims to emulate the blurry and mixed effects of CRT displays rather than masks or curvature. Supports scanning lines.

    • Output size: determined by scale configuration
    • Parameters
      • Composite Connection
      • No Scanlines
      • Signal Resolution Y
      • Signal Resolution I
      • Signal Resolution Q
      • TV Vertical Resolution
      • Black Level
      • Contrast
  • ImageAdjustment:Image parameters adjustment

    • Output size: the same as the input
    • Parameters
      • Target Gamma
      • Monitor Gamma
      • Saturation
      • Luminance
      • Contrast
      • Brightness Boost
      • Black Level
      • Red Channel
      • Green Channel
      • Blue Channel
  • Jinc: Scaling with the Jinc algorithm

    • Output size: determined by scale configuration
    • Parameters
      • Window Sinc Param: The smaller the value is the sharper the images become. Must be greater than 0. Default value: 0.5
      • Sinc Param: The larger the value is the sharper the images become. Must be greater than 0. Default value: 0.825
      • Anti-ringing Strength: The greater the value is the better the effect becomes, but the images will be more blurry.
  • k7_modernAnime: anime-targeted super-resolution algorithm

    • Output size: twice that of the input
  • Lanczos: Scaling with the Lanczos algorithm.

    • Output size: determined by scale configuration
    • Parameters
      • Anti-ringing Strength: The greater the value is the better the effect becomes, but the images will be more blurry.
  • LCAS:Lightweight 3D image scaling algorithm

    • Output size: determined by scale configuration
    • Parameter
      • Sharpness
  • LumaSharpen: A popular sharpening effect in reshade.

    • Output size: the same as the input
    • Parameters
      • Sharpening Strength
      • Sharpening Limit: Anti-ringing strength.
      • Sample Pattern: Filter type.
      • Offset Bias: Filter bias.
  • MMPX:Pixel art scaling algorithm. It can add details while retaining the artistic style.

    • Output size: twice that of the input
  • Nearest: Nearest neighbor interpolation

    • Output size: determined by scale configuration
  • NIS: Port of NVIDIA Image Scaling.

    • Output size: determined by scale configuration
    • Parameters
      • Sharpness
    • Note: Only supports upscaling.
  • NNEDI3 family:These shaders originally designed for deinterlacing and are also high-quality interpolation algorithms. NNEDI3_nns64_win8x6 produces higher quality results, but slower.

    • Output size: twice that of the input
  • NVSharpen: Port of NVSharpen that was published along with NIS.

    • Output size: the same as the input
    • Parameter
      • Sharpness
  • Pixellate: Scale with the Pixellate algorithm. Suitable for upscaling pixel arts.

    • Output size: determined by scale configuration
  • RAVU family: Ported from https://github.com/bjin/mpv-prescalers

    • Output size: twice that of the input
  • RAVU_Zoom family: Ported from https://github.com/bjin/mpv-prescalers

    • Output size: determined by scale configuration
    • Note: Only supports upscaling.
  • SharpBilinear: Scale with the Sharp-Bilinear algorithm. Suitable for upscaling pixel arts.

    • Output size: determined by scale configuration
  • SGSR: Port of Snapdragon Game Super Resolution v1.

    • Output size: determined by scale configuration
    • Parameter
      • Edge Sharpness: Edge sharpening intensity (The larger the value, the sharper the image.)
      • Edge Threshold: Edge detection threshold
  • SMAA_Low, SMAA_Medium, SMAA_High, and SMAA_Ultra: SMAA anti-aliasing. In increasing order of demand for computing power.

    • Output size: the same as the input
  • SSimDownscaler: Downscaling algorithm based on perceptron. Sharper than Catrom.

    • Output size: determined by scale configuration
    • Parameter
      • Oversharp: The larger the value, the sharper the image.
  • xBRZ_2x, xBRZ_3x, xBRZ_4x, xBRZ_5x, and xBRZ_6x: Scale with the xBRZ algorithm. Suitable for upscaling pixel arts.

    • Output size: determined by the variant.
  • xBRZ_Freescale and xBRZ_Freescale_Multipass: xBRZ algorithm supporting any scaling factor.

    • Output size: determined by scale configuration

Comparison Of Capture Methods (`docs/Comparison of capture methods.md`)

Magpie provides several capture methods. They have their pros and cons in different scenarios. For general purposes, it's recommended to use Graphics Capture, as it provides the best compatibility and smoothness.

Graphics Capture Desktop Duplication GDI DwmSharedSurface
Supports DirectComposition (e.g. UWP) Yes Yes No No
Supports recording/streaming No under extreme conditions[1] No Yes Yes
Support the source window to span multiple screens No under extreme conditions[1] No Yes Yes
Ignores DPI virtualization[2] No No Yes Yes
Notes The most recommended capture method Requires Win10 v2004 Not recommended due to unstable performance

[1]: (1) The source window does not support regular window capture. (2) The operating system is Windows 11.

[2]: The system will perform bicubic interpolation upscaling to windows that do not support DPI scaling. The capture methods supporting this options captures the images before such scaling.


Compilation Guide (`docs/Compilation guide.md`)

Prerequisites

In order to compile Magpie, you need to first install:

  1. The latest version of Visual Studio 2026. You need to install both "Desktop development with C++" and "Universal Windows Platform development" workloads and Windows SDK build 26100 or newer.

  2. Python 3.14+

  3. Conan

    bash
    pip install conan

    Make sure that the above dependencies have been added to the system path, and use the following commands to check:

    bash
    python --version
    conan --version

Compiling

  1. Clone the repo

    bash
    git clone https://github.com/Blinue/Magpie
  2. Open the Magpie.slnx in the root directory and build the solution.

Enabling Touch Support

To enable touch input support, TouchHelper.exe needs to be signed. While signing is automatically done in the CI pipeline, you can also manually sign it. Follow these steps:

  1. Create a self-signed certificate and export it as a pfx file.
  2. Replace the CERT_FINGERPRINT constant in src/Magpie/TouchHelper.cpp with the SHA-1 hash (i.e., fingerprint) of your certificate.
  3. Run the following command in the root directory of the repository:
bash
python scripts/publish.py --pfx-path=<pfx path> --pfx-password=<pfx password>

This will compile Magpie and sign TouchHelper.exe. The compiled files will be located in publish\x64.


FAQ (EN) (`docs/FAQ (EN).md`)

Duplicate-monitoring

When displaying performance monitor like RTSS (Rivatuner Statistics Server), there might be 2 OSD layers displayed with Magpie scaling. This is caused by d3d, the screen capture method since v0.7.0. It will be captured by RTSS as well. You can fix this issue by adding it to the blacklist.

The hot keys don't work, but "Scale after `x`s" works.

  1. Try changing the hot keys.
  2. Try running Magpie as Administrator.

Lagging/latency

Please check the Performance optimization page.

Will using Magpie in multi-player games be detected as cheating?

Magpie is designed to be non-intrusive, so it is unlikely to be detected as a cheating tool. There have been no reports of bans for using Magpie. Nevertheless, you should be aware of the risks of using the software.

What is "3D game mode"?

Enabling this option can change the behavior of the cursor and in-game overlay to optimize for 3D games. It is recommended to turn on this option when scaling 3D games.

What is "Disable DirectFlip"?

DirectFlip is a technology to reduce input lags, but it may cause trouble in some circumstances. Please turn on this option when you are in the following situationsL:

  1. The game lags unexpectedly (game known with the issue: Days Gone).
  2. Abnormal low frame rates.
  3. The screen freezes when streaming.

What is "Simulate Exclusive Fullscreen?"

A lot of software checks whether there are games running under dedicated fullscreen mode before popping up windows. Turn on this option if you'd like to play in fullscreen without being disturbed,

What is the frame rate displayed in Magpie?

The frame rate displayed by Magpie is that of its own rather than that of the game. Due to the non-intrusive nature, Magpie has no way to detect the frame rates of games themselves. We recommend you to use tools like RTSS to display the games' frame rates. Their add-on layers can usually be captured by Magpie as well.

Does Magpie support touch input?

Supported from v0.11, see About touch support for details.

Does Magpie support frame generation?

There are no plans to implement frame generation. Magpie's goal is to improve visual quality, not performance, while post-processing frame generation is difficult to achieve a good enough result and adds latency. Game engines can use motion vectors and depth buffers to make improvements, but Magpie has no access to these. Similarly, FSR 2/3 are not on the development roadmap, as they need to be integrated internally and post-processing is almost impossible.

What is the relationship between Magpie and Lossless Scaling?

Lossless Scaling is a paid software on Steam that is similar to Magpie. When Magpie was released in February 2021, existing window scaling software (such as IntegerScaler and Lossless Scaling) only supported simple scaling algorithms like nearest-neighbor scaling and integer scaling. These programs relied on the Magnification API to function, which led to significant limitations.

To support advanced scaling algorithms, I developed and open-sourced Magpie, which implements scaling in a completely different way. Initially, Magpie only supported algorithms like Anime4K, Lanczos, and Adaptive Sharpen. However, based on user feedback, Magpie added support for FSR in July 2021. Soon after, Lossless Scaling released version 1.4.0, which supported FSR in a similar way to Magpie.

Currently, Magpie and Lossless Scaling differ significantly. Magpie focuses on usability and supporting more scaling algorithms, while Lossless Scaling primarily aims to improve 3D game performance.


FAQ (`docs/FAQ.md`)

双重监控

使用性能计数器屏显时,例如 RTSS (Rivatuner Statistics Server),你可能会在缩放时看到两个叠加层。这是由于 Magpie 使用 Direct3D 呈现画面,它也会被 RTSS 捕捉。如果你不关心 Magpie 的性能,请将 Magpie 添加到黑名单。

快捷键不起作用,但可以使用 "`x` 秒后缩放"

  1. 尝试更换快捷键
  2. 尝试以管理员身份运行 Magpie

卡顿/延迟

请查看性能优化建议。

在多人游戏中使用 Magpie 会被认定为作弊吗?

Magpie 被设计为非侵入式,因此一般不会被识别为作弊工具。目前没有因使用 Magpie 被封禁的报告。尽管如此,你应该了解到使用本软件的风险。

什么是“禁用 DirectFlip”?

DirectFlip 是一种用于降低输入延迟的技术,但可能会在一些情况下造成问题。如果你遇到了下面的情形,可以尝试打开这个选项:

  1. 游戏异常卡顿(已知游戏:Days Gone)
  2. 不正常的低帧率
  3. 串流时画面冻结

什么是“3D 游戏模式”?

此选项可以更改光标和游戏内叠加层的行为以适配 3D 游戏,建议在缩放 3D 游戏时开启此选项。

什么是“模拟独占全屏”?

很多软件弹窗或推送前会先检查是否有独占全屏的游戏,开启此选项可以让你在全屏状态下不受打扰。一些用户报告开启此选项后游戏可能无法正常启动 #495,如果你遇到了类似的问题,请关闭它。

Magpie 中显示的帧率是什么?

Magpie 显示的是自己的帧率而不是游戏的,基于非侵入性原则,Magpie 无法获知游戏的帧率。建议使用 RTSS 等工具显示游戏帧率,它们的叠加层一般也可以被 Magpie 捕获到。

是否支持触控?

从 v0.11 开始支持,详情见关于触控支持。

是否支持帧生成?

目前没有实现帧生成的计划。Magpie 的目的是提高游戏画质而不是性能,后处理补帧很难达到足够好的观感,而且还会增加延迟。游戏引擎可以使用运动矢量和深度缓冲以进行改善,但 Magpie 不具备这种条件。与之同理,FSR 2/3 也不在开发计划内,因其必须采用内部集成,后处理几乎无法实现。

Magpie 和 Lossless Scaling 有何关系?

Lossless Scaling 是 Steam 上的一款和 Magpie 功能类似的收费软件。Magpie 于 2021 年 2 月问世,当时市面上的窗口缩放软件(如 IntegerScaler 和 Lossless Scaling)仅支持简单的缩放算法,如最近邻缩放和整数倍缩放。这些软件的核心功能使用 Magnification API 实现,因此存在很大的局限性。

为了支持更高级的缩放算法,我开发并开源了 Magpie,它采用了完全不同的方式来实现缩放。最初,Magpie 仅支持 Anime4K、Lanczos、Adaptive Sharpen 等算法。在用户的反馈下,Magpie 在 2021 年 7 月加入了对 FSR 的支持。不久之后,Lossless Scaling 推出了 1.4.0 版本,采用与 Magpie 类似的方式支持 FSR。

现在,Magpie 和 Lossless Scaling 有很大的不同。Magpie 的重点是可用性和支持更多的缩放算法,而 Lossless Scaling 则主要聚焦于提高 3D 游戏的性能。


Home (EN) (`docs/Home (EN).md`)

Chinese version

Welcome to the Magpie Wiki. Please read CONTRIBUTING if you'd like to contribute the the documentations.


Home (`docs/Home.md`)

English version

欢迎来到 Magpie Wiki。如果你想贡献文档,请阅读贡献指南。


Interact With Magpie Programally (`docs/Interact with Magpie programally.md`)

Magpie provides mechanisms for interaction with other programs. Through these mechanisms, your application can cooperate with Magpie.

MagpieWatcher demonstrates how to use these mechanisms.

How to Receive Notifications When Scaling State Changes

You should listen for the MagpieScalingChanged message.

c++
UINT WM_MAGPIE_SCALINGCHANGED = RegisterWindowMessage(L"MagpieScalingChanged");

Parameters

The wParam parameter indicates the event ID, and the meaning of lParam varies depending on the event. The following events are supported:

  • 0: Scaling has ended or the source window has lost focus. lParam is 0 if scaling has ended, or 1 if the source window has lost focus.
  • 1: Scaling has started or the source window has returned to the foreground. lParam contains the handle of the scaled window.
  • 2: The scaled window’s position or size has changed. This event is exclusive to windowed scaling.
  • 3: User has started resizing or moving the scaled window. This event is exclusive to windowed scaling.

Notes

If your process has a higher integrity level than Magpie, you won't receive messages broadcasted by Magpie due to User Interface Privilege Isolation (UIPI). In such cases, call ChangeWindowMessageFilterEx to allow receiving the MagpieScalingChanged message.

c++
ChangeWindowMessageFilterEx(hYourWindow, WM_MAGPIE_SCALINGCHANGED, MSGFLT_ADD, nullptr);

How to Get the Handle of the Scaled Window

You can listen for the MagpieScalingChanged message to obtain the handle of the scaled window. Additionally, while Magpie is scaling, you can also search for the window with the class name Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22. Magpie ensures that this class name remains unchanged and that only one scaled window exists at a time.

c++
HWND hwndScaling = FindWindow(L"Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22", nullptr);

How to Place Your Window Above the Scaled Window

You should listen for the MagpieScalingChanged message and adjust your window's Z-order accordingly. Below is a simple example. For more advanced use cases, refer to MagpieWatcher.

c++
if (message == WM_MAGPIE_SCALINGCHANGED) {
    if (wParam == 0) {
        // Remove topmost status
        SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
    } else if (wParam == 1) {
        // Ensure your window stays above the scaled window
        SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
    }
}

How to Obtain Scaling Information

Scaling information is stored in the window properties of the scaled window. Currently available properties include:

  • Magpie.Windowed:Indicates whether Magpie is performing windowed scaling
  • Magpie.SrcHWND: Handle of the source window
  • Magpie.SrcLeft、Magpie.SrcTop、Magpie.SrcRight、Magpie.SrcBottom: Source region of scaling
  • Magpie.DestLeft、Magpie.DestTop、Magpie.DestRight、Magpie.DestBottom: Destination region of scaling
c++
HWND hwndSrc = (HWND)GetProp(hwndScaling, L"Magpie.SrcHWND");
bool isWindowed = (bool)GetProp(hwndScaling, L"Magpie.Windowed");

RECT srcRect;
srcRect.left = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcLeft");
srcRect.top = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcTop");
srcRect.right = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcRight");
srcRect.bottom = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcBottom");

RECT destRect;
destRect.left = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestLeft");
destRect.top = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestTop");
destRect.right = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestRight");
destRect.bottom = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestBottom");

Notes

  1. These properties are only guaranteed to exist after the scaled window has completed its initialization. Therefore, it is advisable to check whether the scaled window is visible before retrieving these properties, especially when the window handle is obtained using the class name.
  2. The coordinates stored in these properties are not DPI-virtualized. To use them correctly, you need to set your application's DPI awareness level to Per-Monitor V2. For more details, please refer to High DPI Desktop Application Development on Windows.

MagpieFX (EN) (`docs/MagpieFX (EN).md`)

MagpieFX is based on DirectX 11 compute shader

text
/* Detailed source-code truncated for AI context efficiency. */

Predefined functions

uint2 GetInputSize(): Retrieves the size of the input texture.

float2 GetInputPt(): Retrieves the size of pixel in the input texture.

uint2 GetOutputSize(): Retrieves the size of the output texture.

float2 GetOutputPt(): Retrieves the size of pixel in the output texture.

float2 GetScale(): Retrieves the scaling factor between the output texture and the input texture.

uint2 Rmp8x8(uint id): Maps the values of 0 to 63 to coordinates in an 8x8 square in swizzle order, which can improve texture cache hit rate.

MF{n} MulAdd(MF{m} x, MF{m}x{n} y, MF{n} a): Equivalent to mul(x, y) + a, but with higher performance, making it particularly useful for machine learning-based effects. To use this function, you must declare "USE MulAdd". For details, see #1049.

Predefined macros

MP_BLOCK_WIDTH, MP_BLOCK_HEIGHT: The size of the block being processed in the current pass (specified by "BLOCK_SIZE").

MP_NUM_THREADS_X, MP_NUM_THREADS_Y, MP_NUM_THREADS_Z : The number of threads per thread group in the current pass (specified by "NUM_THREADS").

MP_PS_STYLE: Whether the current pass is a pixel shader style pass (specified by "STYLE").

MP_INLINE_PARAMS: Whether the parameters for the current pass are static constants (specifed by user).

MP_DEBUG: Whether the shader is being compiled in debug mode (when compiling shaders in debug mode, they are not optimized and contain debug information).

MP_FP16: Whether to use half-precision floating-point numbers.

MF, MF1, MF2, ..., MF4x4: Floating-point data types that conform to MP_FP16. When half-precision is not specified, they are aliases for float..., otherwise they are aliases for min16float...

Multiple Render Targets (MRT)

In PS-style, the OUT instruction allows specifying multiple outputs (up to 8 due to DirectX limitations).

hlsl
//!OUT tex1, tex2

Now the entry point has a different signature:

hlsl
void Pass1(float2 pos, out MF4 target1, out MF4 target2);

Load texture from file

hlsl
//!TEXTURE
//!SOURCE test.bmp
Texture2D testTex;

The TEXTURE instruction supports loading textures from files in common image formats such as BMP, PNG, JPG, and DDS. For DDS files, only 2D textures are supported, but mipmaps are allowed. FORMAT can be optionally specified to help the parser generate the correct definition. If FORMAT is not specified, it is always assumed to be of type float4.

Textures loaded from files cannot be used as the output of passes.


MagpieFX (`docs/MagpieFX.md`)

MagpieFX 基于 DirectX 11 计算着色器

text
/* Detailed source-code truncated for AI context efficiency. */

预定义函数

uint2 GetInputSize():获取输入纹理尺寸。

float2 GetInputPt():获取输入纹理每个像素的尺寸。

uint2 GetOutputSize():获取输出纹理尺寸。

float2 GetOutputPt():获取输出纹理每个像素的尺寸。

float2 GetScale():获取输出纹理相对于输入纹理的缩放。

uint2 Rmp8x8(uint id):将 0~63 的值以 swizzle 顺序映射到 8x8 的正方形内的坐标,用以提高纹理缓存的命中率。

MF{n} MulAdd(MF{m} x, MF{m}x{n} y, MF{n} a):等效于 mul(x, y) + a,但性能更高,在基于机器学习的效果中非常有用。必须声明 "USE MulAdd" 才能使用此函数。原理参见 #1049。

预定义宏

MP_BLOCK_WIDTH、MP_BLOCK_HEIGHT:当前通道处理的块的大小(由 "BLOCK_SIZE" 指定)

MP_NUM_THREADS_X、MP_NUM_THREADS_Y、MP_NUM_THREADS_Z:当前通道每个线程组的线程数(由 "NUM_THREADS" 指定)

MP_PS_STYLE:当前通道是否是像素着色器样式(由 "STYLE" 指定)

MP_INLINE_PARAMS:当前通道的参数是否为静态常量(由用户指定)

MP_DEBUG:当前是否为调试模式(调试模式下编译的着色器不进行优化且含有调试信息)

MP_FP16:当前是否使用半精度浮点数

MF、MF1、MF2、...、MF4x4:遵守 fp16 参数的浮点数类型。当未指定 fp16,它们为 float... 的别名,否则为 min16float... 的别名

多渲染目标(MRT)

PS 风格下 OUT 指令可指定多个输出(由于 DirectX 的限制最多 8 个):

hlsl
//!OUT tex1, tex2

这时通道入口有不同的签名:

hlsl
void Pass1(float2 pos, out MF4 target1, out MF4 target2);

从文件加载纹理

hlsl
//!TEXTURE
//!SOURCE test.bmp
Texture2D testTex;

TEXTURE 指令支持从文件加载纹理,支持的格式有 BMP,PNG,JPG 等常见图像格式以及 DDS 文件。加载 DDS 文件时只支持 2D 纹理,但允许使用 mipmap。可选使用 FORMAT,指定后可以帮助解析器生成正确的定义,不指定始终假设是 float4 类型。

从文件加载的纹理不能作为通道的输出。


Performance Optimization (`docs/Performance optimization.md`)

This article may be helpful if you are facing performance issues (e.g. lagging, latency, too much power consumption).

Below are some possible situations:

My graphics card is not powerful enough

If you cannot run some effects with high computing power requirements (e.g. Anime4K, AdaptiveSharpen, etc.) smoothly, try the following:

  1. Change to the variants with lower requirements. For example, Anime4K_Upscale_S is much faster than Anime4K_Upscale_L. CAS is much faster than AdaptiveSharpen. They can effectively improve the smoothness of the effects at the cost of some quality degradation.
  2. Change the capture mode. We recommend you to try each of them.

Intermittent lagging

If your graphics card is powerful enough, but you are still experiencing lagging issues, try the following:

text
For Nvidia users

Assume you're on Windows 11 24H2

The following tips apply only to Nvidia users. Improper driver configuration on Nvidia graphics cards is likely the cause of the stuttering.

Quick tips: Restore your Nvidia driver settings to default (clean install) will solve most problems. However, if you insist on use your own settings, let's explain how driver settings cause trouble to program.

Strange fps drop after upscaling enabled for a while

At the beginning, everything is fine (Game 60 FPS / Magpie 60 FPS). But after about 10~15 seconds, both game and magpie fps drop to about 37 FPS, at the same time GPU usage go up to 100%, GPU MHz goes down from like 1000 to 700.

First, if you're gaming with "Power management mode: Optimal power", then try to set magpie program to "Prefer maximum performance" or maybe "Adaptive" but I haven't try adaptive mode, yet there is no guarantee. Game remains "Optimal power" is fine. By use this setting, GPU MHz will no longer goes down abnormal.

Nvidia App and Nvidia control panel

However, one of my PC doesn't work with this settings while others can be fixed with this way. The investigation result is, there is compatibility issue between Nvidia App and Nvidia control panel. If you use Nvidia App changed your driver settings, open control panel, modify same settings cause the control panel crash or says "Access denied". And settings by Nvidia App are not apply to game or program at all.

Don't use Nvidia App (version 11.0.2.341) to adjust Nvidia driver settings of driver like 572.16. Close Nvidia App and Nvidia control panel, go to C:\ProgramData\NVIDIA Corporation\Drs, delete all .bin files like nvdrsdb0.bin, nvdrsdb1.bin, nvdrssel.bin, update.bin, open Nvidia control panel again and redo all of your global settings and program specified settings, and avoid use Nvidia App driver settings after that.

Screen looks not as smooth as native game window

Game 60 FPS / Magpie 60 FPS, appears in either Graphics Capture or Desktop Duplication.

The investigation result is vertical sync. Although it looks very strange. At least for Windows 11 24H2, you need to turn on vertical sync for a game, to make WGC and DXGI capture doesn't lose frame. If not, even WGC and DXGI capture at 60 FPS and game run at 60 FPS, many or some game frame will lose or called duplicated frame.

Required vertical sync mode for game is "Traditional / Classic / Vertical sync: Use the 3D application setting and enable in-game vsync / Vertical sync: On". Not turn off vertical sync, or use "Vertical sync: Fast". I'm not sure if "Vertical sync: Adaptive / Adaptive (half refresh rate)" will work or not but I have no time for detailed testing.

For magpie, go with "Use the 3D application setting".

Crazy frame lose when using Desktop Duplication

At the same time, Game 60 FPS / Magpie 60 FPS. I find that this situation appears when I am using Magpie v0.10.6. Enable vertical sync in Magpie settings and use "Vertical sync: Use the 3D application setting" for Magpie program settings solved this. Upgrade to Magpie v0.11.1 also solved this.

Crazy frame lose when GPU usage nears 100%

At the same time, Game sightly lower than monitor FPS like Game 57 FPS / Monitor 60 Hz. If not use Magpie, the native game window looks smooth.

Try turn off "Hardware-accelerated GPU scheduling" and restart. I find that when GPU under heavy load and GPU scheduling on, Either WGC and Desktop Duplication can't process frames correctly. By turn off GPU scheduling, your game FPS is still low, but Magpie will not drop to visually under 10 FPS anymore.

Screen looks not smooth but FPS is decent

Game 60 FPS / Magpie 60 FPS / Monitor 60 Hz, but some frames dropped after rendered, instead of present on screen. This also happens on native game Window without use scaling.

Check Max Frame Rate and vertical sync. For example, you have 60 Hz monitor and set vertical sync on as mentioned above, you need to remove Max Frame Rate settings too, if you have set Max Frame Rate to 60 FPS before.

If you have other frame limiter like MSI Afterburner RTSS, also turn it of.

Mislead:

  1. Set global Max Frame Rate to 60 FPS and turn off Max Frame Rate for certain program, this will not work as intend. When you have program Max Frame Rate off and vertical sync off, but you have global Max Frame Rate, game and Magpie still follow global Max Frame Rate limit.
  2. Use Max Frame Rate as "better vertical sync method" because they say "by doing this can reduce input lag". No, Max Frame Rate is not vertical sync, it doesn't guarantee every rendered frame to be present on monitor, which is "old fashion vertical sync" will do.

Low Lantancy Mode

Check these options if you encountered some other strange behavior. I'm not sure if Magpie has these issue, but for Lossless Scaling, use "Low Lantancy Mode: Ultra" will cause WGC API drag and drop position step back after release mouse button.

Set "Low Lantancy Mode: Off" for Magpie. But you may leave "Low Lantancy Mode: Ultra" for games if needed and you know it won't cause bug. For example, some old DirectX 9 game doesn't work well with this setting, it cause frame drop and input lag, if that happen just set it to off.

text
For AMD users

Placeholder

Welcome provide more performance tips for us. You may also check Nvidia tips and guess if some condition match your setup.

text
Hyperthread and big.little CPUs

Hyperthread and Intel Alder Lake big.little CPUs

I suggest if you don't want to turn off Hyperthread, use cmd.exe batch start /affinity 0x55 "" "C:\path to\game.exe" for game or it's launcher, game will inherit parent process affinity. And start /affinity 0xaa for Magpie. Also adjust game graphics options, try to limit game CPU usage below 50% (4 physical core of 4 core 8 thread as example).

The 0x55 specify game run on 0 2 4 6 logical core of 4 core CPU, and other stuff 0xaa run on 1 3 5 7.

For high priority, use start /abovenormal for both game and Magpie, but I find certain game are easy to crash with affinity and higher priority for unknown reason. As an example, dwm.exe system service running at high. In such case, use power plan high performance to make CPU run at highest clock speed is the last choice.

0x55 and 0xaa are example value, I use https://bitsum.com/tools/cpu-affinity-calculator

You may also utilize this trick to force game run on big cores of Intel Alder Lake big.little CPUs.

Reference:
https://superuser.com/questions/690509/does-windows-know-how-to-appropriately-assign-threads-to-a-quad-core-processor-t

Still lagging?

  1. Change the capture mode. We recommend you to try each of them.
  2. Turn on "Disable DirectFlip." DirectFlip is a technology to reduce input lag, but may be incompatible with some certain games.
  3. If you have multiple graphics card, try changing the graphics adaptor.
  4. Increase the process priority of Magpie and the priority in the driver (if such options exist).
  5. Please submit an Issue (Performance) if none of the attempts above works.

I'd like to reduce the power consumption of Magpie

When you need to save electricity or reduce the heat generated, try the following:

  1. Limit the frame rate.
  2. Opt for effects that require lower performance.


以编程方式与 Magpie 交互 (`docs/以编程方式与 Magpie 交互.md`)

Magpie 提供了和其他程序交互的机制。通过它们,你的应用可以和 Magpie 配合使用。

MagpieWatcher 演示了如何使用这些机制。

如何在缩放状态改变时得到通知

你应该监听 MagpieScalingChanged 消息。

c++
UINT WM_MAGPIE_SCALINGCHANGED = RegisterWindowMessage(L"MagpieScalingChanged");

参数

wParam 为事件 ID,对于不同的事件 lParam 有不同的含义。支持以下事件:

  • 0: 缩放已结束或源窗口失去焦点。缩放结束时 lParam 为 0,否则为 1。
  • 1: 缩放已开始或源窗口回到前台。lParam 为缩放窗口句柄。
  • 2: 缩放窗口位置或大小改变。窗口模式缩放时才会生成这个事件。
  • 3: 用户开始调整缩放窗口大小或移动缩放窗口。窗口模式缩放时才会生成这个事件。

在调整缩放窗口大小或移动缩放窗口的过程中不会产生事件,但你可以定期检查窗口属性来获得更新的信息。

注意事项

如果你的进程完整性级别 (Integration level) 比 Magpie 更高,由于用户界面特权隔离 (UIPI),你将无法收到 Magpie 广播的消息。这种情况下请调用 ChangeWindowMessageFilterEx 以允许接收 MagpieScalingChanged 消息。

c++
ChangeWindowMessageFilterEx(hYourWindow, WM_MAGPIE_SCALINGCHANGED, MSGFLT_ADD, nullptr);

如何获取缩放窗口句柄

你可以监听 MagpieScalingChanged 消息来获取缩放窗口句柄,也可以查找类名为Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22的窗口以在缩放中途获取该句柄。Magpie 将确保此类名不会改变,且不会同时存在多个缩放窗口。

c++
HWND hwndScaling = FindWindow(L"Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22", nullptr);

如何将你的窗口置于缩放窗口上方

你应该监听 MagpieScalingChanged 消息,根据事件调整自己的 Z 轴顺序。下面是一个简单的示例,更复杂的用例参见 MagpieWatcher。

c++
if (message == WM_MAGPIE_SCALINGCHANGED) {
    if (wParam == 0) {
        // 取消置顶
        SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
    } else if (wParam == 1) {
        // 确保本窗口在缩放窗口上面
        SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
    }
}

如何获取缩放信息

缩放窗口的窗口属性中存储着缩放信息。目前支持以下属性:

  • Magpie.Windowed:是否处于窗口模式缩放
  • Magpie.SrcHWND: 源窗口句柄
  • Magpie.SrcLeft、Magpie.SrcTop、Magpie.SrcRight、Magpie.SrcBottom: 被缩放区域的边界
  • Magpie.DestLeft、Magpie.DestTop、Magpie.DestRight、Magpie.DestBottom: 缩放后区域矩形边界
c++
HWND hwndSrc = (HWND)GetProp(hwndScaling, L"Magpie.SrcHWND");
bool isWindowed = (bool)GetProp(hwndScaling, L"Magpie.Windowed");

RECT srcRect;
srcRect.left = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcLeft");
srcRect.top = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcTop");
srcRect.right = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcRight");
srcRect.bottom = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcBottom");

RECT destRect;
destRect.left = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestLeft");
destRect.top = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestTop");
destRect.right = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestRight");
destRect.bottom = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestBottom");

注意事项

  1. 这些属性只在缩放窗口初始化完成后才保证存在,因此建议检索属性前检查缩放窗口是否可见,尤其是当窗口句柄是使用类名获取到的。
  2. 这些属性中存储的坐标不受 DPI 虚拟化影响,你需要将程序的 DPI 感知级别设置为 Per-Monitor V2 才能正确使用它们。有关详细信息,请参阅 High DPI Desktop Application Development on Windows。

关于触控支持 (`docs/关于触控支持.md`)

由于操作系统的安全限制,Magpie 需要 UIAccess 权限来支持触控输入。获得此权限需要满足两个条件:

  1. 应用程序必须有一个数字签名,且该签名能够通过与本地计算机上受信任的根证书颁发机构存储相关联的证书来验证。
  2. 应用程序必须位于“安全位置”,例如 Program Files、System32 等文件夹中。

启用触控支持时,Magpie 将进行以下操作:

  1. 向受信任的根证书颁发机构存储添加自签名证书。
  2. 将 TouchHelper.exe 文件复制到 System32\Magpie 文件夹。在缩放时,Magpie 会运行此程序以实现触控支持。

这两项操作都对操作系统构成重大更改,因此需要管理员权限。如果不再需要触控支持,应关闭此选项,Magpie 会撤销这些更改,不在操作系统中留下痕迹。

触控支持可能会因为某些原因失效(比如 TouchHelper.exe 需要更新时),如果发生这种情况,Magpie 会在缩放前请求管理员权限来修复它。


内置效果介绍 (`docs/内置效果介绍.md`)

Magpie 内置了大量效果供组合使用,大部分提供了参数选项以订制行为。所有效果存储在 effects 文件夹中,如果你了解 HLSL,你可以很容易的添加任何你想要的效果,见 MagpieFX。

内置效果介绍

  • ACNet:ACNetGLSL 的移植。适合动画风格图像的缩放,有较强的降噪效果

    • 输出尺寸:输入的两倍
  • AdaptiveSharpen:自适应锐化算法。此算法着重于锐化图像中的模糊边缘,因此相比一般的锐化算法噪点、振铃和条纹更少。

    • 输出尺寸:和输入相同
    • 参数
      • Sharpness:锐化强度
  • Ani4Kv2_ArtCNN_C4F32_i:移植自 Ani4K-v2

    • 输出尺寸:输入的两倍
  • Anime4K_3D_AA_Upscale_US 和 Anime4K_3D_Upscale_US:Anime4K 提供的 3D 游戏画面缩放算法。AA 变体有抗锯齿的功能

    • 输出尺寸:输入的两倍
  • Anime4K_Denoise_Bilateral_Mean、Anime4K_Denoise_Bilateral_Median 和 Anime4K_Denoise_Bilateral_Mode:Anime4K 提供的降噪算法,分别使用平均数、中位数和众数

    • 输出尺寸:和输入相同
    • 参数
      • Strength:降噪强度
  • Anime4K_Restore 族:Anime4K 提供的用于还原动漫画面线条的算法,S->M->L->VL->UL 对性能的需求依次提高,Soft 变体效果稍弱

    • 输出尺寸:和输入相同
  • Anime4K_Thin_HQ:Anime4K 提供的用于细化动漫画面线条的算法

    • 输出尺寸:和输入相同
    • 参数
      • Strength:每次迭代的强度
      • Iterations:迭代次数。降低 Strength 并提高 Iterations 可以提高画面质量,但会降低速度。
  • Anime4K_Upscale 族:Anime4K 提供的动画风格图像缩放算法。Denoise 变体包含降噪效果,GAN 变体处于实验阶段,可以保留更多细节。S、L、VL、UL 对性能的要求依次提高

    • 输出尺寸:输入的两倍
  • Bicubic:双立方(双三次)插值算法

    • 输出尺寸:取决于缩放选项
    • 参数
      • B:过滤参数 B。此项过大将模糊
      • C:过滤参数 C。此项过大将产生振铃
    • 备注:通过自由组合不同的BC数值可以实现不同的变体算法,例如:Mitchell(B=C≈0.333333), Catmull-Rom(B=0 C=0.5), bicubic Photoshop(B=0 C=0.75), Spline(B=1 C=0)
  • Bilinear:双线性插值

    • 输出尺寸:取决于缩放选项
  • CAS:FidelityFX-CAS 的移植。轻量级的锐化效果

    • 输出尺寸:和输入相同
    • 参数
      • Sharpness:锐化强度
  • CAS_Scaling:FidelityFX-CAS 的移植。支持缩放

    • 输出尺寸:取决于缩放选项
    • 参数
      • Sharpness:锐化强度
  • CRT_Easymode:易于配置的轻量级 CRT 着色器

    • 输出尺寸:取决于缩放选项
    • 参数
      • Sharpness Horizontal:横向锐度
      • Sharpness Vertical:纵向锐度
      • Mask Strength:遮罩强度
      • Mask Dot Width
      • Mask Dot Height
      • Mask Stagger
      • Mask Size
      • Scanline Strength
      • Scanline Beam Width Min
      • Scanline Beam Width Max
      • Scanline Brightness Min
      • Scanline Brightness Max
      • Scanline Cutoff
      • Gamma Input
      • Gamma Output
      • Brightness Boost:用于提高亮度
      • Dilation
  • CRT_Geom:最流行的 CRT 着色器之一,旨在模拟 Arcade-machine。此实现不支持模拟隔行扫描。见 Emulation General Wiki

    • 输出尺寸:取决于缩放选项
    • 参数
      • Target Gamma
      • Monitor Gamma
      • Distance
      • Curvature:是否模拟屏幕曲率
      • Curvature Radius:曲率半径
      • Corner Size
      • Corner Smoothness
      • Horizontal Tilt
      • Vertical Tilt
      • Horizontal Overscan
      • Vertical Overscan
      • Dot Mask
      • Sharpness:值越大图像越清晰
      • Scanline Weight
      • Luminance Boost:用于提升亮度
  • CRT_Hyllian:提供锐利清晰的输出,并带有轻微的光晕,类似于索尼的 BVM 系列显示器

    • 输出尺寸:取决于缩放选项
    • 参数
      • Phosphor
      • Vertical Scanlines
      • Input Gamma
      • Output Gamma
      • Sharpness
      • Color Boost
      • Red Boost
      • Green Boost
      • Blue Boost
      • Scanline Strength
      • Min Beam Width
      • Max Beam Width
      • Anti-Ringing
  • CRT_Lottes:提供多种遮罩,可以模拟 Bloom 和 Halation 效果。类似于 CGA 街机显示器

    • 输出尺寸:取决于缩放选项
    • 参数
      • Scanline Hardness
      • Pixel Hardness
      • Horizontal Display Warp
      • Vertical Display Warp
      • Mask Dark
      • Mask Light
      • Shadow Mask:遮罩风格
      • Brightness Boost
      • Bloom-X Soft
      • Bloom-Y Soft
      • Bloom Amount
      • Filter Kernel Shape
  • CuNNy 族:适合视觉小说风格图像的缩放,由 CuNNy 提供。DS 变体有轻微降噪效果

    • 输出尺寸:输入的两倍
  • CuNNy2 族:CuNNy 的改进版

    • 输出尺寸:输入的两倍
  • Deband:去除色带

    • 输出尺寸:和输入相同
    • 参数
      • Threshold:当像素之间的差异低于此值时,它被认为是渐变的一部分
      • Range:采样范围。较高的值将找到更多的梯度,较低的值将更积极地去除色带
      • Iterations:迭代次数。增加迭代次数可能会提高质量,但会减慢着色器的速度
      • Grain:噪点强度。在图像中添加一些额外的噪点可以有效遮盖剩余的条纹和伪影,且对视觉质量的影响较小
  • FineSharp:高质量的锐化效果,最初是 AviSynth 脚本

    • 输出尺寸:和输入相同
    • 参数
      • sstr:锐化强度。如果改变了此参数,也要改变 cstr,见备注
      • cstr:均衡化的强度
      • xstr:XSharpen 风格的最终锐化步骤的强度
      • xrep:用于修复最终锐化步骤产生的伪影
    • 备注:sstr 和 cstr 的对应关系(sstr->cstr):0->0, 0.5->0.1, 1.0->0.6, 2.0->0.9, 2.5->1.00, 3.0->1.09, 3.5->1.15, 4.0->1.19, 8.0->1.249, 255.0->1.5
  • FSR_EASU:FidelityFX-FSR 中缩放步骤的移植

    • 输出尺寸:取决于缩放选项
  • FSR_RCAS:FidelityFX-FSR 中锐化步骤的移植

    • 输出尺寸:和输入相同
    • 参数
      • Sharpness:锐化强度
  • FSRCNNX:FSRCNNX_x2_8-0-4-1 的移植

    • 输出尺寸:输入的两倍
  • FSRCNNX_LineArt:FSRCNNX_x2_8-0-4-1_LineArt 的移植

    • 输出尺寸:输入的两倍
  • FXAA_Medium、FXAA_High 和 FXAA_Ultra:快速近似抗锯齿。对性能的要求依次提高

    • 输出尺寸:和输入相同
  • GTU_v050:旨在模拟 CRT 屏幕的模糊和混合效果而不是遮罩或曲率,支持扫描线

    • 输出尺寸:取决于缩放选项
    • 参数
      • Composite Connection
      • No Scanlines
      • Signal Resolution Y
      • Signal Resolution I
      • Signal Resolution Q
      • TV Vertical Resolution
      • Black Level
      • Contrast
  • ImageAdjustment:图像参数调整

    • 输出尺寸:和输入相同
    • 参数
      • Target Gamma:和 monitorGamma 搭配使用以调节 gamma,此参数指定目标 gamma 值
      • Monitor Gamma:当前屏幕的 gamma 值
      • Saturation:色度
      • Luminance:HSV 空间的明度
      • Contrast:对比度
      • Brightness Boost:亮度调整
      • Black Level:暗场强度
      • Red Channel:红色通道颜色缩放
      • Green Channel:绿色通道颜色缩放
      • Blue Channel:蓝色通道颜色缩放
  • Jinc:使用 Jinc 算法缩放输入

    • 输出尺寸:取决于缩放选项
    • 参数
      • Window Sinc Param:值越小图像越锐利
      • Sinc Param:值越大图像越锐利
      • Anti-ringing Strength:抗振铃强度
  • k7_modernAnime:适合动漫类风格的超分算法

    • 输出尺寸:输入的两倍
  • Lanczos:使用 Lanczos 算法缩放输入。

    • 输出尺寸:取决于缩放选项
    • 参数
      • Anti-ringing Strength:抗震铃强度。值越大抗震铃效果越好,但图像越模糊
  • LCAS:轻量级 3D 画面缩放算法

    • 输出尺寸:取决于缩放选项
    • 参数
      • Sharpness:锐化强度
  • LumaSharpen:reshade 中流行的锐化效果。

    • 输出尺寸:和输入相同
    • 参数
      • Sharpening Strength:锐化强度
      • Sharpening Limit:抗振铃强度
      • Sample Pattern:滤波器类型,支持 4 种滤波器
      • Offset Bias:滤波器参数的偏移量
  • MMPX:像素画缩放算法。可在保留艺术风格的同时添加细节

    • 输出尺寸:输入的两倍
  • Nearest:最近邻插值

    • 输出尺寸:取决于缩放选项
  • NIS:NVIDIA Image Scaling 的移植

    • 输出尺寸:取决于缩放选项
    • 参数
      • Sharpness:锐化强度
    • 备注:只支持放大
  • NNEDI3 族:原本用于去隔行,也是高质量的插值算法。移植自 https://github.com/bjin/mpv-prescalers

    • 输出尺寸:输入的两倍
  • NVSharpen:随 NIS 发布的 NVSharpen 的移植

    • 输出尺寸:和输入相同
    • 参数
      • Sharpness:锐化强度
  • Pixellate:使用 Pixellate 算法缩放输入。适合放大像素画

    • 输出尺寸:取决于缩放选项
  • RAVU 族:移植自 https://github.com/bjin/mpv-prescalers

    • 输出尺寸:输入的两倍
  • RAVU-Zoom 族:移植自 https://github.com/bjin/mpv-prescalers

    • 输出尺寸:取决于缩放选项
    • 备注:只支持放大
  • SGSR:Snapdragon Game Super Resolution v1 的移植

    • 输出尺寸:取决于缩放选项
    • 参数
      • Edge Sharpness:边缘锐化强度(值越大图像越锐利)
      • Edge Threshold:边缘检测阈值
  • SharpBilinear:使用 Sharp-Bilinear 算法缩放输入。适合放大像素画

    • 输出尺寸:取决于缩放选项
  • SMAA_Low、SMAA_Medium、SMAA_High 和 SMAA_Ultra:SMAA 抗锯齿算法。对性能的要求依次提高

    • 输出尺寸:和输入相同
  • SSimDownscaler:基于感知的图像缩小算法。移植自 igv/SSimDownscaler.glsl

    • 输出尺寸:取决于缩放选项
    • 参数
      • Oversharp:值越大图像越锐利
  • xBRZ_2x、xBRZ_3x、xBRZ_4x、xBRZ_5x 和 xBRZ_6x:使用 xBRZ 算法缩放输入。适合放大像素画

    • 输出尺寸:取决于变体。放大到输入的 2-6 倍
  • xBRZ_Freescale:支持任意缩放倍数的 xBRZ 算法

    • 输出尺寸:取决于缩放选项

性能优化建议 (`docs/性能优化建议.md`)

如果你遇到了性能问题(卡顿、延迟、功耗过高等),本文档可能有所帮助。

下面是一些你可能面临的情况:

我的显卡性能不足

如果你无法流畅使用一些有较高性能要求的效果(如 Anime4K、AdaptiveSharpen 等),请尝试下面的操作:

  1. 更换为性能需求更低的效果。如 Anime4K_Upscale_S 比 Anime4K_Upscale_L 快的多,CAS 比 AdaptiveSharpen 快的多,它们可以有效提高流畅度,代价是一定程度的画面质量损失。
  2. 尝试更换捕获模式。建议你每种模式都尝试一下。

间歇性卡顿

假设你的显卡性能对于运行 Magpie 绰绰有余,但依然遇到卡顿问题。请尝试下面的操作:

text
对于 Nvidia 用户

假设您使用的是 Windows 11 24H2

以下提示仅适用于 Nvidia 用户。Nvidia 显卡的驱动程序配置不当可能是造成卡顿的原因。

快速提示:将 Nvidia 驱动程序设置恢复为默认设置(全新安装)将解决大多数问题。但是,如果您坚持使用自己的设置,让我们解释一下驱动程序设置如何给程序带来麻烦。

缩放一段时间后出现奇怪的帧率下降

刚开始时一切正常(游戏 60 FPS / Magpie 60 FPS),但大约 10~15 秒后,游戏和 Magpie 的帧率都会下降到 37 FPS 左右,同时 GPU 占用率飙升至 100%,GPU 频率从约 1000MHz 降至 700MHz。

首先,如果你在游戏时使用了“电源管理模式:最佳功耗”,尝试将 Magpie 设为“首选最大性能”或“自适应”(我尚未测试“自适应”模式,效果不保证)。游戏本身保持“最佳功耗”模式即可。这样设置后,GPU 频率将不会异常下降。

Nvidia App 与 Nvidia 控制面板

不过,我的一台电脑即便使用上述方法仍然无法解决,而其他设备都能正常恢复。经过调查发现,Nvidia App 和 Nvidia 控制面板之间存在兼容性问题。如果你使用 Nvidia App 修改了驱动设置,然后在控制面板中修改相同的设置,可能会导致控制面板崩溃,或出现“访问被拒绝”的错误。此外,Nvidia App 进行的驱动设置更改不会真正应用到游戏或程序。

如果你使用的是 Nvidia App 11.0.2.341 版本,并搭配 572.16 版驱动,请不要通过 Nvidia App 调整 Nvidia 驱动设置。解决方案如下:

  1. 关闭 Nvidia App 和 Nvidia 控制面板。
  2. 进入 C:\ProgramData\NVIDIA Corporation\Drs 目录,删除所有 .bin 文件,例如 nvdrsdb0.bin、nvdrsdb1.bin、nvdrssel.bin、update.bin 等。
  3. 重新打开 Nvidia 控制面板,手动重新配置所有全局设置和特定程序的设置。
  4. 之后避免使用 Nvidia App 修改驱动设置。

画面看起来不如原生游戏窗口流畅

使用 Graphics Capture 或 Desktop Duplication 时,即使游戏和 Magpie 都是 60 FPS,画面仍然不够流畅。

调查结果表明,这可能与垂直同步有关。至少在 Windows 11 24H2 版本中,游戏必须开启垂直同步,才能保证 WGC 和 DXGI 捕获模式不会丢帧。否则,即使捕获和游戏都运行在 60 FPS,仍可能发生帧丢失或重复帧现象。

推荐的垂直同步设置:

  • 游戏:使用传统垂直同步模式,例如:
    • “使用 3D 应用程序设置”并在游戏内启用 V-Sync
    • 直接选择“垂直同步:开”
  • 不要使用以下选项:
    • 关闭垂直同步
    • “垂直同步:快速”模式
  • 未测试但可能有效的选项:
    • “垂直同步:自适应 / 自适应(半刷新率)”

对于 Magpie,请选择“使用 3D 应用程序设置”。

使用 Desktop Duplication 时丢帧严重

即使游戏 60 FPS / Magpie 60 FPS,仍然会遇到大量丢帧问题。我发现这种情况出现在 Magpie v0.10.6 版本。解决方法:

  • 在 Magpie 设置中启用垂直同步,并在 Nvidia 控制面板中将 Magpie 的垂直同步设置为“使用 3D 应用程序设置”。
  • 升级到 Magpie v0.11.1 也能解决此问题。

GPU 使用率接近 100% 时 Magpie 丢帧严重

同时,游戏帧率略低于显示器帧率,例如游戏帧率 57 FPS / 显示器帧率 60 Hz。如果不使用 Magpie,原生游戏窗口看起来很流畅。

尝试关闭“硬件加速 GPU 计划”并重启。我发现,当 GPU 负载过重且 GPU 计划开启时,WGC 和桌面复制都无法正确处理帧。关闭 GPU 计划后,游戏帧率仍然很低,但 Magpie 不会再“视觉上”低于 10 FPS。

屏幕观感不流畅,但帧率看起来正常

游戏 60 FPS / Magpie 60 FPS / 显示器 60 Hz,但出现丢帧。这种情况在未缩放、直接运行游戏窗口时也会发生。

请检查是否启用了“最大帧率限制”和垂直同步。例如,在上述情况下,如果你已经打开了垂直同步,同时将最大帧率限制设为 60 FPS,请移除该限制。

如果你有其他帧率限制程序(如 MSI Afterburner RTSS),也请将其关闭。

常见误区:

  1. 将“最大帧率”设置为全局 60 FPS,然后对某些程序关闭帧率限制,这实际上不会如你所愿生效。如果你对程序关闭了最大帧率限制和垂直同步,但启用了全局最大帧率,游戏和 Magpie 仍会遵循全局的帧率限制。
  2. 有人将“最大帧率”视作更优的垂直同步方法,理由是“这样可以降低输入延迟”。其实并非如此。最大帧率限制并不是垂直同步,它无法保证每一帧都能被完整呈现,而传统的垂直同步正是为此目的而设计的。

低延迟模式

如果遇到其他奇怪的现象,可以检查这些选项。我不确定 Magpie 是否有这些问题,但对于 Lossless Scaling,使用“低延迟模式:超高”会导致 WGC API 缩放后拖拽鼠标时,释放鼠标按钮后鼠标位置和释放按钮时不一致。

为 Magpie 设置“低延迟模式:关闭”。但对于游戏,如果你确定启用“低延迟模式:超高”不会引发问题,也可以保留该设置。例如,一些旧的 DirectX 9 游戏在启用此模式后可能会出现掉帧或输入延迟问题,如果遇到这种情况,建议将其关闭。

text
对于 AMD 用户

欢迎分享更多性能优化技巧!你也可以查看 Nvidia 相关建议,看看其中哪些适用于你的配置。

text
超线程和大小核CPU

超线程与 Intel Alder Lake 大小核架构 CPU

如果你不想关闭超线程,可以使用批处理命令来限制游戏和 Magpie 的 CPU 亲和性(Affinity)。对游戏或其启动器使用 cmd.exe 批处理 start /affinity 0x55 "" "C:\path to\game.exe",游戏将继承父进程的 CPU 亲和性。对 Magpie 使用 start /affinity 0xaa。此外,你还可以调整游戏图形设置,尽量将游戏的 CPU 占用控制在 50% 以下(以 4 核 8 线程 CPU 为例,相当于使用 4 个物理核心)。

0x55 指定游戏在 4 核 CPU 的 0 2 4 6 逻辑核心上运行,0xaa 指定其他程序在 1 3 5 7 上运行。

如果需要提高进程优先级,可以使用 start /abovenormal 为游戏和 Magpie 设置“高于正常”优先级。但需要注意,某些游戏在设置 CPU 亲和性和提高进程优先级后可能更容易崩溃,具体原因不明。例如,dwm.exe 系统服务本身就以“高”优先级运行。若遇到稳定性问题,可以考虑改用高性能电源计划,让 CPU 长时间运行在最高频率。

0x55 和 0xaa 只是示例值,你可以使用 Bitsum CPU 亲和性计算器 来计算适合自己 CPU 的值。

此外,你也可以利用这种方法,强制游戏仅运行在 Intel Alder Lake 大小核架构的“大核”上,以获得更好的性能。

参考:
https://superuser.com/questions/690509/does-windows-know-how-to-appropriately-assign-threads-to-a-quad-core-processor-t

仍然卡顿?

  1. 更换捕获模式。建议你每种模式都尝试一下。
  2. 打开“禁用 DirectFlip”。DirectFlip 是一个用于降低输入延迟的技术,但可能和某些游戏不兼容。
  3. 试试切换使用的显卡。
  4. 提高 Magpie 的进程优先级以及在驱动中提高 Magpie 的优先级(如果有这个选项)。
  5. 如果上面的尝试不起作用,请提交一个 Issue (Performance)。

我想降低 Magpie 的功耗

在需要节省电量或降低发热时,请尝试下面的操作:

  1. 限制帧率。
  2. 更换为性能需求更低的效果。

捕获方式对比 (`docs/捕获方式对比.md`)

Magpie 提供数种捕获方式,根据使用场景,它们各有优劣。无特殊需求应使用 Graphics Capture,它提供最好的兼容性和流畅度。

Graphics Capture Desktop Duplication GDI DwmSharedSurface
支持捕获 DirectComposition (如 UWP) 是 是 否 否
支持录制/串流 特殊情况下不支持[1] 否 是 是
支持源窗口跨越多个屏幕 特殊情况下不支持[1] 否 是 是
无视 DPI 虚拟化[2] 否 否 是 是
备注 首选捕获方式 要求 Win10 v2004 性能不稳定,不建议使用

[1]: (1) 源窗口不支持常规的窗口捕获 (2) 操作系统为 Windows 11

[2]: 系统会对不支持 DPI 缩放的窗口进行双三次插值放大,支持此项的捕获方式可以捕获到放大前的图像


编译指南 (`docs/编译指南.md`)

先决条件

为了编译 Magpie,你首先需要安装:

  1. Visual Studio 2026 的最新版本,需要安装“使用 C++ 的桌面开发”和“通用 Windows 平台开发”两个工作负荷以及 Windows SDK build 26100 或更高版本。

  2. Python 3.14+

  3. Conan

    bash
    pip install conan

    确保上述依赖均已被添加入系统路径,使用以下命令检查:

    bash
    python --version
    conan --version

编译

  1. 克隆存储库

    bash
    git clone https://github.com/Blinue/Magpie
  2. 打开根目录的 Magpie.slnx 然后生成解决方案。

启用触控支持

为了支持触控输入,TouchHelper.exe 应签名。签名是在 CI 中自动进行的,但你也可以手动签名,请执行以下步骤:

  1. 创建自签名证书,将其导出为 pfx。
  2. 将 src/Magpie/TouchHelper.cpp 中的 CERT_FINGERPRINT 常量替换为你的证书的 SHA-1 哈希值(也即该证书的指纹)。
  3. 在存储库根目录下执行以下命令:
bash
python scripts/publish.py --pfx-path=<pfx 路径> --pfx-password=<pfx 密码>

这将编译 Magpie 并为 TouchHelper.exe 签名。编译出的程序位于 publish\x64。


--- METRICS ---