fn new_impl(device: Arc<Device>, dimensions: [u32; 2], format: F, base_usage: ImageUsage,
                samples: u32)
                -> Result<Arc<AttachmentImage<F>>, ImageCreationError>
        where F: FormatDesc
    {
        // TODO: check dimensions against the max_framebuffer_width/height/layers limits

        let is_depth = match format.format().ty() {
            FormatTy::Depth => true,
            FormatTy::DepthStencil => true,
            FormatTy::Stencil => true,
            FormatTy::Compressed => panic!(),
            _ => false,
        };

        let usage = ImageUsage {
            color_attachment: !is_depth,
            depth_stencil_attachment: is_depth,
            ..base_usage
        };

        let (image, mem_reqs) = unsafe {
            let dims = ImageDimensions::Dim2d {
                width: dimensions[0],
                height: dimensions[1],
                array_layers: 1,
                cubemap_compatible: false,
            };

            UnsafeImage::new(device.clone(),
                             usage,
                             format.format(),
                             dims,
                             samples,
                             1,
                             Sharing::Exclusive::<Empty<u32>>,
                             false,
                             false)?
        };

        let mem = MemoryPool::alloc_from_requirements(&Device::standard_pool(&device),
                                    &mem_reqs,
                                    AllocLayout::Optimal,
                                    MappingRequirement::DoNotMap,
                                    DedicatedAlloc::Image(&image),
                                    |t| if t.is_device_local() {
                                        AllocFromRequirementsFilter::Preferred
                                    } else {
                                        AllocFromRequirementsFilter::Allowed
                                    })?;
        debug_assert!((mem.offset() % mem_reqs.alignment) == 0);
        unsafe {
            image.bind_memory(mem.memory(), mem.offset())?;
        }

        let view = unsafe { UnsafeImageView::raw(&image, ViewType::Dim2d, 0 .. 1, 0 .. 1)? };

        Ok(Arc::new(AttachmentImage {
                        image: image,
                        view: view,
                        memory: mem,
                        format: format,
                        attachment_layout: if is_depth {
                            ImageLayout::DepthStencilAttachmentOptimal
                        } else {
                            ImageLayout::ColorAttachmentOptimal
                        },
                        initialized: AtomicBool::new(false),
                        gpu_lock: AtomicUsize::new(0),
                    }))
    }
// All constructors dispatch to this one.
All constructors dispatch to this one.
All constructors dispatch to this one .
fn new_impl(device: Arc<Device>, dimensions: [u32; 2], format: F, base_usage: ImageUsage,
                samples: u32)
                -> Result<Arc<AttachmentImage<F>>, ImageCreationError>
        where F: FormatDesc
    {
        // TODO: check dimensions against the max_framebuffer_width/height/layers limits
        let is_depth = match format.format().ty() {
            FormatTy::Depth => true,
            FormatTy::DepthStencil => true,
            FormatTy::Stencil => true,
            FormatTy::Compressed => panic!(),
            _ => false,
        };
        let usage = ImageUsage {
            color_attachment: !is_depth,
            depth_stencil_attachment: is_depth,
            ..base_usage
        };
        let (image, mem_reqs) = unsafe {
            let dims = ImageDimensions::Dim2d {
                width: dimensions[0],
                height: dimensions[1],
                array_layers: 1,
                cubemap_compatible: false,
            };
            UnsafeImage::new(device.clone(),
                             usage,
                             format.format(),
                             dims,
                             samples,
                             1,
                             Sharing::Exclusive::<Empty<u32>>,
                             false,
                             false)?
        };
        let mem = MemoryPool::alloc_from_requirements(&Device::standard_pool(&device),
                                    &mem_reqs,
                                    AllocLayout::Optimal,
                                    MappingRequirement::DoNotMap,
                                    DedicatedAlloc::Image(&image),
                                    |t| if t.is_device_local() {
                                        AllocFromRequirementsFilter::Preferred
                                    } else {
                                        AllocFromRequirementsFilter::Allowed
                                    })?;
        debug_assert!((mem.offset() % mem_reqs.alignment) == 0);
        unsafe {
            image.bind_memory(mem.memory(), mem.offset())?;
        }
        let view = unsafe { UnsafeImageView::raw(&image, ViewType::Dim2d, 0 .. 1, 0 .. 1)? };
        Ok(Arc::new(AttachmentImage {
                        image: image,
                        view: view,
                        memory: mem,
                        format: format,
                        attachment_layout: if is_depth {
                            ImageLayout::DepthStencilAttachmentOptimal
                        } else {
                            ImageLayout::ColorAttachmentOptimal
                        },
                        initialized: AtomicBool::new(false),
                        gpu_lock: AtomicUsize::new(0),
                    }))
    }
fn new_impl ( device : Arc < Device > , dimensions : [ u32 ; 2 ] , format : F , base_usage : ImageUsage , samples : u32 ) -> Result < Arc < AttachmentImage < F > > , ImageCreationError > where F : FormatDesc { // TODO: check dimensions against the max_framebuffer_width/height/layers limits let is_depth = match format . format ( ) . ty ( ) { FormatTy :: Depth => true , FormatTy :: DepthStencil => true , FormatTy :: Stencil => true , FormatTy :: Compressed => panic ! ( ) , _ => false , } ; let usage = ImageUsage { color_attachment : ! is_depth , depth_stencil_attachment : is_depth , .. base_usage } ; let ( image , mem_reqs ) = unsafe { let dims = ImageDimensions :: Dim2d { width : dimensions [ 0 ] , height : dimensions [ 1 ] , array_layers : 1 , cubemap_compatible : false , } ; UnsafeImage :: new ( device . clone ( ) , usage , format . format ( ) , dims , samples , 1 , Sharing :: Exclusive :: < Empty < u32 > > , false , false ) ? } ; let mem = MemoryPool :: alloc_from_requirements ( & Device :: standard_pool ( & device ) , & mem_reqs , AllocLayout :: Optimal , MappingRequirement :: DoNotMap , DedicatedAlloc :: Image ( & image ) , | t | if t . is_device_local ( ) { AllocFromRequirementsFilter :: Preferred } else { AllocFromRequirementsFilter :: Allowed } ) ? ; debug_assert ! ( ( mem offset ( ) mem_reqs alignment ) 0 ) ; unsafe { image . bind_memory ( mem . memory ( ) , mem . offset ( ) ) ? ; } let view = unsafe { UnsafeImageView :: raw ( & image , ViewType :: Dim2d , 0 .. 1 , 0 .. 1 ) ? } ; Ok ( Arc :: new ( AttachmentImage { image : image , view : view , memory : mem , format : format , attachment_layout : if is_depth { ImageLayout :: DepthStencilAttachmentOptimal } else { ImageLayout :: ColorAttachmentOptimal } , initialized : AtomicBool :: new ( false ) , gpu_lock : AtomicUsize :: new ( 0 ) , } ) ) }
All constructors dispatch to this one.
All constructors dispatch to this one .
device
Arc<Device>
dimensions
[u32; 2]
format
F
base_usage
ImageUsage
samples
u32
device
Arc<Device>
dimensions
[u32; 2]
format
F
base_usage
ImageUsage
samples
u32