{"record":{"id":"d106ab487a26a31c","repo":"stride3d/stride","slug":"the-graphics-resource-is-a-texture-but-its-dimension-is-not","errorCode":null,"errorMessage":"The Graphics Resource is a Texture, but its dimension is not one of the supported types.","messagePattern":"The Graphics Resource is a Texture, but its dimension is not one of the supported types\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/CommandList.Direct3D12.cs","lineNumber":2043,"sourceCode":"                    case TextureDimension.Texture2D:\n                    case TextureDimension.TextureCube:\n                        resourceDescription = texture.ConvertToNativeDescription2D();\n                        resourceDescription.Width = (ulong) width;\n                        resourceDescription.Height = (uint) height;\n                        resourceDescription.DepthOrArraySize = 1;\n                        resourceDescription.MipLevels = 1;\n                        break;\n\n                    case TextureDimension.Texture3D:\n                        resourceDescription = texture.ConvertToNativeDescription3D();\n                        resourceDescription.Width = (ulong) width;\n                        resourceDescription.Height = (uint) height;\n                        resourceDescription.DepthOrArraySize = (ushort) depth;\n                        resourceDescription.MipLevels = 1;\n                        break;\n\n                    default:\n                        throw new ArgumentOutOfRangeException(nameof(texture), \"The Graphics Resource is a Texture, but its dimension is not one of the supported types.\");\n                }\n\n                // TODO D3D12 allocate in upload heap (placed resources?)\n                var heap = new HeapProperties\n                {\n                    CPUPageProperty = CpuPageProperty.WriteBack,\n                    MemoryPoolPreference = MemoryPool.L0,\n                    CreationNodeMask = 1,\n                    VisibleNodeMask = 1,\n                    Type = HeapType.Custom\n                };\n\n                HResult result = NativeDevice.CreateCommittedResource(in heap, HeapFlags.None,\n                                                                      in resourceDescription, ResourceStates.GenericRead,\n                                                                      pOptimizedClearValue: null,\n                                                                      out ComPtr<ID3D12Resource> nativeUploadTexture);\n                if (result.IsFailure)\n                    result.Throw();","sourceCodeStart":2025,"sourceCodeEnd":2061,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/CommandList.Direct3D12.cs#L2025-L2061","documentation":"When creating a texture on the fly for an update, the code maps the TextureDimension to D3D12 resource description fields. Dimensions outside the handled cases (Texture1D/2D/3D style cases) hit the default arm and throw ArgumentOutOfRangeException naming the texture parameter.","triggerScenarios":"Calling Update on a Texture whose Dimension is not one of the supported values handled in the switch (e.g. an unusual/extended dimension or a corrupted default-constructed texture descriptor).","commonSituations":"Constructing a Texture manually without setting Dimension properly; porting textures with cube/array dimension combos not covered by this D3D12 code path; serialization bugs that produce invalid dimensions.","solutions":["Set Texture.Dimension to a supported value (Texture1D, Texture2D, Texture3D) when creating the texture.","Inspect how the texture was created — prefer Texture.New2D/New3D helpers that set valid dimensions.","Verify data loading/serialization isn't corrupting the Dimension field.","Patch the switch to add the missing dimension if the engine added new TextureDimension values."],"exampleFix":"// before\nvar tex = new Texture { Width = 64, Height = 64 }; // Dimension left default\ncommandList.Update(tex, data);\n// after\nvar tex = Texture.New2D(GraphicsDevice, 64, 64, PixelFormat.R8G8B8A8_UNorm, data);","handlingStrategy":"validation","validationCode":"if (texture.Dimension is not TextureDimension.Texture1D\n    and not TextureDimension.Texture2D\n    and not TextureDimension.Texture3D)\n    throw new ArgumentException(\"Unsupported texture dimension\", nameof(texture));","typeGuard":"static bool HasSupportedDimension(Texture t) =>\n    t.Dimension is TextureDimension.Texture1D or TextureDimension.Texture2D or TextureDimension.Texture3D;","tryCatchPattern":"try { commandList.Update(texture, data); }\ncatch (ArgumentOutOfRangeException ex) { log.Error(\"Texture dimension not supported for update\", ex); }","preventionTips":["Create textures via Texture.New2D/New3D helpers so Dimension is always valid.","Validate Dimension after deserializing textures.","Never leave Texture.Dimension at its default in manual construction."],"tags":["direct3d12","graphics","texture","argument-out-of-range"],"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"}