pub fn create_collection(
        &self,
        image_create_info: &vk::ImageCreateInfo,
        pixel_format: fsysmem::PixelFormatType,
        modifiers: &[u64],
        tokens: BufferCollectionTokens,
        scenic_allocator: &fuicomp::AllocatorSynchronousProxy,
        sysmem_allocator: &fsysmem::AllocatorSynchronousProxy,
    ) -> Result<
        (fuicomp::BufferCollectionImportToken, fsysmem::BufferCollectionSynchronousProxy),
        vk::Result,
    > {
        let scenic_import_token =
            register_buffer_collection_with_scenic(tokens.scenic_token, scenic_allocator)?;

        let vk_ext = FuchsiaExtensionPointers::load(|name| unsafe {
            self.instance_pointers.GetDeviceProcAddr(self.device, name.as_ptr()) as *const _
        });

        let mut collection: BufferCollectionFUCHSIA = 0;
        let result = unsafe {
            vk_ext.CreateBufferCollectionFUCHSIAX(
                self.device,
                &BufferCollectionCreateInfoFUCHSIA {
                    sType: STRUCTURE_TYPE_BUFFER_COLLECTION_CREATE_INFO_FUCHSIA,
                    pNext: std::ptr::null(),
                    collectionToken: tokens.vulkan_token.as_handle_ref().raw_handle(),
                },
                std::ptr::null(),
                &mut collection as *mut BufferCollectionFUCHSIA,
            )
        };
        if result != vk::SUCCESS {
            return Err(result);
        }
        assert!(collection != 0);

        let mut image_constraints_info = ImageConstraintsInfoFUCHSIAX::default();
        image_constraints_info.createInfoCount = 1;
        image_constraints_info.pCreateInfos = image_create_info;
        image_constraints_info.minBufferCount = 1;
        image_constraints_info.maxBufferCount = 1;

        let result = unsafe {
            vk_ext.SetBufferCollectionImageConstraintsFUCHSIAX(
                self.device,
                collection,
                &mut image_constraints_info as *mut ImageConstraintsInfoFUCHSIAX,
            )
        };
        if result != vk::SUCCESS {
            return Err(result);
        }

        let (client, remote) =
            fidl::endpoints::create_endpoints::<fsysmem::BufferCollectionMarker>()
                .expect("Failed to create buffer collection endpoints.");

        sysmem_allocator
            .bind_shared_collection(tokens.buffer_token_proxy.into_channel().into(), remote)
            .map_err(|_| vk::ERROR_INITIALIZATION_FAILED)?;
        let buffer_collection =
            fsysmem::BufferCollectionSynchronousProxy::new(client.into_channel());

        let mut constraints = buffer_collection_constraints();
        constraints.image_format_constraints_count = modifiers.len() as u32;
        for (index, modifier) in modifiers.iter().enumerate() {
            let mut image_constraints = fsysmem::ImageFormatConstraints {
                min_coded_width: image_create_info.extent.width,
                min_coded_height: image_create_info.extent.height,
                max_coded_width: image_create_info.extent.width,
                max_coded_height: image_create_info.extent.height,
                min_bytes_per_row: 0,
                color_spaces_count: 1,
                ..IMAGE_FORMAT_CONSTRAINTS_DEFAULT
            };

            image_constraints.pixel_format.type_ = pixel_format;
            image_constraints.pixel_format.has_format_modifier = true;
            image_constraints.pixel_format.format_modifier.value = *modifier;
            image_constraints.color_space[0].type_ = fsysmem::ColorSpaceType::Srgb;

            constraints.image_format_constraints[index] = image_constraints;
        }

        buffer_collection
            .set_constraints(true, &mut constraints)
            .map_err(|_| vk::ERROR_INITIALIZATION_FAILED)?;

        Ok((scenic_import_token, buffer_collection))
    }
/// Creates a new `BufferCollection` and returns the image import endpoint for the collection,
/// as well as an active proxy to the collection.
///
/// Returns an error if creating the collection fails.
Creates a new `BufferCollection` and returns the image import endpoint for the collection,
as well as an active proxy to the collection.

Returns an error if creating the collection fails.
Creates a new ` BufferCollection ` and returns the image import endpoint for the collection as well as an active proxy to the collection . Returns an error if creating the collection fails .
pub fn create_collection(
        &self,
        image_create_info: &vk::ImageCreateInfo,
        pixel_format: fsysmem::PixelFormatType,
        modifiers: &[u64],
        tokens: BufferCollectionTokens,
        scenic_allocator: &fuicomp::AllocatorSynchronousProxy,
        sysmem_allocator: &fsysmem::AllocatorSynchronousProxy,
    ) -> Result<
        (fuicomp::BufferCollectionImportToken, fsysmem::BufferCollectionSynchronousProxy),
        vk::Result,
    > {
        let scenic_import_token =
            register_buffer_collection_with_scenic(tokens.scenic_token, scenic_allocator)?;
        let vk_ext = FuchsiaExtensionPointers::load(|name| unsafe {
            self.instance_pointers.GetDeviceProcAddr(self.device, name.as_ptr()) as *const _
        });
        let mut collection: BufferCollectionFUCHSIA = 0;
        let result = unsafe {
            vk_ext.CreateBufferCollectionFUCHSIAX(
                self.device,
                &BufferCollectionCreateInfoFUCHSIA {
                    sType: STRUCTURE_TYPE_BUFFER_COLLECTION_CREATE_INFO_FUCHSIA,
                    pNext: std::ptr::null(),
                    collectionToken: tokens.vulkan_token.as_handle_ref().raw_handle(),
                },
                std::ptr::null(),
                &mut collection as *mut BufferCollectionFUCHSIA,
            )
        };
        if result != vk::SUCCESS {
            return Err(result);
        }
        assert!(collection != 0);
        let mut image_constraints_info = ImageConstraintsInfoFUCHSIAX::default();
        image_constraints_info.createInfoCount = 1;
        image_constraints_info.pCreateInfos = image_create_info;
        image_constraints_info.minBufferCount = 1;
        image_constraints_info.maxBufferCount = 1;
        let result = unsafe {
            vk_ext.SetBufferCollectionImageConstraintsFUCHSIAX(
                self.device,
                collection,
                &mut image_constraints_info as *mut ImageConstraintsInfoFUCHSIAX,
            )
        };
        if result != vk::SUCCESS {
            return Err(result);
        }
        let (client, remote) =
            fidl::endpoints::create_endpoints::<fsysmem::BufferCollectionMarker>()
                .expect("Failed to create buffer collection endpoints.");
        sysmem_allocator
            .bind_shared_collection(tokens.buffer_token_proxy.into_channel().into(), remote)
            .map_err(|_| vk::ERROR_INITIALIZATION_FAILED)?;
        let buffer_collection =
            fsysmem::BufferCollectionSynchronousProxy::new(client.into_channel());
        let mut constraints = buffer_collection_constraints();
        constraints.image_format_constraints_count = modifiers.len() as u32;
        for (index, modifier) in modifiers.iter().enumerate() {
            let mut image_constraints = fsysmem::ImageFormatConstraints {
                min_coded_width: image_create_info.extent.width,
                min_coded_height: image_create_info.extent.height,
                max_coded_width: image_create_info.extent.width,
                max_coded_height: image_create_info.extent.height,
                min_bytes_per_row: 0,
                color_spaces_count: 1,
                ..IMAGE_FORMAT_CONSTRAINTS_DEFAULT
            };
            image_constraints.pixel_format.type_ = pixel_format;
            image_constraints.pixel_format.has_format_modifier = true;
            image_constraints.pixel_format.format_modifier.value = *modifier;
            image_constraints.color_space[0].type_ = fsysmem::ColorSpaceType::Srgb;
            constraints.image_format_constraints[index] = image_constraints;
        }
        buffer_collection
            .set_constraints(true, &mut constraints)
            .map_err(|_| vk::ERROR_INITIALIZATION_FAILED)?;
        Ok((scenic_import_token, buffer_collection))
    }
pub fn create_collection ( & self , image_create_info : & vk :: ImageCreateInfo , pixel_format : fsysmem :: PixelFormatType , modifiers : & [ u64 ] , tokens : BufferCollectionTokens , scenic_allocator : & fuicomp :: AllocatorSynchronousProxy , sysmem_allocator : & fsysmem :: AllocatorSynchronousProxy , ) -> Result < ( fuicomp :: BufferCollectionImportToken , fsysmem :: BufferCollectionSynchronousProxy ) , vk :: Result , > { let scenic_import_token = register_buffer_collection_with_scenic ( tokens . scenic_token , scenic_allocator ) ? ; let vk_ext = FuchsiaExtensionPointers :: load ( | name | unsafe { self . instance_pointers . GetDeviceProcAddr ( self . device , name . as_ptr ( ) ) as * const _ } ) ; let mut collection : BufferCollectionFUCHSIA = 0 ; let result = unsafe { vk_ext . CreateBufferCollectionFUCHSIAX ( self . device , & BufferCollectionCreateInfoFUCHSIA { sType : STRUCTURE_TYPE_BUFFER_COLLECTION_CREATE_INFO_FUCHSIA , pNext : std :: ptr :: null ( ) , collectionToken : tokens . vulkan_token . as_handle_ref ( ) . raw_handle ( ) , } , std :: ptr :: null ( ) , & mut collection as * mut BufferCollectionFUCHSIA , ) } ; if result != vk :: SUCCESS { return Err ( result ) ; } assert ! ( collection 0 ) ; let mut image_constraints_info = ImageConstraintsInfoFUCHSIAX :: default ( ) ; image_constraints_info . createInfoCount = 1 ; image_constraints_info . pCreateInfos = image_create_info ; image_constraints_info . minBufferCount = 1 ; image_constraints_info . maxBufferCount = 1 ; let result = unsafe { vk_ext . SetBufferCollectionImageConstraintsFUCHSIAX ( self . device , collection , & mut image_constraints_info as * mut ImageConstraintsInfoFUCHSIAX , ) } ; if result != vk :: SUCCESS { return Err ( result ) ; } let ( client , remote ) = fidl :: endpoints :: create_endpoints :: < fsysmem :: BufferCollectionMarker > ( ) . expect ( " " ) ; sysmem_allocator . bind_shared_collection ( tokens . buffer_token_proxy . into_channel ( ) . into ( ) , remote ) . map_err ( | _ | vk :: ERROR_INITIALIZATION_FAILED ) ? ; let buffer_collection = fsysmem :: BufferCollectionSynchronousProxy :: new ( client . into_channel ( ) ) ; let mut constraints = buffer_collection_constraints ( ) ; constraints . image_format_constraints_count = modifiers . len ( ) as u32 ; for ( index , modifier ) in modifiers . iter ( ) . enumerate ( ) { let mut image_constraints = fsysmem :: ImageFormatConstraints { min_coded_width : image_create_info . extent . width , min_coded_height : image_create_info . extent . height , max_coded_width : image_create_info . extent . width , max_coded_height : image_create_info . extent . height , min_bytes_per_row : 0 , color_spaces_count : 1 , .. IMAGE_FORMAT_CONSTRAINTS_DEFAULT } ; image_constraints . pixel_format . type_ = pixel_format ; image_constraints . pixel_format . has_format_modifier = true ; image_constraints . pixel_format . format_modifier . value = * modifier ; image_constraints . color_space [ 0 ] . type_ = fsysmem :: ColorSpaceType :: Srgb ; constraints . image_format_constraints [ index ] = image_constraints ; } buffer_collection . set_constraints ( true , & mut constraints ) . map_err ( | _ | vk :: ERROR_INITIALIZATION_FAILED ) ? ; Ok ( ( scenic_import_token , buffer_collection ) ) }
Creates a new `BufferCollection` and returns the image import endpoint for the collection,
as well as an active proxy to the collection.
Creates a new ` BufferCollection ` and returns the image import endpoint for the collection as well as an active proxy to the collection .
&self
image_create_info
&vk::ImageCreateInfo
pixel_format
fsysmem::PixelFormatType
modifiers
&[u64]
tokens
BufferCollectionTokens
scenic_allocator
&fuicomp::AllocatorSynchronousProxy
sysmem_allocator
&fsysmem::AllocatorSynchronousProxy
&self
image_create_info
&vk::ImageCreateInfo
pixel_format
fsysmem::PixelFormatType
modifiers
&[u64]
tokens
BufferCollectionTokens
scenic_allocator
&fuicomp::AllocatorSynchronousProxy
sysmem_allocator
&fsysmem::AllocatorSynchronousProxy