# 网格着色器

网格着色器是一种可编程图形管线阶段，它在光栅化之前以协作线程组的方式批量处理顶点和图元，用类似计算着色器的模型取代了传统的顶点、曲面细分和几何着色器阶段。NVIDIA 于 2018 年随其 Turing GPU 架构引入了这一概念，并将网格着色器与任务着色器（在 [Direct3D](https://www.edgepedia.org/zh/direct3d) 12 中称为放大着色器）配对使用，后者决定要启动多少几何工作量。<sup>[1](https://developer.nvidia.com/blog/introduction-turing-mesh-shaders/)</sup><sup> • </sup><sup>[2](https://github.com/microsoft/DirectX-Specs/blob/master/d3d/MeshShader.md)</sup>

| 关键事实 | 详情 |
|---|---|
| 引入时间 | NVIDIA Turing 架构，2018 年；两个新阶段：任务着色器和网格着色器<sup>[1](https://developer.nvidia.com/blog/introduction-turing-mesh-shaders/)</sup><sup> • </sup><sup>[3](https://www.nvidia.com/content/dam/en-zz/Solutions/design-visualization/technologies/turing-architecture/NVIDIA-Turing-Architecture-Whitepaper.pdf)</sup> |
| 网格块大小 | 最多 64 个顶点和 126 个图元的小单元，在芯片上生成后交给光栅化器<sup>[1](https://developer.nvidia.com/blog/introduction-turing-mesh-shaders/)</sup> |
| API 支持 | Direct3D 12 Ultimate（2020 年，2019 年测试版）；Vulkan VK_EXT_mesh_shader 于 2022 年 8 月 31 日发布<sup>[4](https://www.pcgamer.com/mesh-shaders-explained/)</sup><sup> • </sup><sup>[5](https://www.khronos.org/news/permalink/khronos-releases-vulkan-mesh-shader-pipeline-extension)</sup> |
| 硬件支持 | Nvidia Turing（RTX 20 系列和 GTX 16 系列）及之后；AMD RDNA 2 及之后；Intel Arc<sup>[6](https://www.tomshardware.com/features/alan-wake-2-will-punish-your-gpu)</sup> |
| 实测收益 | RTX 3090 上 2700 万三角形的 Lucy 扫描模型：网格着色器 0.9 毫秒，使用 32 位索引的顶点着色器 1.8 毫秒<sup>[7](https://developer.nvidia.com/blog/using-mesh-shaders-for-professional-graphics/)</sup> |
| 首个主要游戏应用 | 《心灵杀手2》（2023 年 10 月），首款要求 DirectX 12 网格着色器的游戏，为较旧 GPU 提供较慢的回退路径<sup>[6](https://www.tomshardware.com/features/alan-wake-2-will-punish-your-gpu)</sup> |

## 目的与动机

传统几何管线让顶点经过固定功能的输入装配，然后经过顶点、曲面细分和几何着色器阶段，最后进入光栅化。NVIDIA 的 Turing 发布说明将网格着色描述为面向这些阶段的新着色器模型，支持更灵活、更高效的几何计算，用开发者可控的工作生成和图元输出取代固定功能的顶点、曲面细分和几何处理。<sup>[1](https://developer.nvidia.com/blog/introduction-turing-mesh-shaders/)</sup><sup> • </sup><sup>[8](https://developer.nvidia.com/blog/?p=11872)</sup>

根据微软的 DirectX 规范，其主要目标是让几何管线更灵活、更快速：网格着色器将顶点着色器和几何着色器的大部分工作合并到单个阶段，可以放大或剔除几何体，并允许提前剔除几何体而无需将新的索引缓冲区写入内存。从硬件角度看，该设计消除了输入装配器中索引处理部分的需求，使 GPU 能够更加并行。<sup>[2](https://github.com/microsoft/DirectX-Specs/blob/master/d3d/MeshShader.md)</sup>

## 管线如何工作

**网格块。** 核心数据结构是网格块，即从较大的三角形网格中划分出的一小组顶点和图元。NVIDIA 的网格块最多容纳 64 个顶点和 126 个图元，从而实现更高的顶点重用、更低的带宽和高效的簇剔除。当网格块数据预先计算时，它将网格块描述符与用于顶点索引和用于图元索引的独立缓冲区配对；索引通常缩小到原来大小的约 75%，且光栅化时使用的顺序保持不变。<sup>[1](https://developer.nvidia.com/blog/introduction-turing-mesh-shaders/)</sup><sup> • </sup><sup>[7](https://developer.nvidia.com/blog/using-mesh-shaders-for-professional-graphics/)</sup> 一种典型的组织方式是为每个任务着色器调用分配一组网格块，为每个网格着色器工作组分配一个网格块。<sup>[9](https://docs.vulkan.org/samples/latest/samples/extensions/mesh_shader_culling/README.html)</sup>

**任务着色器和放大着色器。** 任务着色器（D3D12 中称为放大着色器）是一个可选但推荐的阶段，在网格着色器之前运行。它像计算着色器一样在工作组中执行，并间接调度网格着色器工作组。在 Vulkan 中，它通过 `OpEmitMeshTasksEXT` 指令启动网格着色器，该指令接受要发出的网格着色器组数量以及一个对其启动的所有网格着色器调用可见的载荷变量；指令执行后，任务工作组终止，网格着色器启动。<sup>[10](https://docs.vulkan.org/features/latest/features/proposals/VK_EXT_mesh_shader.html)</sup> 任务着色器用于对整个网格块组进行粗粒度剔除以及细节层次决策，根据需要动态生成更多或更少的几何体；NVIDIA 在其 Asteroids 演示中展示了使用动态 LOD 计算的这一做法。<sup>[1](https://developer.nvidia.com/blog/introduction-turing-mesh-shaders/)</sup><sup> • </sup><sup>[10](https://docs.vulkan.org/features/latest/features/proposals/VK_EXT_mesh_shader.html)</sup> Khronos 的示例指南建议在使用网格管线时始终使用任务着色器，仅在非常简单的场景中保留直接调度。<sup>[9](https://docs.vulkan.org/samples/latest/samples/extensions/mesh_shader_culling/README.html)</sup>

**网格着色器。** 网格着色器工作组生成顶点和图元并将其写入光栅化器。与顶点着色器不同，线程与输出顶点或图元之间没有固定关联；着色器通过 `[numthreads]` 声明其线程数，并在运行时指定实际的顶点和图元数量，在 D3D12 中通过 `SetMeshOutputCounts`，在 Vulkan 中通过 `OpSetMeshOutputsEXT`。<sup>[2](https://github.com/microsoft/DirectX-Specs/blob/master/d3d/MeshShader.md)</sup><sup> • </sup><sup>[10](https://docs.vulkan.org/features/latest/features/proposals/VK_EXT_mesh_shader.html)</sup> 输出拓扑仅支持列表；不支持条带和扇形，必须由着色器解包。属性可以按逐顶点或逐图元的速率发出，后续的片段着色器可以读取这两种速率的数据。<sup>[10](https://docs.vulkan.org/features/latest/features/proposals/VK_EXT_mesh_shader.html)</sup>

**光栅化顺序。** 在网格着色器工作组内，图元按照它们在输出索引数组中出现的顺序进行光栅化。工作组按其扁平化工作组索引的顺序依次光栅化；使用任务着色器时，来自较后任务工作组的网格工作组在来自较早任务工作组的工作组之后光栅化。在 D3D12 中使用放大着色器时，仅保证部分顺序：一个放大工作组的子项之间可以以任意顺序完成。<sup>[10](https://docs.vulkan.org/features/latest/features/proposals/VK_EXT_mesh_shader.html)</sup><sup> • </sup><sup>[2](https://github.com/microsoft/DirectX-Specs/blob/master/d3d/MeshShader.md)</sup>

## API 与硬件支持

NVIDIA 从 2018 年起通过 OpenGL 和 Vulkan 的扩展暴露了该能力，微软于 2019 年以测试版形式引入了网格着色器，随后在 2020 年将其作为 DirectX 12 Ultimate 的一部分纳入公开的 Direct3D 版本，与可变速率着色、光线追踪和采样器反馈一同发布。<sup>[1](https://developer.nvidia.com/blog/introduction-turing-mesh-shaders/)</sup><sup> • </sup><sup>[4](https://www.pcgamer.com/mesh-shaders-explained/)</sup><sup> • </sup><sup>[11](https://www.pcgamer.com/hardware/microsoft-celebrates-10-years-of-directx-12-a-decade-of-updates-to-the-low-level-graphics-api-but-its-still-not-the-master-of-all-things-rendering/)</sup> 在 D3D12 中，网格和放大着色器支持通过 `D3D12_MESH_SHADER_TIER` 枚举报告，其值为 `TIER_NOT_SUPPORTED`（0）和 `TIER_1`（10）。<sup>[12](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_mesh_shader_tier)</sup>

在 Vulkan 中，厂商特定的 `VK_NV_mesh_shader` 扩展之后是跨厂商的 `VK_EXT_mesh_shader`，由 Khronos 于 2022 年 8 月 31 日发布，NVIDIA 提供了测试版驱动，开源 RADV 和 ANV 驱动提供了实验性支持。<sup>[5](https://www.khronos.org/news/permalink/khronos-releases-vulkan-mesh-shader-pipeline-extension)</sup> 在硬件方面，Nvidia 自 Turing 起支持网格着色器，涵盖 RTX 20 系列以及不带光线追踪硬件的 GTX 16 系列；AMD 通过 RDNA 2（RX 6000 系列）及之后添加了支持；Intel Arc GPU 也支持该功能。<sup>[6](https://www.tomshardware.com/features/alan-wake-2-will-punish-your-gpu)</sup><sup> • </sup><sup>[13](https://www.techpowerup.com/315149/psa-alan-wake-ii-runs-on-older-gpus-mesh-shaders-not-required?cp=1)</sup>

## 性能

NVIDIA 的专业图形基准测试通过在 RTX 3090 上渲染 2700 万三角形的 Lucy 雕像扫描模型，不进行光栅化也不进行剔除，从而隔离出光栅化前的阶段。在单次绘制调用中使用 32 位索引时，网格着色器渲染耗时 0.9 毫秒，而传统顶点着色器为 1.8 毫秒；将模型拆分为多个缓冲区以使用 16 位索引时，网格着色器仍以 0.8 毫秒对 1.1 毫秒领先。<sup>[7](https://developer.nvidia.com/blog/using-mesh-shaders-for-professional-graphics/)</sup> 同一来源报告称，在 Quadro RTX 6000 上使用 Rungholt 场景、存在大量亚像素三角形的情况下，在网格着色器内部使用子组内建函数压缩输出索引进行图元剔除，在可见性缓冲区或深度预通道场景中获得了接近 2 倍的收益。对于 Turing 和 [Ampere](https://www.edgepedia.org/zh/ampere-microarchitecture)，NVIDIA 的实操调优建议是：在 32 线程的工作组中使用由 64 个顶点和 84 个图元构建的网格块，保持输出紧凑，并压缩索引而不是依赖退化三角形。<sup>[7](https://developer.nvidia.com/blog/using-mesh-shaders-for-professional-graphics/)</sup>

## 在游戏中的应用

2018 年引入后采用缓慢：[UL Solutions](https://www.edgepedia.org/zh/ul-solutions) 于 2021 年宣布了 3DMark 网格着色器功能测试，开发者展示也在那时出现，但除此之外直到《心灵杀手2》之前几乎没有其他应用。<sup>[4](https://www.pcgamer.com/mesh-shaders-explained/)</sup> [绿美迪娱乐](https://www.edgepedia.org/zh/remedy-entertainment)的《心灵杀手2》于 2023 年 10 月发布，是首款要求 DirectX 12 网格着色器的游戏——算是吧：该游戏将网格着色器视为推荐功能，在不支持的 GPU 上显示警告，但回退路径允许游玩，代价是严重的性能损失。<sup>[6](https://www.tomshardware.com/features/alan-wake-2-will-punish-your-gpu)</sup><sup> • </sup><sup>[13](https://www.techpowerup.com/315149/psa-alan-wake-ii-runs-on-older-gpus-mesh-shaders-not-required?cp=1)</sup> 在 TechPowerUp 以 1080p 分辨率进行、未启用图像放大的测试中，缺少硬件网格着色器的 RX 5700 XT 表现不如 GTX 1660 Ti，而后者在大多数仅光栅化的游戏中性能远低于前者；拥有网格着色器硬件的 GTX 16 系列表现符合预期。<sup>[13](https://www.techpowerup.com/315149/psa-alan-wake-ii-runs-on-older-gpus-mesh-shaders-not-required?cp=1)</sup> 绿美迪娱乐的图形程序员埃里克·扬松 在 2024 年的一次演讲中描述了游戏如何转向 GPU 驱动的渲染管线，其中网格着色器是核心部分，在 PS5 和 Xbox Series X|S GPU 上剔除和渲染网格块。<sup>[14](https://www.youtube.com/watch?v=EtX7WnFhxtQ)</sup> 该游戏后来在 2025 年初的 1.2.8 版更新中获得了 NVIDIA 的 RTX Mega Geometry，利用网格着色处理高细节几何体，在 RTX 4090 上以 4K 开启路径追踪时减少了约 1 GB 显存使用，性能提升 13%。<sup>[15](https://www.tomshardware.com/pc-components/gpus/testing-nvidias-rtx-mega-geometry-tech-vram-reducing-tech-a-leap-forward-for-path-traced-rendering)</sup>

## References

1. [Introduction to Turing Mesh Shaders, NVIDIA Technical Blog (2018)](https://developer.nvidia.com/blog/introduction-turing-mesh-shaders/)
2. [DirectX-Specs: MeshShader.md, Microsoft](https://github.com/microsoft/DirectX-Specs/blob/master/d3d/MeshShader.md)
3. [Turing Advanced Shading Technologies, NVIDIA Turing Architecture Whitepaper](https://www.nvidia.com/content/dam/en-zz/Solutions/design-visualization/technologies/turing-architecture/NVIDIA-Turing-Architecture-Whitepaper.pdf)
4. [Mesh shaders explained: What are they, what's the big fuss, and why are they only in Alan Wake 2?, PC Gamer (2023)](https://www.pcgamer.com/mesh-shaders-explained/)
5. [Khronos Releases Vulkan Mesh Shader Pipeline Extension (August 31, 2022)](https://www.khronos.org/news/permalink/khronos-releases-vulkan-mesh-shader-pipeline-extension)
6. [Testing Alan Wake 2: Full Path Tracing and Ray Reconstruction Will Punish Your GPU, Tom's Hardware (2023)](https://www.tomshardware.com/features/alan-wake-2-will-punish-your-gpu)
7. [Using Mesh Shaders for Professional Graphics, NVIDIA Technical Blog](https://developer.nvidia.com/blog/using-mesh-shaders-for-professional-graphics/)
8. [NVIDIA Turing Architecture In-Depth, NVIDIA Technical Blog (2018)](https://developer.nvidia.com/blog/?p=11872)
9. [Mesh Shader Culling, Vulkan Documentation Project samples](https://docs.vulkan.org/samples/latest/samples/extensions/mesh_shader_culling/README.html)
10. [VK_EXT_mesh_shader, Vulkan Documentation Project](https://docs.vulkan.org/features/latest/features/proposals/VK_EXT_mesh_shader.html)
11. [Microsoft celebrates 10 years of DirectX 12, PC Gamer (2025)](https://www.pcgamer.com/hardware/microsoft-celebrates-10-years-of-directx-12-a-decade-of-updates-to-the-low-level-graphics-api-but-its-still-not-the-master-of-all-things-rendering/)
12. [D3D12_MESH_SHADER_TIER enumeration, Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_mesh_shader_tier)
13. [PSA: Alan Wake II Runs on Older GPUs, Mesh Shaders not Required, TechPowerUp (2023)](https://www.techpowerup.com/315149/psa-alan-wake-ii-runs-on-older-gpus-mesh-shaders-not-required?cp=1)
14. [GPU driven Rendering with Mesh Shaders in Alan Wake 2, Erik Jansson, Digital Dragons (2024)](https://www.youtube.com/watch?v=EtX7WnFhxtQ)
15. [Testing Nvidia's RTX Mega Geometry tech, Tom's Hardware (2026)](https://www.tomshardware.com/pc-components/gpus/testing-nvidias-rtx-mega-geometry-tech-vram-reducing-tech-a-leap-forward-for-path-traced-rendering)

---
*Initially written Oct 15, 2026*

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

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/mesh-shader

English original: https://www.edgepedia.org/mesh-shader
