Table of Contents

Class GraphicsResourceBase

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

Base class for a Graphics Resource.

public abstract class GraphicsResourceBase : ComponentBase, IDisposable, IComponent, IReferencable, ICollectorHolder
Inheritance
object
GraphicsResourceBase
Implements
Derived
Inherited Members
Extension Methods

Constructors

GraphicsResourceBase()

Initializes a new instance of the GraphicsResourceBase class.

protected GraphicsResourceBase()

GraphicsResourceBase(GraphicsDevice)

Initializes a new instance of the GraphicsResourceBase class.

protected GraphicsResourceBase(GraphicsDevice device)

Parameters

device GraphicsDevice

The graphics device.

GraphicsResourceBase(GraphicsDevice, string?)

Initializes a new instance of the GraphicsResourceBase class.

protected GraphicsResourceBase(GraphicsDevice device, string? name)

Parameters

device GraphicsDevice

The graphics device.

name string

A name that can be used to identify the Graphics Resource. Specify null to use the type's name instead.

Properties

GraphicsDevice

Gets the GraphicsDevice the Graphics Resource depends on.

public GraphicsDevice GraphicsDevice { get; }

Property Value

GraphicsDevice

IsDebugMode

Gets a value indicating whether the Graphics Resource is in "Debug mode".

protected bool IsDebugMode { get; }

Property Value

bool

true if the Graphics Resource is initialized in "Debug mode"; otherwise, false.

NativeDevice

Gets the internal Direct3D 11 device (Silk.NET.Direct3D11.ID3D11Device) if the resource is attached to a GraphicsDevice, or null if not.

protected ComPtr<ID3D11Device> NativeDevice { get; }

Property Value

ComPtr<ID3D11Device>

Remarks

If the reference is going to be kept, use AddRef() on the COM pointer to increment the internal reference count, and Silk.NET.Core.Native.ComPtr<T>.Dispose() when no longer needed to release the object.

NativeDeviceChild

Gets or sets the internal Silk.NET.Direct3D11.ID3D11DeviceChild.

protected ComPtr<ID3D11DeviceChild> NativeDeviceChild { get; set; }

Property Value

ComPtr<ID3D11DeviceChild>

Remarks

If the reference is going to be kept, use AddRef() on the COM pointer to increment the internal reference count, and Silk.NET.Core.Native.ComPtr<T>.Dispose() when no longer needed to release the object.

NativeResource

Gets the internal Direct3D 11 Resource.

protected ComPtr<ID3D11Resource> NativeResource { get; }

Property Value

ComPtr<ID3D11Resource>

Remarks

If the reference is going to be kept, use AddRef() on the COM pointer to increment the internal reference count, and Silk.NET.Core.Native.ComPtr<T>.Dispose() when no longer needed to release the object.

Methods

Destroy()

Disposes the resources associated with the Graphics Resource, removes itself from the GraphicsDevice's resource registry, and transitions to the Destroyed state.

protected override void Destroy()

OnDestroyed(bool)

Called when the GraphicsDevice has been detected to be internally destroyed, or when the Destroy() methad has been called. Raises the Destroyed event.

protected virtual void OnDestroyed(bool immediately = false)

Parameters

immediately bool

A value indicating whether the resource should be destroyed immediately (true), or if it can be deferred until it's safe to do so (false).

Remarks

This method releases the underlying native resources (Silk.NET.Direct3D11.ID3D11Resource and Silk.NET.Direct3D11.ID3D11DeviceChild).

SetNativeDeviceChild(ComPtr<ID3D11DeviceChild>)

Internal method to set the internal Silk.NET.Direct3D11.ID3D11DeviceChild without incrementing or decrementing the reference count.

protected void SetNativeDeviceChild(ComPtr<ID3D11DeviceChild> deviceChild)

Parameters

deviceChild ComPtr<ID3D11DeviceChild>

UnsetNativeDeviceChild()

Internal method to detach the internal Silk.NET.Direct3D11.ID3D11DeviceChild without incrementing or decrementing the reference count.

protected void UnsetNativeDeviceChild()

Events

Destroyed

Raised when the internal Graphics Resource gets destroyed.

public event EventHandler<EventArgs> Destroyed

Event Type

EventHandler<EventArgs>

Remarks

This event is useful when user-allocated handles associated with the internal resource need to be released.