{"record":{"id":"cf3f314e2c9df2ac","repo":"stride3d/stride","slug":"copy-region-from-staging-texture-is-not-supported-yet","errorCode":null,"errorMessage":"Copy region from staging texture is not supported yet","messagePattern":"Copy region from staging texture is not supported yet","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/CommandList.Direct3D12.cs","lineNumber":1756,"sourceCode":"\n            //\n            // Copies a region from a Texture to another Texture.\n            //\n            void CopyBetweenTextures(Texture sourceTexture, Texture destinationTexture)\n            {\n                if (sourceTexture.Usage == GraphicsResourceUsage.Staging &&\n                    destinationTexture.Usage == GraphicsResourceUsage.Staging)\n                {\n                    throw new NotImplementedException(\"Copy region of staging resources is not supported yet\"); // TODO: Implement copy region for staging resources\n                }\n\n                ResourceBarrierTransition(source, BarrierLayout.CopySource);\n                ResourceBarrierTransition(destination, BarrierLayout.CopyDest);\n                FlushResourceBarriers();\n\n                if (sourceTexture.Usage == GraphicsResourceUsage.Staging)\n                {\n                    throw new NotImplementedException(\"Copy region from staging texture is not supported yet\");\n                }\n\n                var srcRegion = new TextureCopyLocation\n                {\n                    PResource = source.NativeResource,\n                    Type = TextureCopyType.SubresourceIndex,\n                    SubresourceIndex = (uint) sourceSubResourceIndex\n                };\n\n                SkipInit(out TextureCopyLocation destRegion);\n\n                if (destinationTexture.Usage == GraphicsResourceUsage.Staging)\n                {\n                    var destinationParent = destinationTexture.ParentTexture ?? destinationTexture;\n\n                    SkipInit(out PlacedSubresourceFootprint footprint);\n                    uint numRows = 0;\n                    ulong rowSizeInBytes = 0;","sourceCodeStart":1738,"sourceCodeEnd":1774,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/CommandList.Direct3D12.cs#L1738-L1774","documentation":"This NotImplementedException is thrown by CopyRegion when the source texture has GraphicsResourceUsage.Staging. The D3D12 backend only implements full-resource copy for staging sources; copying a specific region out of a staging texture is not implemented yet in the Direct3D12 CommandList.","triggerScenarios":"Calling CommandList.CopyRegion(source, ...) where source.Usage == GraphicsResourceUsage.Staging on the Direct3D12 backend. The full-resource Copy path handles staging; the region overload does not.","commonSituations":"Copying a sub-region between staging textures during CPU<->GPU data staging workflows; porting D3D11 code that used CopySubresourceRegion with staging textures; reading back part of a large staging texture instead of the whole thing.","solutions":["Use Copy with a full-resource copy (or CommandList.Copy that supports staging sources) and do region handling on the CPU after mapping the staging texture.","Recreate the source as a non-staging (Default/Immutable) texture if a GPU-side region copy is genuinely needed, copying staging data in first via Copy.","Restructure so the staging texture already contains only the region of interest, sized exactly to the region.","Patch the engine: implement the staging-source path via Map/UpdateSubresource instead of a GPU copy, or file/track the upstream TODO."],"exampleFix":"// before\ncommandList.CopyRegion(sourceStagingTexture, 0, region, destTexture, 0);\n// after\ncommandList.Copy(sourceStagingTexture, destTexture); // full copy only, then Map dest staging side\ncpuData = ExtractRegionOnCPU(destTexture, region);","handlingStrategy":"validation","validationCode":"if (sourceTexture.Usage == GraphicsResourceUsage.Staging)\n{\n    // region copy unsupported on D3D12: use full Copy or CPU path\n    commandList.Copy(sourceTexture, destinationTexture);\n}\nelse\n{\n    commandList.CopyRegion(sourceTexture, 0, region, destinationTexture, 0);\n}","typeGuard":"static bool SupportsRegionCopy(Texture t) => t.Usage != GraphicsResourceUsage.Staging;","tryCatchPattern":null,"preventionTips":["Never call CopyRegion with staging sources on D3D12.","Keep staging textures for CPU map/copy, and device textures for GPU-to-GPU region copies.","Check GraphicsResourceUsage before GPU copy APIs."],"tags":["direct3d12","graphics","staging-texture","not-implemented"],"backgroundTag":"method-not-implemented","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"}