Skip to content

Commit d3fb8e9

Browse files
committed
Use wgslLanguageFeatures to check for immediates support.
1 parent 3703735 commit d3fb8e9

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

webgpu/lessons/webgpu-immediates.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ them easiest to understand by reading them in order.
1212
Immediates are a new (2026) feature of WebGPU. They are supposed to be a **core** feature,
1313
meaning, they are suppose to be available everywhere, regardless of device.
1414
They will hopefully be shipping in all browsers by the end of 2026.
15-
You can check for support by checking for the existence of the function to set the,
15+
You can check if they are supported by checking if <code>wgslLanguageFeatures</code>
16+
has <code>'immediate_address_space'</code>.
1617
<pre class="prettyprint lang-javascript"><code>
17-
const canUseImmediates = !!GPURenderPassEncoder?.prototype.setImmediates;
18+
const canUseImmediates = navigator.gpu.wgslLanguageFeatures.has('immediate_address_space');
1819
</code></pre>
1920
Ideally, by 2027, you should no longer need this check.
2021
</div>

webgpu/webgpu-immediates-models.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
<canvas></canvas>
2222
</body>
2323
<script type="module">
24-
/* global GPURenderPassEncoder */
2524
// see https://webgpufundamentals.org/webgpu/lessons/webgpu-utils.html#wgpu-matrix
2625
import {mat4} from '../3rdparty/wgpu-matrix.module.js';
2726

@@ -34,8 +33,7 @@
3433
}
3534

3635
// You can probably remove this check by 2027 🙏
37-
const canUseImmediates = !!GPURenderPassEncoder?.prototype.setImmediates;
38-
if (!canUseImmediates) {
36+
if (!navigator.gpu.wgslLanguageFeatures.has('immediate_address_space')) {
3937
fail('need a browser that supports WebGPU immediates');
4038
return;
4139
}

webgpu/webgpu-immediates-triangles.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
<canvas></canvas>
2222
</body>
2323
<script type="module">
24-
/* global GPURenderPassEncoder */
2524
async function main() {
2625
const adapter = await navigator.gpu?.requestAdapter();
2726
const device = await adapter?.requestDevice();
@@ -31,8 +30,7 @@
3130
}
3231

3332
// You can probably remove this check by 2027 🙏
34-
const canUseImmediates = !!GPURenderPassEncoder?.prototype.setImmediates;
35-
if (!canUseImmediates) {
33+
if (!navigator.gpu.wgslLanguageFeatures.has('immediate_address_space')) {
3634
fail('need a browser that supports WebGPU immediates');
3735
return;
3836
}

0 commit comments

Comments
 (0)