@@ -41,6 +41,7 @@ use super::{
4141 buffer:: Buffer ,
4242 render_pass:: RenderPass ,
4343 shader:: Shader ,
44+ texture,
4445 vertex:: VertexAttribute ,
4546 RenderContext ,
4647} ;
@@ -234,7 +235,7 @@ pub struct RenderPipelineBuilder {
234235 bind_group_layouts : Vec < bind:: BindGroupLayout > ,
235236 label : Option < String > ,
236237 use_depth : bool ,
237- depth_format : Option < platform_texture :: DepthFormat > ,
238+ depth_format : Option < texture :: DepthFormat > ,
238239 sample_count : u32 ,
239240 depth_compare : Option < CompareFunction > ,
240241 stencil : Option < platform_pipeline:: StencilState > ,
@@ -307,10 +308,7 @@ impl RenderPipelineBuilder {
307308 }
308309
309310 /// Enable depth with an explicit depth format.
310- pub fn with_depth_format (
311- mut self ,
312- format : platform_texture:: DepthFormat ,
313- ) -> Self {
311+ pub fn with_depth_format ( mut self , format : texture:: DepthFormat ) -> Self {
314312 self . use_depth = true ;
315313 self . depth_format = Some ( format) ;
316314 return self ;
@@ -457,23 +455,25 @@ impl RenderPipelineBuilder {
457455 }
458456
459457 if self . use_depth {
458+ // Engine-level depth format with default
460459 let mut dfmt = self
461460 . depth_format
462- . unwrap_or ( platform_texture :: DepthFormat :: Depth32Float ) ;
461+ . unwrap_or ( texture :: DepthFormat :: Depth32Float ) ;
463462 // If stencil state is configured, ensure a stencil-capable depth format.
464463 if self . stencil . is_some ( )
465- && dfmt != platform_texture :: DepthFormat :: Depth24PlusStencil8
464+ && dfmt != texture :: DepthFormat :: Depth24PlusStencil8
466465 {
467466 #[ cfg( debug_assertions) ]
468467 logging:: error!(
469468 "Stencil configured but depth format {:?} lacks stencil; upgrading to Depth24PlusStencil8" ,
470469 dfmt
471470 ) ;
472- dfmt = platform_texture :: DepthFormat :: Depth24PlusStencil8 ;
471+ dfmt = texture :: DepthFormat :: Depth24PlusStencil8 ;
473472 }
474- // Keep context depth format in sync for attachment creation.
475- render_context. depth_format = dfmt;
476- rp_builder = rp_builder. with_depth_stencil ( dfmt) ;
473+ // Map to platform and keep context depth format in sync for attachment creation.
474+ let dfmt_platform = dfmt. to_platform ( ) ;
475+ render_context. depth_format = dfmt_platform;
476+ rp_builder = rp_builder. with_depth_stencil ( dfmt_platform) ;
477477 if let Some ( compare) = self . depth_compare {
478478 rp_builder = rp_builder. with_depth_compare ( compare. to_platform ( ) ) ;
479479 }
0 commit comments