@@ -54,55 +54,45 @@ impl<RenderBackend: internal::Backend> Instance<RenderBackend> {
5454 }
5555}
5656
57- // ----------------------- INTERNAL INSTANCE OPERATIONS ------------------------
58-
59- pub mod internal {
60- use gfx_hal :: {
61- adapter:: Adapter ,
62- Instance as _ ,
63- } ;
57+ impl < RenderBackend : internal :: Backend > Instance < RenderBackend > {
58+ /// Returns a list of all available adapters.
59+ pub ( super ) fn enumerate_adapters (
60+ & self ,
61+ ) -> Vec < gfx_hal :: adapter:: Adapter < RenderBackend > > {
62+ return self . gfx_hal_instance . enumerate_adapters ( ) ;
63+ }
6464
65- pub use super :: {
66- pipeline :: internal :: * ,
67- shader :: internal :: * ,
68- Instance ,
69- } ;
65+ pub ( super ) fn first_adapter (
66+ & self ,
67+ ) -> gfx_hal :: adapter :: Adapter < RenderBackend > {
68+ return self . gfx_hal_instance . enumerate_adapters ( ) . remove ( 0 ) ;
69+ }
7070
71- /// Helper function to create a low level gfx_hal surface. Not meant to be
72- /// used outside of lambda-platform.
73- #[ inline]
74- pub fn create_surface < RenderBackend : gfx_hal:: Backend > (
75- instance : & Instance < RenderBackend > ,
71+ pub ( super ) fn create_surface (
72+ & self ,
7673 window_handle : & crate :: winit:: WindowHandle ,
7774 ) -> RenderBackend :: Surface {
78- unsafe {
79- let surface = instance
75+ return unsafe {
76+ self
8077 . gfx_hal_instance
8178 . create_surface ( & window_handle. window_handle )
82- . expect ( "Failed to create a surface using the current instance and window handle." ) ;
83-
84- return surface;
79+ . expect ( "Failed to create a surface using the current instance and window handle." )
8580 } ;
8681 }
8782
88- /// Destroy a low level gfx_hal surface using the instance abstraction.
89- pub fn destroy_surface < RenderBackend : gfx_hal:: Backend > (
90- instance : & Instance < RenderBackend > ,
91- surface : RenderBackend :: Surface ,
92- ) {
83+ pub ( super ) fn destroy_surface ( & self , surface : RenderBackend :: Surface ) {
9384 unsafe {
94- instance . gfx_hal_instance . destroy_surface ( surface) ;
85+ self . gfx_hal_instance . destroy_surface ( surface) ;
9586 }
9687 }
88+ }
9789
98- /// Returns a graphical adapter from an instance.
99- pub fn get_adapter < RenderBackend : gfx_hal:: Backend > (
100- instance : & mut Instance < RenderBackend > ,
101- adapter_num : usize ,
102- ) -> Adapter < RenderBackend > {
103- return instance
104- . gfx_hal_instance
105- . enumerate_adapters ( )
106- . remove ( adapter_num) ;
107- }
90+ // ----------------------- INTERNAL INSTANCE OPERATIONS ------------------------
91+
92+ pub mod internal {
93+
94+ pub use super :: {
95+ pipeline:: internal:: * ,
96+ shader:: internal:: * ,
97+ } ;
10898}
0 commit comments