@@ -12,6 +12,8 @@ pub(crate) struct RenderState {
1212 render_pipeline : wgpu:: RenderPipeline ,
1313 transparent_texture : wgpu:: Texture ,
1414 sampler : wgpu:: Sampler ,
15+ desired_width : u32 ,
16+ desired_height : u32 ,
1517 viewport_scale : [ f32 ; 2 ] ,
1618 viewport_offset : [ f32 ; 2 ] ,
1719 viewport_texture : Option < wgpu:: Texture > ,
@@ -171,6 +173,8 @@ impl RenderState {
171173 render_pipeline,
172174 transparent_texture,
173175 sampler,
176+ desired_width : size. width ,
177+ desired_height : size. height ,
174178 viewport_scale : [ 1.0 , 1.0 ] ,
175179 viewport_offset : [ 0.0 , 0.0 ] ,
176180 viewport_texture : None ,
@@ -182,11 +186,8 @@ impl RenderState {
182186 }
183187
184188 pub ( crate ) fn resize ( & mut self , width : u32 , height : u32 ) {
185- if width > 0 && height > 0 && ( self . config . width != width || self . config . height != height) {
186- self . config . width = width;
187- self . config . height = height;
188- self . surface . configure ( & self . context . device , & self . config ) ;
189- }
189+ self . desired_width = width;
190+ self . desired_height = height;
190191 }
191192
192193 pub ( crate ) fn bind_viewport_texture ( & mut self , viewport_texture : wgpu:: Texture ) {
@@ -200,8 +201,17 @@ impl RenderState {
200201 }
201202
202203 pub ( crate ) fn bind_ui_texture ( & mut self , bind_ui_texture : wgpu:: Texture ) {
204+ let width = bind_ui_texture. width ( ) ;
205+ let height = bind_ui_texture. height ( ) ;
206+
203207 self . ui_texture = Some ( bind_ui_texture) ;
204208 self . update_bindgroup ( ) ;
209+
210+ if width > 0 && height > 0 && ( self . config . width != width || self . config . height != height) {
211+ self . config . width = width;
212+ self . config . height = height;
213+ self . surface . configure ( & self . context . device , & self . config ) ;
214+ }
205215 }
206216
207217 pub ( crate ) fn set_viewport_scale ( & mut self , scale : [ f32 ; 2 ] ) {
@@ -235,17 +245,15 @@ impl RenderState {
235245 self . render_overlays ( scene) ;
236246 }
237247
238- let output = self . surface . get_current_texture ( ) . map_err ( |e| RenderError :: SurfaceError ( e) ) ?;
239- let output_width = output. texture . width ( ) ;
240- let output_height = output. texture . height ( ) ;
248+ let output = self . surface . get_current_texture ( ) . map_err ( RenderError :: SurfaceError ) ?;
241249
242250 let view = output. texture . create_view ( & wgpu:: TextureViewDescriptor :: default ( ) ) ;
243251
244252 let mut encoder = self . context . device . create_command_encoder ( & wgpu:: CommandEncoderDescriptor { label : Some ( "Render Encoder" ) } ) ;
245253
246254 {
247255 let mut render_pass = encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
248- label : Some ( "Render Pass" ) ,
256+ label : Some ( "Graphite Composition Render Pass" ) ,
249257 color_attachments : & [ Some ( wgpu:: RenderPassColorAttachment {
250258 view : & view,
251259 resolve_target : None ,
@@ -271,7 +279,7 @@ impl RenderState {
271279 ) ;
272280 if let Some ( bind_group) = & self . bind_group {
273281 render_pass. set_bind_group ( 0 , bind_group, & [ ] ) ;
274- render_pass. draw ( 0 ..6 , 0 ..1 ) ; // Draw 3 vertices for fullscreen triangle
282+ render_pass. draw ( 0 ..3 , 0 ..1 ) ; // Draw 3 vertices for fullscreen triangle
275283 } else {
276284 tracing:: warn!( "No bind group available - showing clear color only" ) ;
277285 }
@@ -281,7 +289,7 @@ impl RenderState {
281289 output. present ( ) ;
282290
283291 if let Some ( ui_texture) = & self . ui_texture
284- && ( output_width != ui_texture. width ( ) || output_height != ui_texture. height ( ) )
292+ && ( self . desired_width != ui_texture. width ( ) || self . desired_height != ui_texture. height ( ) )
285293 {
286294 return Err ( RenderError :: OutdatedUITextureError ) ;
287295 }
0 commit comments