stride3d/stride · error · ArgumentOutOfRangeException
The region's height [ ] cannot be greater than the…
Error message
The region's height [{regionToCheck.Height}] cannot be greater than the mip-level's height [{height}] What it means
Thrown when a ResourceRegion's Height is greater than the height of the targeted mip level. Same validation family as the width check: a sub-resource region must fit inside the mip-level's dimensions. Thrown as ArgumentOutOfRangeException for the region parameter.
Solutions
- Clamp the region's height to max(1, mipHeight >> mipLevel) before calling.
- Derive the region from stagingTexture.Description.MipLevels / mip dimensions instead of hard-coding.
- Omit the region to update the entire sub-resource.
Example fix
// before var region = new ResourceRegion(0, 0, 0, w, h, 1); // h = full-res height texture.SetData(cmd, data, 0, mipLevel: 1, region); // after int mipHeight = Math.Max(1, h >> 1); var region = new ResourceRegion(0, 0, 0, w, mipHeight, 1); texture.SetData(cmd, data, 0, mipLevel: 1, region);
Defensive patterns
Strategy: validation
Validate before calling
int mipHeight = Math.Max(1, texture.Height >> mipLevel);
if (region != null && region.Height > mipHeight)
throw new InvalidOperationException($"Region height {region.Height} exceeds mip {mipLevel} height {mipHeight}"); Try / catch
try { texture.SetData(cmd, data, arrayIndex, mipLevel, region); }
catch (ArgumentOutOfRangeException e) when (e.ParamName == "region") { log.Error("Region height too large for mip", e); } Prevention
- Compute both width and height per mip level together.
- Clamp regions: region = Intersect(region, mipBounds).
- Write a helper that builds mip-safe regions.
When it happens
Trigger: Calling Texture.SetData (or similar) with a ResourceRegion whose Height exceeds the mip-level height, e.g. a region sized for the full-resolution texture while targeting a smaller mip.
Common situations: Copy-pasted region setup that only accounts for width; uploading data to mipmaps with full-size regions; resolution changed but region constants not updated.
Related errors
- The Graphics Resource is a Texture, but its dimension is…
- The region's width [ ] cannot be greater than the…
- Invalid mipmap level
- Invalid z slice index
- Invalid array slice index
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/e57ae512470d5e4a.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Texture.cs:1467
ArgumentNullException.ThrowIfNull(commandList);
if (region.HasValue && Usage != GraphicsResourceUsage.Default)
throw new ArgumentException($"A region can only be specified for Textures with {nameof(GraphicsResourceUsage)}.{nameof(GraphicsResourceUsage.Default)}", nameof(region));
// Get a description for the specified mip-level
ref readonly var mipmap = ref GetMipMapDescription(mipLevel);
int width = mipmap.Width;
int height = mipmap.Height;
int depth = mipmap.Depth;
// If we are using a region, then check that parameters are fine
if (region is ResourceRegion regionToCheck)
{
if (regionToCheck.Width > width)
throw new ArgumentOutOfRangeException(nameof(region), $"The region's width [{regionToCheck.Width}] cannot be greater than the mip-level's width [{width}]");
if (regionToCheck.Height > height)
throw new ArgumentOutOfRangeException(nameof(region), $"The region's height [{regionToCheck.Height}] cannot be greater than the mip-level's height [{height}]");
if (regionToCheck.Depth > depth)
throw new ArgumentOutOfRangeException(nameof(region), $"The region's depth [{regionToCheck.Depth}] cannot be greater than the mip-level's depth [{depth}]");
width = regionToCheck.Width;
height = regionToCheck.Height;
depth = regionToCheck.Depth;
}
var sizePerElement = Format.SizeInBytes;
// Compute actual pitch
Image.ComputePitch(Format, width, height, out var rowStride, out var textureDepthStride, out width, out height);
// Size Of actual texture data
int sizeOfTextureData = textureDepthStride * depth;
int fromDataSizeInBytes = fromData.Length * sizeof(TData);
View on GitHub (pinned to 96fad776d2)