[][src]Struct grr::Device

pub struct Device(_, _);

Logical device, representation one or multiple physical devices (hardware or software).

This wraps an existing GL context and acts as the main API interface. It's the responsibility of the user to keep the context alive.

Implementations

impl Device[src]

pub unsafe fn create_buffer(
    &self,
    size: u64,
    memory: MemoryFlags
) -> Result<Buffer>
[src]

Create a new empty buffer.

Parameters

  • size: Length in bytes of the associated storage memory.
  • memory: Properties of the internal memory slice. Indicating the usage and locality of the allocation.

pub unsafe fn create_buffer_from_host(
    &self,
    data: &[u8],
    memory: MemoryFlags
) -> Result<Buffer>
[src]

Create a new buffer from host memory data.

Parameters

  • data: Host data, which will copied into the buffer on creation.
  • memory: Properties of the internal memory slice. Indicating the usage and locality of the allocation.

pub unsafe fn map_buffer<T>(
    &self,
    buffer: Buffer,
    range: Range<u64>,
    mapping: MappingFlags
) -> &mut [T]
[src]

Persistently map memory to host accessible virtual memory.

Valid usage

  • range.end may not be larger than the size of the buffer.
  • range.start must be smaller than range.end
  • buffer must be created with CPU_MAP_READ or CPU_MAP_WRITE flags.
  • range.end - range.start must be a multiple of the size of T
  • If the buffer has not been created with CPU_MAP_READ the host should not read from the returned slice.
  • If the buffer has not been created with CPU_MAP_WRITE the host should not write to the returned slice.
  • A buffer can not be mapped multiple times.

Return

Returns a typed slice of the mapped memory range.

pub unsafe fn unmap_buffer(&self, buffer: Buffer) -> bool[src]

Unmap a buffer from virtual host memory.

Valid usage

  • The buffer must be currently mapped.

Return

Returns if the unmapping operation was successfull.

pub unsafe fn delete_buffer(&self, buffer: Buffer)[src]

Delete a buffer.

pub unsafe fn delete_buffers(&self, buffers: &[Buffer])[src]

Delete multiple buffers.

pub unsafe fn copy_host_to_buffer(
    &self,
    buffer: Buffer,
    offset: isize,
    data: &[u8]
)
[src]

Copy memory from the host into the buffer memory.

pub unsafe fn bind_uniform_buffers(&self, first: u32, ranges: &[BufferRange])[src]

Bind buffer ranges as uniform buffers.

Shader can access the buffer memory as readonly.

pub unsafe fn bind_storage_buffers(&self, first: u32, ranges: &[BufferRange])[src]

Bind buffer ranges as shader storage buffers.

Shaders can access the buffer memory as readwrite.

pub unsafe fn bind_draw_indirect_buffer(&self, buffer: Buffer)[src]

Bind indirect buffer for draw commands.

pub unsafe fn unbind_draw_indirect_buffer(&self)[src]

Unbind indirect buffer for draw commands.

pub unsafe fn bind_dispatch_indirect_buffer(&self, buffer: Buffer)[src]

Bind indirect buffer for dispatch commands.

pub unsafe fn unbind_dispatch_indirect_buffer(&self)[src]

Unbind indirect buffer for draw commands.

pub unsafe fn bind_parameter_buffer(&self, buffer: Buffer)[src]

Bind parameter buffer for indirect commands.

Requires GL 4.6

impl Device[src]

pub unsafe fn bind_uniform_constants(
    &self,
    pipeline: Pipeline,
    first: u32,
    constants: &[Constant]
)
[src]

Set uniform constants for a pipeline.

pub unsafe fn set_viewport(&self, first: u32, viewports: &[Viewport])[src]

Set viewport transformation parameters.

The viewport determines the mapping from NDC (normalized device coordinates) into framebuffer coordinates.

See Viewport for more information about the viewport transformation.

pub unsafe fn set_scissor(&self, first: u32, scissors: &[Region])[src]

Set scissor rectangles for viewports.

Valid usage

  • Every active viewport needs an associated scissor.

pub unsafe fn set_depth_bias(&self, constant_factor: f32, slope_factor: f32)[src]

Set depth bias factors.

pub unsafe fn draw(
    &self,
    primitive: Primitive,
    vertices: Range<u32>,
    instance: Range<u32>
)
[src]

Submit a (non-indexed) draw call.

Valid usage

  • There must be a valid graphics pipeline currently bound.
  • There must be a valid vertex array currently bound.
  • For each attribute in the bound vertex array there must be a vertex buffer bound at the specified binding slot.
  • For each attribute in the bound vertex array there must be a vertex attribute specified in the shader with matching format and location.
  • The access vertices must be in bound of the vertex buffers bound.
  • vertices.end must be larger than vertices.start.
  • vertices.end - vertices.start must be allow assembling complete primitives.
  • instances.end must be larger than instances.start.

pub unsafe fn draw_indexed(
    &self,
    primitive: Primitive,
    index_ty: IndexTy,
    indices: Range<u32>,
    instance: Range<u32>,
    base_vertex: i32
)
[src]

Submit an indexed draw call.

Valid usage

  • There must be a valid graphics pipeline currently bound.
  • There must be a valid vertex array currently bound.
  • For each attribute in the bound vertex array there must be a vertex buffer bound at the specified binding slot.
  • For each attribute in the bound vertex array there must be a vertex attribute specified in the shader with matching format and location.
  • The access vertices must be in bound of the vertex buffers bound.
  • indices.end must be larger than indices.start.
  • indices.end - indices.start must allow to assemble complete primitives.
  • instances.end must be larger than instances.start.

pub unsafe fn draw_indirect(
    &self,
    primitive: Primitive,
    offset: u64,
    count: u32,
    stride: u32
)
[src]

Submit an indirect draw call.

Valid Usage

  • There must be a valid graphics pipeline currently bound.
  • There must be a valid draw indirect buffer currently bound.

pub unsafe fn draw_indirect_from_host(
    &self,
    primitive: Primitive,
    data: &[DrawIndirectCmd]
)
[src]

Submit an indirect draw call.

pub unsafe fn draw_indexed_indirect(
    &self,
    primitive: Primitive,
    index_ty: IndexTy,
    offset: u64,
    count: u32,
    stride: u32
)
[src]

Indirect draw call.

pub unsafe fn draw_indexed_indirect_from_host(
    &self,
    primitive: Primitive,
    index_ty: IndexTy,
    data: &[DrawIndexedIndirectCmd]
)
[src]

Indirect (indexed) draw call.

pub unsafe fn dispatch(&self, x: u32, y: u32, z: u32)[src]

Dispatch a workgroup for computation.

Valid usage

  • There must be a valid compute shader currently bound.

pub unsafe fn dispatch_indirect(&self, offset: u64)[src]

pub unsafe fn blit(
    &self,
    src: Framebuffer,
    src_region: Region,
    dst: Framebuffer,
    dst_region: Region,
    filter: Filter
)
[src]

pub unsafe fn draw_mesh_tasks_nv(&self, task_count: u32, first_task: u32)[src]

pub unsafe fn draw_mesh_tasks_indirect_nv(
    &self,
    offset: u64,
    draw_count: u32,
    stride: u32
)
[src]

pub unsafe fn draw_mesh_tasks_indirect_count_nv(
    &self,
    offset: u64,
    count_buffer_offset: u64,
    max_draw_count: u32,
    stride: u32
)
[src]

impl Device[src]

pub unsafe fn object_name<T: Object>(&self, object: T, name: &str)[src]

Associate a name with an object.

pub unsafe fn enable_debug_message(
    &self,
    src: MsgFilter<DebugSource>,
    ty: MsgFilter<DebugType>,
    flags: DebugReport,
    ids: Option<&[u32]>
)
[src]

pub unsafe fn disable_debug_message(
    &self,
    src: MsgFilter<DebugSource>,
    ty: MsgFilter<DebugType>,
    flags: DebugReport,
    ids: Option<&[u32]>
)
[src]

pub unsafe fn begin_debug_marker(&self, src: DebugSource, id: u32, msg: &str)[src]

pub unsafe fn end_debug_marker(&self)[src]

impl Device[src]

pub unsafe fn new<F>(loader: F, debug: Debug<DebugCallback>) -> Self where
    F: FnMut(&str) -> *const c_void
[src]

Create a new device from an existing context.

The context must be initialized with GL 4.5+ core profile. The passed loader is used to obtain the function pointers from the context.

pub unsafe fn context(&self) -> &Gl[src]

Return the underlying context for the device

pub unsafe fn limits(&self) -> DeviceLimits[src]

pub unsafe fn features(&self) -> DeviceFeatures[src]

pub unsafe fn submit(&self)[src]

Submit all pending operations for device execution.

This function may return before all operations have finished executing.

pub unsafe fn wait_idle(&self)[src]

Wait on the host for execution of all outstanding device operations.

impl Device[src]

pub unsafe fn create_framebuffer(&self) -> Result<Framebuffer>[src]

Create a new framebuffer.

pub unsafe fn delete_framebuffer(&self, framebuffer: Framebuffer)[src]

Delete a framebuffer.

pub unsafe fn delete_framebuffers(&self, framebuffers: &[Framebuffer])[src]

Delete multiple framebuffers.

pub unsafe fn create_renderbuffer(
    &self,
    format: Format,
    width: u32,
    height: u32,
    samples: u32
) -> Result<Renderbuffer>
[src]

Create a new framebuffer.

pub unsafe fn delete_renderbuffer(&self, renderbuffer: Renderbuffer)[src]

Delete a renderbuffer.

pub unsafe fn delete_renderbuffers(&self, renderbuffers: &[Renderbuffer])[src]

Delete multiple renderbuffers.

pub unsafe fn clear_attachment(&self, fb: Framebuffer, cv: ClearAttachment)[src]

Clear framebuffer attachment.

pub unsafe fn invalidate_attachments(
    &self,
    framebuffer: Framebuffer,
    attachments: &[Attachment],
    region: Region
)
[src]

pub unsafe fn bind_framebuffer(&self, framebuffer: Framebuffer)[src]

Bind a framebuffer for draw and read commands.

This will overwrite both (draw and read) binding points.

pub unsafe fn bind_draw_framebuffer(&self, framebuffer: Framebuffer)[src]

Bind a framebuffer for draw commands.

pub unsafe fn bind_read_framebuffer(&self, framebuffer: Framebuffer)[src]

Bind a framebuffer for read commands.

pub unsafe fn bind_attachments(
    &self,
    framebuffer: Framebuffer,
    attachments: &[(Attachment, AttachmentView)]
)
[src]

Bind attachments to the framebuffer.

All previously bound attachments become invalid.

pub unsafe fn set_color_attachments(
    &self,
    framebuffer: Framebuffer,
    attachments: &[u32]
)
[src]

Specify color attachments.

Defines the color render targets for the next draw calls. This builds the link between fragment outputs in the fragment shader and attachments bound on the framebuffer.

pub unsafe fn set_read_attachment(
    &self,
    framebuffer: Framebuffer,
    attachment: u32
)
[src]

Specify read attachment.

impl Device[src]

pub unsafe fn create_image(
    &self,
    ty: ImageType,
    format: Format,
    levels: u32
) -> Result<Image>
[src]

pub unsafe fn delete_image(&self, image: Image)[src]

Delete an images.

pub unsafe fn delete_images(&self, images: &[Image])[src]

Delete multiple images.

pub unsafe fn create_image_view(
    &self,
    image: Image,
    ty: ImageViewType,
    format: Format,
    range: SubresourceRange
) -> Result<ImageView>
[src]

Create an image view from an image.

pub unsafe fn create_image_and_view(
    &self,
    ty: ImageType,
    format: Format,
    levels: u32
) -> Result<(Image, ImageView)>
[src]

Create an image and an associated view.

The image view type is derived from the ImageType. It creates either non-arrayed or arrayed view types.

pub unsafe fn delete_image_view(&self, view: ImageView)[src]

Delete an image views.

pub unsafe fn delete_image_views(&self, views: &[ImageView])[src]

Delete multipe image views.

pub unsafe fn bind_image_views(&self, first: u32, views: &[ImageView])[src]

Bind image views to texture units.

pub unsafe fn bind_storage_image_views(&self, first: u32, views: &[ImageView])[src]

Bind image views to storage image units.

pub unsafe fn generate_mipmaps(&self, image: Image)[src]

Generate mipmaps.

This generates the remaining mipmap levels using the base layer via downscaling. The number of levels are determined on resource creation.

The downscaling filter is implementation dependent!

impl Device[src]

pub unsafe fn create_shader(
    &self,
    stage: ShaderStage,
    source: &[u8],
    flags: ShaderFlags
) -> Result<Shader>
[src]

Create a new shader from GLSL.

Valid usage

  • source must be a NULL-terminated C-String.
  • The GLSL shader version must be 450 core or higher.
  • The stage parameter must be a valid stage of the passed shader source.

pub unsafe fn get_shader_log(&self, shader: Shader) -> Option<String>[src]

Return the log, if any, from compiling the shader.

pub unsafe fn delete_shader(&self, shader: Shader)[src]

Delete a shader.

pub unsafe fn delete_shaders(&self, shaders: &[Shader])[src]

Delete multiple shaders.

pub unsafe fn get_pipeline_log(&self, pipeline: Pipeline) -> Option<String>[src]

Retrieve the log from the most recent program link.

Returns

  • Ok(log) if the link was successful.
  • Err(log) if the link failed.

pub unsafe fn create_graphics_pipeline<D>(
    &self,
    desc: D,
    flags: PipelineFlags
) -> Result<Pipeline> where
    D: Into<GraphicsPipelineDesc>, 
[src]

Create a graphics pipeline.

This equals a Program in GL terminology.

Valid usage

  • The vertex shader in desc must be valid and created with ShaderStage::Vertex.
  • The tessellation control shader in desc must be valid and created with ShaderStage::TessellationControl if specified.
  • The tessellation evaluation shader in desc must be valid and created with ShaderStage::TessellationEvalution if specified.
  • The geometry shader in desc must be valid and created with ShaderStage::Geometry if specified.
  • The fragment shader in desc must be valid and created with ShaderStage::Fragment if specified.

pub unsafe fn create_compute_pipeline(
    &self,
    compute_shader: Shader,
    flags: PipelineFlags
) -> Result<Pipeline>
[src]

Create a compute pipeline.

This equals a Program in GL terminology.

Valid usage

  • The compute shader in must be valid and created with ShaderStage::Compute.

pub unsafe fn create_pipeline(
    &self,
    shaders: &[Shader],
    flags: PipelineFlags
) -> Result<Pipeline>
[src]

Create a generic pipeline with an arbitrary list of shaders.

This equals a Program in GL terminology.

Valid usage

  • The shaders must all be valid.
  • The shader stages must be mutually compatible.

pub unsafe fn delete_pipeline(&self, pipeline: Pipeline)[src]

Delete a pipeline.

pub unsafe fn delete_pipelines(&self, pipelines: &[Pipeline])[src]

Delete multiple pipelines.

pub unsafe fn get_work_group_size(&self, pipeline: Pipeline) -> Option<[i32; 3]>[src]

For a compute pipeline, return the size of the work group defined in the main shader.

pub unsafe fn bind_input_assembly_state(&self, state: InputAssembly)[src]

Bind input assembly pipeline state.

pub unsafe fn bind_color_blend_state(&self, state: &ColorBlend)[src]

Bind color blending pipeline state.

pub unsafe fn bind_depth_stencil_state(&self, state: &DepthStencil)[src]

Bind depth-stencil pipeline state.

Examples

Basic Less-Equal depth test with write:

grr.bind_depth_stencil_state(&grr::DepthStencil {
    depth_test: true,
    depth_write: true,
    depth_compare_op: grr::Compare::LessEqual,
    stencil_test: false,
    stencil_front: grr::StencilFace::KEEP,
    stencil_back: grr::StencilFace::KEEP,
});

pub unsafe fn bind_rasterization_state(&self, state: &Rasterization)[src]

Bind rasterization pipeline state.

pub unsafe fn bind_multisample_state(&self, state: Option<&Multisample>)[src]

pub unsafe fn bind_pipeline(&self, pipeline: Pipeline)[src]

Bind a pipeline for usage.

impl Device[src]

pub unsafe fn create_query(&self, ty: QueryType) -> Query[src]

pub unsafe fn begin_query(&self, query: Query)[src]

pub unsafe fn end_query(&self, query: Query)[src]

pub unsafe fn write_timestamp(&self, query: Query)[src]

pub unsafe fn get_query_result_u32(
    &self,
    query: Query,
    flags: QueryResultFlags
) -> u32
[src]

pub unsafe fn get_query_result_u64(
    &self,
    query: Query,
    flags: QueryResultFlags
) -> u64
[src]

pub unsafe fn begin_conditional_rendering(
    &self,
    query: Query,
    mode: ConditionalMode
)
[src]

pub unsafe fn end_conditional_rendering(&self)[src]

impl Device[src]

pub unsafe fn create_sampler(&self, desc: SamplerDesc) -> Result<Sampler>[src]

Create a sampler object.

pub unsafe fn bind_samplers(&self, first: u32, samplers: &[Sampler])[src]

Bind samplers to specific texture units.

pub unsafe fn delete_sampler(&self, sampler: Sampler)[src]

pub unsafe fn delete_samplers(&self, samplers: &[Sampler])[src]

Delete multiple samplers.

impl Device[src]

pub unsafe fn memory_barrier(&self, flags: Barrier)[src]

pub unsafe fn memory_barrier_by_region(&self, flags: RegionBarrier)[src]

impl Device[src]

pub unsafe fn copy_host_to_image<T>(
    &self,
    src_host: &[T],
    dst_image: Image,
    region: HostImageCopy
)
[src]

Copy image data from host memory to device memory.

pub unsafe fn copy_buffer_to_image(
    &self,
    src_buffer: Buffer,
    dst_image: Image,
    region: BufferImageCopy
)
[src]

Copy image data from buffer to device memory.

pub unsafe fn copy_image_to_host<T>(
    &self,
    src_image: Image,
    dst_host: &mut [T],
    region: HostImageCopy
)
[src]

Copy image data from device memory to a host array.

pub unsafe fn copy_image_to_buffer(
    &self,
    src_image: Image,
    dst_buffer: Buffer,
    region: BufferImageCopy
)
[src]

Copy image data from device memory to a buffer object.

pub unsafe fn copy_attachment_to_host<T: Sized>(
    &self,
    region: Region,
    layout: MemoryLayout,
    data: &mut [T]
)
[src]

Read a region of pixel data from the current read framebuffer into the provided storage slice.

Remarks:

The transfer in copy_attachement_to_host is done synchronously; the method won't return until the transfer is complete.

See also

pub unsafe fn copy_attachment_to_buffer(
    &self,
    region: Region,
    layout: MemoryLayout,
    buffer_range: BufferRange
)
[src]

Read a region of pixel data from the current read framebuffer into a buffer object.

Remarks:

The transfer for copy_attachment_to_buffer is asynchronous.

pub unsafe fn copy_image(
    &self,
    src_image: Image,
    dst_image: Image,
    region: ImageCopy
)
[src]

pub unsafe fn copy_buffer(
    &self,
    src_buffer: Buffer,
    src_offset: u64,
    dst_buffer: Buffer,
    dst_offset: u64,
    size: u64
)
[src]

Copy data from one buffer into another buffer.

Valid usage

  • src_buffer and dst_buffer must be valid handles.
  • src_offset must be less than the size of src_buffer.
  • dst_offset must be less than the size of dst_buffer.
  • size must be less than or equal the size of src_buffer minus src_offset.
  • size must be less than or equal the size of dst_buffer minus dst_offset.
  • The source and destination region must not overlap in memory.

pub unsafe fn fill_buffer(
    &self,
    buffer: BufferRange,
    buffer_format: Format,
    base_format: BaseFormat,
    format_layout: FormatLayout,
    value: &[u8]
)
[src]

Fill buffer with data.

impl Device[src]

pub unsafe fn create_vertex_array(
    &self,
    attributes: &[VertexAttributeDesc]
) -> Result<VertexArray>
[src]

Create a new vertex array, storing information for the input assembler.

The vertex array specified the vertex attributes and their binding to vertex buffer objects.

pub unsafe fn delete_vertex_array(&self, vao: VertexArray)[src]

Delete a vertex array.

pub unsafe fn delete_vertex_arrays(&self, vao: &[VertexArray])[src]

Delete multiple vertex arrays.

pub unsafe fn bind_vertex_array(&self, vao: VertexArray)[src]

Bind a vertex array for usage.

pub unsafe fn bind_vertex_buffers(
    &self,
    vao: VertexArray,
    first: u32,
    views: &[VertexBufferView]
)
[src]

Bind vertex buffers to a vertex array.

pub unsafe fn bind_index_buffer(&self, vao: VertexArray, buffer: Buffer)[src]

Bind a index buffer to a vertex array.

Auto Trait Implementations

impl RefUnwindSafe for Device

impl Send for Device

impl !Sync for Device

impl Unpin for Device

impl UnwindSafe for Device

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.