stride3d/stride · error · ArgumentException
Unsupported Graphics Resource. Only Textures, Buffers and…
Error message
Unsupported Graphics Resource. Only Textures, Buffers and QueryPools are supported
What it means
GraphicsResourceAllocator.UpdateReference only knows how to track Texture, Buffer, and QueryPool resources; any other GraphicsResourceBase-derived type hits the switch's default arm and throws ArgumentException naming the 'resource' parameter. The allocator maintains per-type caches for exactly these three kinds.
Solutions
- Only pass Texture, Buffer, or QueryPool instances to AddReference/ReleaseReference.
- If a new resource kind must be tracked, extend the allocator with an additional cache and switch arm.
- Unwrap or convert wrapper objects to the underlying supported resource before calling.
Example fix
// before
allocator.AddReference(myCustomResource); // not supported
// after
if (myCustomResource is Texture t) allocator.AddReference(t);
else throw new NotSupportedException("Only Texture/Buffer/QueryPool are tracked"); Defensive patterns
Strategy: type-guard
Validate before calling
if (resource is not (Texture or Buffer or QueryPool))
throw new NotSupportedException("Allocator tracks only Texture/Buffer/QueryPool"); Type guard
bool Trackable(GraphicsResourceBase r) => r is Texture or Buffer or QueryPool;
Try / catch
try { allocator.AddReference(resource); }
catch (ArgumentException ex) { log.Error($"Unsupported resource {resource.GetType().Name}", ex); } Prevention
- Only pass Texture/Buffer/QueryPool to allocator reference APIs
- Extend the allocator explicitly for new resource kinds
- Avoid wrapping resources before ref-counting
When it happens
Trigger: Calling AddReference or ReleaseReference with a graphics resource that is not a Texture, Buffer, or QueryPool (e.g. some custom GraphicsResourceBase subclass or another resource type).
Common situations: Custom engine extensions introducing new resource kinds and passing them to the allocator; misuse of the allocator API assuming it tracks all GraphicsResourceBase types; type confusion where a wrapper object is passed instead of the underlying resource.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Type [ ] is not supported as a modifiable collection
- Invalid Z slice index
- MipLevels must be <=
- Width/Height/Depth must be power of 2
- Image format not supported
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/fdd9c07abb7e4f2b.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/GraphicsResourceAllocator.cs:473
/// or if the Graphics Resource was not allocated by this allocator.
/// </exception>
/// <exception cref="ArgumentException">
/// The <paramref name="referenceDelta"/> is invalid. It cannot make the reference count of the <paramref name="resource"/> negative.
/// </exception>
private void UpdateReference(GraphicsResourceBase resource, int referenceDelta)
{
if (resource is null)
return;
bool resourceFound = false;
resourceFound = resource switch
{
Texture texture => UpdateReferenceCount(textureCache, texture, GetTextureDescription, referenceDelta),
Buffer buffer => UpdateReferenceCount(bufferCache, buffer, GetBufferDescription, referenceDelta),
QueryPool queryPool => UpdateReferenceCount(queryPoolCache, queryPool, GetQueryPoolDescription, referenceDelta),
_ => throw new ArgumentException("Unsupported Graphics Resource. Only Textures, Buffers and QueryPools are supported", nameof(resource))
};
if (!resourceFound)
throw new ArgumentException("The Graphics Resource was not allocated by this allocator", nameof(resource));
}
/// <summary>
/// Updates the reference count for a specified Graphics Resource.
/// </summary>
/// <typeparam name="TResource">The type of the Graphics Resource.</typeparam>
/// <typeparam name="TDescription">The type of an object that describes the characteristics of the Graphics Resource.</typeparam>
/// <param name="cache">The cache of allocated Graphics Resources of the intended type.</param>
/// <param name="resource">The Graphics Resource whose reference count is to be updated.</param>
/// <param name="getDescription">
/// A delegate that retrieves the actual description of a Graphics Resource.
/// See <see cref="GetTextureDescription"/>, <see cref="GetBufferDescription"/>, or <see cref="GetQueryPoolDescription"/> for examples.
/// </param>
/// <param name="referenceDelta">View on GitHub (pinned to 96fad776d2)