2026-03-27 22:13:17 +08:00
|
|
|
|
# Vulkan 测试专项规范
|
|
|
|
|
|
|
|
|
|
|
|
本文档是 [tests/TEST_SPEC.md](../TEST_SPEC.md) 在 Vulkan 后端上的补充入口,描述当前已经落地的 Vulkan 专项测试树。
|
|
|
|
|
|
|
|
|
|
|
|
## 1. 当前结构
|
|
|
|
|
|
|
|
|
|
|
|
```text
|
|
|
|
|
|
tests/RHI/Vulkan/
|
|
|
|
|
|
|- CMakeLists.txt
|
|
|
|
|
|
|- TEST_SPEC.md
|
2026-03-27 23:26:45 +08:00
|
|
|
|
\- integration/
|
|
|
|
|
|
| |- CMakeLists.txt
|
2026-03-27 23:55:23 +08:00
|
|
|
|
| |- quad/
|
|
|
|
|
|
| | |- CMakeLists.txt
|
|
|
|
|
|
| | |- GT.ppm
|
|
|
|
|
|
| | |- main.cpp
|
|
|
|
|
|
| | \- Res/
|
2026-03-28 00:09:05 +08:00
|
|
|
|
| |- sphere/
|
|
|
|
|
|
| | |- CMakeLists.txt
|
|
|
|
|
|
| | |- GT.ppm
|
|
|
|
|
|
| | |- main.cpp
|
|
|
|
|
|
| | \- Res/
|
2026-03-27 23:26:45 +08:00
|
|
|
|
| \- minimal/
|
|
|
|
|
|
| |- CMakeLists.txt
|
|
|
|
|
|
| |- GT.ppm
|
|
|
|
|
|
| \- main.cpp
|
2026-03-27 22:13:17 +08:00
|
|
|
|
\- unit/
|
|
|
|
|
|
|- CMakeLists.txt
|
2026-03-27 22:28:18 +08:00
|
|
|
|
|- fixtures/
|
|
|
|
|
|
| |- VulkanTestFixture.cpp
|
|
|
|
|
|
| \- VulkanTestFixture.h
|
|
|
|
|
|
|- test_compute.cpp
|
2026-03-27 23:26:45 +08:00
|
|
|
|
|- test_descriptor_set.cpp
|
|
|
|
|
|
|- test_pipeline_layout.cpp
|
2026-03-27 22:28:18 +08:00
|
|
|
|
|- test_pipeline_state.cpp
|
|
|
|
|
|
|- test_render_pass.cpp
|
|
|
|
|
|
\- test_shader.cpp
|
2026-03-27 22:13:17 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 2. 当前目标
|
|
|
|
|
|
|
|
|
|
|
|
| 类别 | target |
|
|
|
|
|
|
| --- | --- |
|
|
|
|
|
|
| Vulkan 后端单元测试 | `rhi_vulkan_tests` |
|
2026-03-28 00:09:05 +08:00
|
|
|
|
| Vulkan 后端集成测试 | `vulkan_minimal_test` `vulkan_triangle_test` `vulkan_quad_test` `vulkan_sphere_test` |
|
2026-03-28 00:20:22 +08:00
|
|
|
|
| Vulkan 后端聚合 target | `rhi_vulkan_backend_tests` |
|
2026-03-27 22:13:17 +08:00
|
|
|
|
|
|
|
|
|
|
## 3. 当前覆盖
|
|
|
|
|
|
|
|
|
|
|
|
`rhi_vulkan_tests` 当前覆盖 Vulkan 后端专属语义,包括:
|
|
|
|
|
|
|
|
|
|
|
|
- RenderPass / Framebuffer clear 到真实 Vulkan 纹理后的像素结果验证
|
|
|
|
|
|
- `CopyResource` 纹理复制后的像素回读验证
|
|
|
|
|
|
- SPIR-V / GLSL 两条 shader 创建路径
|
|
|
|
|
|
- 基于 GLSL 的 graphics pipeline 创建
|
|
|
|
|
|
- UAV 视图创建与 compute dispatch 写纹理链路
|
2026-03-28 00:13:02 +08:00
|
|
|
|
- RTV / DSV / SRV 视图创建与原生 image-view 句柄有效性
|
|
|
|
|
|
- `Sampler` 创建与原生 sampler 句柄有效性
|
2026-03-27 22:33:26 +08:00
|
|
|
|
- `DescriptorSet` 的原生句柄、绑定布局元数据与常量缓冲脏标记行为
|
2026-03-28 00:17:16 +08:00
|
|
|
|
- graphics draw 到离屏纹理后的像素回读,以及 `SetGraphicsDescriptorSets(firstSet != 0)` 绑定路径
|
2026-03-27 22:33:26 +08:00
|
|
|
|
- `PipelineLayout` 的显式 set-layout 聚合与 flat-count 合成逻辑
|
2026-03-27 22:13:17 +08:00
|
|
|
|
|
2026-03-27 22:28:18 +08:00
|
|
|
|
当前这些 Vulkan backend unit 用例已经按职责拆分为 fixture / render-pass / shader / pipeline / compute 几个文件,避免后续继续堆到单个巨型测试文件中。
|
|
|
|
|
|
|
2026-03-27 22:13:17 +08:00
|
|
|
|
这些测试允许直接依赖 Vulkan 具体类型、原生句柄和 Vulkan API;这类断言不应再回流到 `tests/RHI/unit/`。
|
|
|
|
|
|
|
|
|
|
|
|
## 4. 分层约束
|
|
|
|
|
|
|
|
|
|
|
|
- `tests/RHI/unit/` 继续只承载 RHI 抽象层统一语义测试。
|
|
|
|
|
|
- `tests/RHI/Vulkan/unit/` 承载 Vulkan 专属断言、原生对象检查和需要直接调用 Vulkan API 的测试。
|
2026-03-28 00:09:05 +08:00
|
|
|
|
- `tests/RHI/Vulkan/integration/` 承载 Vulkan 后端直连场景,当前已经落地 `minimal / triangle / quad / sphere`。
|
2026-03-27 22:13:17 +08:00
|
|
|
|
|
|
|
|
|
|
## 5. 推荐执行方式
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-03-28 00:20:22 +08:00
|
|
|
|
cmake --build build --config Debug --target rhi_vulkan_backend_tests
|
2026-03-27 22:13:17 +08:00
|
|
|
|
build\tests\RHI\Vulkan\unit\Debug\rhi_vulkan_tests.exe --gtest_brief=1
|
2026-03-27 23:26:45 +08:00
|
|
|
|
|
2026-03-28 00:09:05 +08:00
|
|
|
|
cmake --build build --config Debug --target vulkan_sphere_test
|
|
|
|
|
|
ctest -C Debug -R "vulkan_(minimal|triangle|quad|sphere)_test" --test-dir build
|
2026-03-27 22:13:17 +08:00
|
|
|
|
```
|