@@ -46,7 +46,8 @@ export class ViewGpuContext extends Disposable {
46
46
readonly canvas : FastDomNode < HTMLCanvasElement > ;
47
47
readonly ctx : GPUCanvasContext ;
48
48
49
- readonly device : Promise < GPUDevice > ;
49
+ static device : Promise < GPUDevice > ;
50
+ static deviceSync : GPUDevice | undefined ;
50
51
51
52
readonly rectangleRenderer : RectangleRenderer ;
52
53
@@ -109,18 +110,23 @@ export class ViewGpuContext extends Disposable {
109
110
110
111
this . ctx = ensureNonNullable ( this . canvas . domNode . getContext ( 'webgpu' ) ) ;
111
112
112
- this . device = GPULifecycle . requestDevice ( ( message ) => {
113
- const choices : IPromptChoice [ ] = [ {
114
- label : nls . localize ( 'editor.dom.render' , "Use DOM-based rendering" ) ,
115
- run : ( ) => this . configurationService . updateValue ( 'editor.experimentalGpuAcceleration' , 'off' ) ,
116
- } ] ;
117
- this . _notificationService . prompt ( Severity . Warning , message , choices ) ;
118
- } ) . then ( ref => this . _register ( ref ) . object ) ;
119
- this . device . then ( device => {
120
- if ( ! ViewGpuContext . _atlas ) {
121
- ViewGpuContext . _atlas = this . _instantiationService . createInstance ( TextureAtlas , device . limits . maxTextureDimension2D , undefined ) ;
122
- }
123
- } ) ;
113
+ // Request the GPU device, we only want to do this a single time per window as it's async
114
+ // and can delay the initial render.
115
+ if ( ! ViewGpuContext . device ) {
116
+ ViewGpuContext . device = GPULifecycle . requestDevice ( ( message ) => {
117
+ const choices : IPromptChoice [ ] = [ {
118
+ label : nls . localize ( 'editor.dom.render' , "Use DOM-based rendering" ) ,
119
+ run : ( ) => this . configurationService . updateValue ( 'editor.experimentalGpuAcceleration' , 'off' ) ,
120
+ } ] ;
121
+ this . _notificationService . prompt ( Severity . Warning , message , choices ) ;
122
+ } ) . then ( ref => {
123
+ ViewGpuContext . deviceSync = ref . object ;
124
+ if ( ! ViewGpuContext . _atlas ) {
125
+ ViewGpuContext . _atlas = this . _instantiationService . createInstance ( TextureAtlas , ref . object . limits . maxTextureDimension2D , undefined ) ;
126
+ }
127
+ return ref . object ;
128
+ } ) ;
129
+ }
124
130
125
131
const dprObs = observableValue ( this , getActiveWindow ( ) . devicePixelRatio ) ;
126
132
this . _register ( addDisposableListener ( getActiveWindow ( ) , 'resize' , ( ) => {
@@ -147,8 +153,7 @@ export class ViewGpuContext extends Disposable {
147
153
} ) ) ;
148
154
this . contentLeft = contentLeft ;
149
155
150
-
151
- this . rectangleRenderer = this . _instantiationService . createInstance ( RectangleRenderer , context , this . contentLeft , this . devicePixelRatio , this . canvas . domNode , this . ctx , this . device ) ;
156
+ this . rectangleRenderer = this . _instantiationService . createInstance ( RectangleRenderer , context , this . contentLeft , this . devicePixelRatio , this . canvas . domNode , this . ctx , ViewGpuContext . device ) ;
152
157
}
153
158
154
159
/**
0 commit comments