{"record":{"id":"4d01e36efaaff0e6","repo":"stride3d/stride","slug":"the-options-specified-for-the-texture-are-not-valid","errorCode":null,"errorMessage":"The options specified for the Texture are not valid.","messagePattern":"The options specified for the Texture are not valid\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs","lineNumber":362,"sourceCode":"                HResult result = NativeDeviceChild.QueryInterface(out ComPtr<IDXGIResource> sharedResource);\n\n                if (result.IsFailure)\n                    result.Throw();\n\n                void* sharedHandle = null;\n                result = sharedResource.GetSharedHandle(ref sharedHandle);\n\n                if (result.IsFailure)\n                    result.Throw();\n\n                sharedResource.Release();\n\n                SharedHandle = new(sharedHandle);\n            }\n            else\n            {\n                // Argument `textureDescription` comes from the constructor\n                throw new ArgumentOutOfRangeException(\"textureDescription.Options\", \"The options specified for the Texture are not valid.\");\n            }\n\n            //\n            // Creates the internal Direct3D resource for a 1D Texture.\n            //\n            ComPtr<ID3D11Texture1D> CreateTexture1D(DataBox[] initialData)\n            {\n                ComPtr<ID3D11Texture1D> texture1D = default;\n\n                Texture1DDesc description = ConvertToNativeDescription1D();\n                ReadOnlySpan<SubresourceData> initiatDataPerSubresource = ConvertDataBoxes(initialData);\n\n                HResult result = initiatDataPerSubresource.IsEmpty\n                    ? NativeDevice.CreateTexture1D(in description, pInitialData: null, ref texture1D)\n                    : NativeDevice.CreateTexture1D(in description, in initiatDataPerSubresource.GetReference(), ref texture1D);\n\n                if (result.IsFailure)\n                    result.Throw();","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs#L344-L380","documentation":"Texture.InitializeFromImpl switches on the TextureDescription.Options to decide how to create the native D3D11 resource (e.g. shared handles). Options values outside the recognized set hit the else branch and throw ArgumentOutOfRangeException for 'textureDescription.Options', meaning the caller supplied an invalid or unsupported TextureOptions combination.","triggerScenarios":"Constructing or recreating a D3D11 Texture whose TextureDescription.Options contains an unexpected value — typically Options flags the D3D11 path does not recognize (e.g. shared/protected option bits set incorrectly or a corrupted description).","commonSituations":"Copying texture descriptions between backends where option flags have different meanings; programmatically building descriptions with option flags misused; default-struct initialization that leaves Options in an invalid state.","solutions":["Set TextureDescription.Options to a supported value (e.g. None) for D3D11 texture creation.","Inspect the description you build and remove option flags not supported by the Direct3D 11 backend.","If sharing textures across devices, use the dedicated shared-handle API path instead of ad-hoc Options bits.","Log the raw Options value to identify which flag combination is being rejected."],"exampleFix":"// before\nvar desc = new TextureDescription { Width = w, Height = h, Options = TextureOptions.Unexpected };\nvar tex = new Texture(device, desc);\n// after\nvar desc = new TextureDescription { Width = w, Height = h, Options = TextureOptions.None };\nvar tex = new Texture(device, desc);","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(TextureOptions), description.Options) || description.Options.HasFlag(unsupportedBits))\n    throw new ArgumentException(\"Unsupported TextureOptions for D3D11.\");\nvar tex = new Texture(device, description);","typeGuard":"static bool HasValidOptions(TextureDescription d) => d.Options is TextureOptions.None or TextureOptions.Shared;","tryCatchPattern":"try { tex = new Texture(device, desc); }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"textureDescription.Options\") { desc.Options = TextureOptions.None; tex = new Texture(device, desc); }","preventionTips":["Only set Options flags documented for the D3D11 backend","Never share raw TextureDescription structs across backends unchanged","Default to TextureOptions.None unless a shared-handle feature specifically requires it"],"tags":["direct3d11","texture","argument-out-of-range","options"],"backgroundTag":"invalid-argument-value","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"}