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
colorColorThe 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
colorVector4The 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
rfloatThe red channel, normalized between 0-1.
gfloatThe green channel, normalized between 0-1.
bfloatThe blue channel, normalized between 0-1.
afloatThe 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
flagsClearFlagsWhich part(s) of the depth-stencil buffer to clear.
depthfloatThe depth value to clear with.
stencilbyteThe stencil value to clear with.
CreateBlendState(BlendStateDescription)
Create a new blend state from the blend state description.
public abstract BlendState CreateBlendState(BlendStateDescription description)
Parameters
descriptionBlendStateDescriptionThe 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
bufferTypeBufferTypeThe type of buffer that should be created.
sizeInBytesuintThe size, in bytes, that this buffer should be.
dynamicboolWhether 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
bufferTypeBufferTypeThe type of buffer that should be created.
sizeInBytesuintThe size, in bytes, that this buffer should be.
datanintThe data pointer.
dynamicboolWhether 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
bufferTypeBufferTypeThe type of buffer that should be created.
sizeInBytesuintThe size, in bytes, that this buffer should be.
datavoid*The data pointer.
dynamicboolWhether 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
bufferTypeBufferTypeThe type of buffer that should be created.
dataTThe data itself.
dynamicboolWhether or not this buffer is dynamic.
Returns
- GraphicsBuffer
The created graphics buffer.
Type Parameters
TAny 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
bufferTypeBufferTypeThe type of buffer that should be created.
dataT[]The data itself.
dynamicboolWhether or not this buffer is dynamic.
Returns
- GraphicsBuffer
The created graphics buffer.
Type Parameters
TAny unmanaged type.
CreateD3D11(nint, Size, GraphicsDeviceOptions)
Create a Direct3D 11 graphics device.
public static GraphicsDevice CreateD3D11(nint hwnd, Size winSize, GraphicsDeviceOptions options = default)
Parameters
hwndnintThe HWND pointer.
winSizeSizeThe size of the window on startup.
optionsGraphicsDeviceOptionsThe 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
descriptionDepthStencilStateDescriptionThe 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
attachmentsFramebufferAttachment[]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
inputLayoutDescriptionsInputLayoutDescription[]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
winSizeSizeThe initial window size. (Use 0x0 if you're not using a window).
optionsGraphicsDeviceOptionsThe 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
contextPieGlContextThe GL context.
winSizeSizeThe size of the window on startup.
isEsboolIf enabled, the device will behave like it has been created with an OpenGL ES 3.0 context.
optionsGraphicsDeviceOptionsThe 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
descriptionRasterizerStateDescriptionThe 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
descriptionSamplerStateDescriptionThe 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
attachmentsShaderAttachment[]The attachments for this shader.
constantsSpecializationConstant[]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
descriptionTextureDescriptionThe 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
descriptionTextureDescriptionThe description of the texture.
datanintThe 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
descriptionTextureDescriptionThe description of the texture.
datavoid*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
descriptionTextureDescriptionThe description of the texture.
dataT[]The initial data of the texture.
Returns
- Texture
The created texture.
Type Parameters
TThe 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
descriptionTextureDescriptionThe description of the texture.
dataT[][]The initial array data of the texture.
Returns
- Texture
The created texture.
Type Parameters
TThe 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
groupCountXuintThe number of thread groups in X.
groupCountYuintThe number of thread groups in Y.
groupCountZuintThe 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
vertexCountuintThe 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
vertexCountuintThe number of vertices.
startVertexintThe 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
indexCountuintThe 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
indexCountuintThe number of indices.
startIndexintThe starting index of the indices to draw.
baseVertexintThe 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
textureTexture
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
resourceMappableResourceThe resource to map.
modeMapModeThe 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
swapIntervalint- 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
newSizeSizeThe 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
stateBlendStateThe 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
stateDepthStencilStateThe depth-stencil state to use.
stencilRefintThe 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
framebufferFramebufferThe 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
bufferGraphicsBufferThe buffer to use.
typeIndexTypeThe type of indices.
SetInputLayout(InputLayout)
Sets the input layout what will be used on next draw.
public abstract void SetInputLayout(InputLayout layout)
Parameters
layoutInputLayoutThe input layout to use.
SetPrimitiveType(PrimitiveType)
Set the primitive type that will be used on next draw.
public abstract void SetPrimitiveType(PrimitiveType type)
Parameters
typePrimitiveTypeThe 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
stateRasterizerStateThe rasterizer state to use.
SetShader(Shader)
Set the shader that will be used on next draw.
public abstract void SetShader(Shader shader)
Parameters
shaderShaderThe 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
bindingSlotuintThe binding slot that this texture will be used in.
textureTextureThe texture to use.
samplerStateSamplerStateThe 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
bindingSlotuintbufferGraphicsBufferThe 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
slotuintThe input slot.
bufferGraphicsBufferThe buffer to use.
strideuintThe stride, in bytes, for the input layout.
UnmapResource(MappableResource)
Unmapped the given mapped resource.
public abstract void UnmapResource(MappableResource resource)
Parameters
resourceMappableResourceThe 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
bufferGraphicsBufferThe buffer to update.
offsetInBytesuintThe offset in bytes, if any, where the data will be updated.
sizeInBytesuintThe size in bytes of the data.
datanintThe 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
bufferGraphicsBufferThe buffer to update.
offsetInBytesuintThe offset in bytes, if any, where the data will be updated.
sizeInBytesuintThe size in bytes of the data.
datavoid*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
bufferGraphicsBufferThe buffer to update.
offsetInBytesuintThe offset in bytes, if any, where the data will be updated.
dataTThe data itself.
Type Parameters
TAny 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
bufferGraphicsBufferThe buffer to update.
offsetInBytesuintThe offset in bytes, if any, where the data will be updated.
dataT[]The data itself.
Type Parameters
TAny 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
textureTextureThe texture to update.
mipLevelintThe mip level to update.
arrayIndexintThe array index to update.
xintThe x-offset in pixels of the data.
yintThe y-offset in pixels of the data.
zintThe z-offset in pixels of the data.
widthintThe width in pixels of the data.
heightintThe height in pixels of the data.
depthintThe depth in pixels of the texture.
datanintThe 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
textureTextureThe texture to update.
mipLevelintThe mip level to update.
arrayIndexintThe array index to update.
xintThe x-offset in pixels of the data.
yintThe y-offset in pixels of the data.
zintThe z-offset in pixels of the data.
widthintThe width in pixels of the data.
heightintThe height in pixels of the data.
depthintThe depth in pixels of the texture.
datavoid*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
textureTextureThe texture to update.
mipLevelintThe mip level to update.
arrayIndexintThe array index to update.
xintThe x-offset in pixels of the data.
yintThe y-offset in pixels of the data.
zintThe z-offset in pixels of the data.
widthintThe width in pixels of the data.
heightintThe height in pixels of the data.
depthintThe depth in pixels of the texture.
dataT[]The data itself.
Type Parameters
TThe data type, typically byte or float. This type should match the Format in the texture's TextureDescription.