@@ -161,14 +161,7 @@ impl RenderContextBuilder {
161161 let texture_usage = config. usage ;
162162
163163 // Initialize a depth texture matching the surface size.
164- let depth_format = platform:: texture:: DepthFormat :: Depth32Float ;
165- let depth_texture = Some (
166- platform:: texture:: DepthTextureBuilder :: new ( )
167- . with_size ( size. 0 . max ( 1 ) , size. 1 . max ( 1 ) )
168- . with_format ( depth_format)
169- . with_label ( "lambda-depth" )
170- . build ( & gpu) ,
171- ) ;
164+ let depth_format = texture:: DepthFormat :: Depth32Float ;
172165
173166 return Ok ( RenderContext {
174167 label : name,
@@ -179,7 +172,7 @@ impl RenderContextBuilder {
179172 present_mode,
180173 texture_usage,
181174 size,
182- depth_texture,
175+ depth_texture : None ,
183176 depth_format,
184177 depth_sample_count : 1 ,
185178 msaa_color : None ,
@@ -219,10 +212,10 @@ pub struct RenderContext {
219212 present_mode : surface:: PresentMode ,
220213 texture_usage : texture:: TextureUsages ,
221214 size : ( u32 , u32 ) ,
222- depth_texture : Option < platform :: texture:: DepthTexture > ,
223- depth_format : platform :: texture:: DepthFormat ,
215+ depth_texture : Option < texture:: DepthTexture > ,
216+ depth_format : texture:: DepthFormat ,
224217 depth_sample_count : u32 ,
225- msaa_color : Option < platform :: texture:: ColorAttachmentTexture > ,
218+ msaa_color : Option < texture:: ColorAttachmentTexture > ,
226219 msaa_sample_count : u32 ,
227220 render_passes : Vec < RenderPassDesc > ,
228221 render_pipelines : Vec < RenderPipeline > ,
@@ -319,12 +312,12 @@ impl RenderContext {
319312
320313 // Recreate depth texture to match new size.
321314 self . depth_texture = Some (
322- platform :: texture:: DepthTextureBuilder :: new ( )
315+ texture:: DepthTextureBuilder :: new ( )
323316 . with_size ( self . size . 0 . max ( 1 ) , self . size . 1 . max ( 1 ) )
324317 . with_format ( self . depth_format )
325318 . with_sample_count ( self . depth_sample_count )
326319 . with_label ( "lambda-depth" )
327- . build ( self . gpu ( ) ) ,
320+ . build ( self ) ,
328321 ) ;
329322 // Drop MSAA color target so it is rebuilt on demand with the new size.
330323 self . msaa_color = None ;
@@ -352,7 +345,7 @@ impl RenderContext {
352345 return self . config . format ;
353346 }
354347
355- pub ( crate ) fn depth_format ( & self ) -> platform :: texture:: DepthFormat {
348+ pub ( crate ) fn depth_format ( & self ) -> texture:: DepthFormat {
356349 return self . depth_format ;
357350 }
358351
@@ -368,12 +361,12 @@ impl RenderContext {
368361
369362 pub ( crate ) fn supports_depth_sample_count (
370363 & self ,
371- format : platform :: texture:: DepthFormat ,
364+ format : texture:: DepthFormat ,
372365 sample_count : u32 ,
373366 ) -> bool {
374367 return self
375368 . gpu
376- . supports_sample_count_for_depth ( format, sample_count) ;
369+ . supports_sample_count_for_depth ( format. to_platform ( ) , sample_count) ;
377370 }
378371
379372 /// Device limit: maximum bytes that can be bound for a single uniform buffer binding.
@@ -409,21 +402,19 @@ impl RenderContext {
409402 fn ensure_msaa_color_texture (
410403 & mut self ,
411404 sample_count : u32 ,
412- ) -> platform :: surface:: TextureViewRef < ' _ > {
405+ ) -> surface:: TextureView < ' _ > {
413406 let need_recreate = match & self . msaa_color {
414407 Some ( _) => self . msaa_sample_count != sample_count,
415408 None => true ,
416409 } ;
417410
418411 if need_recreate {
419412 self . msaa_color = Some (
420- platform:: texture:: ColorAttachmentTextureBuilder :: new (
421- self . config . format . to_platform ( ) ,
422- )
423- . with_size ( self . size . 0 . max ( 1 ) , self . size . 1 . max ( 1 ) )
424- . with_sample_count ( sample_count)
425- . with_label ( "lambda-msaa-color" )
426- . build ( self . gpu ( ) ) ,
413+ texture:: ColorAttachmentTextureBuilder :: new ( self . config . format )
414+ . with_size ( self . size . 0 . max ( 1 ) , self . size . 1 . max ( 1 ) )
415+ . with_sample_count ( sample_count)
416+ . with_label ( "lambda-msaa-color" )
417+ . build ( self ) ,
427418 ) ;
428419 self . msaa_sample_count = sample_count;
429420 }
@@ -520,10 +511,7 @@ impl RenderContext {
520511 // Create color attachments for the surface pass. The MSAA view is
521512 // retrieved here after the mutable borrow for texture creation ends.
522513 let msaa_view = if sample_count > 1 {
523- self
524- . msaa_color
525- . as_ref ( )
526- . map ( |t| surface:: TextureView :: from_platform ( t. view_ref ( ) ) )
514+ self . msaa_color . as_ref ( ) . map ( |t| t. view_ref ( ) )
527515 } else {
528516 None
529517 } ;
@@ -547,8 +535,7 @@ impl RenderContext {
547535
548536 // If stencil is requested on the pass, ensure we use a stencil-capable format.
549537 if pass. stencil_operations ( ) . is_some ( )
550- && self . depth_format
551- != platform:: texture:: DepthFormat :: Depth24PlusStencil8
538+ && self . depth_format != texture:: DepthFormat :: Depth24PlusStencil8
552539 {
553540 #[ cfg( any(
554541 debug_assertions,
@@ -558,8 +545,7 @@ impl RenderContext {
558545 "Render pass has stencil ops but depth format {:?} lacks stencil; upgrading to Depth24PlusStencil8" ,
559546 self . depth_format
560547 ) ;
561- self . depth_format =
562- platform:: texture:: DepthFormat :: Depth24PlusStencil8 ;
548+ self . depth_format = texture:: DepthFormat :: Depth24PlusStencil8 ;
563549 }
564550
565551 let format_mismatch = self
@@ -573,12 +559,12 @@ impl RenderContext {
573559 || format_mismatch
574560 {
575561 self . depth_texture = Some (
576- platform :: texture:: DepthTextureBuilder :: new ( )
562+ texture:: DepthTextureBuilder :: new ( )
577563 . with_size ( self . size . 0 . max ( 1 ) , self . size . 1 . max ( 1 ) )
578564 . with_format ( self . depth_format )
579565 . with_sample_count ( desired_samples)
580566 . with_label ( "lambda-depth" )
581- . build ( self . gpu ( ) ) ,
567+ . build ( self ) ,
582568 ) ;
583569 self . depth_sample_count = desired_samples;
584570 }
@@ -587,7 +573,7 @@ impl RenderContext {
587573 . depth_texture
588574 . as_ref ( )
589575 . expect ( "depth texture should be present" )
590- . view_ref ( ) ;
576+ . platform_view_ref ( ) ;
591577
592578 // Map depth operations when explicitly provided; leave depth
593579 // untouched for stencil-only passes.
0 commit comments