Struct grr::Device

source ·
pub struct Device(_);
Expand description

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

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.

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.

Unmap a buffer from virtual host memory.

Valid usage
  • The buffer must be currently mapped.

Delete a buffer.

Bind vertex buffers to a vertex array.

Bind a index buffer to a vertex array.

Bind a pipeline for usage.

Set viewport transformation parameters.

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

Set scissor rectangles for viewports.

Valid usage
  • Every active viewport needs an associated scissor.

Submit a (non-indexed) draw call.

Valid usage
  • There must be a valid graphics pipeline currently bound.
  • There must be a calid 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.

Submit an indexed draw call.

Valid usage
  • There must be a valid graphics pipeline currently bound.
  • There must be a calid 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 be allow assembling complete primitives.
  • instances.end must be larger than instances.start.

Dispatch a workgroup for computation.

Valid usage
  • group_x, group_y and group_z must be larger than 0.
  • There must be a valid compute shader currently bound.

Create a new device from an existing context.

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

Clear framebuffer attachment.

Create a sampler object.

Bind samplers to specific texture units.

Delete a sampler.

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.

Delete a shader.

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.

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.

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.

Delete a vertex array.

Bind a vertex array for usage.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.