@@ -176,7 +176,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
176176 this . samples = this . backBufferAntialias ? 4 : 1 ;
177177
178178 // WGSL features
179- const wgslFeatures = navigator . gpu . wgslLanguageFeatures ;
179+ const wgslFeatures = window . navigator . gpu . wgslLanguageFeatures ;
180180 this . supportsStorageTextureRead = wgslFeatures ?. has ( 'readonly_and_readwrite_storage_textures' ) ;
181181
182182 this . initCapsDefines ( ) ;
@@ -291,7 +291,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
291291 let canvasToneMapping = 'standard' ;
292292
293293 // pixel format of the framebuffer that is the most efficient one on the system
294- let preferredCanvasFormat = navigator . gpu . getPreferredCanvasFormat ( ) ;
294+ let preferredCanvasFormat = window . navigator . gpu . getPreferredCanvasFormat ( ) ;
295295
296296 // display format the user asked for
297297 const displayFormat = this . initOptions . displayFormat ;
@@ -346,7 +346,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
346346 // (this allows us to view the preferred format as srgb)
347347 viewFormats : displayFormat === DISPLAYFORMAT_LDR_SRGB ? [ this . backBufferViewFormat ] : [ ]
348348 } ;
349- this . gpuContext . configure ( this . canvasConfig ) ;
349+ this . gpuContext ? .configure ( this . canvasConfig ) ;
350350
351351 this . createBackbuffer ( ) ;
352352
@@ -411,8 +411,8 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
411411 WebgpuDebug . memory ( this ) ;
412412 WebgpuDebug . validate ( this ) ;
413413
414- // current frame color output buffer
415- const outColorBuffer = this . gpuContext . getCurrentTexture ( ) ;
414+ // current frame color output buffer (fallback to external backbuffer if not available)
415+ const outColorBuffer = this . gpuContext ? .getCurrentTexture ?. ( ) ?? this . externalBackbuffer ?. impl . gpuTexture ;
416416 DebugHelper . setLabel ( outColorBuffer , `${ this . backBuffer . name } ` ) ;
417417
418418 // reallocate framebuffer if dimensions change, to match the output texture
0 commit comments