Skip to content

GraphicsAPI reference

Class GraphicsResource

Namespace: MicroEngine.Graphics.Devices
Assembly: MicroEngine.Graphics.dll
Guide: The graphics device

Base of every device object. A resource belongs to the device that created it: using it with another device is an ArgumentException, using it after Dispose an ObjectDisposedException, both raised by core validation before a backend sees the call. Every resource has a Handle with a generation: once the resource is disposed the handle no longer resolves (TryGetResource``1), even if its slot is reused. Destruction is deferred: the backend object is released only when no submitted work uses it any more (at once on devices that execute command lists at Submit).

C#
public abstract class GraphicsResource : IDisposable

Inheritance

object ← GraphicsResource

Derived

GpuBuffer, Pipeline, RenderTarget, Shader, Texture

Implements

IDisposable

Constructors

GraphicsResource(IGraphicsDevice, string?)

Creates a resource owned by device.

C#
protected GraphicsResource(IGraphicsDevice device, string? name)

Parameters

device IGraphicsDevice

name string?

Properties

Device

The owning device.

C#
public IGraphicsDevice Device { get; }

Property Value

IGraphicsDevice

Handle

The resource’s handle on its device: a slot and a generation. None until the device registers the resource (core does it when the create call returns) and after a device that is not a GraphicsDeviceBase created it.

C#
public Handle<GraphicsResource> Handle { get; }

Property Value

Handle<GraphicsResource>

IsDisposed

True after Dispose (or, for a surface target, after Present).

C#
public bool IsDisposed { get; }

Property Value

bool

IsLost

True when a backend that detects device loss marked the resource lost; restorable resources are re-uploaded by their owner.

C#
public bool IsLost { get; }

Property Value

bool

Name

Debug name.

C#
public string? Name { get; }

Property Value

string?

OwnedBy

When not null, Dispose throws InvalidOperationException with this text: device-owned objects (built-in pipelines, a render target’s colour texture, the surface target) are not disposed by callers.

C#
protected virtual string? OwnedBy { get; }

Property Value

string?

Methods

Dispose()

Releases the resource (deferred until submitted work no longer uses it). Idempotent.

C#
public void Dispose()

Exceptions

InvalidOperationException

The resource is owned by its device or its render target.

Expire()

Lets a backend end the life of an owned object (a surface target at present, a target’s colour texture with its target).

C#
protected void Expire()

MarkLost()

Lets a backend that detects device loss mark the resource lost.

C#
protected void MarkLost()

Release()

Backend release: called once, when no submitted work uses the resource any more.

C#
protected abstract void Release()