Search Results for

    Show / Hide Table of Contents

    Class GraphicsContext

    Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and generates shaders.

    Inheritance
    object
    GraphicsContext
    DX11GraphicsContext
    DX12GraphicsContext
    MTLGraphicsContext
    GLGraphicsContext
    VKGraphicsContext
    WGPUGraphicsContext
    Implements
    IGetNativePointers
    Namespace: Evergine.Common.Graphics
    Assembly: Evergine.Common.dll
    Syntax
    public abstract class GraphicsContext : 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, etc.)

    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 textures efficiently to dedicated GPU memory, first a large buffer is created in shared GPU memory. Before using these buffers and textures, a parallel copy queue executes all the copy commands at once. The initial size of these uploaders is defined by this property. The default value is (256 * 1024 * 1024).

    DefaultSampler

    Gets the default Sampler state used when a sampler is missing 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 textures efficiently to dedicated GPU memory, first a big buffer is created in shared GPU memory. Before using these buffers and textures, a parallel copy queue executes all the copy commands at once. The initial size of these 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 the validation layer is enabled or disabled.

    Declaration
    public bool IsValidationLayerEnabled { get; }
    Property Value
    Type Description
    bool

    NativeDevicePointer

    Gets the native device pointer.

    Declaration
    public abstract nint NativeDevicePointer { get; }
    Property Value
    Type Description
    nint

    ValidationLayer

    Gets the graphics validation layer pointer.

    Declaration
    public ValidationLayer ValidationLayer { get; }
    Property Value
    Type Description
    ValidationLayer

    Methods

    CreateDefaultSampler()

    Creates the default sampler.

    Declaration
    protected virtual void CreateDefaultSampler()

    CreateDevice(ValidationLayer)

    Initializes the graphics context to be used in a compute shader.

    Declaration
    public void CreateDevice(ValidationLayer validationLayer = null)
    Parameters
    Type Name Description
    ValidationLayer validationLayer

    Indicates whether the validation layer is active or not.

    CreateDeviceInternal()

    Initializes the graphics context to be used in a compute shader.

    Declaration
    public abstract void CreateDeviceInternal()

    CreateSwapChain(SwapChainDescription)

    Initializes the swap chain.

    Declaration
    public abstract SwapChain CreateSwapChain(SwapChainDescription description)
    Parameters
    Type Name Description
    SwapChainDescription description

    The swap chain descriptor.

    Returns
    Type Description
    SwapChain

    Created Swap chain.

    Dispose()

    Performs tasks defined by the application 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

    true to release both managed and unmanaged resources; false to release only unmanaged resources.

    GenerateTextureMipmapping(Texture)

    Generates mipmapping texture levels.

    Declaration
    public abstract bool GenerateTextureMipmapping(Texture texture)
    Parameters
    Type Name Description
    Texture texture

    The texture for which mipmapping is generated.

    Returns
    Type Description
    bool

    True if the mipmapping has been generated.

    GetNativePointer(string, out nint)

    Obtains a native pointer for this graphics context using the given key.

    Declaration
    public virtual bool GetNativePointer(string pointerKey, out nint nativePointer)
    Parameters
    Type Name Description
    string pointerKey

    The pointer key.

    nint nativePointer

    The native pointer.

    Returns
    Type Description
    bool

    True if there is an available pointer with this key.

    InternalUpdateBufferData(Buffer, nint, uint, uint)

    Fills the buffer from a pointer.

    Declaration
    protected abstract void InternalUpdateBufferData(Buffer buffer, nint source, uint sourceSizeInBytes, uint destinationOffsetInBytes = 0)
    Parameters
    Type Name Description
    Buffer buffer

    Buffer instance.

    nint source

    The data pointer.

    uint sourceSizeInBytes

    The size in bytes.

    uint destinationOffsetInBytes

    The offset in bytes.

    MapMemory(GraphicsResource, MapMode, uint)

    Maps a Buffer or Texture to a CPU-accessible data region.

    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. Applies only to 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 entry point function name.

    ShaderStages stage

    The shader stage, ShaderStages.

    Returns
    Type Description
    CompilationResult

    The shader bytecode.

    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 entry point function name.

    ShaderStages stage

    The shader stage, ShaderStages.

    CompilerParameters parameters

    The compiler parameters.

    Returns
    Type Description
    CompilationResult

    The shader bytecode.

    SyncUpcopyQueue()

    Syncs the current buffer data in the copyQueue. Internal function used in the UploadBuffer strategy.

    Declaration
    public virtual void SyncUpcopyQueue()

    UnmapMemory(GraphicsResource, uint)

    Invalidates a previously-mapped data region for the given Buffer or Texture.

    Declaration
    public abstract void UnmapMemory(GraphicsResource resource, uint subResource = 0)
    Parameters
    Type Name Description
    GraphicsResource resource

    The graphics resource to unmap.

    uint subResource

    The subresource to unmap. Subresources are indexed first by mip slice and then by array layer. Only for Textures.

    UpdateBufferData(Buffer, nint, uint, uint)

    Fills the buffer from a pointer.

    Declaration
    public void UpdateBufferData(Buffer buffer, nint source, uint sourceSizeInBytes, uint destinationOffsetInBytes = 0)
    Parameters
    Type Name Description
    Buffer buffer

    Buffer instance.

    nint source

    The data pointer.

    uint sourceSizeInBytes

    The size in bytes.

    uint destinationOffsetInBytes

    The offset in bytes.

    UpdateBufferData<T>(Buffer, ref T, uint)

    Fills 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)

    Fills 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)

    Fills 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

    The buffer instance.

    T[] data

    The data array.

    uint count

    The number of elements.

    uint destinationOffsetInBytes

    The destination offset in bytes.

    Type Parameters
    Name Description
    T

    The data type.

    UpdateTextureData(Texture, nint, uint, uint)

    Fills the buffer from a pointer.

    Declaration
    public abstract void UpdateTextureData(Texture texture, nint source, uint sourceSizeInBytes, uint subResource)
    Parameters
    Type Name Description
    Texture texture

    Texture instance.

    nint source

    The data pointer.

    uint sourceSizeInBytes

    The size in bytes.

    uint subResource

    The sub-resource index.

    UpdateTextureData<T>(Texture, ref T, uint)

    Fills 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

    The 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)

    Fills 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

    The texture instance.

    T[] data

    The data array.

    uint destinationOffsetInBytes

    The destination offset in bytes.

    Type Parameters
    Name Description
    T

    The data type.

    UpdateTextureData<T>(Texture, T[], uint, uint)

    Fills 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.

    Implements

    IGetNativePointers

    Extension Methods

    ReflectionHelper.GetMemberAssembly(object)
    ReflectionHelper.GetTypeName(object)
    In this article
    Back to top
    Generated by DocFX