wgpu-hs-0.1.0.0: WGPU
CopyrightCopyright (C) Jonathan Merritt 2021
LicenseBSD-3-Clause
MaintainerJonathan Merritt <j.s.merritt@gmail.com>
Stabilityexperimental
PortabilitymacOS
Safe HaskellNone
LanguageHaskell2010

WGPU

Description

Layout of this module should be guided by the evolving WebGPU Specification.

Synopsis

Introduction

Introduction to WebGPU

WebGPU is a future web standard for graphics and compute, developed by the W3C. It is currently (August 2021) an emerging technology, and not yet stable. In addition to its JavaScript API, there are also early attempts to create a native binding (ie. a C language binding). Two implementations of the native binding are:

  • wgpu-native: a Mozilla-backed WebGPU native implementation, written in Rust, used in the Firefox web browser. This is the binding to which this Haskell library is currently tied.
  • dawn: a Google-backed WebGPU native implementation, written in C++, used in the Chrome web browser. In the future, we hope to support this backend too.

The native bindings to WebGPU have the potential to become a portable, next-generation GPU API which is easy to use. Vulkan is also currently available across platforms, but it is very low-level. In the opinion of the author of this package, Vulkan is very difficult to use directly from Haskell. It would benefit greatly from a shim layer which performs common tasks and streamlines many operations. Not unexpectedly, that is exactly the role that WebGPU native can play.

Platform Support

Currently, only macOS (with the Metal backend) is supported. The limitation is not fundamental and only exists because, so far, only macOS surface creation has been implemented. In the future, other backends should be added.

Dependence on GLFW-b

This package currently uses only GLFW-b for windowing and event processing. Clearly, it is undesirable to be tied to only a single library for this purpose, when options like sdl2 are available and might be preferred by many users.

GFLW is used because it is the windowing library used in the C examples from wgpu-native and it exposes an API to obtain a pointer to the underlying windowing system's native window. In the future, other options will be investigated as time permits.

Structure of Bindings

The bindings to wgpu-native are structured in three packages:

  1. The wgpu-raw-hs-codegen package is a code generator for the raw bindings. It creates all the packages named WGPU.Raw.Generated.* (without exception!), using a custom code generator based on `langage-c`. This package is not in Hackage, since it is only used offline.
  2. The wgpu-raw-hs package provides raw bindings to wgpu-native. These raw bindings are mostly auto-generated, but have some manual curation of top-level types and function aliases. They are "raw" in the sense that they contain raw pointers and are not usable without manual management of memory to construct all the C structs that must be passed to the API.
  3. The wgpu-hs package (this one) provides high-level bindings. These bindings are written manually. They are improvements on the raw bindings in the following ways:

    • There are no more raw Ptr types. Memory for structs passed to the raw API is managed using a type class (ToRaw) that encapsulates a mapping between high-level API types and raw types. The possibility to allocate memory as part of this conversion (and later free it) is achieved by embedding conversion to the raw types inside the ContT continuation monad.
    • There are no callbacks. Several WebGPU native calls use callbacks to indicate completion rather than blocking. The author decided that, in the Haskell context, blocking was probably preferable. So, internally, these calls are converted into a blocking form by waiting on MVars that are set by the callbacks.
    • Several parts of the API are tweaked slightly to more closely resemble the Rust API. This is done in cases where, for example, a parameter to the C API is unused except in one branch of a sum type. When this can be done easily enough, it is preferred to using the flattened "union" approach.
    • Names are de-duplicated. Where possible, names are identical to the C API (sometimes with prefixes removed). However, where name conflicts exist, names are changed to somewhat-idiomatic Haskell variants.

Native Library Handling

The native library for wgpu-native is not required at compile-time for this package. Indeed, other packages containing executables that depend on this one can be compiled without the native library! Instead, the library is loaded dynamically and its symbols bound at runtime. This has the benefit that the Haskell tooling need not be concerned with handling a Rust library (yay!), but it is a point of common failure at runtime. To achieve this independence, the header files for wgpu-native are packaged inside wgpu-raw-hs. Of course, care should be taken to ensure that a fully-compatible version of the library is used at runtime.

Initialization

The first step in using these Haskell bindings is to obtain an Instance. This acts as a handle to the rest of the API. An Instance is obtained at runtime by loading a dynamic library containing the WGPU binding symbols. Currently, only the C/Rust library from wgpu-native is supported.

To load the dynamic library and obtain an instance, use the withInstance bracketing function:

withInstance "libwgpu_native.dylib" (Just logStdout) $ inst -> do
  -- set the logging level (optional)
  setLogLevel inst Warn
  -- run the rest of the program...

After creating an Instance, you may next want to create a surface.

data Instance #

Instance of the WGPU API.

An instance is loaded from a dynamic library using the withInstance function.

Instances

Instances details
Show Instance 
Instance details

Defined in WGPU.Internal.Instance

ToRaw Instance WGPUHsInstance 
Instance details

Defined in WGPU.Internal.Instance

withInstance #

Arguments

:: FilePath

Name of the wgpu-native dynamic library, or a complete path to it.

-> Maybe LogCallback

Optional logging callback. Just logStdout can be supplied here to print log messages to stdout for debugging purposes.

-> (Instance -> IO a)

The Program. A function which takes an Instance and returns an IO action that uses the instance.

-> IO a

IO action which loads the WGPU Instance, passes it to the program, and returns the result of running the program.

Load the WGPU API from a dynamic library and supply an Instance to a program.

Surface

A Surface is a handle to a platform-specific presentable surface, like a window. Currently, only GLFW windows are supported for surface creation. Once you have a GLFW window, you may create a Surface for it using the createGLFWSurface function.

Once you have a Surface, the next step is usually to request an adapter that is compatible with it.

data Surface #

Handle to a presentable surface.

A Surface presents a platform-specific surface (eg. a window) on to which rendered images may be presented. A Surface can be created for a GLFW window using createGLFWSurface.

Instances

Instances details
Eq Surface 
Instance details

Defined in WGPU.Internal.Surface

Methods

(==) :: Surface -> Surface -> Bool #

(/=) :: Surface -> Surface -> Bool #

Show Surface 
Instance details

Defined in WGPU.Internal.Surface

ToRaw Surface WGPUSurface 
Instance details

Defined in WGPU.Internal.Surface

Methods

raw :: Surface -> ContT c IO WGPUSurface #

createGLFWSurface #

Arguments

:: Instance

API instance.

-> Window

GLFW window for which the surface will be created.

-> IO Surface

IO action to create the surface.

Create a WGPU Surface for a GLFW Window.

This function is not part of the wgpu-native API, but is part of the Haskell API until the native WGPU API has a better story around windowing.

Adapter

An Adapter is a handle to a physical device. For example, a physical display adaptor (GPU) or a software renderer. Currently you obtain an adapter using requestAdapter, which requests an adapter that is compatible with an existing Surface.

After obtaining an adapter, you will typically want to request a device.

data Adapter #

Handle to a physical graphics and/or compute device.

Request an Adapter for a Surface using the requestAdapter function.

Instances

Instances details
Eq Adapter 
Instance details

Defined in WGPU.Internal.Adapter

Methods

(==) :: Adapter -> Adapter -> Bool #

(/=) :: Adapter -> Adapter -> Bool #

Show Adapter 
Instance details

Defined in WGPU.Internal.Adapter

ToRaw Adapter WGPUAdapter 
Instance details

Defined in WGPU.Internal.Adapter

Methods

raw :: Adapter -> ContT c IO WGPUAdapter #

requestAdapter #

Arguments

:: Surface

Existing surface for which to request an Adapter.

-> IO (Maybe Adapter)

The returned Adapter, if it could be retrieved.

Request an Adapter that is compatible with a given Surface.

This action blocks until an available adapter is returned.

Device

A Device is an open connection to a graphics and/or compute device. A Device is created using the requestDevice function.

(According to the WebGPU API documentation, a Device may also be "lost". However, it's not yet clear how that event will be signalled to the C API, nor how to handle it.)

data Device #

An open connection to a graphics and/or compute device.

A Device may be created using the requestDevice function.

Instances

Instances details
Eq Device 
Instance details

Defined in WGPU.Internal.Device

Methods

(==) :: Device -> Device -> Bool #

(/=) :: Device -> Device -> Bool #

Show Device 
Instance details

Defined in WGPU.Internal.Device

ToRaw Device WGPUDevice 
Instance details

Defined in WGPU.Internal.Device

Methods

raw :: Device -> ContT c IO WGPUDevice #

data DeviceDescriptor #

Describes a Device.

Constructors

DeviceDescriptor 

Fields

data Limits #

Device limits.

Represents the set of limits an adapter/device supports.

Constructors

Limits 

Fields

Instances

Instances details
Eq Limits 
Instance details

Defined in WGPU.Internal.Device

Methods

(==) :: Limits -> Limits -> Bool #

(/=) :: Limits -> Limits -> Bool #

Show Limits 
Instance details

Defined in WGPU.Internal.Device

Default Limits 
Instance details

Defined in WGPU.Internal.Device

Methods

def :: Limits #

newtype Features #

Device features that are not guaranteed to be supported.

Instances

Instances details
Eq Features 
Instance details

Defined in WGPU.Internal.Device

Show Features 
Instance details

Defined in WGPU.Internal.Device

Default Features 
Instance details

Defined in WGPU.Internal.Device

Methods

def :: Features #

ToRaw Features WGPUNativeFeature 
Instance details

Defined in WGPU.Internal.Device

requestDevice #

Arguments

:: Adapter

Adapter for which the device will be returned.

-> DeviceDescriptor

The features and limits requested for the device.

-> IO (Maybe Device)

The returned Device, if it could be retrieved.

Requests a connection to a physical device, creating a logical device.

This action blocks until an available device is returned.

Textures and Views

data TextureView #

Handle to a texture view.

A TextureView describes a texture and associated metadata needed by a rendering pipeline or bind group.

Instances

Instances details
Eq TextureView 
Instance details

Defined in WGPU.Internal.Texture

Show TextureView 
Instance details

Defined in WGPU.Internal.Texture

ToRaw TextureView WGPUTextureView 
Instance details

Defined in WGPU.Internal.Texture

data TextureFormat #

Texture data format.

Instances

Instances details
Eq TextureFormat 
Instance details

Defined in WGPU.Internal.Texture

Show TextureFormat 
Instance details

Defined in WGPU.Internal.Texture

ToRaw TextureFormat WGPUTextureFormat 
Instance details

Defined in WGPU.Internal.Texture

data TextureUsage #

Different ways you can use a texture.

The usages determine from what kind of memory the texture is allocated, and in what actions the texture can partake.

Instances

Instances details
Eq TextureUsage 
Instance details

Defined in WGPU.Internal.Texture

Show TextureUsage 
Instance details

Defined in WGPU.Internal.Texture

ToRaw TextureUsage WGPUTextureUsage 
Instance details

Defined in WGPU.Internal.Texture

Swapchain

data SwapChain #

Instances

Instances details
Eq SwapChain 
Instance details

Defined in WGPU.Internal.SwapChain

Show SwapChain 
Instance details

Defined in WGPU.Internal.SwapChain

ToRaw SwapChain WGPUSwapChain 
Instance details

Defined in WGPU.Internal.SwapChain

data SwapChainDescriptor #

Describes a swapchain.

Constructors

SwapChainDescriptor 

Fields

data PresentMode #

Behaviour of the presentation engine based on frame rate.

Constructors

PresentModeImmediate

The presentation engine does not wait for a vertical blanking period and the request is presented immediately. This is a low-latency presentation mode, but visible tearing may be observed. Will fallback to Fifo if unavailable on the selected platform and backend. Not optimal for mobile.

PresentModeMailbox

The presentation engine waits for the next vertical blanking period to update the current image, but frames may be submitted without delay. This is a low-latency presentation mode and visible tearing will not be observed. Will fallback to Fifo if unavailable on the selected platform and backend. Not optimal for mobile.

PresentModeFifo

The presentation engine waits for the next vertical blanking period to update the current image. The framerate will be capped at the display refresh rate, corresponding to the VSync. Tearing cannot be observed. Optimal for mobile.

Instances

Instances details
Eq PresentMode 
Instance details

Defined in WGPU.Internal.SwapChain

Show PresentMode 
Instance details

Defined in WGPU.Internal.SwapChain

ToRaw PresentMode WGPUPresentMode 
Instance details

Defined in WGPU.Internal.SwapChain

getSwapChainPreferredFormat #

Arguments

:: Surface

Surface for which to obtain an optimal texture format.

-> Adapter

Adapter for which to obtain an optimal texture format.

-> IO TextureFormat

IO action which returns the optimal texture format.

Returns an optimal texture format to use for the swapchain with this adapter and surface.

createSwapChain #

Arguments

:: Device

Device for which the SwapChain will be created.

-> Surface

Surface for which the SwapChain will be created.

-> SwapChainDescriptor

Description of the SwapChain to be created.

-> IO SwapChain

IO action which creates the swap chain.

Createa a new SwapChain which targets a Surface.

To determine the preferred TextureFormat for the Surface, use the getSwapChainPreferredFormat function.

getSwapChainCurrentTextureView #

Arguments

:: SwapChain

Swap chain from which to fetch the current texture view.

-> IO TextureView

IO action which returns the current swap chain texture view.

Get the TextureView for the current swap chain frame.

swapChainPresent #

Arguments

:: SwapChain

Swap chain to present.

-> IO ()

IO action which presents the swap chain image.

Present the latest swap chain image.

Samplers

Resource Binding

data BindGroupLayout #

Handle to a binding group layout.

A BindGroupLayout is a handle to the GPU-side layout of a binding group.

data BindGroupLayoutEntry #

Describes a single binding inside a bind group.

Constructors

BindGroupLayoutEntry 

Fields

newtype Binding #

Binding index.

This must match a shader index, and be unique inside a binding group layout.

Constructors

Binding 

Fields

Instances

Instances details
Eq Binding 
Instance details

Defined in WGPU.Internal.Binding

Methods

(==) :: Binding -> Binding -> Bool #

(/=) :: Binding -> Binding -> Bool #

Show Binding 
Instance details

Defined in WGPU.Internal.Binding

ToRaw Binding Word32 
Instance details

Defined in WGPU.Internal.Binding

Methods

raw :: Binding -> ContT c IO Word32 #

data ShaderStage #

Describes the shader stages from which a binding will be visible.

Constructors

ShaderStage 

Fields

  • stageVertex :: !Bool

    Binding is visible from the vertex shader of a render pipeline.

  • stageFragment :: !Bool

    Binding is visible from the fragment shader of a render pipeline.

  • stageCompute :: !Bool

    Binding is visible from the compute shader of a compute pipeline.

Instances

Instances details
Eq ShaderStage 
Instance details

Defined in WGPU.Internal.Binding

Show ShaderStage 
Instance details

Defined in WGPU.Internal.Binding

ToRaw ShaderStage WGPUShaderStageFlags 
Instance details

Defined in WGPU.Internal.Binding

data BindingType #

Specifies type of a binding.

Constructors

BindingTypeBuffer !BufferBindingLayout

A buffer binding.

BindingTypeSampler !SamplerBindingLayout

A sampler that can be used to sample a texture.

BindingTypeTexture !TextureBindingLayout

A texture binding.

BindingTypeStorageTexture !StorageTextureBindingLayout

A storage texture.

Instances

Instances details
Eq BindingType 
Instance details

Defined in WGPU.Internal.Binding

Show BindingType 
Instance details

Defined in WGPU.Internal.Binding

data BufferBindingLayout #

A buffer binding.

Constructors

BufferBindingLayout 

Fields

data TextureBindingLayout #

A texture binding.

Constructors

TextureBindingLayout 

Fields

data BufferBindingType #

Specific type of a buffer binding.

Constructors

Uniform 
Storage 

Fields

createBindGroupLayout #

Arguments

:: Device

The device for which the bind group layout will be created.

-> BindGroupLayoutDescriptor

Description of the bind group layout.

-> IO BindGroupLayout

IO action that creates a bind group layout.

Creates a BindGroupLayout.

Shader Modules

data ShaderModule #

Handle to a compiled shader module.

Instances

Instances details
Eq ShaderModule 
Instance details

Defined in WGPU.Internal.Shader

Show ShaderModule 
Instance details

Defined in WGPU.Internal.Shader

ToRaw ShaderModule WGPUShaderModule 
Instance details

Defined in WGPU.Internal.Shader

data ShaderSource #

Source for a shader module.

Constructors

ShaderSourceSPIRV !SPIRV

Use shader source from a SPIRV module (pre-compiled).

ShaderSourceWGSL !WGSL

Use shader source from WGSL string.

Instances

Instances details
Eq ShaderSource 
Instance details

Defined in WGPU.Internal.Shader

Show ShaderSource 
Instance details

Defined in WGPU.Internal.Shader

newtype SPIRV #

Pre-compiled SPIRV module bytes.

Constructors

SPIRV ByteString 

Instances

Instances details
Eq SPIRV 
Instance details

Defined in WGPU.Internal.Shader

Methods

(==) :: SPIRV -> SPIRV -> Bool #

(/=) :: SPIRV -> SPIRV -> Bool #

Show SPIRV 
Instance details

Defined in WGPU.Internal.Shader

Methods

showsPrec :: Int -> SPIRV -> ShowS #

show :: SPIRV -> String #

showList :: [SPIRV] -> ShowS #

ToRaw SPIRV WGPUShaderModuleSPIRVDescriptor 
Instance details

Defined in WGPU.Internal.Shader

newtype WGSL #

WGSL shader source code.

Constructors

WGSL Text 

Instances

Instances details
Eq WGSL 
Instance details

Defined in WGPU.Internal.Shader

Methods

(==) :: WGSL -> WGSL -> Bool #

(/=) :: WGSL -> WGSL -> Bool #

Show WGSL 
Instance details

Defined in WGPU.Internal.Shader

Methods

showsPrec :: Int -> WGSL -> ShowS #

show :: WGSL -> String #

showList :: [WGSL] -> ShowS #

ToRaw WGSL WGPUShaderModuleWGSLDescriptor 
Instance details

Defined in WGPU.Internal.Shader

newtype ShaderEntryPoint #

Name of a shader entry point.

Constructors

ShaderEntryPoint 

createShaderModule #

Arguments

:: Device

Device for the shader.

-> ShaderModuleDescriptor

Descriptor of the shader module.

-> IO ShaderModule

IO action producing the shader module.

Create a shader module from either SPIR-V or WGSL source code.

createShaderModuleSPIRV #

Arguments

:: Device

Device for which the shader should be created.

-> Text

Debugging label for the shader.

-> SPIRV

Shader source code (SPIR-V bytestring).

-> IO ShaderModule

IO action creating the shader module.

Create a shader module from SPIR-V source code.

createShaderModuleWGSL #

Arguments

:: Device

Device for which the shader should be created.

-> Text

Debugging label for the shader.

-> WGSL

Shader source code (WGSL source string).

-> IO ShaderModule

IO action creating the shader module.

Create a shader module from WGSL source code.

Pipelines

Compute

Render

data RenderPipelineDescriptor #

Describes a render (graphics) pipeline.

Constructors

RenderPipelineDescriptor 

Fields

data VertexAttribute #

Vertex inputs (attributes) to shaders.

Constructors

VertexAttribute 

Fields

data InputStepMode #

Determines when vertex data is advanced.

Constructors

InputStepModeVertex

Input data is advanced every vertex.

InputStepModeInstance

Input data is advanced every instance.

Instances

Instances details
Eq InputStepMode 
Instance details

Defined in WGPU.Internal.Pipeline

Show InputStepMode 
Instance details

Defined in WGPU.Internal.Pipeline

ToRaw InputStepMode WGPUInputStepMode

Convert an InputStepMode to its raw value.

Instance details

Defined in WGPU.Internal.Pipeline

data VertexBufferLayout #

Describes how a vertex buffer is interpreted.

Constructors

VertexBufferLayout 

Fields

data VertexState #

Describes the vertex process in a render pipeline.

Constructors

VertexState 

Fields

Instances

Instances details
Eq VertexState 
Instance details

Defined in WGPU.Internal.Pipeline

Show VertexState 
Instance details

Defined in WGPU.Internal.Pipeline

ToRaw VertexState WGPUVertexState 
Instance details

Defined in WGPU.Internal.Pipeline

data IndexFormat #

Format of indices used within a pipeline.

Constructors

IndexFormatUint16

Indices are 16-bit unsigned integers (Word16)

IndexFormatUint32

Indices are 32-bit unsigned integers (Word32)

Instances

Instances details
Eq IndexFormat 
Instance details

Defined in WGPU.Internal.Pipeline

Show IndexFormat 
Instance details

Defined in WGPU.Internal.Pipeline

ToRaw IndexFormat WGPUIndexFormat

Convert an IndexFormat to its raw value.

Instance details

Defined in WGPU.Internal.Pipeline

data FrontFace #

Winding order which classifies the "front" face.

Constructors

FrontFaceCCW

Triangles with counter-clockwise vertices are the front face.

FrontFaceCW

Triangles with clockwise vertices are the front face.

Instances

Instances details
Eq FrontFace 
Instance details

Defined in WGPU.Internal.Pipeline

Show FrontFace 
Instance details

Defined in WGPU.Internal.Pipeline

Default FrontFace 
Instance details

Defined in WGPU.Internal.Pipeline

Methods

def :: FrontFace #

ToRaw FrontFace WGPUFrontFace

Convert a FrontFace to its raw value.

Instance details

Defined in WGPU.Internal.Pipeline

data CullMode #

Whether to cull the face of a vertex.

Constructors

CullModeFront

Cull the front face.

CullModeBack

Cull the back face.

CullModeNone

Do not cull either face.

Instances

Instances details
Eq CullMode 
Instance details

Defined in WGPU.Internal.Pipeline

Show CullMode 
Instance details

Defined in WGPU.Internal.Pipeline

Default CullMode 
Instance details

Defined in WGPU.Internal.Pipeline

Methods

def :: CullMode #

ToRaw CullMode WGPUCullMode

Convert a CullMode to its raw value.

Instance details

Defined in WGPU.Internal.Pipeline

data PrimitiveState #

Describes the state of primitive assembly and rasterization in a render pipeline.

Differences between this and the Rust API: - no clamp_depth member - no polygon_mode member - no conservative member

Constructors

PrimitiveState 

Fields

data StencilState #

State of the stencil operation (fixed pipeline stage).

Constructors

StencilState 

Fields

Instances

Instances details
Eq StencilState 
Instance details

Defined in WGPU.Internal.Pipeline

Show StencilState 
Instance details

Defined in WGPU.Internal.Pipeline

data DepthBiasState #

Describes the biasing setting for the depth target.

Constructors

DepthBiasState 

Fields

Instances

Instances details
Eq DepthBiasState 
Instance details

Defined in WGPU.Internal.Pipeline

Show DepthBiasState 
Instance details

Defined in WGPU.Internal.Pipeline

data DepthStencilState #

Describes the depth / stencil state of a render pipeline.

Constructors

DepthStencilState 

Fields

data MultisampleState #

Describes the multi-sampling state of a render pipeline.

Constructors

MultisampleState 

Fields

  • count :: Word32

    Number of samples calculated per pixel (for MSAA). For non-multisampled textures, this should be 1.

  • mask :: Word32

    Bitmask that restricts the samples of a pixel modified by this pipeline. All samples can be enabled by using 0XFFFFFFFF (ie. zero complement).

  • alphaToCoverageEnabled :: Bool

    When enabled, produces another sample mask per pixel based on the alpha output value, and that is AND-ed with the sample mask and the primitive coverage to restrict the set of samples affected by a primitive.

data BlendComponent #

Describes the blend component of a pipeline.

Constructors

BlendComponent 

Fields

data BlendState #

Describes the blend state of a render pipeline.

Constructors

BlendState 

Fields

Instances

Instances details
Eq BlendState 
Instance details

Defined in WGPU.Internal.Pipeline

Show BlendState 
Instance details

Defined in WGPU.Internal.Pipeline

ToRaw BlendState WGPUBlendState 
Instance details

Defined in WGPU.Internal.Pipeline

data ColorWriteMask #

Describes which color channels are written.

Constructors

ColorWriteMask 

Fields

data ColorTargetState #

Describes the color state of a render pipeline.

Constructors

ColorTargetState 

Fields

data FragmentState #

Describes the fragment processing in a render pipeline.

Constructors

FragmentState 

Fields

createPipelineLayout #

Arguments

:: Device

The device for which the pipeline layout will be created.

-> PipelineLayoutDescriptor

Descriptor of the pipeline.

-> IO PipelineLayout 

Create a pipeline layout.

colorWriteMaskAll :: ColorWriteMask #

A ColorWriteMask that writes all colors and the alpha value.

Command Buffers

Command Encoding

data CommandEncoder #

Handle to an encoder for a series of GPU operations.

A command encoder can record render passes, compute passes, and transfer operations between driver-managed resources like buffers and textures.

data Color #

RGBA double-precision color.

Constructors

Color 

Fields

Instances

Instances details
Eq Color 
Instance details

Defined in WGPU.Internal.Color

Methods

(==) :: Color -> Color -> Bool #

(/=) :: Color -> Color -> Bool #

Show Color 
Instance details

Defined in WGPU.Internal.Color

Methods

showsPrec :: Int -> Color -> ShowS #

show :: Color -> String #

showList :: [Color] -> ShowS #

ToRaw Color WGPUColor 
Instance details

Defined in WGPU.Internal.Color

Methods

raw :: Color -> ContT c IO WGPUColor #

data LoadOp a #

Operation to perform to the output attachment at the start of a render pass.

Constructors

LoadOpClear !a

Clear with the specified color value.

LoadOpLoad

Load from memory.

Instances

Instances details
Eq a => Eq (LoadOp a) 
Instance details

Defined in WGPU.Internal.RenderPass

Methods

(==) :: LoadOp a -> LoadOp a -> Bool #

(/=) :: LoadOp a -> LoadOp a -> Bool #

Show a => Show (LoadOp a) 
Instance details

Defined in WGPU.Internal.RenderPass

Methods

showsPrec :: Int -> LoadOp a -> ShowS #

show :: LoadOp a -> String #

showList :: [LoadOp a] -> ShowS #

data StoreOp #

Operation to perform to the output attachment at the end of the render pass.

Constructors

StoreOpStore

Store the result.

StoreOpClear

Discard the result.

Instances

Instances details
Eq StoreOp 
Instance details

Defined in WGPU.Internal.RenderPass

Methods

(==) :: StoreOp -> StoreOp -> Bool #

(/=) :: StoreOp -> StoreOp -> Bool #

Show StoreOp 
Instance details

Defined in WGPU.Internal.RenderPass

ToRaw StoreOp WGPUStoreOp 
Instance details

Defined in WGPU.Internal.RenderPass

Methods

raw :: StoreOp -> ContT c IO WGPUStoreOp #

data Operations a #

Constructors

Operations 

Fields

Instances

Instances details
Eq a => Eq (Operations a) 
Instance details

Defined in WGPU.Internal.RenderPass

Methods

(==) :: Operations a -> Operations a -> Bool #

(/=) :: Operations a -> Operations a -> Bool #

Show a => Show (Operations a) 
Instance details

Defined in WGPU.Internal.RenderPass

data RenderPassColorAttachment #

Describes a color attachment to a render pass.

Constructors

RenderPassColorAttachment 

Fields

data RenderPassDescriptor #

Describes the attachments of a render pass.

Constructors

RenderPassDescriptor 

Fields

data Range a #

Half open range. It includes the start value but not the end value.

Constructors

Range 

Fields

Instances

Instances details
Eq a => Eq (Range a) 
Instance details

Defined in WGPU.Internal.RenderPass

Methods

(==) :: Range a -> Range a -> Bool #

(/=) :: Range a -> Range a -> Bool #

Show a => Show (Range a) 
Instance details

Defined in WGPU.Internal.RenderPass

Methods

showsPrec :: Int -> Range a -> ShowS #

show :: Range a -> String #

showList :: [Range a] -> ShowS #

createCommandEncoder #

Arguments

:: Device

Device for which to create the command encoder.

-> Text

Debug label for the command encoder.

-> IO CommandEncoder

IO action that returns the command encoder.

Create an empty command encoder.

commandEncoderFinish #

Arguments

:: CommandEncoder

Command encoder to finish.

-> Text

Debugging label for the command buffer.

-> IO CommandBuffer

IO action which returns the command buffer.

Finish encoding commands, returning a command buffer.

beginRenderPass #

Arguments

:: CommandEncoder

CommandEncoder to contain the render pass.

-> RenderPassDescriptor

Description of the render pass.

-> IO RenderPassEncoder

IO action which returns the render pass encoder.

Begins recording of a render pass.

renderPassSetPipeline #

Arguments

:: RenderPassEncoder

Render pass encoder on which to act.

-> RenderPipeline

Render pipeline to set active.

-> IO ()

IO action which sets the active render pipeline.

Sets the active render pipeline.

Subsequent draw calls will exhibit the behaviour defined by the pipeline.

renderPassDraw #

Arguments

:: RenderPassEncoder

Render pass encoder on which to act.

-> Range Word32

Range of vertices to draw.

-> Range Word32

Range of instances to draw.

-> IO ()

IO action which stores the draw command.

Draws primitives from the active vertex buffers.

endRenderPass #

Arguments

:: RenderPassEncoder

Render pass encoder on which to finish recording.

-> IO ()

IO action that finishes recording.

Finish recording of a render pass.

Queue

data Queue #

Instances

Instances details
Eq Queue 
Instance details

Defined in WGPU.Internal.Queue

Methods

(==) :: Queue -> Queue -> Bool #

(/=) :: Queue -> Queue -> Bool #

Show Queue 
Instance details

Defined in WGPU.Internal.Queue

Methods

showsPrec :: Int -> Queue -> ShowS #

show :: Queue -> String #

showList :: [Queue] -> ShowS #

ToRaw Queue WGPUQueue 
Instance details

Defined in WGPU.Internal.Queue

Methods

raw :: Queue -> ContT c IO WGPUQueue #

getQueue :: Device -> IO Queue #

Get the queue for a device.

queueSubmit :: Queue -> Vector CommandBuffer -> IO () #

Submit a list of command buffers to a device queue.

Version

data Version #

Version of WGPU native.

Constructors

Version 

Fields

Instances

Instances details
Eq Version 
Instance details

Defined in WGPU.Internal.Instance

Methods

(==) :: Version -> Version -> Bool #

(/=) :: Version -> Version -> Bool #

Show Version 
Instance details

Defined in WGPU.Internal.Instance

getVersion :: Instance -> IO Version #

Return the exact version of the WGPU native instance.

versionToText :: Version -> Text #

Convert a Version value to a text string.

>>> versionToText (Version 0 9 2 2)
"v0.9.2.2"

Logging

data LogLevel #

Logging level.

Constructors

Trace 
Debug 
Info 
Warn 
Error 

Instances

Instances details
Eq LogLevel 
Instance details

Defined in WGPU.Internal.Instance

Show LogLevel 
Instance details

Defined in WGPU.Internal.Instance

type LogCallback = LogLevel -> Text -> IO () #

Logging callback function.

setLogLevel :: Instance -> LogLevel -> IO () #

Set the current logging level for the instance.

logStdout :: LogLevel -> Text -> IO () #

A logging function which prints to stdout.

This logging function can be supplied to withInstance to print logging messages to stdout for debugging purposes.

logLevelToText :: LogLevel -> Text #

Convert a LogLevel to a text string.

Multipurpose

Extras

Strict Maybe

data SMaybe a #

Strict version of the Maybe type.

Constructors

SNothing 
SJust !a 

Instances

Instances details
Eq a => Eq (SMaybe a) 
Instance details

Defined in WGPU.Internal.SMaybe

Methods

(==) :: SMaybe a -> SMaybe a -> Bool #

(/=) :: SMaybe a -> SMaybe a -> Bool #

Show a => Show (SMaybe a) 
Instance details

Defined in WGPU.Internal.SMaybe

Methods

showsPrec :: Int -> SMaybe a -> ShowS #

show :: SMaybe a -> String #

showList :: [SMaybe a] -> ShowS #