[]Trait amethyst_rendy::rendy::hal::Device

pub trait Device<B>: Send + Sync + Any + Debug where
    B: Backend
{ unsafe fn allocate_memory(
        &self,
        memory_type: MemoryTypeId,
        size: u64
    ) -> Result<<B as Backend>::Memory, AllocationError>;
unsafe fn free_memory(&self, memory: <B as Backend>::Memory);
unsafe fn create_command_pool(
        &self,
        family: QueueFamilyId,
        create_flags: CommandPoolCreateFlags
    ) -> Result<<B as Backend>::CommandPool, OutOfMemory>;
unsafe fn destroy_command_pool(&self, pool: <B as Backend>::CommandPool);
unsafe fn create_render_pass<'a, IA, IS, ID>(
        &self,
        attachments: IA,
        subpasses: IS,
        dependencies: ID
    ) -> Result<<B as Backend>::RenderPass, OutOfMemory>
    where
        IA: IntoIterator,
        ID: IntoIterator,
        IS: IntoIterator,
        <IA as IntoIterator>::Item: Borrow<Attachment>,
        <IS as IntoIterator>::Item: Borrow<SubpassDesc<'a>>,
        <ID as IntoIterator>::Item: Borrow<SubpassDependency>
;
unsafe fn destroy_render_pass(&self, rp: <B as Backend>::RenderPass);
unsafe fn create_pipeline_layout<IS, IR>(
        &self,
        set_layouts: IS,
        push_constant: IR
    ) -> Result<<B as Backend>::PipelineLayout, OutOfMemory>
    where
        IR: IntoIterator,
        IS: IntoIterator,
        <IS as IntoIterator>::Item: Borrow<<B as Backend>::DescriptorSetLayout>,
        <IR as IntoIterator>::Item: Borrow<(ShaderStageFlags, Range<u32>)>
;
unsafe fn destroy_pipeline_layout(
        &self,
        layout: <B as Backend>::PipelineLayout
    );
unsafe fn create_pipeline_cache(
        &self,
        data: Option<&[u8]>
    ) -> Result<<B as Backend>::PipelineCache, OutOfMemory>;
unsafe fn get_pipeline_cache_data(
        &self,
        cache: &<B as Backend>::PipelineCache
    ) -> Result<Vec<u8>, OutOfMemory>;
unsafe fn merge_pipeline_caches<I>(
        &self,
        target: &<B as Backend>::PipelineCache,
        sources: I
    ) -> Result<(), OutOfMemory>
    where
        I: IntoIterator,
        <I as IntoIterator>::Item: Borrow<<B as Backend>::PipelineCache>
;
unsafe fn destroy_pipeline_cache(
        &self,
        cache: <B as Backend>::PipelineCache
    );
unsafe fn destroy_graphics_pipeline(
        &self,
        pipeline: <B as Backend>::GraphicsPipeline
    );
unsafe fn destroy_compute_pipeline(
        &self,
        pipeline: <B as Backend>::ComputePipeline
    );
unsafe fn create_framebuffer<I>(
        &self,
        pass: &<B as Backend>::RenderPass,
        attachments: I,
        extent: Extent
    ) -> Result<<B as Backend>::Framebuffer, OutOfMemory>
    where
        I: IntoIterator,
        <I as IntoIterator>::Item: Borrow<<B as Backend>::ImageView>
;
unsafe fn destroy_framebuffer(&self, buf: <B as Backend>::Framebuffer);
unsafe fn create_shader_module(
        &self,
        spirv_data: &[u32]
    ) -> Result<<B as Backend>::ShaderModule, ShaderError>;
unsafe fn destroy_shader_module(&self, shader: <B as Backend>::ShaderModule);
unsafe fn create_buffer(
        &self,
        size: u64,
        usage: Usage
    ) -> Result<<B as Backend>::Buffer, CreationError>;
unsafe fn get_buffer_requirements(
        &self,
        buf: &<B as Backend>::Buffer
    ) -> Requirements;
unsafe fn bind_buffer_memory(
        &self,
        memory: &<B as Backend>::Memory,
        offset: u64,
        buf: &mut <B as Backend>::Buffer
    ) -> Result<(), BindError>;
unsafe fn destroy_buffer(&self, buffer: <B as Backend>::Buffer);
unsafe fn create_buffer_view<R>(
        &self,
        buf: &<B as Backend>::Buffer,
        fmt: Option<Format>,
        range: R
    ) -> Result<<B as Backend>::BufferView, ViewCreationError>
    where
        R: RangeArg<u64>
;
unsafe fn destroy_buffer_view(&self, view: <B as Backend>::BufferView);
unsafe fn create_image(
        &self,
        kind: Kind,
        mip_levels: u8,
        format: Format,
        tiling: Tiling,
        usage: Usage,
        view_caps: ViewCapabilities
    ) -> Result<<B as Backend>::Image, CreationError>;
unsafe fn get_image_requirements(
        &self,
        image: &<B as Backend>::Image
    ) -> Requirements;
unsafe fn get_image_subresource_footprint(
        &self,
        image: &<B as Backend>::Image,
        subresource: Subresource
    ) -> SubresourceFootprint;
unsafe fn bind_image_memory(
        &self,
        memory: &<B as Backend>::Memory,
        offset: u64,
        image: &mut <B as Backend>::Image
    ) -> Result<(), BindError>;
unsafe fn destroy_image(&self, image: <B as Backend>::Image);
unsafe fn create_image_view(
        &self,
        image: &<B as Backend>::Image,
        view_kind: ViewKind,
        format: Format,
        swizzle: Swizzle,
        range: SubresourceRange
    ) -> Result<<B as Backend>::ImageView, ViewError>;
unsafe fn destroy_image_view(&self, view: <B as Backend>::ImageView);
unsafe fn create_sampler(
        &self,
        info: SamplerInfo
    ) -> Result<<B as Backend>::Sampler, AllocationError>;
unsafe fn destroy_sampler(&self, sampler: <B as Backend>::Sampler);
unsafe fn create_descriptor_pool<I>(
        &self,
        max_sets: usize,
        descriptor_ranges: I,
        flags: DescriptorPoolCreateFlags
    ) -> Result<<B as Backend>::DescriptorPool, OutOfMemory>
    where
        I: IntoIterator,
        <I as IntoIterator>::Item: Borrow<DescriptorRangeDesc>
;
unsafe fn destroy_descriptor_pool(
        &self,
        pool: <B as Backend>::DescriptorPool
    );
unsafe fn create_descriptor_set_layout<I, J>(
        &self,
        bindings: I,
        immutable_samplers: J
    ) -> Result<<B as Backend>::DescriptorSetLayout, OutOfMemory>
    where
        I: IntoIterator,
        J: IntoIterator,
        <I as IntoIterator>::Item: Borrow<DescriptorSetLayoutBinding>,
        <J as IntoIterator>::Item: Borrow<<B as Backend>::Sampler>
;
unsafe fn destroy_descriptor_set_layout(
        &self,
        layout: <B as Backend>::DescriptorSetLayout
    );
unsafe fn write_descriptor_sets<'a, I, J>(&self, write_iter: I)
    where
        I: IntoIterator<Item = DescriptorSetWrite<'a, B, J>>,
        J: IntoIterator,
        <J as IntoIterator>::Item: Borrow<Descriptor<'a, B>>
;
unsafe fn copy_descriptor_sets<'a, I>(&self, copy_iter: I)
    where
        I: IntoIterator,
        <I as IntoIterator>::Item: Borrow<DescriptorSetCopy<'a, B>>
;
unsafe fn map_memory<R>(
        &self,
        memory: &<B as Backend>::Memory,
        range: R
    ) -> Result<*mut u8, Error>
    where
        R: RangeArg<u64>
;
unsafe fn flush_mapped_memory_ranges<'a, I, R>(
        &self,
        ranges: I
    ) -> Result<(), OutOfMemory>
    where
        I: IntoIterator,
        R: RangeArg<u64>,
        <I as IntoIterator>::Item: Borrow<(&'a <B as Backend>::Memory, R)>
;
unsafe fn invalidate_mapped_memory_ranges<'a, I, R>(
        &self,
        ranges: I
    ) -> Result<(), OutOfMemory>
    where
        I: IntoIterator,
        R: RangeArg<u64>,
        <I as IntoIterator>::Item: Borrow<(&'a <B as Backend>::Memory, R)>
;
unsafe fn unmap_memory(&self, memory: &<B as Backend>::Memory);
fn create_semaphore(&self) -> Result<<B as Backend>::Semaphore, OutOfMemory>;
unsafe fn destroy_semaphore(&self, semaphore: <B as Backend>::Semaphore);
fn create_fence(
        &self,
        signaled: bool
    ) -> Result<<B as Backend>::Fence, OutOfMemory>;
unsafe fn get_fence_status(
        &self,
        fence: &<B as Backend>::Fence
    ) -> Result<bool, DeviceLost>;
unsafe fn destroy_fence(&self, fence: <B as Backend>::Fence);
fn create_event(&self) -> Result<<B as Backend>::Event, OutOfMemory>;
unsafe fn destroy_event(&self, event: <B as Backend>::Event);
unsafe fn get_event_status(
        &self,
        event: &<B as Backend>::Event
    ) -> Result<bool, OomOrDeviceLost>;
unsafe fn set_event(
        &self,
        event: &<B as Backend>::Event
    ) -> Result<(), OutOfMemory>;
unsafe fn reset_event(
        &self,
        event: &<B as Backend>::Event
    ) -> Result<(), OutOfMemory>;
unsafe fn create_query_pool(
        &self,
        ty: Type,
        count: u32
    ) -> Result<<B as Backend>::QueryPool, CreationError>;
unsafe fn destroy_query_pool(&self, pool: <B as Backend>::QueryPool);
unsafe fn get_query_pool_results(
        &self,
        pool: &<B as Backend>::QueryPool,
        queries: Range<u32>,
        data: &mut [u8],
        stride: u64,
        flags: ResultFlags
    ) -> Result<bool, OomOrDeviceLost>;
unsafe fn create_swapchain(
        &self,
        surface: &mut <B as Backend>::Surface,
        config: SwapchainConfig,
        old_swapchain: Option<<B as Backend>::Swapchain>
    ) -> Result<(<B as Backend>::Swapchain, Vec<<B as Backend>::Image>), CreationError>;
unsafe fn destroy_swapchain(&self, swapchain: <B as Backend>::Swapchain);
fn wait_idle(&self) -> Result<(), HostExecutionError>; unsafe fn create_command_pool_typed<C>(
        &self,
        group: &QueueGroup<B, C>,
        flags: CommandPoolCreateFlags
    ) -> Result<CommandPool<B, C>, OutOfMemory> { ... }
unsafe fn create_graphics_pipeline(
        &self,
        desc: &GraphicsPipelineDesc<'a, B>,
        cache: Option<&<B as Backend>::PipelineCache>
    ) -> Result<<B as Backend>::GraphicsPipeline, CreationError> { ... }
unsafe fn create_graphics_pipelines<'a, I>(
        &self,
        descs: I,
        cache: Option<&<B as Backend>::PipelineCache>
    ) -> Vec<Result<<B as Backend>::GraphicsPipeline, CreationError>>
    where
        I: IntoIterator,
        <I as IntoIterator>::Item: Borrow<GraphicsPipelineDesc<'a, B>>
, { ... }
unsafe fn create_compute_pipeline(
        &self,
        desc: &ComputePipelineDesc<'a, B>,
        cache: Option<&<B as Backend>::PipelineCache>
    ) -> Result<<B as Backend>::ComputePipeline, CreationError> { ... }
unsafe fn create_compute_pipelines<'a, I>(
        &self,
        descs: I,
        cache: Option<&<B as Backend>::PipelineCache>
    ) -> Vec<Result<<B as Backend>::ComputePipeline, CreationError>>
    where
        I: IntoIterator,
        <I as IntoIterator>::Item: Borrow<ComputePipelineDesc<'a, B>>
, { ... }
unsafe fn acquire_mapping_reader<T>(
        &self,
        memory: &'a <B as Backend>::Memory,
        range: Range<u64>
    ) -> Result<Reader<'a, B, T>, Error>
    where
        T: Copy
, { ... }
unsafe fn release_mapping_reader<T>(&self, reader: Reader<'a, B, T>) { ... }
unsafe fn acquire_mapping_writer<T>(
        &self,
        memory: &'a <B as Backend>::Memory,
        range: Range<u64>
    ) -> Result<Writer<'a, B, T>, Error>
    where
        T: Copy
, { ... }
unsafe fn release_mapping_writer<T>(
        &self,
        writer: Writer<'a, B, T>
    ) -> Result<(), OutOfMemory> { ... }
unsafe fn reset_fence(
        &self,
        fence: &<B as Backend>::Fence
    ) -> Result<(), OutOfMemory> { ... }
unsafe fn reset_fences<I>(&self, fences: I) -> Result<(), OutOfMemory>
    where
        I: IntoIterator,
        <I as IntoIterator>::Item: Borrow<<B as Backend>::Fence>
, { ... }
unsafe fn wait_for_fence(
        &self,
        fence: &<B as Backend>::Fence,
        timeout_ns: u64
    ) -> Result<bool, OomOrDeviceLost> { ... }
unsafe fn wait_for_fences<I>(
        &self,
        fences: I,
        wait: WaitFor,
        timeout_ns: u64
    ) -> Result<bool, OomOrDeviceLost>
    where
        I: IntoIterator,
        <I as IntoIterator>::Item: Borrow<<B as Backend>::Fence>
, { ... } }

Overview

A Device is responsible for creating and managing resources for the physical device it was created from.

Resource Construction and Handling

This device structure can then be used to create and manage different resources, like buffers, shader programs and textures. See the individual methods for more information.

Mutability

All the methods get &self. Any internal mutability of the Device is hidden from the user.

Synchronization

Device should be usable concurrently from multiple threads. The Send and Sync bounds are not enforced at the HAL level due to OpenGL constraint (to be revised). Users can still benefit from the backends that support synchronization of the Device.

Required methods

unsafe fn allocate_memory(
    &self,
    memory_type: MemoryTypeId,
    size: u64
) -> Result<<B as Backend>::Memory, AllocationError>

Allocates a memory segment of a specified type.

There is only a limited amount of allocations allowed depending on the implementation!

Arguments

  • memory_type - Index of the memory type in the memory properties of the associated physical device.
  • size - Size of the allocation.

unsafe fn free_memory(&self, memory: <B as Backend>::Memory)

Free device memory

unsafe fn create_command_pool(
    &self,
    family: QueueFamilyId,
    create_flags: CommandPoolCreateFlags
) -> Result<<B as Backend>::CommandPool, OutOfMemory>

Create a new command pool for a given queue family.

Note: the family has to be associated by one as the Gpu::queue_groups.

unsafe fn destroy_command_pool(&self, pool: <B as Backend>::CommandPool)

Destroy a command pool.

unsafe fn create_render_pass<'a, IA, IS, ID>(
    &self,
    attachments: IA,
    subpasses: IS,
    dependencies: ID
) -> Result<<B as Backend>::RenderPass, OutOfMemory> where
    IA: IntoIterator,
    ID: IntoIterator,
    IS: IntoIterator,
    <IA as IntoIterator>::Item: Borrow<Attachment>,
    <IS as IntoIterator>::Item: Borrow<SubpassDesc<'a>>,
    <ID as IntoIterator>::Item: Borrow<SubpassDependency>, 

Create a render pass with the given attachments and subpasses.

A render pass represents a collection of attachments, subpasses, and dependencies between the subpasses, and describes how the attachments are used over the course of the subpasses. The use of a render pass in a command buffer is a render pass instance.

unsafe fn destroy_render_pass(&self, rp: <B as Backend>::RenderPass)

Destroy a RenderPass.

unsafe fn create_pipeline_layout<IS, IR>(
    &self,
    set_layouts: IS,
    push_constant: IR
) -> Result<<B as Backend>::PipelineLayout, OutOfMemory> where
    IR: IntoIterator,
    IS: IntoIterator,
    <IS as IntoIterator>::Item: Borrow<<B as Backend>::DescriptorSetLayout>,
    <IR as IntoIterator>::Item: Borrow<(ShaderStageFlags, Range<u32>)>, 

Create a new pipeline layout object.

Arguments

  • set_layouts - Descriptor set layouts
  • push_constants - Ranges of push constants. A shader stage may only contain one push constant block. The length of the range indicates the number of u32 constants occupied by the push constant block.

PipelineLayout

Access to descriptor sets from a pipeline is accomplished through a pipeline layout. Zero or more descriptor set layouts and zero or more push constant ranges are combined to form a pipeline layout object which describes the complete set of resources that can be accessed by a pipeline. The pipeline layout represents a sequence of descriptor sets with each having a specific layout. This sequence of layouts is used to determine the interface between shader stages and shader resources. Each pipeline is created using a pipeline layout.

unsafe fn destroy_pipeline_layout(&self, layout: <B as Backend>::PipelineLayout)

Destroy a pipeline layout object

unsafe fn create_pipeline_cache(
    &self,
    data: Option<&[u8]>
) -> Result<<B as Backend>::PipelineCache, OutOfMemory>

Create a pipeline cache object.

unsafe fn get_pipeline_cache_data(
    &self,
    cache: &<B as Backend>::PipelineCache
) -> Result<Vec<u8>, OutOfMemory>

Retrieve data from pipeline cache object.

unsafe fn merge_pipeline_caches<I>(
    &self,
    target: &<B as Backend>::PipelineCache,
    sources: I
) -> Result<(), OutOfMemory> where
    I: IntoIterator,
    <I as IntoIterator>::Item: Borrow<<B as Backend>::PipelineCache>, 

Merge a number of source pipeline caches into the target one.

unsafe fn destroy_pipeline_cache(&self, cache: <B as Backend>::PipelineCache)

Destroy a pipeline cache object.

unsafe fn destroy_graphics_pipeline(
    &self,
    pipeline: <B as Backend>::GraphicsPipeline
)

Destroy a graphics pipeline.

The graphics pipeline shouldn't be destroyed before any submitted command buffer, which references the graphics pipeline, has finished execution.

unsafe fn destroy_compute_pipeline(
    &self,
    pipeline: <B as Backend>::ComputePipeline
)

Destroy a compute pipeline.

The compute pipeline shouldn't be destroyed before any submitted command buffer, which references the compute pipeline, has finished execution.

unsafe fn create_framebuffer<I>(
    &self,
    pass: &<B as Backend>::RenderPass,
    attachments: I,
    extent: Extent
) -> Result<<B as Backend>::Framebuffer, OutOfMemory> where
    I: IntoIterator,
    <I as IntoIterator>::Item: Borrow<<B as Backend>::ImageView>, 

Create a new framebuffer object.

Safety

  • extent.width, extent.height and extent.depth must be greater than 0.

unsafe fn destroy_framebuffer(&self, buf: <B as Backend>::Framebuffer)

Destroy a framebuffer.

The framebuffer shouldn't be destroy before any submitted command buffer, which references the framebuffer, has finished execution.

unsafe fn create_shader_module(
    &self,
    spirv_data: &[u32]
) -> Result<<B as Backend>::ShaderModule, ShaderError>

Create a new shader module object through the SPIR-V binary data.

Once a shader module has been created, any entry points it contains can be used in pipeline shader stages as described in Compute Pipelines and Graphics Pipelines.

unsafe fn destroy_shader_module(&self, shader: <B as Backend>::ShaderModule)

Destroy a shader module module

A shader module can be destroyed while pipelines created using its shaders are still in use.

unsafe fn create_buffer(
    &self,
    size: u64,
    usage: Usage
) -> Result<<B as Backend>::Buffer, CreationError>

Create a new buffer (unbound).

The created buffer won't have associated memory until bind_buffer_memory is called.

unsafe fn get_buffer_requirements(
    &self,
    buf: &<B as Backend>::Buffer
) -> Requirements

Get memory requirements for the buffer

unsafe fn bind_buffer_memory(
    &self,
    memory: &<B as Backend>::Memory,
    offset: u64,
    buf: &mut <B as Backend>::Buffer
) -> Result<(), BindError>

Bind memory to a buffer.

Be sure to check that there is enough memory available for the buffer. Use get_buffer_requirements to acquire the memory requirements.

unsafe fn destroy_buffer(&self, buffer: <B as Backend>::Buffer)

Destroy a buffer.

The buffer shouldn't be destroyed before any submitted command buffer, which references the images, has finished execution.

unsafe fn create_buffer_view<R>(
    &self,
    buf: &<B as Backend>::Buffer,
    fmt: Option<Format>,
    range: R
) -> Result<<B as Backend>::BufferView, ViewCreationError> where
    R: RangeArg<u64>, 

Create a new buffer view object

unsafe fn destroy_buffer_view(&self, view: <B as Backend>::BufferView)

Destroy a buffer view object

unsafe fn create_image(
    &self,
    kind: Kind,
    mip_levels: u8,
    format: Format,
    tiling: Tiling,
    usage: Usage,
    view_caps: ViewCapabilities
) -> Result<<B as Backend>::Image, CreationError>

Create a new image object

unsafe fn get_image_requirements(
    &self,
    image: &<B as Backend>::Image
) -> Requirements

Get memory requirements for the Image

unsafe fn get_image_subresource_footprint(
    &self,
    image: &<B as Backend>::Image,
    subresource: Subresource
) -> SubresourceFootprint

unsafe fn bind_image_memory(
    &self,
    memory: &<B as Backend>::Memory,
    offset: u64,
    image: &mut <B as Backend>::Image
) -> Result<(), BindError>

Bind device memory to an image object

unsafe fn destroy_image(&self, image: <B as Backend>::Image)

Destroy an image.

The image shouldn't be destroyed before any submitted command buffer, which references the images, has finished execution.

unsafe fn create_image_view(
    &self,
    image: &<B as Backend>::Image,
    view_kind: ViewKind,
    format: Format,
    swizzle: Swizzle,
    range: SubresourceRange
) -> Result<<B as Backend>::ImageView, ViewError>

Create an image view from an existing image

unsafe fn destroy_image_view(&self, view: <B as Backend>::ImageView)

Destroy an image view object

unsafe fn create_sampler(
    &self,
    info: SamplerInfo
) -> Result<<B as Backend>::Sampler, AllocationError>

Create a new sampler object

unsafe fn destroy_sampler(&self, sampler: <B as Backend>::Sampler)

Destroy a sampler object

unsafe fn create_descriptor_pool<I>(
    &self,
    max_sets: usize,
    descriptor_ranges: I,
    flags: DescriptorPoolCreateFlags
) -> Result<<B as Backend>::DescriptorPool, OutOfMemory> where
    I: IntoIterator,
    <I as IntoIterator>::Item: Borrow<DescriptorRangeDesc>, 

Create a descriptor pool.

Descriptor pools allow allocation of descriptor sets. The pool can't be modified directly, only through updating descriptor sets.

unsafe fn destroy_descriptor_pool(&self, pool: <B as Backend>::DescriptorPool)

Destroy a descriptor pool object

When a pool is destroyed, all descriptor sets allocated from the pool are implicitly freed and become invalid. Descriptor sets allocated from a given pool do not need to be freed before destroying that descriptor pool.

unsafe fn create_descriptor_set_layout<I, J>(
    &self,
    bindings: I,
    immutable_samplers: J
) -> Result<<B as Backend>::DescriptorSetLayout, OutOfMemory> where
    I: IntoIterator,
    J: IntoIterator,
    <I as IntoIterator>::Item: Borrow<DescriptorSetLayoutBinding>,
    <J as IntoIterator>::Item: Borrow<<B as Backend>::Sampler>, 

Create a descriptor set layout.

A descriptor set layout object is defined by an array of zero or more descriptor bindings. Each individual descriptor binding is specified by a descriptor type, a count (array size) of the number of descriptors in the binding, a set of shader stages that can access the binding, and (if using immutable samplers) an array of sampler descriptors.

unsafe fn destroy_descriptor_set_layout(
    &self,
    layout: <B as Backend>::DescriptorSetLayout
)

Destroy a descriptor set layout object

unsafe fn write_descriptor_sets<'a, I, J>(&self, write_iter: I) where
    I: IntoIterator<Item = DescriptorSetWrite<'a, B, J>>,
    J: IntoIterator,
    <J as IntoIterator>::Item: Borrow<Descriptor<'a, B>>, 

Specifying the parameters of a descriptor set write operation

unsafe fn copy_descriptor_sets<'a, I>(&self, copy_iter: I) where
    I: IntoIterator,
    <I as IntoIterator>::Item: Borrow<DescriptorSetCopy<'a, B>>, 

Structure specifying a copy descriptor set operation

unsafe fn map_memory<R>(
    &self,
    memory: &<B as Backend>::Memory,
    range: R
) -> Result<*mut u8, Error> where
    R: RangeArg<u64>, 

Map a memory object into application address space

Call map_memory() to retrieve a host virtual address pointer to a region of a mappable memory object

unsafe fn flush_mapped_memory_ranges<'a, I, R>(
    &self,
    ranges: I
) -> Result<(), OutOfMemory> where
    I: IntoIterator,
    R: RangeArg<u64>,
    <I as IntoIterator>::Item: Borrow<(&'a <B as Backend>::Memory, R)>, 

Flush mapped memory ranges

unsafe fn invalidate_mapped_memory_ranges<'a, I, R>(
    &self,
    ranges: I
) -> Result<(), OutOfMemory> where
    I: IntoIterator,
    R: RangeArg<u64>,
    <I as IntoIterator>::Item: Borrow<(&'a <B as Backend>::Memory, R)>, 

Invalidate ranges of non-coherent memory from the host caches

unsafe fn unmap_memory(&self, memory: &<B as Backend>::Memory)

Unmap a memory object once host access to it is no longer needed by the application

fn create_semaphore(&self) -> Result<<B as Backend>::Semaphore, OutOfMemory>

Create a new semaphore object

unsafe fn destroy_semaphore(&self, semaphore: <B as Backend>::Semaphore)

Destroy a semaphore object

fn create_fence(
    &self,
    signaled: bool
) -> Result<<B as Backend>::Fence, OutOfMemory>

Create a new fence object

Fences are a synchronization primitive that can be used to insert a dependency from a queue to the host. Fences have two states - signaled and unsignaled. A fence can be signaled as part of the execution of a queue submission command. Fences can be unsignaled on the host with reset_fences. Fences can be waited on by the host with the wait_for_fences command, and the current state can be queried with get_fence_status.

unsafe fn get_fence_status(
    &self,
    fence: &<B as Backend>::Fence
) -> Result<bool, DeviceLost>

true for signaled, false for not ready

unsafe fn destroy_fence(&self, fence: <B as Backend>::Fence)

Destroy a fence object

fn create_event(&self) -> Result<<B as Backend>::Event, OutOfMemory>

Create an event object.

unsafe fn destroy_event(&self, event: <B as Backend>::Event)

Destroy an event object.

unsafe fn get_event_status(
    &self,
    event: &<B as Backend>::Event
) -> Result<bool, OomOrDeviceLost>

Query the status of an event.

Returns true if the event is set, or false if it is reset.

unsafe fn set_event(
    &self,
    event: &<B as Backend>::Event
) -> Result<(), OutOfMemory>

Sets an event.

unsafe fn reset_event(
    &self,
    event: &<B as Backend>::Event
) -> Result<(), OutOfMemory>

Resets an event.

unsafe fn create_query_pool(
    &self,
    ty: Type,
    count: u32
) -> Result<<B as Backend>::QueryPool, CreationError>

Create a new query pool object

Queries are managed using query pool objects. Each query pool is a collection of a specific number of queries of a particular type.

unsafe fn destroy_query_pool(&self, pool: <B as Backend>::QueryPool)

Destroy a query pool object

unsafe fn get_query_pool_results(
    &self,
    pool: &<B as Backend>::QueryPool,
    queries: Range<u32>,
    data: &mut [u8],
    stride: u64,
    flags: ResultFlags
) -> Result<bool, OomOrDeviceLost>

Get query pool results into the specified CPU memory. Returns Ok(false) if the results are not ready yet and neither of WAIT or PARTIAL flags are set.

unsafe fn create_swapchain(
    &self,
    surface: &mut <B as Backend>::Surface,
    config: SwapchainConfig,
    old_swapchain: Option<<B as Backend>::Swapchain>
) -> Result<(<B as Backend>::Swapchain, Vec<<B as Backend>::Image>), CreationError>

Create a new swapchain from a surface and a queue family, optionally providing the old swapchain to aid in resource reuse and rendering continuity.

Note: The number of exposed images in the back buffer might differ from number of internally used buffers.

Safety

The queue family must support surface presentation. This can be checked by calling supports_queue_family on this surface.

Examples

use gfx_hal::{Device, SwapchainConfig};
use gfx_hal::format::Format;

let swapchain_config = SwapchainConfig::new(100, 100, Format::Rgba8Srgb, 2);
device.create_swapchain(&mut surface, swapchain_config, None);

unsafe fn destroy_swapchain(&self, swapchain: <B as Backend>::Swapchain)

fn wait_idle(&self) -> Result<(), HostExecutionError>

Wait for all queues associated with this device to idle.

Host access to all queues needs to be externally sycnhronized!

Loading content...

Provided methods

unsafe fn create_command_pool_typed<C>(
    &self,
    group: &QueueGroup<B, C>,
    flags: CommandPoolCreateFlags
) -> Result<CommandPool<B, C>, OutOfMemory>

Create a strongly typed command pool wrapper.

unsafe fn create_graphics_pipeline(
    &self,
    desc: &GraphicsPipelineDesc<'a, B>,
    cache: Option<&<B as Backend>::PipelineCache>
) -> Result<<B as Backend>::GraphicsPipeline, CreationError>

Create a graphics pipeline.

unsafe fn create_graphics_pipelines<'a, I>(
    &self,
    descs: I,
    cache: Option<&<B as Backend>::PipelineCache>
) -> Vec<Result<<B as Backend>::GraphicsPipeline, CreationError>> where
    I: IntoIterator,
    <I as IntoIterator>::Item: Borrow<GraphicsPipelineDesc<'a, B>>, 

Create graphics pipelines.

unsafe fn create_compute_pipeline(
    &self,
    desc: &ComputePipelineDesc<'a, B>,
    cache: Option<&<B as Backend>::PipelineCache>
) -> Result<<B as Backend>::ComputePipeline, CreationError>

Create a compute pipeline.

unsafe fn create_compute_pipelines<'a, I>(
    &self,
    descs: I,
    cache: Option<&<B as Backend>::PipelineCache>
) -> Vec<Result<<B as Backend>::ComputePipeline, CreationError>> where
    I: IntoIterator,
    <I as IntoIterator>::Item: Borrow<ComputePipelineDesc<'a, B>>, 

Create compute pipelines.

unsafe fn acquire_mapping_reader<T>(
    &self,
    memory: &'a <B as Backend>::Memory,
    range: Range<u64>
) -> Result<Reader<'a, B, T>, Error> where
    T: Copy

Acquire a mapping Reader.

The accessible slice will correspond to the specified range (in bytes).

unsafe fn release_mapping_reader<T>(&self, reader: Reader<'a, B, T>)

Release a mapping Reader.

unsafe fn acquire_mapping_writer<T>(
    &self,
    memory: &'a <B as Backend>::Memory,
    range: Range<u64>
) -> Result<Writer<'a, B, T>, Error> where
    T: Copy

Acquire a mapping Writer.

The accessible slice will correspond to the specified range (in bytes).

unsafe fn release_mapping_writer<T>(
    &self,
    writer: Writer<'a, B, T>
) -> Result<(), OutOfMemory>

Release a mapping Writer.

unsafe fn reset_fence(
    &self,
    fence: &<B as Backend>::Fence
) -> Result<(), OutOfMemory>

unsafe fn reset_fences<I>(&self, fences: I) -> Result<(), OutOfMemory> where
    I: IntoIterator,
    <I as IntoIterator>::Item: Borrow<<B as Backend>::Fence>, 

unsafe fn wait_for_fence(
    &self,
    fence: &<B as Backend>::Fence,
    timeout_ns: u64
) -> Result<bool, OomOrDeviceLost>

Blocks until the given fence is signaled. Returns true if the fence was signaled before the timeout.

unsafe fn wait_for_fences<I>(
    &self,
    fences: I,
    wait: WaitFor,
    timeout_ns: u64
) -> Result<bool, OomOrDeviceLost> where
    I: IntoIterator,
    <I as IntoIterator>::Item: Borrow<<B as Backend>::Fence>, 

Blocks until all or one of the given fences are signaled. Returns true if fences were signaled before the timeout.

Loading content...

Implementors

impl Device<Backend> for Device

Loading content...