{"record":{"id":"717e44278c85f547","repo":"stride3d/stride","slug":"copy-region-of-staging-resources-is-not-supported-yet","errorCode":null,"errorMessage":"Copy region of staging resources is not supported yet","messagePattern":"Copy region of staging resources is not supported yet","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"warning","filePath":"sources/engine/Stride.Graphics/Direct3D12/CommandList.Direct3D12.cs","lineNumber":1747,"sourceCode":"            {\n                CopyBetweenTextures(sourceTexture, destinationTexture);\n            }\n            else if (source is Buffer sourceBuffer &&\n                     destination is Buffer destinationBuffer)\n            {\n                CopyBetweenBuffers(sourceBuffer, destinationBuffer);\n            }\n            else throw new InvalidOperationException(\"Cannot copy data between Buffers and Textures.\");\n\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","sourceCodeStart":1729,"sourceCodeEnd":1765,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/CommandList.Direct3D12.cs#L1729-L1765","documentation":"Within CopyRegion's internal CopyBetweenTextures helper, copying region-wise between two textures both created with GraphicsResourceUsage.Staging is not implemented on the D3D12 backend and throws NotImplementedException. Other usage combinations fall through to the normal GPU barrier + copy path.","triggerScenarios":"Calling CommandList.CopyRegion(sourceTexture, destinationTexture, region) where both sourceTexture.Usage and destinationTexture.Usage equal GraphicsResourceUsage.Staging.","commonSituations":"CPU-side staging-to-staging data merges (e.g. building a texture atlas incrementally on the CPU); test code copying between two staging textures; porting GL/D3D11 staging logic expecting CPU memcpy semantics.","solutions":["Do the staging-to-staging copy on the CPU: map both textures (or copy their data pointers) and blit the region manually.","Copy into an intermediate GPU (Default/Immutable-to-Default) texture instead of staging-to-staging.","Set one of the textures to a non-Staging usage if a GPU copy path is acceptable."],"exampleFix":"// before\ncommandList.CopyRegion(stagingA, stagingB, region); // throws\n\n// after\nif (stagingA.Usage == GraphicsResourceUsage.Staging && stagingB.Usage == GraphicsResourceUsage.Staging)\n    CopyStagingRegionOnCpu(stagingA, stagingB, region); // manual CPU copy\nelse\n    commandList.CopyRegion(stagingA, stagingB, region);","handlingStrategy":"try-catch","validationCode":"if (source is Texture s && destination is Texture d &&\n    s.Usage == GraphicsResourceUsage.Staging && d.Usage == GraphicsResourceUsage.Staging)\n{\n    // handle staging-to-staging on CPU instead of calling CopyRegion\n}","typeGuard":"static bool IsStagingToStaging(Texture s, Texture d) =>\n    s.Usage == GraphicsResourceUsage.Staging && d.Usage == GraphicsResourceUsage.Staging;","tryCatchPattern":"try\n{\n    commandList.CopyRegion(srcTex, dstTex, region);\n}\ncatch (NotImplementedException)\n{\n    CopyStagingRegionOnCpu(srcTex, dstTex, region); // manual CPU blit\n}","preventionTips":["Avoid designing pipelines that require staging-to-staging GPU copies; merge staging data on the CPU.","Use a Default-usage intermediate texture when region copies are needed.","Check both textures' Usage before calling CopyRegion and dispatch accordingly."],"tags":["direct3d12","graphics","copy","staging","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"}