stride3d/stride · error · ArgumentException
Expecting a Texture supporting UAV
Error message
Expecting a Texture supporting UAV
What it means
ClearReadWrite(Texture, Vector4) clears a texture through its D3D11 UAV view via ClearUnorderedAccessViewFloat. Textures created without the UnorderedAccess flag have a null NativeUnorderedAccessView, so the method throws an ArgumentException naming 'texture'.
Solutions
- Recreate the texture with GraphicsResourceFlags.UnorderedAccess in its flags.
- Ensure mip/array slices used for clearing are created as UAV-eligible (no unsupported formats).
- Pre-check the texture's UAV handle/nullability at the call site and use Clear (render target) instead for RT-only textures.
Example fix
// before var tex = Texture.New2D(device, w, h, PixelFormat.R32G32B32A32_Float, GraphicsResourceFlags.ShaderResource); commandList.ClearReadWrite(tex, Vector4.Zero); // after var tex = Texture.New2D(device, w, h, PixelFormat.R32G32B32A32_Float, GraphicsResourceFlags.ShaderResource | GraphicsResourceFlags.UnorderedAccess); commandList.ClearReadWrite(tex, Vector4.Zero);
Defensive patterns
Strategy: validation
Validate before calling
if (texture.NativeUnorderedAccessView.IsNull())
throw new InvalidOperationException("Texture must be created with GraphicsResourceFlags.UnorderedAccess");
commandList.ClearReadWrite(texture, value); Type guard
static bool SupportsUavClear(Texture t) => t is not null && !t.NativeUnorderedAccessView.IsNull();
Try / catch
try { commandList.ClearReadWrite(texture, Vector4.Zero); }
catch (ArgumentException ex) when (ex.ParamName == "texture") { /* recreate texture with UAV flag or clear as render target */ } Prevention
- Set GraphicsResourceFlags.UnorderedAccess on textures targeted by compute or UAV clears.
- Ensure the pixel format is UAV-compatible when enabling the flag.
- Use ClearRenderTarget for render-target-only textures instead.
When it happens
Trigger: Calling commandList.ClearReadWrite(texture, new Vector4(...)) on a Texture whose TextureDescription flags lack GraphicsResourceFlags.UnorderedAccess.
Common situations: Render-target textures created with RenderTarget flag only and later cleared as UAVs; textures loaded from assets without UAV usage; switching an algorithm from render-target blit to compute UAV without recreating the texture.
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
- Expecting a Buffer supporting UAV
- Invalid shader stage
- Cannot clear a stencil buffer without a Stencil Buffer…
- Expecting texture supporting UAV
- Missing content storage.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/aee3a00bdb117ea0.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Direct3D11/CommandList.Direct3D11.cs:1006
throw new ArgumentException("Expecting a Buffer supporting UAV", nameof(buffer));
nativeDeviceContext->ClearUnorderedAccessViewUint(buffer.NativeUnorderedAccessView, (uint*) &value);
}
/// <summary>
/// Clears a Read-Write Texture.
/// </summary>
/// <param name="texture">The Texture to clear. It must have been created with read-write / unordered access flags.</param>
/// <param name="value">The value to use to clear the Texture.</param>
/// <exception cref="ArgumentNullException"><paramref name="texture"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException"><paramref name="texture"/> must support Unordered Access.</exception>
public unsafe void ClearReadWrite(Texture texture, Vector4 value)
{
ArgumentNullException.ThrowIfNull(texture);
RecordDebugCounter(DebugCounterKind.Clear);
if (texture.NativeUnorderedAccessView.IsNull())
throw new ArgumentException("Expecting a Texture supporting UAV", nameof(texture));
nativeDeviceContext->ClearUnorderedAccessViewFloat(texture.NativeUnorderedAccessView, (float*) &value);
}
/// <summary>
/// Clears a Read-Write Texture.
/// </summary>
/// <param name="texture">The Texture to clear. It must have been created with read-write / unordered access flags.</param>
/// <param name="value">The value to use to clear the Texture.</param>
/// <exception cref="ArgumentNullException"><paramref name="texture"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException"><paramref name="texture"/> must support Unordered Access.</exception>
public unsafe void ClearReadWrite(Texture texture, Int4 value)
{
ArgumentNullException.ThrowIfNull(texture);
RecordDebugCounter(DebugCounterKind.Clear);
if (texture.NativeUnorderedAccessView.IsNull())
throw new ArgumentException("Expecting a Texture supporting UAV", nameof(texture));View on GitHub (pinned to 96fad776d2)