1 // Copyright (c) 2017 The vulkano developers
2 // Licensed under the Apache License, Version 2.0
3 // <LICENSE-APACHE or
4 // https://www.apache.org/licenses/LICENSE-2.0> or the MIT
5 // license <LICENSE-MIT or https://opensource.org/licenses/MIT>,
6 // at your option. All files in the project carrying such
7 // notice may not be copied, modified, or distributed except
8 // according to those terms.
9
10 use super::{AccessCheckError, FlushError, GpuFuture, SubmitAnyBuilder};
11 use crate::{
12 buffer::Buffer,
13 device::{Device, DeviceOwned, Queue},
14 image::{sys::Image, ImageLayout},
15 swapchain::Swapchain,
16 DeviceSize,
17 };
18 use std::{ops::Range, sync::Arc};
19
20 /// Builds a future that represents "now".
21 #[inline]
now(device: Arc<Device>) -> NowFuture22 pub fn now(device: Arc<Device>) -> NowFuture {
23 NowFuture { device }
24 }
25
26 /// A dummy future that represents "now".
27 pub struct NowFuture {
28 device: Arc<Device>,
29 }
30
31 unsafe impl GpuFuture for NowFuture {
32 #[inline]
cleanup_finished(&mut self)33 fn cleanup_finished(&mut self) {}
34
35 #[inline]
build_submission(&self) -> Result<SubmitAnyBuilder, FlushError>36 unsafe fn build_submission(&self) -> Result<SubmitAnyBuilder, FlushError> {
37 Ok(SubmitAnyBuilder::Empty)
38 }
39
40 #[inline]
flush(&self) -> Result<(), FlushError>41 fn flush(&self) -> Result<(), FlushError> {
42 Ok(())
43 }
44
45 #[inline]
signal_finished(&self)46 unsafe fn signal_finished(&self) {}
47
48 #[inline]
queue_change_allowed(&self) -> bool49 fn queue_change_allowed(&self) -> bool {
50 true
51 }
52
53 #[inline]
queue(&self) -> Option<Arc<Queue>>54 fn queue(&self) -> Option<Arc<Queue>> {
55 None
56 }
57
58 #[inline]
check_buffer_access( &self, _buffer: &Buffer, _range: Range<DeviceSize>, _exclusive: bool, _queue: &Queue, ) -> Result<(), AccessCheckError>59 fn check_buffer_access(
60 &self,
61 _buffer: &Buffer,
62 _range: Range<DeviceSize>,
63 _exclusive: bool,
64 _queue: &Queue,
65 ) -> Result<(), AccessCheckError> {
66 Err(AccessCheckError::Unknown)
67 }
68
69 #[inline]
check_image_access( &self, _image: &Image, _range: Range<DeviceSize>, _exclusive: bool, _expected_layout: ImageLayout, _queue: &Queue, ) -> Result<(), AccessCheckError>70 fn check_image_access(
71 &self,
72 _image: &Image,
73 _range: Range<DeviceSize>,
74 _exclusive: bool,
75 _expected_layout: ImageLayout,
76 _queue: &Queue,
77 ) -> Result<(), AccessCheckError> {
78 Err(AccessCheckError::Unknown)
79 }
80
81 #[inline]
check_swapchain_image_acquired( &self, _swapchain: &Swapchain, _image_index: u32, _before: bool, ) -> Result<(), AccessCheckError>82 fn check_swapchain_image_acquired(
83 &self,
84 _swapchain: &Swapchain,
85 _image_index: u32,
86 _before: bool,
87 ) -> Result<(), AccessCheckError> {
88 Err(AccessCheckError::Unknown)
89 }
90 }
91
92 unsafe impl DeviceOwned for NowFuture {
93 #[inline]
device(&self) -> &Arc<Device>94 fn device(&self) -> &Arc<Device> {
95 &self.device
96 }
97 }
98