Resource IDs

class D3DRESID

An indirect identifier for a resource.

Resource IDs are used to indirectly identify resources in the engine. The indirection is then used for streaming and stubbing out resources which are not yet loaded. E.g. binding SRVs to shaders is usually done through the shader var system, which in turn uses resource IDs and not raw texture object pointers.

Note

Consists of an index for an entry inside the resource manager and a generation counter to distinguish between different resources stored within the same slot. For most uses these details are of little importance.

Comparison operators

IDs are totally ordered w.r.t. the underlying representation to allow for use in ordered containers. No semantic meaning is attached to the ordering.

inline bool operator==(const D3DRESID &rhs) const
inline bool operator!=(const D3DRESID &rhs) const
inline bool operator<(const D3DRESID &rhs) const
inline bool operator>(const D3DRESID &rhs) const

Public Functions

constexpr D3DRESID() = default

Constructs an invalid resource ID.

D3DRESID(const D3DRESID &rhs) = default
D3DRESID(D3DRESID &&rhs) = default
D3DRESID &operator=(const D3DRESID&) = default
D3DRESID &operator=(D3DRESID&&) = default
inline explicit constexpr D3DRESID(unsigned h)

Conversion from the underlying representation.

inline explicit operator unsigned() const

Conversion to the underlying representation.

inline explicit operator bool() const

Checks validity of the handle (it still might be broken though)

inline void reset()

Resets the resource ID to an invalid state.

inline unsigned index() const

Gets the entry index for this ID.

inline unsigned generation() const

Gets the entry value generation for this ID.

inline bool checkMarkerBit() const

Checks whether the ID is not broken (generation MUST be odd)

Public Static Functions

static inline D3DRESID make(unsigned index, unsigned gen)

Creates a new resource ID from an index and a generation.

Parameters:
  • index – The resource manager entry index

  • gen – The generation counter for the resource

Returns:

A new resource ID

static D3DRESID fromIndex(unsigned index)

Creates a new resource ID from an index.

The generation counter is acquired from the resource manager entry corresponding to the index.

Parameters:

index – The resource manager entry index

Returns:

A new resource ID

static constexpr D3DRESID BAD_D3DRESID

An invalid resource ID constant.

Legacy aliases are also provided for compatibility with older code from times where only textures were supported for resource management.

typedef D3DRESID TEXTUREID

Alias for backward compatibility and readability.

static constexpr D3DRESID BAD_TEXTUREID

Alias for backwards compatibility and readability.