const adapter = await navigator.gpu.requestAdapter();
if (adapter) {
// Print out some basic details about the adapter.
console.log(`Found adapter: ${adapter.name}`);
const features = [...adapter.features.values()];
console.log(`Supported features: ${features.join(", ")}`);
} else {
console.error("No adapter found");
}
接著,使用 deno run --unstable 運作看看吧!
圖片渲染
接著,讓我們嘗試渲染一張圖片出來吧!
在的中 webgpu 範例,我們可以隨便選擇一個使用 Deno 進行圖片輸出:
$deno run --unstable --allow-write=output.png https://raw.githubusercontent.com/crowlKats/webgpu-examples/f3b979f57fd471b11a28c5b0c91d0447221ba77b/hello-triangle/mod.ts