@@ -631,14 +631,31 @@ var onRun = () => {
631631 } ) ;
632632}
633633
634+ function appendOutput ( editor , textLine ) {
635+ editor . setValue ( editor . getValue ( ) + textLine + "\n" ) ;
636+ }
637+
634638function compileOrRun ( ) {
635639 const userSource = monacoEditor . getValue ( ) ;
636640 const shaderType = checkShaderType ( userSource ) ;
641+
637642 if ( shaderType == SlangCompiler . NON_RUNNABLE_SHADER ) {
638643 onCompile ( ) ;
639644 }
640645 else {
641- onRun ( ) ;
646+ if ( device == null ) {
647+ onCompile ( ) . then ( ( ) => {
648+ if ( diagnosticsArea . getValue ( ) == "" )
649+ appendOutput ( diagnosticsArea , `The shader compiled successfully,` +
650+ `but it cannot run because your browser does not support WebGPU.\n` +
651+ `WebGPU is supported in Chrome, Edge, Firefox Nightly or Safari Technology Preview. ` +
652+ `On iOS, WebGPU support requires Safari 16.4 or later and must be enabled in settings. ` +
653+ `Please check your browser version and enable WebGPU if possible.` ) ;
654+ } ) ;
655+ }
656+ else {
657+ onRun ( ) ;
658+ }
642659 }
643660}
644661
@@ -730,6 +747,7 @@ function loadEditor(readOnlyMode = false, containerId, preloadCode) {
730747 readOnly : readOnlyMode ,
731748 lineNumbers : readOnlyMode ? "off" : "on" ,
732749 automaticLayout : true ,
750+ wordWrap : containerId == "diagnostics" ? "on" : "off" ,
733751 "semanticHighlighting.enabled" : true ,
734752 renderValidationDecorations : "on" ,
735753 minimap : {
@@ -771,7 +789,7 @@ var Module = {
771789 const progressBar = document . getElementById ( 'progress-bar' ) ;
772790 const compressedData = await fetchWithProgress ( 'slang-wasm.wasm.gz' , ( loaded , total ) => {
773791 const progress = ( loaded / total ) * 100 ;
774- progressBar . style . width = `${ progress } % ` ;
792+ progressBar . style . width = `${ progress } % ` ;
775793 } ) ;
776794
777795 // Step 2: Decompress the gzip data
@@ -842,14 +860,12 @@ function runIfFullyInitialized() {
842860
843861 restoreSelectedTargetFromURL ( ) ;
844862
845- if ( device ) {
846- if ( restoreDemoSelectionFromURL ( ) ) { }
847- else if ( monacoEditor . getValue ( ) == "" ) {
848- loadDemo ( defaultShaderURL ) ;
849- }
850- else {
851- compileOrRun ( ) ;
852- }
863+ if ( restoreDemoSelectionFromURL ( ) ) { }
864+ else if ( monacoEditor . getValue ( ) == "" ) {
865+ loadDemo ( defaultShaderURL ) ;
866+ }
867+ else {
868+ compileOrRun ( ) ;
853869 }
854870 }
855871}
0 commit comments