stride3d/stride · error · ArgumentOutOfRangeException
The options specified for the Texture are not valid.
Error message
The options specified for the Texture are not valid.
What it means
Texture.InitializeFromImpl switches on the TextureDescription.Options to decide how to create the native D3D11 resource (e.g. shared handles). Options values outside the recognized set hit the else branch and throw ArgumentOutOfRangeException for 'textureDescription.Options', meaning the caller supplied an invalid or unsupported TextureOptions combination.
Solutions
- Set TextureDescription.Options to a supported value (e.g. None) for D3D11 texture creation.
- Inspect the description you build and remove option flags not supported by the Direct3D 11 backend.
- If sharing textures across devices, use the dedicated shared-handle API path instead of ad-hoc Options bits.
- Log the raw Options value to identify which flag combination is being rejected.
Example fix
// before
var desc = new TextureDescription { Width = w, Height = h, Options = TextureOptions.Unexpected };
var tex = new Texture(device, desc);
// after
var desc = new TextureDescription { Width = w, Height = h, Options = TextureOptions.None };
var tex = new Texture(device, desc); Defensive patterns
Strategy: validation
Validate before calling
if (!Enum.IsDefined(typeof(TextureOptions), description.Options) || description.Options.HasFlag(unsupportedBits))
throw new ArgumentException("Unsupported TextureOptions for D3D11.");
var tex = new Texture(device, description); Type guard
static bool HasValidOptions(TextureDescription d) => d.Options is TextureOptions.None or TextureOptions.Shared;
Try / catch
try { tex = new Texture(device, desc); }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "textureDescription.Options") { desc.Options = TextureOptions.None; tex = new Texture(device, desc); } Prevention
- Only set Options flags documented for the D3D11 backend
- Never share raw TextureDescription structs across backends unchanged
- Default to TextureOptions.None unless a shared-handle feature specifically requires it
When it happens
Trigger: Constructing or recreating a D3D11 Texture whose TextureDescription.Options contains an unexpected value — typically Options flags the D3D11 path does not recognize (e.g. shared/protected option bits set incorrectly or a corrupted description).
Common situations: Copying texture descriptions between backends where option flags have different meanings; programmatically building descriptions with option flags misused; default-struct initialization that leaves Options in an invalid state.
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 Texture supporting UAV
- Creating a texture from a SRV with dimension
- Multi-sampling is only supported for 2D Textures
- Texture Cubes must have an array size greater than 1
- The Graphics Resource is a Texture, but its dimension is…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/4d01e36efaaff0e6.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs:362
HResult result = NativeDeviceChild.QueryInterface(out ComPtr<IDXGIResource> sharedResource);
if (result.IsFailure)
result.Throw();
void* sharedHandle = null;
result = sharedResource.GetSharedHandle(ref sharedHandle);
if (result.IsFailure)
result.Throw();
sharedResource.Release();
SharedHandle = new(sharedHandle);
}
else
{
// Argument `textureDescription` comes from the constructor
throw new ArgumentOutOfRangeException("textureDescription.Options", "The options specified for the Texture are not valid.");
}
//
// Creates the internal Direct3D resource for a 1D Texture.
//
ComPtr<ID3D11Texture1D> CreateTexture1D(DataBox[] initialData)
{
ComPtr<ID3D11Texture1D> texture1D = default;
Texture1DDesc description = ConvertToNativeDescription1D();
ReadOnlySpan<SubresourceData> initiatDataPerSubresource = ConvertDataBoxes(initialData);
HResult result = initiatDataPerSubresource.IsEmpty
? NativeDevice.CreateTexture1D(in description, pInitialData: null, ref texture1D)
: NativeDevice.CreateTexture1D(in description, in initiatDataPerSubresource.GetReference(), ref texture1D);
if (result.IsFailure)
result.Throw();View on GitHub (pinned to 96fad776d2)