Merge pull request #422 from tomaka/image-getters

Add some getters to Image
This commit is contained in:
tomaka 2017-04-17 13:58:01 +02:00 committed by GitHub
commit b61a89cb5c
5 changed files with 92 additions and 0 deletions

View File

@ -16,6 +16,7 @@ use std::sync::atomic::Ordering;
use device::Device;
use device::Queue;
use format::ClearValue;
use format::Format;
use format::FormatDesc;
use format::FormatTy;
use image::Dimensions;
@ -289,6 +290,21 @@ unsafe impl<F, A> Image for Arc<AttachmentImage<F, A>>
already_locked: AtomicBool::new(false),
}
}
#[inline]
fn format(&self) -> Format {
self.image.format()
}
#[inline]
fn samples(&self) -> u32 {
self.image.samples()
}
#[inline]
fn dimensions(&self) -> ImageDimensions {
self.image.dimensions()
}
}
unsafe impl<F, A> ImageView for Arc<AttachmentImage<F, A>>

View File

@ -12,8 +12,10 @@ use smallvec::SmallVec;
use device::Device;
use device::Queue;
use format::Format;
use format::FormatDesc;
use image::Dimensions;
use image::ImageDimensions;
use image::MipmapsCount;
use image::sys::ImageCreationError;
use image::sys::Layout;
@ -135,6 +137,21 @@ unsafe impl<F, A> Image for Arc<ImmutableImage<F, A>>
fn access(self) -> Self {
self
}
#[inline]
fn format(&self) -> Format {
self.image.format()
}
#[inline]
fn samples(&self) -> u32 {
self.image.samples()
}
#[inline]
fn dimensions(&self) -> ImageDimensions {
self.image.dimensions()
}
}
// FIXME: wrong

View File

@ -18,7 +18,9 @@ use device::Queue;
use format::ClearValue;
use format::FormatDesc;
use format::FormatTy;
use format::Format;
use image::Dimensions;
use image::ImageDimensions;
use image::sys::ImageCreationError;
use image::sys::Layout;
use image::sys::UnsafeImage;
@ -152,6 +154,21 @@ unsafe impl<F, A> Image for Arc<StorageImage<F, A>>
fn access(self) -> Self {
self
}
#[inline]
fn format(&self) -> Format {
self.image.format()
}
#[inline]
fn samples(&self) -> u32 {
self.image.samples()
}
#[inline]
fn dimensions(&self) -> ImageDimensions {
self.image.dimensions()
}
}
// FIXME: wrong

View File

@ -13,6 +13,7 @@ use device::Queue;
use format::ClearValue;
use format::Format;
use format::FormatDesc;
use image::ImageDimensions;
use image::Dimensions;
use image::ViewType;
use image::traits::ImageAccess;
@ -179,9 +180,25 @@ unsafe impl ImageViewAccess for SwapchainImage {
unsafe impl Image for SwapchainImage {
type Access = SwapchainImage;
#[inline]
fn access(self) -> Self::Access {
self
}
#[inline]
fn format(&self) -> Format {
self.image.format()
}
#[inline]
fn samples(&self) -> u32 {
self.image.samples()
}
#[inline]
fn dimensions(&self) -> ImageDimensions {
self.image.dimensions()
}
}
unsafe impl ImageView for SwapchainImage {
@ -195,9 +212,25 @@ unsafe impl ImageView for SwapchainImage {
unsafe impl Image for Arc<SwapchainImage> {
type Access = Arc<SwapchainImage>;
#[inline]
fn access(self) -> Self::Access {
self
}
#[inline]
fn format(&self) -> Format {
self.image.format()
}
#[inline]
fn samples(&self) -> u32 {
self.image.samples()
}
#[inline]
fn dimensions(&self) -> ImageDimensions {
self.image.dimensions()
}
}
unsafe impl ImageView for Arc<SwapchainImage> {

View File

@ -34,6 +34,15 @@ pub unsafe trait Image {
/// Builds an object that represents a GPU access to the image.
fn access(self) -> Self::Access;
/// Returns the format of this image.
fn format(&self) -> Format;
/// Returns the number of samples of this image.
fn samples(&self) -> u32;
/// Returns the dimensions of the image.
fn dimensions(&self) -> ImageDimensions;
}
/// Trait for types that represent the way a GPU can access an image.