1- //! GPU fence & semaphore implementations for rendering synchronizations. These
2- //! implementations built on top of gfx-hal and are used by the lambda-platform
3- //! rendering implementations to synchronize GPU operations.
1+ //! GPU synchronization Implementations that are built on top of gfx-hal and
2+ //! are used by the lambda-platform rendering implementations to synchronize
3+ //! GPU operations.
44
55use gfx_hal:: device:: Device ;
66
@@ -25,6 +25,9 @@ impl RenderSemaphoreBuilder {
2525 }
2626}
2727
28+ /// Render semaphores are used to synchronize operations happening within the
29+ /// GPU. This allows for us to tell the GPU to wait for a frame to finish
30+ /// rendering before presenting it to the screen.
2831pub struct RenderSemaphore < RenderBackend : gfx_hal:: Backend > {
2932 semaphore : RenderBackend :: Semaphore ,
3033}
@@ -75,6 +78,9 @@ impl RenderSubmissionFenceBuilder {
7578 }
7679}
7780
81+ /// A GPU fence is used to synchronize GPU operations. It is used to ensure that
82+ /// a GPU operation has completed before the CPU attempts to submit commands to
83+ /// it.
7884pub struct RenderSubmissionFence < RenderBackend : gfx_hal:: Backend > {
7985 fence : RenderBackend :: Fence ,
8086 default_render_timeout : u64 ,
@@ -95,12 +101,13 @@ impl<RenderBackend: gfx_hal::Backend> RenderSubmissionFence<RenderBackend> {
95101 unsafe {
96102 super :: gpu:: internal:: logical_device_for ( gpu)
97103 . wait_for_fence ( & self . fence , timeout)
98- . expect ( "The GPU ran out of memory or has become detached from the current context." ) ;
104+ }
105+ . expect ( "The GPU ran out of memory or has become detached from the current context." ) ;
99106
100- super :: gpu:: internal:: logical_device_for ( gpu)
101- . reset_fence ( & mut self . fence )
102- . expect ( "The fence failed to reset." ) ;
107+ unsafe {
108+ super :: gpu:: internal:: logical_device_for ( gpu) . reset_fence ( & mut self . fence )
103109 }
110+ . expect ( "The fence failed to reset." ) ;
104111 }
105112
106113 /// Destroy this fence given the GPU that created it.
0 commit comments