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).
public abstract class GraphicsResource : IDisposableInheritance
Derived
GpuBuffer, Pipeline, RenderTarget, Shader, Texture
Implements
Constructors
GraphicsResource(IGraphicsDevice, string?)
Creates a resource owned by device.
protected GraphicsResource(IGraphicsDevice device, string? name)Parameters
device IGraphicsDevice
name string?
Properties
Device
The owning device.
public IGraphicsDevice Device { get; }Property Value
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.
public Handle<GraphicsResource> Handle { get; }Property Value
IsDisposed
True after Dispose (or, for a surface target, after Present).
public bool IsDisposed { get; }Property Value
IsLost
True when a backend that detects device loss marked the resource lost; restorable resources are re-uploaded by their owner.
public bool IsLost { get; }Property Value
Name
Debug name.
public string? Name { get; }Property Value
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.
protected virtual string? OwnedBy { get; }Property Value
Methods
Dispose()
Releases the resource (deferred until submitted work no longer uses it). Idempotent.
public void Dispose()Exceptions
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).
protected void Expire()MarkLost()
Lets a backend that detects device loss mark the resource lost.
protected void MarkLost()Release()
Backend release: called once, when no submitted work uses the resource any more.
protected abstract void Release()