Skip to content

Commit ad0aa6c

Browse files
author
vanitynie
committed
test(gfx): 新增 custom-pipeline compute shader 测试场景与自动化用例
- cases/GFX/compute-demo: compute-demo.scene + raytracingByCompute.ts(RaytracingWeekend 自定义管线,compute pass 写 storage image 后全屏 blit 输出) - resources/raytracing-compute: rt-compute(compute shader)+ rt-swizzle(输出)effect/material,保留 meta 以维持 mtl->effect uuid 引用 - auto-test-case/dynamic/GFX/compute-demo.test.ts: 截图式动态测试,import 管线模块确保 setCustomPipeline 注册 - 注意:3.8.4 运行需在项目设置将 Render Pipeline 切换为 custom-pipeline,浏览器预览后端 WebGPU;auto-test-config 的 sceneList 注册由本地 QA 自行维护
1 parent 22001c3 commit ad0aa6c

20 files changed

Lines changed: 1031 additions & 0 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ts-ignore
2+
import { director } from 'cc';
3+
//@ts-ignore
4+
import { runScene, testCase, testClass } from 'db://automation-framework/runtime/test-framework.mjs';
5+
import { screenshot_custom } from '../common/utils';
6+
// ensure the compute pipeline module is loaded/registered before the scene renders
7+
import '../../../cases/GFX/compute-demo/raytracingByCompute';
8+
9+
@runScene('compute-demo')
10+
@testClass('ComputeDemo')
11+
export class ComputeDemo {
12+
// give the compute pipeline a few frames to create storage/dispatch resources
13+
_delay = 5;
14+
15+
@testCase
16+
async index() {
17+
await screenshot_custom(this._delay);
18+
}
19+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ver": "4.0.24",
3+
"importer": "typescript",
4+
"imported": true,
5+
"uuid": "67fcc6d9-9d47-4afa-ad24-615700d5df98",
6+
"files": [],
7+
"subMetas": {},
8+
"userData": {}
9+
}

assets/cases/GFX/compute-demo.meta

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ver": "1.2.0",
3+
"importer": "directory",
4+
"imported": true,
5+
"uuid": "1c1a1db3-316b-49b0-811a-054e2d66cd12",
6+
"files": [],
7+
"subMetas": {},
8+
"userData": {}
9+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# compute-demo (Custom Pipeline / Compute Shader)
2+
3+
Mirror of Cocos official tutorial-005-compute (raytracing by compute) from
4+
cocos-example-custom-pipeline, adapted as an automation test case.
5+
6+
## 运行前提(重要)
7+
8+
1. **后端(Backend)**:浏览器预览必须先开启 **WebGPU** —— 使用支持 WebGPU 的
9+
Chrome / Edge 等浏览器(较新版本默认开启;旧版本需在 chrome://flags 打开
10+
WebGPU 相关开关)。桌面预览可用 Vulkan / Metal。
11+
2. **渲染管线(图形设置)**:项目设置 -> 功能裁剪(Feature Cropping)-> 图形 /
12+
渲染管线选择**新的渲染管线(custom-pipeline)**,并在管线名称(Custom Pipeline
13+
Name)中填写 **RaytracingWeekend** —— 必须与 raytracingByCompute.ts 中
14+
rendering.setCustomPipeline('RaytracingWeekend', ...) 的注册名一致,否则管线不会生效。
15+
16+
## 文件说明
17+
18+
- raytracingByCompute.ts - PipelineBuilder + rendering.setCustomPipeline('RaytracingWeekend', ...)
19+
(compute pass writes to a storage texture, a fullscreen quad blits it to the swapchain)
20+
- compute-demo.scene - camera + main light only, compute output fills the window
21+
- ../pipeline-data.ts - window/framebuffer helper imported by the pipeline script
22+
- assets/resources/raytracing-compute/ - rt-compute (compute shader) and
23+
rt-swizzle (blit) effects + materials, loaded at runtime via resources.load
24+
25+
## QA 步骤
26+
27+
1. 按"运行前提"完成配置:浏览器预览开启 WebGPU;图形设置选新渲染管线,
28+
管线名称填 RaytracingWeekend。
29+
2. 打开场景 compute-demo.scene。手动预览时,把 raytracingByCompute.ts
30+
(组件 pipeline_005_raytracing_in_1_weekend)挂到任意节点上,
31+
否则管线不会被注册。
32+
3. 预览或跑自动化验证 compute 输出。
33+
34+
## 自动化
35+
36+
- Registered in assets/auto-test-config.json under sceneList as compute-demo.
37+
- Test: assets/auto-test-case/dynamic/GFX/compute-demo.test.ts (screenshot based).
38+
39+
## 维护
40+
41+
- Edit scene content in rt-compute.effect (spheres uniform, imageStore).
42+
- addDispatch(width/8, height/4, 1) must match layout(local_size_x = 8, local_size_y = 4).
43+
- The .effect.meta/.mtl.meta files are kept on purpose: .mtl binds the
44+
effect by uuid. If you delete them, re-assign the effect on both materials
45+
after Creator regenerates the metas.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"ver": "1.0.1",
3+
"importer": "text",
4+
"imported": true,
5+
"uuid": "8bff7cee-33e4-4903-8f38-87f2e4c243ca",
6+
"files": [
7+
".json"
8+
],
9+
"subMetas": {},
10+
"userData": {}
11+
}

0 commit comments

Comments
 (0)