mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-26 00:34:19 +00:00
Add some dummy code
This commit is contained in:
parent
54b3e1025d
commit
179c3d6dae
@ -0,0 +1,26 @@
|
|||||||
|
use lock;
|
||||||
|
|
||||||
|
unsafe trait BufferLock {
|
||||||
|
unsafe fn get_id(&self) -> u64;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> BufferLock for T where T: lock::Lock<Buffer> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Buffer {
|
||||||
|
id: ,
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl BufferLock for Buffer {
|
||||||
|
#[inline]
|
||||||
|
unsafe fn get_id(&self) -> u64 {
|
||||||
|
self.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for Buffer {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
error::check_result(unsafe { ffi::grDestroyBuffer(self.id) }).unwrap();
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
use buffer::BufferLock;
|
||||||
|
|
||||||
/// Represents a prototype of a command buffer.
|
/// Represents a prototype of a command buffer.
|
||||||
///
|
///
|
||||||
@ -24,7 +25,7 @@ pub struct CommandBufferBuilder {
|
|||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
cmd: Option<ffi::GR_CMD_BUFFER>,
|
cmd: Option<ffi::GR_CMD_BUFFER>,
|
||||||
memory_refs: Vec<ffi::GR_MEMORY_REF>,
|
memory_refs: Vec<ffi::GR_MEMORY_REF>,
|
||||||
buffers: Vec<Arc<Buffer>>,
|
buffers: Vec<Arc<BufferLock>>,
|
||||||
images: Vec<Arc<Image>>,
|
images: Vec<Arc<Image>>,
|
||||||
pipelines: Vec<Arc<Pipeline>>,
|
pipelines: Vec<Arc<Pipeline>>,
|
||||||
}
|
}
|
||||||
@ -85,7 +86,7 @@ pub struct CommandBuffer {
|
|||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
cmd: ffi::GR_CMD_BUFFER,
|
cmd: ffi::GR_CMD_BUFFER,
|
||||||
memory_refs: Vec<ffi::GR_MEMORY_REF>,
|
memory_refs: Vec<ffi::GR_MEMORY_REF>,
|
||||||
buffers: Vec<Arc<Buffer>>,
|
buffers: Vec<Arc<BufferLock>>,
|
||||||
images: Vec<Arc<Image>>,
|
images: Vec<Arc<Image>>,
|
||||||
pipelines: Vec<Arc<Pipeline>>,
|
pipelines: Vec<Arc<Pipeline>>,
|
||||||
}
|
}
|
||||||
|
32
src/lock.rs
Normal file
32
src/lock.rs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
use std::sync;
|
||||||
|
|
||||||
|
use Fence;
|
||||||
|
|
||||||
|
/// Defines a strategy for read-write access and relation with fences.
|
||||||
|
pub trait Lock<T> {
|
||||||
|
fn shared_access(&self);
|
||||||
|
fn exclusive_access(&self);
|
||||||
|
|
||||||
|
fn shared_access_until(&self, Fence);
|
||||||
|
fn exclusive_access_until(&self, Fence);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Mutex<T> {
|
||||||
|
inner: sync::Mutex<T>,
|
||||||
|
fence: Option<Fence>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Mutex<T> {
|
||||||
|
pub fn lock(&self) -> Result<MutexLock<T>, MutexlockError> {
|
||||||
|
self.fence.wait();
|
||||||
|
let inner = try!(self.inner.lock());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Lock<T> for Mutex<T> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct MutexLock<'a, T> {
|
||||||
|
inner: sync::LockGuard<'a, T>,
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user