wgpu-hs-0.4.0.0: WGPU
Safe HaskellNone
LanguageHaskell2010

WGPU.BoneYard.SimpleSDL

Description

This is a kind of skeleton for a very simple SDL app. It is intended for bootstrapping development. A common use case is when you want a window to draw in with everything configured. This provides a version of that functionality that can later be replaced or refined (easily) by the app developer if necessary.

Synopsis

Swap Chain

Types

data SwapChainState Source #

Contains mutable state to manage the swap chain.

Functions

withSwapChain :: forall r m a. (HasDevice r m, HasSurface r m, HasAdapter r m, Has Window r, Has SwapChainState r) => ReaderT (SwapChain, r) m a -> m a Source #

Provide a ReaderT with a properly-configured SwapChain.

Buffers

Types

data Buffers Source #

Container for buffers (map of BufferName to Buffer).

Functions

emptyBuffers :: MonadResource m => m Buffers Source #

Create an empty Buffers collection.

createBuffer Source #

Arguments

:: (MonadIO m, HasDevice r m, Has Buffers r) 
=> BufferName

Name of the buffer.

-> ByteSize

Size of the buffer in bytes.

-> BufferUsage

Usage of the buffer.

-> m Buffer

Action which creates the buffer.

Create an uninitialized Buffer.

createBufferInit Source #

Arguments

:: (MonadIO m, HasDevice r m, Has Buffers r, ReadableMemoryBuffer a) 
=> BufferName

Name of the buffer.

-> BufferUsage

Usage of the buffer.

-> a

Contents of the buffer.

-> m Buffer

Action which creates the buffer.

Create a Buffer with specified content, storing it in the Buffers map.

getBuffer :: (MonadIO m, Has Buffers r, MonadReader r m, MonadThrow m) => BufferName -> m Buffer Source #

Fetch a buffer that was previously created.

If the buffer pipeline is not available, this function throws an exception of type AppException.

Textures

Types

data Textures Source #

Container for textures (map of TextureName to Texture).

Functions

emptyTextures :: MonadResource m => m Textures Source #

Create an empty Textures collection.

createTexture Source #

Arguments

:: (MonadIO m, HasDevice r m, Has Textures r) 
=> TextureName

Name of the texture to create.

-> Extent3D

Extent / size of the texture.

-> Word32

Mip level count.

-> Word32

Sample count.

-> TextureDimension

Dimension (1D, 2D, 3D) of the texture.

-> TextureFormat

Format of an element of the texture.

-> TextureUsage

Usages of the texture.

-> m Texture

Action to create the texture.

Create a Texture and add it to the Textures map.

getTexture Source #

Arguments

:: (MonadIO m, Has Textures r, MonadReader r m, MonadThrow m) 
=> TextureName

Name of the texture to fetch.

-> m Texture

Action which fetches the texture.

Fetch a texture that was previously created using createTexture.

If the texture is not available, this function throws an exception of type AppException.

Bind Groups

Types

data BindGroups Source #

Container for bind groups that contains a map of bind groups.

Functions

emptyBindGroups :: MonadResource m => m BindGroups Source #

Create an empty BindGroups collection.

createBindGroup :: (MonadIO m, HasDevice r m, Has BindGroups r) => BindGroupName -> BindGroupDescriptor -> m BindGroup Source #

Create a new BindGroup, adding it to the BindGroups collection.

getBindGroup :: (MonadIO m, Has BindGroups r, MonadReader r m, MonadThrow m) => BindGroupName -> m BindGroup Source #

Fetch a BindGroup that was previously created using createBindGroup.

If the bind group is not available, this function throws an exception of type AppException.

Render Pipelines

Types

data RenderPipelines Source #

Container for mutable state that contains a map of render pipelines.

Functions

createRenderPipeline Source #

Arguments

:: (MonadIO m, HasDevice r m, Has RenderPipelines r) 
=> RenderPipelineName

Name of the render pipeline.

-> RenderPipelineDescriptor

Descriptor of the render pipeline.

-> m RenderPipeline

The created render pipeline.

Create a RenderPipeline, storing it in the RenderPipelines map.

A RenderPipeline created this way can be fetched using getRenderPipeline. This calls createRenderPipeline under the hood.

getRenderPipeline Source #

Arguments

:: (Has RenderPipelines r, MonadReader r m, MonadIO m, MonadThrow m) 
=> RenderPipelineName

Name of the render pipeline to fetch.

-> m RenderPipeline

The render pipeline.

Fetch a render pipeline that was previously created using createRenderPipeline.

If the render pipeline is not available, this function throws an exception of type AppException.

Shaders

Types

data Shaders Source #

Container for mutable state that contains a map of shaders.

Functions

emptyShaders :: MonadResource m => m Shaders Source #

Create an empty Shaders.

compileWGSL Source #

Arguments

:: (Has Device r, Has Shaders r, MonadReader r m, MonadResource m) 
=> ShaderName

Name of the shader.

-> WGSL

Shader source code.

-> m ShaderModule

Action that returns the compiled shader module, after adding it to the Shaders map.

Compile a WGSL shader, adding it to the Shaders map, and returning the compiled ShaderModule.

compileWGSL_ Source #

Arguments

:: (Has Device r, Has Shaders r, MonadReader r m, MonadResource m) 
=> ShaderName

Name of the shader.

-> WGSL

Shader source code.

-> m ()

Action that compiles the shader and adds it to the Shaders map.

Compile a WGSL shader, adding it to the Shaders map.

getShader Source #

Arguments

:: (Has Shaders r, MonadReader r m, MonadIO m, MonadThrow m) 
=> ShaderName

Name of the shader to fetch.

-> m ShaderModule

The shader module.

Fetch a shader that was previously compiled.

If the shader is not available, this function throws an exception of type AppException.

Resources

Types

data Params Source #

Parameters for initialization.

Constructors

Params 

Fields

data Resources Source #

Resources for the app.

Constructors

Resources 

Instances

Instances details
Generic Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Associated Types

type Rep Resources :: Type -> Type #

Has Window Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Has Queue Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Has Device Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Has Adapter Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Has Surface Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Has Instance Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

type Rep Resources Source # 
Instance details

Defined in WGPU.BoneYard.SimpleSDL

Functions

loadResources Source #

Arguments

:: forall m. (MonadResource m, MonadThrow m) 
=> Params

Initialization parameters.

-> m Resources

Created application resources.

Load the resources for an application.

This creates: - Instance, - SDL Window (which is shown) - Surface for the SDL window - Adapter - Device - Queue

Exceptions

data AppException Source #

Exceptions from SimpleSDL.

Constructors

AdapterRequestFailed

Requesting an adapter failed.

DeviceRequestFailed

Requesting a device failed.

UnknownShaderName ShaderName

Requesting a shader failed.

UnknownRenderPipelineName RenderPipelineName

Requesting a render pipeline failed.

UnknownBufferName BufferName

Requesting a buffer failed.

UnknownTextureName TextureName

Requesting a texture failed.

UnknownBindGroupName BindGroupName

Requesting a bind group failed.