Skip to content

Commit 5c39b59

Browse files
committed
Enable features impacting WGSL if available
Defines an allow list of features that impact the WGSL environment, and enables them if the adapter says they're available. Fixes #100
1 parent 9ef5dd7 commit 5c39b59

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/App.vue

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,28 @@ async function tryGetDevice() {
100100
console.log('need a browser that supports WebGPU');
101101
return null;
102102
}
103-
const requiredFeatures: [] = [];
104-
105-
let device = await adapter?.requestDevice({ requiredFeatures });
103+
// Allow list of GPU features that can impact WGSL
104+
const allowedFeatures: GPUFeatureName[] = [
105+
"depth32float-stencil8",
106+
"texture-compression-bc",
107+
"texture-compression-bc-sliced-3d",
108+
"texture-compression-etc2",
109+
"texture-compression-astc",
110+
"texture-compression-astc-sliced-3d",
111+
"shader-f16",
112+
"rg11b10ufloat-renderable",
113+
"bgra8unorm-storage",
114+
"float32-filterable",
115+
"float32-blendable",
116+
"clip-distances",
117+
"dual-source-blending",
118+
"subgroups",
119+
"texture-formats-tier1",
120+
"texture-formats-tier2",
121+
];
122+
const requiredFeatures: GPUFeatureName[] = allowedFeatures.filter(f => adapter.features.has(f));
123+
124+
let device = await adapter.requestDevice({ requiredFeatures });
106125
if (!device) {
107126
console.log('need a browser that supports WebGPU');
108127
return null;

0 commit comments

Comments
 (0)