打开 Windows 之窗:将 RADV 移植到 Win32
Cracking Windows Open: Porting RADV to Win32

原始链接: https://www.collabora.com/news-and-blog/news-and-events/cracking-windows-open-porting-radv-to-win32.html

Louis-Francis Ratté-Boulianne 详细介绍了将开源 Mesa Vulkan 驱动程序 RADV(适用于 AMD GPU)移植到 Windows 的持续努力。RADV 是 Linux 上的标准驱动,而 Windows 用户目前只能使用 AMD 的专有驱动程序。 该项目基于 Faith Ekstrand 的初步研究,通过逆向工程与专有的 WDDM2 内核模式驱动程序进行交互。通过记录不透明的厂商特定数据调用,团队成功使 RADV 能够运行包括《反恐精英 2》在内的 3D 应用程序。这一举措改善了跨平台调试,促进了社区贡献,并建立了一个统一的代码库。 尽管取得了进展,但仍存在重大障碍。由于依赖于逆向工程所得的无文档接口,驱动程序非常脆弱,因为 AMD 会频繁更新其专有结构。要实现生产级的稳定性,需要 AMD 提供官方的文档化接口或稳定的中间层。此外,在高性能呈现层(如 DXGI 交换链)方面,还需要进一步的工作。 在 Valve 的支持下,该项目展示了在 Windows 上使用开源 Vulkan 驱动程序的潜力,旨在鼓励行业合作,为该平台未来的图形技术建立一个稳定且可维护的基础。

最近的一场 Hacker News 讨论探讨了将开源 GPU 驱动程序移植到旧版 Windows 操作系统(如 Windows 95/98)的可行性。讨论核心围绕着 Collabora 关于将 RADV Vulkan 驱动程序移植到 Win32 的文章展开。 虽然开发专用的内核模式驱动程序(KMD)常被视为一大障碍,但参与者认为,现代大语言模型(LLM)有望辅助完成此类项目所需的繁琐“粘合代码”编写工作。讨论指出,利用现有的 AMD、NVIDIA 和 Intel 开源驱动程序,可以为早期从未获得原生支持的 Windows 环境提供完整的 2D 和 3D 加速。爱好者们认为,在人工智能辅助编程的帮助下,即使是在 Windows 95 上运行 CUDA 等复杂功能,从理论上讲也是可以实现的。
相关文章

原文

Louis-Francis Ratté-Boulianne
July 28, 2026

RADV is the open source Mesa Vulkan driver for AMD GPUs. Over the years, it has become a cornerstone of the Linux graphics stack. It has now effectively become the de facto Vulkan driver for AMD hardware on Linux. AMD even discontinued their PAL-based (Platform Abstraction Library) alternative in its favor, consolidating their open-source efforts around Mesa.

On Windows however, AMD users are still served only by the proprietary driver. But don't panic, we have a solution: porting RADV to Windows, bringing the same open source Vulkan implementation that has proven itself on Linux to them. It's such an improbable proposition that we might actually get there faster than light (spoiler alert: that's going to be a little slower).

An open source Vulkan driver on Windows opens up a number of possibilities: a shared codebase across platforms, easier debugging and experimentation, faster turnaround on fixes, and a path for the community (e.g., game developers) to report problems or contribute improvements that benefit everyone regardless of operating system.

From first triangle...

This effort builds directly on the groundwork laid by Faith Ekstrand, who first explored the feasibility of running RADV on Windows and presented her findings at XDC 2024. We strongly suggest you go watch the talk, but here is a quick summary.

A central theme of her talk is that since Windows 10, the WDDM2 interface provides a much better foundation for a third-party driver than what came before. It defines a clear model for how a user-mode driver (UMD) interacts with the operating system and the kernel-mode driver (KMD).

However, there is of course a significant catch: many D3DKMT calls can carry private driver data - opaque, vendor-specific blobs whose contents are entirely up to the driver. This means the UMD and KMD remain tightly coupled and that this interface is totally undocumented.

To work around this, Faith created the wddm2-pdd-re tool to log the WDDM2 calls and the private data content for some D3D12 applications. Using this approach, she was able to reverse engineer enough of the private interface — querying adapter info, allocating buffers, creating queues, and submitting commands — to get RADV to submit work to the proprietary kernel driver. And ultimately she was even able to get a rotating 3D model displayed on her screen in all its glory.

...to first game

Where Faith's work established that this could be done, this project picked up the thread. The goal was to improve upon it to make it more flexible (support for different hardware by reducing hard-coded values), more portable (breaking free of WSL with native Windows support), and far more stable (no longer crashing after two minutes of deqp-vk testing).

We improved command stream handling and synchronization and added support for, among others, sparse bindings, tessellation and task shaders, and dynamic querying of GPU properties. It is still not conformant (even though the success rate has dramatically increased), but the real highlight is being able to run our first game with RADV: Counter-Strike 2. Anyone can try it by switching the renderer with the -vulkan argument.

CounterStrike 2 running on top of RADV

...through darkness

Like any port and/or reverse-engineering project, it brought some challenges:

  • New generation is so oversensitive: We were experimenting on Gen 11 hardware (RX 7900 XT) while Faith was working with a 10th Gen GPU (RX 7800 XT). We weren't able to replicate Faith's results for quite a while, due to architecture changes between these two generations. The main problem was that it would hang as soon as we tried to do anything more complicated than clearing a surface to a hard-coded color. Unfortunately, with no tools to debug such hangs on Windows, this forced us to improve the tooling to reduce discrepancies with the proprietary driver as much as possible. We upgraded the reverse-engineering utility into a full WDDM2 logging layer, able to analyze any application run with the official Vulkan driver, and added support to dump the command streams, registers, and shader code.

  • Compilers are not playing nice: Mesa is developed primarily against GCC and Clang, and its code base relies on a number of assumptions that don't stand when compiling with MSVC. For instance, MSVC doesn't agree with the other compilers on how to handle enums: it can interpret a value as signed and limit them to 32-bit values, which can result in quite surprising behaviors.

  • I've heard you liked opaque blobs: So let's put opaque data inside your opaque API call - D3DKMTEscape. WDDM2 has the possibility of vendor-specific hooks through that method, where the entire content is completely up to the vendor. There is no defined structure, and the only limitation is that it shouldn't replicate something for an existing "standardized" call. Fortunately for us, it looks like we can safely ignore those for now, as they seem to focus on advanced features such as multi-GPU rendering.

...and beyond

The biggest open question for making this production-ready is the interface to the proprietary kernel driver. Developing our own KMD is not really an option, so we need to communicate with AMD's. Right now, doing so relies on reverse-engineered knowledge of private data structures — which is inherently fragile. To make matters worse, the UMD and KMD ship together as a matched pair with no backward-compatibility guarantee, so these structures can change between driver versions with no notice.

For RADV to become genuinely stable and maintainable on Windows, we need one of:

  • A stable, documented interface to the proprietary kernel-mode driver, or
  • A shim library that mediates communication with the KMD through the private data channel, giving us a stable surface to build against even as the underlying blobs evolve.

There is also significant work remaining on presentation. While Jesse Natalie did some work on WSI for Windows (in the context of the Dozen driver), RADV currently only supports the slower CPU path for presentation. More work is needed to enable the use of DXGI swapchains to improve performance, but that requires being able to import an image from D3D12 (more opaque metadata, hurrah!). Even more work would be required to achieve zero-copy swaps, the pinnacle of graphics pipelines. It could potentially lead to a 3x performance gain for applications that are not GPU-bound. Accomplishing that last step would also require direct involvement from AMD and probably Microsoft (as there are some limitations related to image sharing). There are precedents to that kind of quality-of-life improvements for open-source projects, so there is hope!

We hope this work demonstrates the value of an open Vulkan driver on Windows and helps motivate everybody involved to work toward that stable foundation. For anyone interested, the work is currently sitting in this branch.

Thanks also to Valve for sponsoring this phase of our work to bring open drivers to Windows.

 

联系我们 contact @ memedata.com