@@ -177,7 +177,7 @@ impl SwapchainBuilder {
177177 ) -> Swapchain {
178178 let physical_device = gpu. internal_physical_device ( ) ;
179179 let caps = surface. gfx_hal_surface . capabilities ( physical_device) ;
180- let format = internal :: get_first_supported_format ( surface , physical_device) ;
180+ let format = surface . get_first_supported_format ( physical_device) ;
181181 let ( width, height) = self . size ;
182182
183183 let mut swapchain_config = gfx_hal:: window:: SwapchainConfig :: from_caps (
@@ -235,39 +235,51 @@ mod tests {
235235 }
236236}
237237
238- /// Internal functions to work with the gfx-hal surface components
239- pub mod internal {
240- use gfx_hal:: window:: {
241- PresentationSurface ,
242- Surface as _,
243- } ;
244-
238+ impl < RenderBackend : Backend > Surface < RenderBackend > {
245239 /// Checks the queue family if the current Surface can support the GPU.
246- pub fn can_support_queue_family < RenderBackend : gfx_hal :: Backend > (
247- surface : & super :: Surface < RenderBackend > ,
240+ pub ( super ) fn can_support_queue_family (
241+ & self ,
248242 queue_family : & RenderBackend :: QueueFamily ,
249243 ) -> bool {
250- return surface . gfx_hal_surface . supports_queue_family ( queue_family) ;
244+ return self . gfx_hal_surface . supports_queue_family ( queue_family) ;
251245 }
252246
253- /// Get the supported gfx_hal color formats for a given format.
254- pub fn get_supported_formats < RenderBackend : gfx_hal:: Backend > (
255- surface : & super :: Surface < RenderBackend > ,
247+ pub ( super ) fn get_supported_formats (
248+ & self ,
256249 physical_device : & RenderBackend :: PhysicalDevice ,
257250 ) -> Vec < gfx_hal:: format:: Format > {
258- return surface
251+ return self
259252 . gfx_hal_surface
260253 . supported_formats ( physical_device)
261254 . unwrap_or ( vec ! [ ] ) ;
262255 }
263256
257+ pub ( super ) fn get_first_supported_format (
258+ & self ,
259+ physical_device : & RenderBackend :: PhysicalDevice ,
260+ ) -> gfx_hal:: format:: Format {
261+ return self
262+ . get_supported_formats ( physical_device)
263+ . get ( 0 )
264+ . unwrap_or ( & gfx_hal:: format:: Format :: Rgba8Srgb )
265+ . clone ( ) ;
266+ }
267+ }
268+
269+ /// Internal functions to work with the gfx-hal surface components
270+ pub mod internal {
271+ use gfx_hal:: window:: {
272+ PresentationSurface ,
273+ Surface as _,
274+ } ;
275+
264276 /// Helper function to retrieve the first supported format given a physical
265277 /// GPU device.
266278 pub fn get_first_supported_format < RenderBackend : gfx_hal:: Backend > (
267279 surface : & super :: Surface < RenderBackend > ,
268280 physical_device : & RenderBackend :: PhysicalDevice ,
269281 ) -> gfx_hal:: format:: Format {
270- let supported_formats = get_supported_formats ( & surface , physical_device) ;
282+ let supported_formats = surface . get_supported_formats ( physical_device) ;
271283
272284 let default_format = * supported_formats
273285 . get ( 0 )
0 commit comments