No longer require buffer content to be 'static

This commit is contained in:
Pierre Krieger 2017-05-11 12:45:50 +02:00
parent b81d204df9
commit a3d73719e4
4 changed files with 13 additions and 17 deletions

View File

@ -192,7 +192,7 @@ impl<T: ?Sized> CpuBufferPool<T> {
}
}
impl<T, A> CpuBufferPool<T, A> where A: MemoryPool, T: 'static {
impl<T, A> CpuBufferPool<T, A> where A: MemoryPool {
/// Sets the capacity to `capacity`, or does nothing if the capacity is already higher.
///
/// Since this can involve a memory allocation, an `OomError` can happen.
@ -394,7 +394,7 @@ unsafe impl<T: ?Sized, A> Buffer for CpuBufferPoolSubbuffer<T, A>
}
unsafe impl<T: ?Sized, A> TypedBuffer for CpuBufferPoolSubbuffer<T, A>
where A: MemoryPool, T: 'static
where A: MemoryPool
{
type Content = T;
}
@ -460,7 +460,7 @@ unsafe impl<T: ?Sized, A> BufferAccess for CpuBufferPoolSubbuffer<T, A>
}
unsafe impl<T: ?Sized, A> TypedBufferAccess for CpuBufferPoolSubbuffer<T, A>
where A: MemoryPool, T: 'static + Copy + Clone
where A: MemoryPool
{
type Content = T;
}

View File

@ -68,7 +68,7 @@ impl<T: ?Sized, B> Clone for BufferSlice<T, B>
impl<T: ?Sized, B> BufferSlice<T, B> {
#[inline]
pub fn from_typed_buffer(r: B) -> BufferSlice<T, B>
where B: TypedBuffer<Content = T>, T: 'static
where B: TypedBuffer<Content = T>
{
let size = r.size();
@ -82,7 +82,7 @@ impl<T: ?Sized, B> BufferSlice<T, B> {
#[inline]
pub fn from_typed_buffer_access(r: B) -> BufferSlice<T, B>
where B: TypedBufferAccess<Content = T>, T: 'static
where B: TypedBufferAccess<Content = T>
{
let size = r.size();
@ -251,7 +251,7 @@ unsafe impl<T: ?Sized, B> BufferAccess for BufferSlice<T, B> where B: BufferAcce
}
}
unsafe impl<T: ?Sized, B> TypedBufferAccess for BufferSlice<T, B> where B: BufferAccess, T: 'static {
unsafe impl<T: ?Sized, B> TypedBufferAccess for BufferSlice<T, B> where B: BufferAccess, {
type Content = T;
}

View File

@ -50,8 +50,7 @@ pub unsafe trait Buffer {
/// Returns `None` if out of range.
#[inline]
fn slice<T>(self, range: Range<usize>) -> Option<BufferSlice<[T], Self>>
where Self: Sized + TypedBuffer<Content = [T]>,
T: 'static
where Self: Sized + TypedBuffer<Content = [T]>
{
BufferSlice::slice(self.into_buffer_slice(), range)
}
@ -74,8 +73,7 @@ pub unsafe trait Buffer {
/// Returns `None` if out of range.
#[inline]
fn index<T>(self, index: usize) -> Option<BufferSlice<[T], Self>>
where Self: Sized + TypedBuffer<Content = [T]>,
T: 'static
where Self: Sized + TypedBuffer<Content = [T]>
{
self.slice(index .. (index + 1))
}
@ -84,7 +82,7 @@ pub unsafe trait Buffer {
/// Extension trait for `Buffer`. Indicates the type of the content of the buffer.
pub unsafe trait TypedBuffer: Buffer {
/// The type of the content of the buffer.
type Content: ?Sized + 'static;
type Content: ?Sized;
}
/// Trait for objects that represent a way for the GPU to have access to a buffer or a slice of a
@ -128,8 +126,7 @@ pub unsafe trait BufferAccess: DeviceOwned {
/// Returns `None` if out of range.
#[inline]
fn slice<T>(&self, range: Range<usize>) -> Option<BufferSlice<[T], &Self>>
where Self: Sized + TypedBufferAccess<Content = [T]>,
T: 'static
where Self: Sized + TypedBufferAccess<Content = [T]>
{
BufferSlice::slice(self.as_buffer_slice(), range)
}
@ -152,8 +149,7 @@ pub unsafe trait BufferAccess: DeviceOwned {
/// Returns `None` if out of range.
#[inline]
fn index<T>(&self, index: usize) -> Option<BufferSlice<[T], &Self>>
where Self: Sized + TypedBufferAccess<Content = [T]>,
T: 'static
where Self: Sized + TypedBufferAccess<Content = [T]>
{
self.slice(index .. (index + 1))
}
@ -286,7 +282,7 @@ unsafe impl<T> BufferAccess for T where T: SafeDeref, T::Target: BufferAccess {
/// Extension trait for `BufferAccess`. Indicates the type of the content of the buffer.
pub unsafe trait TypedBufferAccess: BufferAccess {
/// The type of the content.
type Content: ?Sized + 'static;
type Content: ?Sized;
}
unsafe impl<T> TypedBufferAccess for T where T: SafeDeref, T::Target: TypedBufferAccess {

View File

@ -230,7 +230,7 @@ impl<D> MappedDeviceMemory<D> where D: SafeDeref<Target = Device> {
///
#[inline]
pub unsafe fn read_write<T: ?Sized>(&self, range: Range<usize>) -> CpuAccess<T, D>
where T: Content + 'static
where T: Content
{
let vk = self.memory.device().pointers();
let pointer = T::ref_from_ptr((self.pointer as usize + range.start) as *mut _,