diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:19 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:19 +0100 |
commit | 34ca085717195302c8048c46f64ff771476ee4a2 (patch) | |
tree | ae2fb5af1fb8fdf3a36231813f5100b84a89d7e7 /stockton-render/src/draw/frame.rs | |
parent | 21a0be717e4c52bbc30ccb11855a9638946fc7b4 (diff) |
feat(render): added vulkan initialisation, etc.
Diffstat (limited to 'stockton-render/src/draw/frame.rs')
-rw-r--r-- | stockton-render/src/draw/frame.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/stockton-render/src/draw/frame.rs b/stockton-render/src/draw/frame.rs new file mode 100644 index 0000000..d1e617c --- /dev/null +++ b/stockton-render/src/draw/frame.rs @@ -0,0 +1,51 @@ +// Copyright (C) 2019 Oscar Shrimpton + +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation, either version 3 of the License, or (at your option) +// any later version. + +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +// more details. + +// You should have received a copy of the GNU General Public License along +// with this program. If not, see <http://www.gnu.org/licenses/>. + +//! Helper struct. Keeps the data for each frame 'in flight' seperate instead of linked lists. +use hal::{Device as DeviceTrait}; +use hal::command::CommandBuffer; +use hal::Graphics; +use back::{Backend}; +use hal::pool::{CommandPool}; + + +/// Helper struct for a frame that can be in flight +pub struct FrameCell { + /// How we ask the GPU to do work for us. + pub command_buffer: CommandBuffer<Backend, Graphics>, + + /// Signalled once an image is acquired to draw on. + pub image_available: <Backend as hal::Backend>::Semaphore, + + /// Signalled once the frame is done being drawn. + pub render_finished: <Backend as hal::Backend>::Semaphore, + + /// Signalled once the frame is presented. + pub frame_presented: <Backend as hal::Backend>::Fence +} + +impl FrameCell { + /// Safely deinitialises all the objects in this struct. + /// Use this instead of drop. + pub unsafe fn destroy(self, device: &<Backend as hal::Backend>::Device, command_pool: &mut CommandPool<Backend, Graphics>) { + // fences & semaphores + device.destroy_semaphore(self.image_available); + device.destroy_semaphore(self.render_finished); + device.destroy_fence(self.frame_presented); + + // command buffer + command_pool.free(vec![self.command_buffer]); + } +}
\ No newline at end of file |