File tree 2 files changed +19
-13
lines changed
2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 47
47
< script src ="compiler.js "> </ script >
48
48
< script src ="try-slang.js "> </ script >
49
49
< script src ="language-server.js "> </ script >
50
- < script src ="slang-wasm.js "> </ script >
50
+ < script async src ="slang-wasm.js "> </ script >
51
51
< script async src ="https://www.googletagmanager.com/gtag/js?id=G-TMTZVLLMBP "> </ script >
52
52
< script >
53
53
window . dataLayer = window . dataLayer || [ ] ;
Original file line number Diff line number Diff line change @@ -38,20 +38,23 @@ var randFloatPipeline;
38
38
var randFloatResources ;
39
39
40
40
async function webgpuInit ( ) {
41
- const adapter = await navigator . gpu ?. requestAdapter ( ) ;
42
- if ( ! adapter ) {
43
- console . log ( 'need a browser that supports WebGPU' ) ;
44
- return ;
45
- }
46
- const requiredFeatures = [ ] ;
41
+ try {
42
+ const adapter = await navigator . gpu ?. requestAdapter ( ) ;
43
+ if ( ! adapter ) {
44
+ console . log ( 'need a browser that supports WebGPU' ) ;
45
+ return ;
46
+ }
47
+ const requiredFeatures = [ ] ;
47
48
48
- device = await adapter ?. requestDevice ( { requiredFeatures } ) ;
49
- if ( ! device ) {
50
- console . log ( 'need a browser that supports WebGPU' ) ;
51
- return ;
49
+ device = await adapter ?. requestDevice ( { requiredFeatures } ) ;
50
+ if ( ! device ) {
51
+ console . log ( 'need a browser that supports WebGPU' ) ;
52
+ return ;
53
+ }
54
+ context = configContext ( device , canvas ) ;
55
+ }
56
+ catch {
52
57
}
53
- context = configContext ( device , canvas ) ;
54
-
55
58
// The default resolution of a canvas element is 300x150, which is too small compared to the container size of the canvas,
56
59
// therefore, we have to set the resolution same as the container size.
57
60
@@ -60,6 +63,9 @@ async function webgpuInit() {
60
63
}
61
64
62
65
function resizeCanvas ( entries ) {
66
+ if ( device == null )
67
+ return ;
68
+
63
69
const canvas = entries [ 0 ] . target ;
64
70
65
71
const width = canvas . clientWidth ;
You can’t perform that action at this time.
0 commit comments