# Xui.GPU.Hardware.Metal

Assembly: **Xui.Runtime.IOS** · [C# declarations](index.cs) · [Assembly overview](../index.md)

## Types

- [`class IOSGpuDevice`](#api-83e4358894d98c2e)

<a id="api-83e4358894d98c2e"></a>

## `class IOSGpuDevice`

Apple Metal hardware GPU device implementation. Provides hardware-accelerated shader compilation and rendering on macOS and iOS.

This backend uses the Metal framework for rendering and the Metal shader compiler for MSL shader compilation. Supports offscreen readback targets and native MTKView presentation targets.

```csharp
public sealed partial class IOSGpuDevice : IGpuResourceDevice
{
    public string BackendName { get; }
    public bool IsDisposed { get; }

    public IOSGpuDevice();
    public IGpuVertexShader CompileVertexShader(string source, string entryPoint);
    public IGpuFragmentShader CompileFragmentShader(string source, string entryPoint);
    public IGpuRenderTarget CreateRenderTarget(int width, int height);
    public IGpuCommandList CreateCommandList();
    public void Dispose();
}
public sealed partial class IOSGpuDevice
{
    public unsafe IGpuTexture CreateSampledTexture(int width, int height, IReadOnlyList<byte[]> mipLevels);
    public unsafe IGpuVertexBuffer CreateVertexBuffer(ReadOnlySpan<byte> vertices, int stride);
}
```

<a id="api-6ee76add3ac762dc"></a>

### [`IOSGpuDevice.IOSGpuDevice()`](#api-6ee76add3ac762dc)


```csharp
public IOSGpuDevice();
```

Creates a new Metal GPU device using the system default device.

**Throws** `Thrown if no Metal device is available.`: Thrown if no Metal device is available.

<a id="api-cc944a3a5b45ff1a"></a>

### [`string IOSGpuDevice.BackendName`](#api-cc944a3a5b45ff1a)


```csharp
public string BackendName { get; }
```

Gets the name of this GPU backend (e.g., &quot;D3D11&quot;, &quot;Metal&quot;).

<a id="api-d3561ff360279105"></a>

### [`IGpuFragmentShader IOSGpuDevice.CompileFragmentShader(string source, string entryPoint)`](#api-d3561ff360279105)


```csharp
public IGpuFragmentShader CompileFragmentShader(string source, string entryPoint);
```

Compiles a fragment (pixel) shader from native shader source code.

- **`source`** — The shader source (HLSL for D3D11, MSL for Metal).

- **`entryPoint`** — The name of the entry point function.

**Returns:** A compiled fragment shader.

<a id="api-0cb39208c0a5f447"></a>

### [`IGpuVertexShader IOSGpuDevice.CompileVertexShader(string source, string entryPoint)`](#api-0cb39208c0a5f447)


```csharp
public IGpuVertexShader CompileVertexShader(string source, string entryPoint);
```

Compiles a vertex shader from native shader source code.

- **`source`** — The shader source (HLSL for D3D11, MSL for Metal).

- **`entryPoint`** — The name of the entry point function.

**Returns:** A compiled vertex shader.

<a id="api-a4067c4938dcbc16"></a>

### [`IGpuCommandList IOSGpuDevice.CreateCommandList()`](#api-a4067c4938dcbc16)


```csharp
public IGpuCommandList CreateCommandList();
```

Creates a command list for recording rendering commands.

<a id="api-46700ed11902c7ab"></a>

### [`IGpuRenderTarget IOSGpuDevice.CreateRenderTarget(int width, int height)`](#api-46700ed11902c7ab)


```csharp
public IGpuRenderTarget CreateRenderTarget(int width, int height);
```

Creates a render target texture.

- **`width`** — Width in pixels.

- **`height`** — Height in pixels.

**Returns:** A render target that can be used with a command list.

<a id="api-4a5ca61569720a41"></a>

### [`IGpuTexture IOSGpuDevice.CreateSampledTexture(int width, int height, IReadOnlyList<byte[]> mipLevels)`](#api-4a5ca61569720a41)


```csharp
public unsafe IGpuTexture CreateSampledTexture(int width, int height, IReadOnlyList<byte[]> mipLevels);
```

Uploads premultiplied RGBA8 mip levels, largest first, with tightly packed rows.

<a id="api-349032cfa5168305"></a>

### [`IGpuVertexBuffer IOSGpuDevice.CreateVertexBuffer(ReadOnlySpan<byte> vertices, int stride)`](#api-349032cfa5168305)


```csharp
public unsafe IGpuVertexBuffer CreateVertexBuffer(ReadOnlySpan<byte> vertices, int stride);
```

Uploads immutable vertices once. The caller owns the returned buffer.

<a id="api-6f1315165c04cbcd"></a>

### [`void IOSGpuDevice.Dispose()`](#api-6f1315165c04cbcd)


```csharp
public void Dispose();
```

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

<a id="api-b206abcf5c2badb8"></a>

### [`bool IOSGpuDevice.IsDisposed`](#api-b206abcf5c2badb8)


```csharp
public bool IsDisposed { get; }
```

Gets whether this device has been disposed.

