Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions assets/auto-test-case/dynamic/GFX/compute-demo.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ts-ignore
import { director } from 'cc';
//@ts-ignore
import { runScene, testCase, testClass } from 'db://automation-framework/runtime/test-framework.mjs';
import { screenshot_custom } from '../common/utils';
// ensure the compute pipeline module is loaded/registered before the scene renders
import '../../../cases/GFX/compute-demo/raytracingByCompute';

@runScene('compute-demo')
@testClass('ComputeDemo')
export class ComputeDemo {
// give the compute pipeline a few frames to create storage/dispatch resources
_delay = 5;

@testCase
async index() {
await screenshot_custom(this._delay);
}
}
9 changes: 9 additions & 0 deletions assets/auto-test-case/dynamic/GFX/compute-demo.test.ts.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "67fcc6d9-9d47-4afa-ad24-615700d5df98",
"files": [],
"subMetas": {},
"userData": {}
}
9 changes: 9 additions & 0 deletions assets/cases/GFX/compute-demo.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "1c1a1db3-316b-49b0-811a-054e2d66cd12",
"files": [],
"subMetas": {},
"userData": {}
}
45 changes: 45 additions & 0 deletions assets/cases/GFX/compute-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# compute-demo (Custom Pipeline / Compute Shader)

Mirror of Cocos official tutorial-005-compute (raytracing by compute) from
cocos-example-custom-pipeline, adapted as an automation test case.

## 运行前提(重要)

1. **后端(Backend)**:浏览器预览必须先开启 **WebGPU** —— 使用支持 WebGPU 的
Chrome / Edge 等浏览器(较新版本默认开启;旧版本需在 chrome://flags 打开
WebGPU 相关开关)。桌面预览可用 Vulkan / Metal。
2. **渲染管线(图形设置)**:项目设置 -> 功能裁剪(Feature Cropping)-> 图形 /
渲染管线选择**新的渲染管线(custom-pipeline)**,并在管线名称(Custom Pipeline
Name)中填写 **RaytracingWeekend** —— 必须与 raytracingByCompute.ts 中
rendering.setCustomPipeline('RaytracingWeekend', ...) 的注册名一致,否则管线不会生效。

## 文件说明

- raytracingByCompute.ts - PipelineBuilder + rendering.setCustomPipeline('RaytracingWeekend', ...)
(compute pass writes to a storage texture, a fullscreen quad blits it to the swapchain)
- compute-demo.scene - camera + main light only, compute output fills the window
- ../pipeline-data.ts - window/framebuffer helper imported by the pipeline script
- assets/resources/raytracing-compute/ - rt-compute (compute shader) and
rt-swizzle (blit) effects + materials, loaded at runtime via resources.load

## QA 步骤

1. 按"运行前提"完成配置:浏览器预览开启 WebGPU;图形设置选新渲染管线,
管线名称填 RaytracingWeekend。
2. 打开场景 compute-demo.scene。手动预览时,把 raytracingByCompute.ts
(组件 pipeline_005_raytracing_in_1_weekend)挂到任意节点上,
否则管线不会被注册。
3. 预览或跑自动化验证 compute 输出。

## 自动化

- Registered in assets/auto-test-config.json under sceneList as compute-demo.
- Test: assets/auto-test-case/dynamic/GFX/compute-demo.test.ts (screenshot based).

## 维护

- Edit scene content in rt-compute.effect (spheres uniform, imageStore).
- addDispatch(width/8, height/4, 1) must match layout(local_size_x = 8, local_size_y = 4).
- The .effect.meta/.mtl.meta files are kept on purpose: .mtl binds the
effect by uuid. If you delete them, re-assign the effect on both materials
after Creator regenerates the metas.
11 changes: 11 additions & 0 deletions assets/cases/GFX/compute-demo/README.md.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"ver": "1.0.1",
"importer": "text",
"imported": true,
"uuid": "8bff7cee-33e4-4903-8f38-87f2e4c243ca",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}
Loading