# DirectX 光线追踪

**DirectX 光线追踪**（DirectX Raytracing，DXR）是微软推出的光线追踪API，作为DirectX 12的一项功能，于2018年3月19日在[游戏开发者大会](https://www.edgepedia.org/zh/game-developers-conference)上公布。它让游戏能够在GPU上针对场景的完整三维表示进行光线追踪，因此反射、阴影和全局光照等效果直接来自算法本身，而非光栅化的变通手段。<sup>[1](https://devblogs.microsoft.com/directx/announcing-microsoft-directx-raytracing/)</sup>

| 关键事实 | 详情 |
|---|---|
| 公布时间 | 2018年3月19日，GDC，作为DirectX 12的一项功能<sup>[1](https://devblogs.microsoft.com/directx/announcing-microsoft-directx-raytracing/)</sup> |
| 交付用户 | Windows 10 2018年10月更新，DXR在支持的硬件上开箱即用<sup>[2](https://devblogs.microsoft.com/directx/directx-raytracing-and-the-windows-10-october-2018-update/)</sup> |
| 首款游戏 | 《战地V》，2018年11月，光线追踪反射是其唯一的光线追踪效果<sup>[3](https://www.tomshardware.com/pc-components/gpus/testing-nvidias-rtx-mega-geometry-tech-vram-reducing-tech-a-leap-forward-for-path-traced-rendering)</sup> |
| 核心API组件 | 加速结构、DispatchRays命令、新的HLSL着色器类型（光线生成、最近命中、任意命中、未命中）以及光线追踪管线状态对象<sup>[1](https://devblogs.microsoft.com/directx/announcing-microsoft-directx-raytracing/)</sup> |
| DXR 1.2 | 在GDC 2025上公布，包含不透明度微图和着色器执行重排序；2025年4月下旬发布预览版Agility SDK<sup>[4](https://devblogs.microsoft.com/directx/announcing-directx-raytracing-1-2-pix-neural-rendering-and-more-at-gdc-2025/)</sup> |
| SER性能 | 微软报告称，在早期演示中启用着色器执行重排序后，帧率提升最高达90%<sup>[5](https://www.windowscentral.com/microsoft/windows/directx-update-shader-execution-reordering-ser-ray-tracing)</sup> |
| 平台保证 | DirectX 12 Ultimate硬件，包括Xbox Series X，保证支持DirectX光线追踪、可变速率着色、网格着色器和采样器反馈<sup>[6](https://devblogs.microsoft.com/directx/announcing-directx-12-ultimate/)</sup> |

## 微软为何加入该功能

公布之时，几乎所有游戏都使用光栅化渲染，即将三维图元投影到屏幕的二维平面上并并行地为像素着色。光栅化效率很高，但三维世界的信息在投影时丢失了，因此由光线在场景中交互所产生的效果——如阴影、反射和间接光照——必须用阴影贴图、环境贴图和屏幕空间反射等独立技术来模拟。微软将DXR定位为一座桥梁：通过允许遍历游戏世界的完整三维表示，它让屏幕空间反射等现有技术能够从被遮挡或屏幕外的几何体填充数据，并使光栅化难以实现的技术成为可能，如真正的全局光照。<sup>[1](https://devblogs.microsoft.com/directx/announcing-microsoft-directx-raytracing/)</sup>

光线追踪本身通过追踪本应产生某个像素的光线路径来计算该像素的颜色，因此阴影、反射和间接光照是算法的自然结果。它可以应用于每个像素，也可以只应用于部分像素，例如反射表面上的像素。<sup>[1](https://devblogs.microsoft.com/directx/announcing-microsoft-directx-raytracing/)</sup>

## API的工作原理

DXR为DirectX 12 API引入了四个概念：<sup>[1](https://devblogs.microsoft.com/directx/announcing-microsoft-directx-raytracing/)</sup>

1. **加速结构**，一个以GPU遍历最优格式表示完整三维环境的对象，构建为两级层次结构，使GPU能够高效遍历，同时应用程序能够高效修改动态对象。
2. **DispatchRays**，一种新的命令列表方法，将光线追踪工作负载提交给GPU。
3. **新的HLSL着色器类型**，包括光线生成、最近命中、任意命中和未命中着色器。光线生成着色器在调用DispatchRays时运行，并使用TraceRay内置函数来追踪光线；根据光线去向，在交点处调用命中或未命中着色器，让每个对象携带自己的着色器和纹理。
4. **光线追踪管线状态**，与图形和计算管线状态对象配套，封装光线追踪着色器及相关状态。

DXR刻意不在DirectX 12现有的图形和计算引擎之外添加新的GPU引擎；DXR工作负载在任一现有引擎上运行，因为光线追踪从根本上是一种类计算的工作负载。该管线省略了输入装配器和输出合并器等固定功能单元，因此着色器接收解释几何体所需的最小属性，即交点在图元内的重心坐标（三角形内的位置，以加权顶点混合表示）。TraceRay也可以在命中和未命中着色器内部调用，从而支持多次反弹效果的光线递归。<sup>[1](https://devblogs.microsoft.com/directx/announcing-microsoft-directx-raytracing/)</sup>

功能规范详细描述了加速结构的构建：给定一组由D3D12_RAYTRACING_GEOMETRY_DESC数组描述的几何体，应用程序在命令列表上调用BuildRaytracingAccelerationStructure()，系统将不透明的加速结构构建到应用程序拥有的GPU内存中。<sup>[7](https://microsoft.github.io/DirectX-Specs/d3d/Raytracing.html)</sup>

## 硬件支持与回退层

DXR设计为在发布时可用的硬件上运行，微软还提供了一个回退层，让开发者无需任何特定硬件支持即可试验DirectX光线追踪。<sup>[1](https://devblogs.microsoft.com/directx/announcing-microsoft-directx-raytracing/)</sup> 2020年，DirectX 12 Ultimate将DXR纳入认证基线：带有DX12 Ultimate标志的硬件以及Xbox Series X，保证支持DirectX光线追踪以及可变速率着色、网格着色器和采样器反馈。<sup>[6](https://devblogs.microsoft.com/directx/announcing-directx-12-ultimate/)</sup> 例如，英特尔的Arc（Alchemist）GPU通过专用硬件加速模块支持包括DXR在内的完整DirectX 12 Ultimate功能集。<sup>[8](https://www.intel.com/content/www/us/en/developer/articles/guide/real-time-ray-tracing-in-games.html)</sup> 微软的软件渲染器WARP也完全符合DirectX 12 Ultimate，支持光线追踪、网格着色器和工作图。<sup>[9](https://developer.microsoft.com/en-us/games/articles/2025/03/gdc-2025-directx-state-of-the-union/)</sup>

## 版本历史

**DXR 1.0（2018年）。** 初始API随Windows 10 2018年10月更新发布。<sup>[2](https://devblogs.microsoft.com/directx/directx-raytracing-and-the-windows-10-october-2018-update/)</sup> 《战地V》于2018年11月成为首款使用该技术的作品，支持单一光线追踪效果——反射。<sup>[3](https://www.tomshardware.com/pc-components/gpus/testing-nvidias-rtx-mega-geometry-tech-vram-reducing-tech-a-leap-forward-for-path-traced-rendering)</sup> 2019年，《[控制](https://www.edgepedia.org/zh/control-video-game)》推出时包含多种光线追踪效果：光线追踪反射、光线追踪透明反射、间接漫射光照、光线追踪接触阴影和光线追踪碎片。后来的作品转向完全光线追踪，即路径追踪，如《雷神之锤II RTX》和《[赛博朋克2077](https://www.edgepedia.org/zh/cyberpunk-2077)》等游戏。<sup>[3](https://www.tomshardware.com/pc-components/gpus/testing-nvidias-rtx-mega-geometry-tech-vram-reducing-tech-a-leap-forward-for-path-traced-rendering)</sup>

**DXR 1.2（2025年）。** 在GDC 2025上公布，DXR 1.2引入了两项旨在提升光线追踪性能的技术：不透明度微图（OMM）和着色器执行重排序（SER），以及协作向量和增强的PIX工具，均可从2025年4月下旬的预览版Agility SDK中获取。<sup>[4](https://devblogs.microsoft.com/directx/announcing-directx-raytracing-1-2-pix-neural-rendering-and-more-at-gdc-2025/)</sup> SER最初由NVIDIA于2022年随其RTX 40系列显卡一同发布，可降低光线追踪的性能开销，是[虚幻引擎5](https://www.edgepedia.org/zh/unreal-engine-5)的重要组成部分；它在Agility SDK 1.619版本中正式面向DXR 1.2提供，此前自GDC 2025起处于预览状态，微软报告称早期演示中帧率提升最高达90%。<sup>[5](https://www.windowscentral.com/microsoft/windows/directx-update-shader-execution-reordering-ser-ray-tracing)</sup>

DXR 1.2的协作向量还将光线追踪与神经渲染连接起来。在将NVIDIA的神经纹理压缩与DXR 1.2协作向量（允许神经网络利用NVIDIA GPU上的人工智能硬件实时运行）相结合的早期测试中，显存占用下降了高达90%。<sup>[10](https://www.windowscentral.com/hardware/nvidia/nvidia-neural-texture-compression-directx-raytracing-vram-early-tests)</sup>

**DXR 2（开发中）。** DirectX-Specs仓库将Raytracing2规范列为进行中的工作，尚未进入预览阶段，发布可能从2026年夏末的预览版开始。DXR2的工作增加了基于簇的加速结构对象，包括簇构建、簇模板和分区顶层加速结构，序列化模式也扩展以覆盖新的对象类型。<sup>[11](https://microsoft.github.io/DirectX-Specs/d3d/Raytracing2.html)</sup>

## 实践中的混合渲染

DXR明确设计为与基于光栅化的管线配合使用，因此开发者可以将其集成到现有引擎中而无需重建引擎。<sup>[2](https://devblogs.microsoft.com/directx/directx-raytracing-and-the-windows-10-october-2018-update/)</sup> 典型的混合方法使用光栅化将场景渲染到G-buffer中，然后使用光线追踪处理反射和阴影等次级效果。<sup>[12](https://diligentgraphics.github.io/docs/d1/d67/DiligentSamples_Tutorials_Tutorial22_HybridRendering_readme.html)</sup> 电子艺界的SEED团队在Project PICA PICA中展示了这一点，该管线中光栅化、计算和光线追踪着色器协同工作，实时接近离线路径追踪的视觉质量。<sup>[13](https://www.ea.com/seed/news/hybrid-rendering-for-real-time-ray-tracing)</sup> 微软自己的发布指南也遵循同样的思路：DXR最初将补充屏幕空间反射等技术，其应用将逐渐扩展到光栅化难以实现的技术，而光栅化仍然是渲染到平面像素网格的绝佳匹配。<sup>[1](https://devblogs.microsoft.com/directx/announcing-microsoft-directx-raytracing/)</sup>

通过DXR进行的光线追踪不限于渲染；相同的全场景可见性查询可用于物理和碰撞检测或AI可见性检查等目的。<sup>[14](https://www.gamedeveloper.com/programming/practical-techniques-for-ray-tracing-in-games)</sup>

## 与其他API的关系

[Khronos Group](https://www.edgepedia.org/zh/khronos-group)的Vulkan光线追踪规范于2020年在吸纳行业和社区意见后最终确定，<sup>[15](https://media.contentapi.ea.com/content/dam/ea/seed/presentations/seed-i3d21-trace-all-the-rays.pdf)</sup>遵循类似的编程模型；Khronos文档指出，在Vulkan光线追踪和DXR之间移植代码很直接。<sup>[16](https://www.khronos.org/assets/uploads/apis/Vulkan-Ray-Tracing-Nov20.pdf)</sup> NVIDIA的OptiX API同样采用与DXR和Vulkan光线追踪类似的编程模型。<sup>[17](https://raytracing-docs.nvidia.com/optix7/guide/optix_guide.230712.LTR.pdf)</sup> 与NVIDIA OptiX或微软DXR等专有API不同，Vulkan设计为跨多个厂商的硬件运行，包括AMD、英特尔和Nvidia。<sup>[18](https://upcommons.upc.edu/server/api/core/bitstreams/13f72687-9711-4efa-aa06-147e375bdc3c/content)</sup>

## 采用与评测

DXR作品成为实时光线追踪的跨厂商标准基准：Tom's Hardware在其光线追踪对比中选择同时运行于AMD和Nvidia GPU的DXR游戏，<sup>[19](https://www.tomshardware.com/features/amd-vs-nvidia-best-gpu-for-ray-tracing)</sup>而3DMark [Port Royal](https://www.edgepedia.org/zh/port-royal)和Speed Way等合成测试套件被用作新显卡的光线追踪基准。<sup>[20](https://www.tomshardware.com/pc-components/gpus/amds-new-radeon-rx-9050-is-roughly-30-percent-slower-than-the-rtx-5050-in-games-early-testing-shows-the-cheapest-8gb-rdna-4-gpu-comfortably-handles-1080p-gaming-but-doesnt-impress)</sup> 在光线追踪游戏中，《控制》被认为是传统渲染与DXR之间差异最为明显的作品。<sup>[21](https://www.tomshardware.com/features/gpu-tests)</sup>

## References

1. [Announcing Microsoft DirectX Raytracing!, DirectX Developer Blog, March 19, 2018](https://devblogs.microsoft.com/directx/announcing-microsoft-directx-raytracing/)
2. [DirectX Raytracing and the Windows 10 October 2018 Update, DirectX Developer Blog](https://devblogs.microsoft.com/directx/directx-raytracing-and-the-windows-10-october-2018-update/)
3. [Testing Nvidia's RTX Mega Geometry tech, Tom's Hardware](https://www.tomshardware.com/pc-components/gpus/testing-nvidias-rtx-mega-geometry-tech-vram-reducing-tech-a-leap-forward-for-path-traced-rendering)
4. [Announcing DirectX Raytracing 1.2, PIX, Neural Rendering and more at GDC 2025!, DirectX Developer Blog](https://devblogs.microsoft.com/directx/announcing-directx-raytracing-1-2-pix-neural-rendering-and-more-at-gdc-2025/)
5. [Microsoft's latest DirectX update boosts ray-tracing performance by up to 90%, Windows Central](https://www.windowscentral.com/microsoft/windows/directx-update-shader-execution-reordering-ser-ray-tracing)
6. [Announcing DirectX 12 Ultimate, DirectX Developer Blog](https://devblogs.microsoft.com/directx/announcing-directx-12-ultimate/)
7. [DirectX Raytracing (DXR) Functional Spec, DirectX-Specs](https://microsoft.github.io/DirectX-Specs/d3d/Raytracing.html)
8. [Intel Arc Graphics Developer Guide for Real-Time Ray Tracing in Games, Intel](https://www.intel.com/content/www/us/en/developer/articles/guide/real-time-ray-tracing-in-games.html)
9. [GDC 2025: DirectX State of the Union, Microsoft Developer](https://developer.microsoft.com/en-us/games/articles/2025/03/gdc-2025-directx-state-of-the-union/)
10. [NVIDIA Neural Texture Compression and DirectX Raytracing 1.2 Cooperative Vectors early tests, Windows Central](https://www.windowscentral.com/hardware/nvidia/nvidia-neural-texture-compression-directx-raytracing-vram-early-tests)
11. [DirectX Raytracing (DXR) Functional Spec, Part 2, DirectX-Specs](https://microsoft.github.io/DirectX-Specs/d3d/Raytracing2.html)
12. [Diligent Engine: Tutorial 22 - Hybrid Rendering](https://diligentgraphics.github.io/docs/d1/d67/DiligentSamples_Tutorials_Tutorial22_HybridRendering_readme.html)
13. [Hybrid Rendering for Real-Time Ray Tracing, EA SEED](https://www.ea.com/seed/news/hybrid-rendering-for-real-time-ray-tracing)
14. [Practical techniques for ray tracing in games, Game Developer](https://www.gamedeveloper.com/programming/practical-techniques-for-ray-tracing-in-games)
15. [State of the Union, EA SEED presentation](https://media.contentapi.ea.com/content/dam/ea/seed/presentations/seed-i3d21-trace-all-the-rays.pdf)
16. [Vulkan Ray Tracing and DXR, Khronos Group](https://www.khronos.org/assets/uploads/apis/Vulkan-Ray-Tracing-Nov20.pdf)
17. [NVIDIA OptiX 7 Programming Guide](https://raytracing-docs.nvidia.com/optix7/guide/optix_guide.230712.LTR.pdf)
18. [Hardware Accelerated Path Tracing thesis, UPC](https://upcommons.upc.edu/server/api/core/bitstreams/13f72687-9711-4efa-aa06-147e375bdc3c/content)
19. [AMD vs Nvidia: Which GPUs Are Best for Ray Tracing?, Tom's Hardware](https://www.tomshardware.com/features/amd-vs-nvidia-best-gpu-for-ray-tracing)
20. [AMD Radeon RX 9050 early testing, Tom's Hardware](https://www.tomshardware.com/pc-components/gpus/amds-new-radeon-rx-9050-is-roughly-30-percent-slower-than-the-rtx-5050-in-games-early-testing-shows-the-cheapest-8gb-rdna-4-gpu-comfortably-handles-1080p-gaming-but-doesnt-impress)
21. [Graphics Card Tests, Tom's Hardware](https://www.tomshardware.com/features/gpu-tests)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 计算机硬件 › Graphics & GPU hardware › GPGPU & GPU computing › GPU compute application domains

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/directx-raytracing

English original: https://www.edgepedia.org/directx-raytracing
