Skip to content

Commit 9154a2d

Browse files
authored
Enable GPUFeatures impacting WGSL, if available (#155)
* 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 * Removing newer GPUFeatures from allow list These GPUFeatures aren't recognized by the version of Vue used by slang playground. Removing them for now.
1 parent 9ef5dd7 commit 9154a2d

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/App.vue

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,25 @@ 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+
];
119+
const requiredFeatures: GPUFeatureName[] = allowedFeatures.filter(f => adapter.features.has(f));
120+
121+
let device = await adapter.requestDevice({ requiredFeatures });
106122
if (!device) {
107123
console.log('need a browser that supports WebGPU');
108124
return null;

0 commit comments

Comments
 (0)