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.

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.

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.
Return

Returns if the unmapping operation was successfull.

Delete a buffer.

Delete multiple buffers.

Copy memory from the host into the buffer memory.

Copy data from one buffer into another buffer.

Fill buffer with data.

Bind buffer ranges as uniform buffers.

Shader can access the buffer memory as readonly.

Bind buffer ranges as shader storage buffers.

Shaders can access the buffer memory as readwrite.

Bind indirect buffer for draw commands.

Bind indirect buffer for dispatch commands.

Set uniform constants for a pipeline.

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.

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 allow to assemble complete primitives.
  • instances.end must be larger than instances.start.

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.

Submit an indirect draw call.

Indirect draw call.

Indirect (indexed) draw call.

Dispatch a workgroup for computation.

Valid usage
  • There must be a valid compute shader currently bound.

Associate a name with an object.

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.

Create a new framebuffer.

Delete a framebuffer.

Delete multiple framebuffers.

Create a new framebuffer.

Delete a renderbuffer.

Delete multiple renderbuffers.

Clear framebuffer attachment.

Bind a framebuffer for draw commands.

Bind attachments to the framebuffer.

All previously bound attachments become invalid.

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.

Delete an images.

Delete multiple images.

Copy image data from host memory to device memory.

Create an image view from an image.

Delete an image views.

Delete multipe image views.

Bind image views to texture units.

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!

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.

Delete multiple shaders.

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.

Delete a pipeline.

Delete multiple pipelines.

Bind input assembly pipeline state.

Bind color blending pipeline state.

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,
});

Bind rasterization pipeline state.

Bind a pipeline for usage.

Create a sampler object.

Bind samplers to specific texture units.

Delete multiple samplers.

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.

Delete multiple vertex arrays.

Bind a vertex array for usage.

Bind vertex buffers to a vertex array.

Bind a index buffer to a vertex array.

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.