Home

MTLResource

MTLResource is a protocol in Apple’s Metal framework that defines the common interface for GPU resources. It is adopted by concrete resource types such as MTLBuffer and MTLTexture, which represent memory regions used for data storage and texture data on the GPU. The protocol provides a uniform set of capabilities that all resource objects share, regardless of their specific kind or storage location.

Key aspects of MTLResource include a reference to the device that created the resource, an optional label

A notable feature of MTLResource is support for purgeable state management. The protocol defines a method to

Usage and lifetimes: Resources are created by the device, often via specific creation methods that return objects

Notes: API availability and behavior can vary by OS version and device. MTLResource serves as the foundational

for
debugging
and
profiling,
and
metadata
describing
how
the
resource
is
stored
and
accessed.
Resources
expose
information
about
memory
configuration,
including
cache
behavior
for
CPU
access
(cpuCacheMode)
and
the
memory
location
and
behavior
(storageMode).
Some
implementations
also
expose
a
hazard-tracking
mode,
reflecting
how
the
runtime
tracks
potential
hazards
when
resources
are
used
across
CPU
and
GPU.
set
the
resource’s
purgeable
state,
allowing
the
system
to
reclaim
memory
when
necessary.
Applications
can
query
and
adjust
the
purgeability
of
resources
to
balance
performance
and
memory
pressure.
conforming
to
MTLResource
(for
example,
buffers
and
textures).
They
may
be
allocated
directly
or
from
a
heap
(MTLHeap).
The
exact
capabilities
and
available
properties
depend
on
the
concrete
resource
type
and
the
platform
version.
interface;
details
are
implemented
by
MTLBuffer,
MTLTexture,
and
related
resource
classes.