Class GraphicsContext
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders.
Inheritance
Inherited Members
Namespace: Evergine.Common.Graphics
Assembly: Evergine.Common.dll
Syntax
public abstract class GraphicsContext : IDisposable, IGetNativePointers
Fields
TimestampFrequency
the rate at which the GPU timestamp counter increments.
Declaration
public ulong TimestampFrequency
Field Value
Type | Description |
---|---|
ulong |
Properties
AvailablePointerKeys
Gets a list of all available keys to obtain native pointers.
Declaration
public virtual IEnumerable<string> AvailablePointerKeys { get; }
Property Value
Type | Description |
---|---|
IEnumerable<string> |
BackendType
Gets the backend type (DirectX, OpenGL ...)
Declaration
public abstract GraphicsBackend BackendType { get; }
Property Value
Type | Description |
---|---|
GraphicsBackend |
Capabilities
Gets the capabilities of this graphics context.
Declaration
public abstract GraphicsContextCapabilities Capabilities { get; }
Property Value
Type | Description |
---|---|
GraphicsContextCapabilities |
DefaultBufferUploaderSize
Gets or sets a value indicating the size in bytes of the buffer uploader.
Declaration
public ulong DefaultBufferUploaderSize { get; set; }
Property Value
Type | Description |
---|---|
ulong |
Remarks
To upload buffers and Texture efficiently to dedicate GPU memory first a big buffer is created on shared GPU memory, before to use this buffers and texture, a parallel copyqueue execute all the copy command at once. The initial size of this uploaders is defined by this property, The Default value is (256 * 1024 * 1024).
DefaultSampler
Gets the default Sampler state used when there is a missing sampler in a resource set.
Declaration
public SamplerState DefaultSampler { get; }
Property Value
Type | Description |
---|---|
SamplerState |
DefaultTextureUploaderSize
Gets or sets a value indicating the size in bytes of the texture uploader.
Declaration
public ulong DefaultTextureUploaderSize { get; set; }
Property Value
Type | Description |
---|---|
ulong |
Remarks
To upload buffers and Texture efficiently to dedicate GPU memory first a big buffer is created on shared GPU memory, before to use this buffers and texture, a parallel copyqueue execute all the copy command at once. The initial size of this uploaders is defined by this property, The Default value is (256 * 1024 * 1024).
Factory
Gets or sets the resource factory.
Declaration
public ResourceFactory Factory { get; protected set; }
Property Value
Type | Description |
---|---|
ResourceFactory |
IsValidationLayerEnabled
Gets a value indicating whether validationlayer is enable or disable.
Declaration
public bool IsValidationLayerEnabled { get; }
Property Value
Type | Description |
---|---|
bool |
NativeDevicePointer
Gets the native device pointer.
Declaration
public abstract IntPtr NativeDevicePointer { get; }
Property Value
Type | Description |
---|---|
IntPtr |
ValidationLayer
Gets the graphics validation layer pointer.
Declaration
public ValidationLayer ValidationLayer { get; }
Property Value
Type | Description |
---|---|
ValidationLayer |
Methods
CreateDefaultSampler()
Create the default sampler.
Declaration
protected virtual void CreateDefaultSampler()
CreateDevice(ValidationLayer)
Initialize the graphics context to be used in a compute shader.
Declaration
public void CreateDevice(ValidationLayer validationLayer = null)
Parameters
Type | Name | Description |
---|---|---|
ValidationLayer | validationLayer | Whether the validation layer is active or not. |
CreateDeviceInternal()
Initialize the graphics context to be used in a compute shader.
Declaration
public abstract void CreateDeviceInternal()
CreateSwapChain(SwapChainDescription)
Initialize the swapchain.
Declaration
public abstract SwapChain CreateSwapChain(SwapChainDescription description)
Parameters
Type | Name | Description |
---|---|---|
SwapChainDescription | description | The swapchain descriptor. |
Returns
Type | Description |
---|---|
SwapChain | Created Swapchain. |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
Declaration
protected abstract void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
|
GenerateTextureMipmapping(Texture)
Generate mipmapping texture levels.
Declaration
public abstract bool GenerateTextureMipmapping(Texture texture)
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | The texture to generate mipmapping. |
Returns
Type | Description |
---|---|
bool | True if the mipmapping has been generated. |
GetNativePointer(string, out IntPtr)
Obtain a native pointer of this graphics context using the given key.
Declaration
public virtual bool GetNativePointer(string pointerKey, out IntPtr nativePointer)
Parameters
Type | Name | Description |
---|---|---|
string | pointerKey | The pointer key. |
IntPtr | nativePointer | The native pointer. |
Returns
Type | Description |
---|---|
bool | True if there are an available pointer with this key. |
InternalUpdateBufferData(Buffer, IntPtr, uint, uint)
Fill the buffer from a pointer.
Declaration
protected abstract void InternalUpdateBufferData(Buffer buffer, IntPtr source, uint sourceSizeInBytes, uint destinationOffsetInBytes = 0)
Parameters
Type | Name | Description |
---|---|---|
Buffer | buffer | Buffer instance. |
IntPtr | source | The data pointer. |
uint | sourceSizeInBytes | The size in bytes. |
uint | destinationOffsetInBytes | The offset in bytes. |
MapMemory(GraphicsResource, MapMode, uint)
Declaration
public abstract MappedResource MapMemory(GraphicsResource resource, MapMode mode, uint subResource = 0)
Parameters
Type | Name | Description |
---|---|---|
GraphicsResource | resource | The graphics resource to map. |
MapMode | mode | The MapMode used to map the resource. |
uint | subResource | The subresource to map. Subresources are indexed first by mip slice and then by array layer. Only for Textures. |
Returns
Type | Description |
---|---|
MappedResource | A MappedResource structure describing the mapped data region. |
ShaderCompile(string, string, ShaderStages)
Converts the shader source into bytecode.
Declaration
public CompilationResult ShaderCompile(string shaderSource, string entryPoint, ShaderStages stage)
Parameters
Type | Name | Description |
---|---|---|
string | shaderSource | The shader source text. |
string | entryPoint | The entrypoint function name. |
ShaderStages | stage | The shader stage, ShaderStages. |
Returns
Type | Description |
---|---|
CompilationResult | The shader bytecodes. |
ShaderCompile(string, string, ShaderStages, CompilerParameters)
Converts the shader source into bytecode.
Declaration
public abstract CompilationResult ShaderCompile(string shaderSource, string entryPoint, ShaderStages stage, CompilerParameters parameters)
Parameters
Type | Name | Description |
---|---|---|
string | shaderSource | The shader source text. |
string | entryPoint | The entrypoint function name. |
ShaderStages | stage | The shader stage, ShaderStages. |
CompilerParameters | parameters | The compiler parameters. |
Returns
Type | Description |
---|---|
CompilationResult | The shader bytecodes. |
SyncUpcopyQueue()
Sync the current buffer data in the copyQueue. Internal function used in the uploadbuffer strategy.
Declaration
public virtual void SyncUpcopyQueue()
UnmapMemory(GraphicsResource, uint)
Declaration
public abstract void UnmapMemory(GraphicsResource resource, uint subResource = 0)
Parameters
Type | Name | Description |
---|---|---|
GraphicsResource | resource | The graphics resource to map. |
uint | subResource | The subresource to map. Subresources are indexed first by mip slice and then by array layer. Only for Textures. |
UpdateBufferData(Buffer, IntPtr, uint, uint)
Fill the buffer from a pointer.
Declaration
public void UpdateBufferData(Buffer buffer, IntPtr source, uint sourceSizeInBytes, uint destinationOffsetInBytes = 0)
Parameters
Type | Name | Description |
---|---|---|
Buffer | buffer | Buffer instance. |
IntPtr | source | The data pointer. |
uint | sourceSizeInBytes | The size in bytes. |
uint | destinationOffsetInBytes | The offset in bytes. |
UpdateBufferData<T>(Buffer, ref T, uint)
Fill the buffer with a data array.
Declaration
public void UpdateBufferData<T>(Buffer buffer, ref T data, uint destinationOffsetInBytes = 0) where T : struct
Parameters
Type | Name | Description |
---|---|---|
Buffer | buffer | Buffer instance. |
T | data | The data array. |
uint | destinationOffsetInBytes | The destination offset. |
Type Parameters
Name | Description |
---|---|
T | The data type. |
UpdateBufferData<T>(Buffer, T[], uint)
Fill the buffer with a data array.
Declaration
public void UpdateBufferData<T>(Buffer buffer, T[] data, uint destinationOffsetInBytes = 0) where T : struct
Parameters
Type | Name | Description |
---|---|---|
Buffer | buffer | Buffer instance. |
T[] | data | The data array. |
uint | destinationOffsetInBytes | The destination offset. |
Type Parameters
Name | Description |
---|---|
T | The data type. |
UpdateBufferData<T>(Buffer, T[], uint, uint)
Fill the buffer with a data array.
Declaration
public void UpdateBufferData<T>(Buffer buffer, T[] data, uint count, uint destinationOffsetInBytes = 0) where T : struct
Parameters
Type | Name | Description |
---|---|---|
Buffer | buffer | Buffer instance. |
T[] | data | The data array. |
uint | count | The number of elements. |
uint | destinationOffsetInBytes | The destination offset. |
Type Parameters
Name | Description |
---|---|
T | The data type. |
UpdateTextureData(Texture, IntPtr, uint, uint)
Fill the buffer from a pointer.
Declaration
public abstract void UpdateTextureData(Texture texture, IntPtr source, uint sourceSizeInBytes, uint subResource)
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | Texture instance. |
IntPtr | source | The data pointer. |
uint | sourceSizeInBytes | The size in bytes. |
uint | subResource | The subResource index. |
UpdateTextureData<T>(Texture, ref T, uint)
Fill the buffer with a data array.
Declaration
public void UpdateTextureData<T>(Texture texture, ref T data, uint destinationOffsetInBytes = 0) where T : struct
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | Texture instance. |
T | data | The data array. |
uint | destinationOffsetInBytes | The destination offset. |
Type Parameters
Name | Description |
---|---|
T | The data type. |
UpdateTextureData<T>(Texture, T[], uint)
Fill the buffer with a data array.
Declaration
public void UpdateTextureData<T>(Texture texture, T[] data, uint destinationOffsetInBytes = 0) where T : struct
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | Texture instance. |
T[] | data | The data array. |
uint | destinationOffsetInBytes | The destination offset. |
Type Parameters
Name | Description |
---|---|
T | The data type. |
UpdateTextureData<T>(Texture, T[], uint, uint)
Fill the buffer with a data array.
Declaration
public void UpdateTextureData<T>(Texture texture, T[] data, uint count, uint destinationOffsetInBytes = 0) where T : struct
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | Texture instance. |
T[] | data | The data array. |
uint | count | The number of elements. |
uint | destinationOffsetInBytes | The destination offset. |
Type Parameters
Name | Description |
---|---|
T | The data type. |