@@ -232,26 +232,28 @@ impl GraphicsState {
232232 self . config . width = width;
233233 self . config . height = height;
234234 self . surface . configure ( & self . device , & self . config ) ;
235+ let texture = self . device . create_texture ( & wgpu:: TextureDescriptor {
236+ label : Some ( "CEF Texture" ) ,
237+ size : wgpu:: Extent3d {
238+ width,
239+ height,
240+ depth_or_array_layers : 1 ,
241+ } ,
242+ mip_level_count : 1 ,
243+ sample_count : 1 ,
244+ dimension : wgpu:: TextureDimension :: D2 ,
245+ format : wgpu:: TextureFormat :: Bgra8UnormSrgb ,
246+ usage : wgpu:: TextureUsages :: TEXTURE_BINDING | wgpu:: TextureUsages :: COPY_DST ,
247+ view_formats : & [ ] ,
248+ } ) ;
249+ self . texture = Some ( texture) ;
235250 }
236251
237- let texture = self . device . create_texture ( & wgpu:: TextureDescriptor {
238- label : Some ( "CEF Texture" ) ,
239- size : wgpu:: Extent3d {
240- width,
241- height,
242- depth_or_array_layers : 1 ,
243- } ,
244- mip_level_count : 1 ,
245- sample_count : 1 ,
246- dimension : wgpu:: TextureDimension :: D2 ,
247- format : wgpu:: TextureFormat :: Bgra8UnormSrgb ,
248- usage : wgpu:: TextureUsages :: TEXTURE_BINDING | wgpu:: TextureUsages :: COPY_DST ,
249- view_formats : & [ ] ,
250- } ) ;
252+ let Some ( ref texture) = self . texture else { return } ;
251253
252254 self . queue . write_texture (
253255 wgpu:: TexelCopyTextureInfo {
254- texture : & texture ,
256+ texture,
255257 mip_level : 0 ,
256258 origin : wgpu:: Origin3d :: ZERO ,
257259 aspect : wgpu:: TextureAspect :: All ,
@@ -286,7 +288,6 @@ impl GraphicsState {
286288 label : Some ( "texture_bind_group" ) ,
287289 } ) ;
288290
289- self . texture = Some ( texture) ;
290291 self . bind_group = Some ( bind_group) ;
291292 }
292293
0 commit comments