{"record":{"id":"e57ae512470d5e4a","repo":"stride3d/stride","slug":"the-region-s-height-regiontocheck-height-cannot-be-greater","errorCode":null,"errorMessage":"The region's height [{regionToCheck.Height}] cannot be greater than the mip-level's height [{height}]","messagePattern":"The region's height \\[(.+?)\\] cannot be greater than the mip-level's height \\[(.+?)\\]","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Texture.cs","lineNumber":1467,"sourceCode":"            ArgumentNullException.ThrowIfNull(commandList);\n\n            if (region.HasValue && Usage != GraphicsResourceUsage.Default)\n                throw new ArgumentException($\"A region can only be specified for Textures with {nameof(GraphicsResourceUsage)}.{nameof(GraphicsResourceUsage.Default)}\", nameof(region));\n\n            // Get a description for the specified mip-level\n            ref readonly var mipmap = ref GetMipMapDescription(mipLevel);\n\n            int width = mipmap.Width;\n            int height = mipmap.Height;\n            int depth = mipmap.Depth;\n\n            // If we are using a region, then check that parameters are fine\n            if (region is ResourceRegion regionToCheck)\n            {\n                if (regionToCheck.Width > width)\n                    throw new ArgumentOutOfRangeException(nameof(region), $\"The region's width [{regionToCheck.Width}] cannot be greater than the mip-level's width [{width}]\");\n                if (regionToCheck.Height > height)\n                    throw new ArgumentOutOfRangeException(nameof(region), $\"The region's height [{regionToCheck.Height}] cannot be greater than the mip-level's height [{height}]\");\n                if (regionToCheck.Depth > depth)\n                    throw new ArgumentOutOfRangeException(nameof(region), $\"The region's depth [{regionToCheck.Depth}] cannot be greater than the mip-level's depth [{depth}]\");\n\n                width = regionToCheck.Width;\n                height = regionToCheck.Height;\n                depth = regionToCheck.Depth;\n            }\n\n            var sizePerElement = Format.SizeInBytes;\n\n            // Compute actual pitch\n            Image.ComputePitch(Format, width, height, out var rowStride, out var textureDepthStride, out width, out height);\n\n            // Size Of actual texture data\n            int sizeOfTextureData = textureDepthStride * depth;\n\n            int fromDataSizeInBytes = fromData.Length * sizeof(TData);\n","sourceCodeStart":1449,"sourceCodeEnd":1485,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Texture.cs#L1449-L1485","documentation":"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.","triggerScenarios":"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.","commonSituations":"Copy-pasted region setup that only accounts for width; uploading data to mipmaps with full-size regions; resolution changed but region constants not updated.","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."],"exampleFix":"// before\nvar region = new ResourceRegion(0, 0, 0, w, h, 1); // h = full-res height\ntexture.SetData(cmd, data, 0, mipLevel: 1, region);\n// after\nint mipHeight = Math.Max(1, h >> 1);\nvar region = new ResourceRegion(0, 0, 0, w, mipHeight, 1);\ntexture.SetData(cmd, data, 0, mipLevel: 1, region);","handlingStrategy":"validation","validationCode":"int mipHeight = Math.Max(1, texture.Height >> mipLevel);\nif (region != null && region.Height > mipHeight)\n    throw new InvalidOperationException($\"Region height {region.Height} exceeds mip {mipLevel} height {mipHeight}\");","typeGuard":null,"tryCatchPattern":"try { texture.SetData(cmd, data, arrayIndex, mipLevel, region); }\ncatch (ArgumentOutOfRangeException e) when (e.ParamName == \"region\") { log.Error(\"Region height too large for mip\", e); }","preventionTips":["Compute both width and height per mip level together.","Clamp regions: region = Intersect(region, mipBounds).","Write a helper that builds mip-safe regions."],"tags":["graphics","argument-out-of-range","texture"],"backgroundTag":"argument-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}