Vala プログラミング

WebGPU プログラミング

おなが@京都先端科学大

WebGPU WGSL 仕様 update

最近のWebGPUとWGSLの仕様 update により、前回プログラムにエラーが出て表示できなくなっていました。WebGPUでは、ワーニングが出ます。

Error : WGSL
E1: a compute shader must include 'workgroup_size' in its attributes
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
修正
[[stage(compute)]] -> [[stage(compute), workgroup_size(1)]]

E2: expected decoration
var<storage> particle: [[access(read_write)]] Particles;
修正
var<storage, read_write> particle: Particles;

storage buffer に関して、 accessモードの書き方が変更になっています。

Warning : WebGPU
configureSwapChain() is deprecated.
Use configure() instead and call getCurrentTexture() directly on the context.
Note that configure() must also be called if you want to change the size of
the textures returned by getCurrentTexture()
修正
var swapChain = context.configureSwapChain({
 -> context.configure({
swapChain.getCurrentTexture().createView();
 -> context.getCurrentTexture().createView();