{"record":{"id":"3970636bf8afaf80","repo":"stride3d/stride","slug":"unknown-type-of-graphics-resource","errorCode":null,"errorMessage":"Unknown type of Graphics Resource","messagePattern":"Unknown type of Graphics Resource","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/CommandList.Direct3D12.cs","lineNumber":2004,"sourceCode":"        ///   </para>\n        /// </param>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"resource\"/> is <see langword=\"null\"/>.</exception\n        /// <exception cref=\"ArgumentOutOfRangeException\">\n        ///   <paramref name=\"resource\"/> is a <see cref=\"Texture\"/>, but its <see cref=\"Texture.Dimension\"/> is not one of the supported types.\n        /// </exception\n        /// <exception cref=\"InvalidOperationException\"><paramref name=\"resource\"/> is of an unknown type and cannot be updated.</exception>\n        /// <inheritdoc cref=\"UpdateSubResource(GraphicsResource, int, ReadOnlySpan{byte}, ResourceRegion)\" path=\"/remarks\" />\n        internal unsafe partial void UpdateSubResource(GraphicsResource resource, int subResourceIndex, DataBox sourceData, ResourceRegion region)\n        {\n            if (resource is Texture texture)\n            {\n                UpdateTexture(texture);\n            }\n            else if (resource is Buffer)\n            {\n                UpdateBuffer();\n            }\n            else throw new InvalidOperationException(\"Unknown type of Graphics Resource\");\n\n            //\n            // Updates a Texture with data from CPU memory.\n            //\n            void UpdateTexture(Texture texture)\n            {\n                var width = region.Right - region.Left;\n                var height = region.Bottom - region.Top;\n                var depth = region.Back - region.Front;\n\n                SkipInit(out ResourceDesc resourceDescription);\n                switch (texture.Dimension)\n                {\n                    case TextureDimension.Texture1D:\n                        resourceDescription = texture.ConvertToNativeDescription1D();\n                        resourceDescription.Width = (ulong) width;\n                        resourceDescription.DepthOrArraySize = 1;\n                        resourceDescription.MipLevels = 1;","sourceCodeStart":1986,"sourceCodeEnd":2022,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/CommandList.Direct3D12.cs#L1986-L2022","documentation":"CommandList.Update dispatches based on resource type: it calls UpdateTexture for Texture and UpdateBuffer for Buffer. Any other GraphicsResource type hits the else and throws InvalidOperationException('Unknown type of Graphics Resource').","triggerScenarios":"Calling CommandList.Update(resource, sourceData, ...) with a resource that is neither Texture nor Buffer on the Direct3D12 backend, including custom GraphicsResource subclasses.","commonSituations":"Updating a query pool, custom GPU resource, or accidentally passing the wrong object; code refactors where a new resource type was introduced but Update wasn't extended.","solutions":["Only call Update with Texture or Buffer instances.","For other resource kinds, use their dedicated update/upload API instead of the generic Update.","If a custom resource type is required, implement the upload path yourself (e.g. staging buffer + CopyResource) rather than routing through Update.","Null-check before calling: null also fails both type tests."],"exampleFix":"// before\ncommandList.Update(myCustomResource, data); // throws\n// after\nif (myResource is Texture tex) commandList.Update(tex, data);\nelse if (myResource is Buffer buf) commandList.Update(buf, data);","handlingStrategy":"type-guard","validationCode":"if (resource is not Texture && resource is not Buffer)\n    throw new ArgumentException(\"Update requires Texture or Buffer\", nameof(resource));","typeGuard":"static bool CanUpdate(GraphicsResource r) => r is Texture or Buffer;","tryCatchPattern":"try { commandList.Update(resource, data); }\ncatch (InvalidOperationException ex) { log.Error(\"Update: unsupported resource type\", ex); }","preventionTips":["Dispatch to resource-specific upload APIs for non-texture/buffer kinds.","Null-check before generic Update calls.","Keep custom resources out of the generic Update path."],"tags":["direct3d12","graphics","type-mismatch"],"backgroundTag":"type-mismatch","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"}