Class MTLGraphicsContext
Graphics context in Metal.
Implements
Inherited Members
Namespace: Evergine.Metal
Assembly: Evergine.Metal.dll
Syntax
public class MTLGraphicsContext : GraphicsContext, IGetNativePointers
Constructors
MTLGraphicsContext()
Initializes a new instance of the MTLGraphicsContext class.
Declaration
public MTLGraphicsContext()
Fields
SupportedFeatures
The set of supported features.
Declaration
public MTLFeatures SupportedFeatures
Field Value
| Type | Description |
|---|---|
| MTLFeatures |
device
The Metal device.
Declaration
public IMTLDevice device
Field Value
| Type | Description |
|---|---|
| IMTLDevice |
Properties
BackendType
Gets the backend type (DirectX, OpenGL, etc.)
Declaration
public override GraphicsBackend BackendType { get; }
Property Value
| Type | Description |
|---|---|
| GraphicsBackend |
Overrides
Capabilities
Gets the capabilities of this graphics context.
Declaration
public override GraphicsContextCapabilities Capabilities { get; }
Property Value
| Type | Description |
|---|---|
| GraphicsContextCapabilities |
Overrides
NativeDevicePointer
Gets the native device pointer.
Declaration
public override nint NativeDevicePointer { get; }
Property Value
| Type | Description |
|---|---|
| nint |
Overrides
captureManager
Gets the shared Metal capture manager.
Declaration
public MTLCaptureManager captureManager { get; }
Property Value
| Type | Description |
|---|---|
| MTLCaptureManager |
Methods
CreateDeviceInternal()
Initializes the graphics context to be used in a compute shader.
Declaration
public override void CreateDeviceInternal()
Overrides
CreateSwapChain(SwapChainDescription)
Initializes the swap chain.
Declaration
public override SwapChain CreateSwapChain(SwapChainDescription description)
Parameters
| Type | Name | Description |
|---|---|---|
| SwapChainDescription | description | The swap chain descriptor. |
Returns
| Type | Description |
|---|---|
| SwapChain | Created Swap chain. |
Overrides
Dispose(bool)
Releases unmanaged and optionally managed resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
|
Overrides
GenerateTextureMipmapping(Texture)
Generates mipmapping texture levels.
Declaration
public override 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. |
Overrides
InternalUpdateBufferData(Buffer, nint, uint, uint)
Fills the buffer from a pointer.
Declaration
protected override 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. |
Overrides
MapMemory(GraphicsResource, MapMode, uint)
Declaration
public override 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. |
Overrides
ShaderCompile(string, string, ShaderStages, CompilerParameters)
Converts the shader source into bytecode.
Declaration
public override 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. |
Overrides
StartCapture(string, string, bool)
Starts a capture of the graphics commands for debugging purposes.
Declaration
public string StartCapture(string outputDirectory = null, string captureName = null, bool appendTimestamp = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | outputDirectory | The directory where the capture file will be written. If null, /tmp is used. |
| string | captureName | The capture file name without extension. If null, the application name is used. |
| bool | appendTimestamp | Indicates whether a timestamp should be appended to the capture file name. |
Returns
| Type | Description |
|---|---|
| string | The full path where the capture document will be written. |
StopCapture()
Ends the capture of the graphics commands for debugging purposes.
Declaration
public void StopCapture()
SyncUpcopyQueue()
Syncs the current buffer data in the copyQueue. Internal function used in the UploadBuffer strategy.
Please, note that this function is designed to work together with the UploadSyncLock synchronization lock, so it should be called inside a write lock of the UploadSyncLock lock. While this is not a writer, entering write lock gives us what we wanted: it makes sure that no more copy operations are being recorded while we submit the copy command buffer and wait for it to finish, and also make sure that no more copy operations are being recorded while we destroy the pending resources. Upload operations recording are getting reader lock, so they will be able to run in parallel and this thread will stop if any of them are still running, but once we enter here, every copy operation that one to run in any other thread will wait until we release the lock.
Thread A: | |-- copy --| Thread B: | |----- copy -----| Thread C: | |---- Waits to Render Thread ----||-- copy --| Render Thread: | |= Waits for B =||= Submit and releases =| .
Declaration
public override void SyncUpcopyQueue()
Overrides
UnmapMemory(GraphicsResource, uint)
Declaration
public override 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. |
Overrides
UpdateTextureData(Texture, nint, uint, uint)
Fills the buffer from a pointer.
Declaration
public override 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. |