Class GraphicsDevice
- Namespace
- Pie
- Assembly
- Pie.dll
A Pie Graphics Device provides all the rendering functions for a given physical graphics device.
public abstract class GraphicsDevice : IDisposable
- Inheritance
-
GraphicsDevice
- Implements
- Inherited Members
Properties
Adapter
The GraphicsAdapter this device is running on.
public abstract GraphicsAdapter Adapter { get; }
Property Value
- GraphicsAdapter
- A Pie Graphics Device provides all the rendering functions for a given physical graphics device.
Api
Get the GraphicsApi this device is using.
public abstract GraphicsApi Api { get; }
Property Value
- GraphicsApi
- A Pie Graphics Device provides all the rendering functions for a given physical graphics device.
Scissor
Get or set the scissor rectangle of this device.
public abstract Rectangle Scissor { get; set; }
Property Value
- Rectangle
- A Pie Graphics Device provides all the rendering functions for a given physical graphics device.
Swapchain
Get the Swapchain of this device.
public abstract Swapchain Swapchain { get; }
Property Value
- Swapchain
- A Pie Graphics Device provides all the rendering functions for a given physical graphics device.
Viewport
Get or set the viewport of this device.
public abstract Rectangle Viewport { get; set; }
Property Value
- Rectangle
- A Pie Graphics Device provides all the rendering functions for a given physical graphics device.
Methods
ClearColorBuffer(Color)
Clears the set Framebuffer's color texture with the given color and flags. If no framebuffer is set, this clears the back buffer.
public abstract void ClearColorBuffer(Color color)
Parameters
color
ColorThe color to clear with.
ClearColorBuffer(Vector4)
Clears the set Framebuffer's color texture with the given normalized color and flags. If no framebuffer is set, this clears the back buffer.
public abstract void ClearColorBuffer(Vector4 color)
Parameters
color
Vector4The color to clear with. This value should be normalized between 0-1.
ClearColorBuffer(float, float, float, float)
Clears the set Framebuffer's color texture with the given normalized color and flags. If no framebuffer is set, this clears the back buffer.
public abstract void ClearColorBuffer(float r, float g, float b, float a)
Parameters
r
floatThe red channel, normalized between 0-1.
g
floatThe green channel, normalized between 0-1.
b
floatThe blue channel, normalized between 0-1.
a
floatThe alpha channel, normalized between 0-1.
ClearDepthStencilBuffer(ClearFlags, float, byte)
Clears the set Framebuffer's depth stencil texture with the given flags. If no framebuffer is set, this clears the back buffer.
public abstract void ClearDepthStencilBuffer(ClearFlags flags, float depth, byte stencil)
Parameters
flags
ClearFlagsWhich part(s) of the depth-stencil buffer to clear.
depth
floatThe depth value to clear with.
stencil
byteThe stencil value to clear with.
CreateBlendState(BlendStateDescription)
Create a new blend state from the blend state description.
public abstract BlendState CreateBlendState(BlendStateDescription description)
Parameters
description
BlendStateDescriptionThe blend state description to create from.
Returns
- BlendState
The created blend state.
CreateBuffer(BufferType, uint, bool)
Create an empty graphics buffer with the given size.
public abstract GraphicsBuffer CreateBuffer(BufferType bufferType, uint sizeInBytes, bool dynamic = false)
Parameters
bufferType
BufferTypeThe type of buffer that should be created.
sizeInBytes
uintThe size, in bytes, that this buffer should be.
dynamic
boolWhether or not this buffer is dynamic.
Returns
- GraphicsBuffer
The created graphics buffer.
CreateBuffer(BufferType, uint, nint, bool)
Create a graphics buffer with the given type and data.
public abstract GraphicsBuffer CreateBuffer(BufferType bufferType, uint sizeInBytes, nint data, bool dynamic = false)
Parameters
bufferType
BufferTypeThe type of buffer that should be created.
sizeInBytes
uintThe size, in bytes, that this buffer should be.
data
nintThe data pointer.
dynamic
boolWhether or not this buffer is dynamic.
Returns
- GraphicsBuffer
The created graphics buffer.
CreateBuffer(BufferType, uint, void*, bool)
Create a graphics buffer with the given type and data.
public abstract GraphicsBuffer CreateBuffer(BufferType bufferType, uint sizeInBytes, void* data, bool dynamic = false)
Parameters
bufferType
BufferTypeThe type of buffer that should be created.
sizeInBytes
uintThe size, in bytes, that this buffer should be.
data
void*The data pointer.
dynamic
boolWhether or not this buffer is dynamic.
Returns
- GraphicsBuffer
The created graphics buffer.
CreateBuffer<T>(BufferType, T, bool)
Create a graphics buffer with the given type and data.
public abstract GraphicsBuffer CreateBuffer<T>(BufferType bufferType, T data, bool dynamic = false) where T : unmanaged
Parameters
bufferType
BufferTypeThe type of buffer that should be created.
data
TThe data itself.
dynamic
boolWhether or not this buffer is dynamic.
Returns
- GraphicsBuffer
The created graphics buffer.
Type Parameters
T
Any unmanaged type.
CreateBuffer<T>(BufferType, T[], bool)
Create a graphics buffer with the given type and data.
public abstract GraphicsBuffer CreateBuffer<T>(BufferType bufferType, T[] data, bool dynamic = false) where T : unmanaged
Parameters
bufferType
BufferTypeThe type of buffer that should be created.
data
T[]The data itself.
dynamic
boolWhether or not this buffer is dynamic.
Returns
- GraphicsBuffer
The created graphics buffer.
Type Parameters
T
Any unmanaged type.
CreateD3D11(nint, Size, GraphicsDeviceOptions)
Create a Direct3D 11 graphics device.
public static GraphicsDevice CreateD3D11(nint hwnd, Size winSize, GraphicsDeviceOptions options = default)
Parameters
hwnd
nintThe HWND pointer.
winSize
SizeThe size of the window on startup.
options
GraphicsDeviceOptionsThe options for this graphics device, if any.
Returns
- GraphicsDevice
The created graphics device.
CreateDepthStencilState(DepthStencilStateDescription)
Create a new depth state from the depth state description.
public abstract DepthStencilState CreateDepthStencilState(DepthStencilStateDescription description)
Parameters
description
DepthStencilStateDescriptionThe depth state description to create from.
Returns
- DepthStencilState
The created depth state.
CreateFramebuffer(params FramebufferAttachment[])
Create a framebuffer, also known as a render target, that can be rendered to.
public abstract Framebuffer CreateFramebuffer(params FramebufferAttachment[] attachments)
Parameters
attachments
FramebufferAttachment[]The framebuffer attachments to attach.
Returns
- Framebuffer
The created framebuffer.
CreateInputLayout(params InputLayoutDescription[])
Create an input layout which can be used with a vertex buffer.
public abstract InputLayout CreateInputLayout(params InputLayoutDescription[] inputLayoutDescriptions)
Parameters
inputLayoutDescriptions
InputLayoutDescription[]The descriptions for this layout.
Returns
- InputLayout
The created input layout.
CreateNull(Size, GraphicsDeviceOptions)
Create a null graphics device.
public static GraphicsDevice CreateNull(Size winSize, GraphicsDeviceOptions options = default)
Parameters
winSize
SizeThe initial window size. (Use 0x0 if you're not using a window).
options
GraphicsDeviceOptionsThe options for this graphics device, if any.
Returns
- GraphicsDevice
The created graphics device.
CreateOpenGL(PieGlContext, Size, bool, GraphicsDeviceOptions)
Create an OpenGL 3.3 graphics device.
public static GraphicsDevice CreateOpenGL(PieGlContext context, Size winSize, bool isEs, GraphicsDeviceOptions options = default)
Parameters
context
PieGlContextThe GL context.
winSize
SizeThe size of the window on startup.
isEs
boolIf enabled, the device will behave like it has been created with an OpenGL ES 3.0 context.
options
GraphicsDeviceOptionsThe options for this graphics device, if any.
Returns
- GraphicsDevice
The created graphics device.
CreateRasterizerState(RasterizerStateDescription)
Create a new rasterizer state from the given description.
public abstract RasterizerState CreateRasterizerState(RasterizerStateDescription description)
Parameters
description
RasterizerStateDescriptionThe rasterizer state description.
Returns
- RasterizerState
The created rasterizer state.
CreateSamplerState(SamplerStateDescription)
Create a new sampler state from the sampler state description.
public abstract SamplerState CreateSamplerState(SamplerStateDescription description)
Parameters
description
SamplerStateDescriptionThe sampler state description to create from.
Returns
- SamplerState
The created sampler state.
CreateShader(ShaderAttachment[], SpecializationConstant[])
Create a shader with the given shader attachments.
public abstract Shader CreateShader(ShaderAttachment[] attachments, SpecializationConstant[] constants = null)
Parameters
attachments
ShaderAttachment[]The attachments for this shader.
constants
SpecializationConstant[]Any specialization constants to use in this shader.
Returns
- Shader
The created shader.
CreateTexture(TextureDescription)
Create an empty texture with the given description.
public abstract Texture CreateTexture(TextureDescription description)
Parameters
description
TextureDescriptionThe description of the texture.
Returns
- Texture
The created texture.
CreateTexture(TextureDescription, nint)
Create a texture with the given description and data.
public abstract Texture CreateTexture(TextureDescription description, nint data)
Parameters
description
TextureDescriptionThe description of the texture.
data
nintThe pointer to the data.
Returns
- Texture
The created texture.
CreateTexture(TextureDescription, void*)
Create a texture with the given description and data.
public abstract Texture CreateTexture(TextureDescription description, void* data)
Parameters
description
TextureDescriptionThe description of the texture.
data
void*The pointer to the data.
Returns
- Texture
The created texture.
CreateTexture<T>(TextureDescription, T[])
Create a texture with the given description and data.
public abstract Texture CreateTexture<T>(TextureDescription description, T[] data) where T : unmanaged
Parameters
description
TextureDescriptionThe description of the texture.
data
T[]The initial data of the texture.
Returns
- Texture
The created texture.
Type Parameters
T
The data type, typically byte or float. This type should match the Format in the
description
.
CreateTexture<T>(TextureDescription, T[][])
Create a texture with the given description and array data.
public abstract Texture CreateTexture<T>(TextureDescription description, T[][] data) where T : unmanaged
Parameters
description
TextureDescriptionThe description of the texture.
data
T[][]The initial array data of the texture.
Returns
- Texture
The created texture.
Type Parameters
T
The data type, typically byte or float. This type should match the Format in the
description
.
Remarks
As this takes in array data, this method should only be used with array textures and cubemaps.
Dispatch(uint, uint, uint)
Dispatch the current compute shader.
public abstract void Dispatch(uint groupCountX, uint groupCountY, uint groupCountZ)
Parameters
groupCountX
uintThe number of thread groups in X.
groupCountY
uintThe number of thread groups in Y.
groupCountZ
uintThe number of thread groups in Z.
Dispose()
Dispose of this graphics device.
public abstract void Dispose()
Draw(uint)
Draw to the screen with the given number of vertices.
public abstract void Draw(uint vertexCount)
Parameters
vertexCount
uintThe number of vertices.
Draw(uint, int)
Draw to the screen with the given number of vertices, at the given start vertex.
public abstract void Draw(uint vertexCount, int startVertex)
Parameters
vertexCount
uintThe number of vertices.
startVertex
intThe starting vertex of the vertices to draw.
DrawIndexed(uint)
Draw to the screen with the given indices count.
public abstract void DrawIndexed(uint indexCount)
Parameters
indexCount
uintThe number of indices.
DrawIndexed(uint, int)
Draw to the screen with the given indices count, at the given start index.
public abstract void DrawIndexed(uint indexCount, int startIndex)
Parameters
DrawIndexed(uint, int, int)
Draw to the screen with the given indices count, at the given start index, at the given base vertex.
public abstract void DrawIndexed(uint indexCount, int startIndex, int baseVertex)
Parameters
indexCount
uintThe number of indices.
startIndex
intThe starting index of the indices to draw.
baseVertex
intThe base vertex of the indices to draw.
DrawIndexedInstanced(uint, uint)
Draw with instancing, with the given indices count and number of instances.
public abstract void DrawIndexedInstanced(uint indexCount, uint instanceCount)
Parameters
Flush()
Force the device to execute all queued commands in the command buffer.
public abstract void Flush()
GenerateMipmaps(Texture)
Generate mipmaps for the given texture.
public abstract void GenerateMipmaps(Texture texture)
Parameters
texture
Texture
GetBestApiForPlatform()
Determine the best graphics API to use for the current platform.
public static GraphicsApi GetBestApiForPlatform()
Returns
MapResource(MappableResource, MapMode)
Map the given resource to CPU accessible memory.
public abstract MappedSubresource MapResource(MappableResource resource, MapMode mode)
Parameters
resource
MappableResourceThe resource to map.
mode
MapModeThe CPU access mode of this resource.
Returns
- MappedSubresource
The mapped resource's data.
Present(int)
Present to the screen.
public abstract void Present(int swapInterval)
Parameters
swapInterval
int- A Pie Graphics Device provides all the rendering functions for a given physical graphics device.
ResizeSwapchain(Size)
Resize the swapchain.
public abstract void ResizeSwapchain(Size newSize)
Parameters
newSize
SizeThe new size of the swapchain.
SetBlendState(BlendState)
Set the blend state that will be used on next draw.
public abstract void SetBlendState(BlendState state)
Parameters
state
BlendStateThe blend state to use.
SetDepthStencilState(DepthStencilState, int)
Set the depth-stencil state that will be used on next draw.
public abstract void SetDepthStencilState(DepthStencilState state, int stencilRef = 0)
Parameters
state
DepthStencilStateThe depth-stencil state to use.
stencilRef
intThe reference value to perform against when performing a stencil test.
SetFramebuffer(Framebuffer)
Set the framebuffer that will be used on next draw. Set as null to use the default back buffer.
public abstract void SetFramebuffer(Framebuffer framebuffer)
Parameters
framebuffer
FramebufferThe framebuffer to use.
SetIndexBuffer(GraphicsBuffer, IndexType)
Set the index buffer that will be used on next draw.
public abstract void SetIndexBuffer(GraphicsBuffer buffer, IndexType type)
Parameters
buffer
GraphicsBufferThe buffer to use.
type
IndexTypeThe type of indices.
SetInputLayout(InputLayout)
Sets the input layout what will be used on next draw.
public abstract void SetInputLayout(InputLayout layout)
Parameters
layout
InputLayoutThe input layout to use.
SetPrimitiveType(PrimitiveType)
Set the primitive type that will be used on next draw.
public abstract void SetPrimitiveType(PrimitiveType type)
Parameters
type
PrimitiveTypeThe primitive type to draw with.
SetRasterizerState(RasterizerState)
Set the rasterizer state that will be used on next draw.
public abstract void SetRasterizerState(RasterizerState state)
Parameters
state
RasterizerStateThe rasterizer state to use.
SetShader(Shader)
Set the shader that will be used on next draw.
public abstract void SetShader(Shader shader)
Parameters
shader
ShaderThe shader to use.
SetTexture(uint, Texture, SamplerState)
Set the texture that will be used on next draw.
public abstract void SetTexture(uint bindingSlot, Texture texture, SamplerState samplerState)
Parameters
bindingSlot
uintThe binding slot that this texture will be used in.
texture
TextureThe texture to use.
samplerState
SamplerStateThe sampler state to use for this texture.
SetUniformBuffer(uint, GraphicsBuffer)
Set the uniform buffer that will be used on next draw.
public abstract void SetUniformBuffer(uint bindingSlot, GraphicsBuffer buffer)
Parameters
bindingSlot
uintbuffer
GraphicsBufferThe buffer to use.
SetVertexBuffer(uint, GraphicsBuffer, uint)
Set the vertex buffer that will be used on next draw.
public abstract void SetVertexBuffer(uint slot, GraphicsBuffer buffer, uint stride)
Parameters
slot
uintThe input slot.
buffer
GraphicsBufferThe buffer to use.
stride
uintThe stride, in bytes, for the input layout.
UnmapResource(MappableResource)
Unmapped the given mapped resource.
public abstract void UnmapResource(MappableResource resource)
Parameters
resource
MappableResourceThe resource to unmap.
UpdateBuffer(GraphicsBuffer, uint, uint, nint)
Update the given buffer with the given data at the given offset in bytes.
public abstract void UpdateBuffer(GraphicsBuffer buffer, uint offsetInBytes, uint sizeInBytes, nint data)
Parameters
buffer
GraphicsBufferThe buffer to update.
offsetInBytes
uintThe offset in bytes, if any, where the data will be updated.
sizeInBytes
uintThe size in bytes of the data.
data
nintThe data pointer.
UpdateBuffer(GraphicsBuffer, uint, uint, void*)
Update the given buffer with the given data at the given offset in bytes.
public abstract void UpdateBuffer(GraphicsBuffer buffer, uint offsetInBytes, uint sizeInBytes, void* data)
Parameters
buffer
GraphicsBufferThe buffer to update.
offsetInBytes
uintThe offset in bytes, if any, where the data will be updated.
sizeInBytes
uintThe size in bytes of the data.
data
void*The data pointer.
UpdateBuffer<T>(GraphicsBuffer, uint, T)
Update the given buffer with the given data at the given offset in bytes.
public abstract void UpdateBuffer<T>(GraphicsBuffer buffer, uint offsetInBytes, T data) where T : unmanaged
Parameters
buffer
GraphicsBufferThe buffer to update.
offsetInBytes
uintThe offset in bytes, if any, where the data will be updated.
data
TThe data itself.
Type Parameters
T
Any unmanaged type.
UpdateBuffer<T>(GraphicsBuffer, uint, T[])
Update the given buffer with the given data at the given offset in bytes.
public abstract void UpdateBuffer<T>(GraphicsBuffer buffer, uint offsetInBytes, T[] data) where T : unmanaged
Parameters
buffer
GraphicsBufferThe buffer to update.
offsetInBytes
uintThe offset in bytes, if any, where the data will be updated.
data
T[]The data itself.
Type Parameters
T
Any unmanaged type.
UpdateTexture(Texture, int, int, int, int, int, int, int, int, nint)
Update a region of this texture with the given data.
public abstract void UpdateTexture(Texture texture, int mipLevel, int arrayIndex, int x, int y, int z, int width, int height, int depth, nint data)
Parameters
texture
TextureThe texture to update.
mipLevel
intThe mip level to update.
arrayIndex
intThe array index to update.
x
intThe x-offset in pixels of the data.
y
intThe y-offset in pixels of the data.
z
intThe z-offset in pixels of the data.
width
intThe width in pixels of the data.
height
intThe height in pixels of the data.
depth
intThe depth in pixels of the texture.
data
nintThe data pointer.
UpdateTexture(Texture, int, int, int, int, int, int, int, int, void*)
Update a region of this texture with the given data.
public abstract void UpdateTexture(Texture texture, int mipLevel, int arrayIndex, int x, int y, int z, int width, int height, int depth, void* data)
Parameters
texture
TextureThe texture to update.
mipLevel
intThe mip level to update.
arrayIndex
intThe array index to update.
x
intThe x-offset in pixels of the data.
y
intThe y-offset in pixels of the data.
z
intThe z-offset in pixels of the data.
width
intThe width in pixels of the data.
height
intThe height in pixels of the data.
depth
intThe depth in pixels of the texture.
data
void*The data pointer.
UpdateTexture<T>(Texture, int, int, int, int, int, int, int, int, T[])
Update a region of this texture with the given data.
public abstract void UpdateTexture<T>(Texture texture, int mipLevel, int arrayIndex, int x, int y, int z, int width, int height, int depth, T[] data) where T : unmanaged
Parameters
texture
TextureThe texture to update.
mipLevel
intThe mip level to update.
arrayIndex
intThe array index to update.
x
intThe x-offset in pixels of the data.
y
intThe y-offset in pixels of the data.
z
intThe z-offset in pixels of the data.
width
intThe width in pixels of the data.
height
intThe height in pixels of the data.
depth
intThe depth in pixels of the texture.
data
T[]The data itself.
Type Parameters
T
The data type, typically byte or float. This type should match the Format in the texture's TextureDescription.