- install node JS
- npm create vite@latest
- "npm i @webgpu/types" and "npm install --save @webgpu/types"
- to install ViTest "npm install -D vitest"
- "npm install"
- Because webgpu is a experimental, you need to register an tail token https://developer.chrome.com/origintrials/
- run project: "npx vite"
- To Debug React Components in Chromes:
- visit https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en
- for other browsers: npm install -g react-devtools, and then run "react-devtools" to activate the tool
- React Docs: https://beta.reactjs.org/
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}",
// "runtimeArgs": ["--enable-unsafe-webgpu"]
}
]
}
Env Update: Chrome 110, Windows, WebGPU on Linux has bugs
Env Update: Chrome 113 ships with webgpu now
```json Typescript Config
// tsc config
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"types": ["vite/client", "@webgpu/types"]
},
"include": ["src"],
"exclude": ["node_modules"],
"references": [{ "path": "./tsconfig.node.json" }]
}
- Single Uniform Buffer (2 matrices: mvp and modelview)
- Configure BindGroup: (with single buffer, the data alignment must be 256, for each bind point within a group)
- Configure BindGroup V2: (Or One just use one bind point within a group, and decleare a struct with many fields for Uniform the sahder)
- Use Free-Look camera
- Transforms of cubes are generated by cpu
- Instance number: 99999
- Noticeable slow down when more than 99999 cubes
- GPU is throttled by CPU
Offscreen is the basics of a lot special effects, e.g. shadow map, deferred rendering
- make sure texture map works
- display/debug texture in a sub view port
- hook up compute pipeline and use what has been set up in step 2 for debug
- Compute Shader
- Texture 2D Array
- Texture Splatting