{"record":{"id":"40952f6847b0853c","repo":"stride3d/stride","slug":"multi-sampling-is-not-supported-for-unordered-access-views","errorCode":null,"errorMessage":"Multi-sampling is not supported for Unordered Access Views","messagePattern":"Multi-sampling is not supported for Unordered Access Views","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs","lineNumber":706,"sourceCode":"        }\n\n        /// <summary>\n        ///   Gets a specific <see cref=\"ID3D11UnorderedAccessView\"/> from the Texture.\n        /// </summary>\n        /// <param name=\"viewType\">The desired View type of the Unordered Access View.</param>\n        /// <param name=\"arrayOrDepthSlice\">The index of the Texture array or depth slice.</param>\n        /// <param name=\"mipIndex\">The index of the mip-level.</param>\n        /// <returns>An <see cref=\"ID3D11UnorderedAccessView\"/> for the Texture.</returns>\n        /// <exception cref=\"NotSupportedException\">Multi-sampling is not supported for Unordered Access Views.</exception>\n        /// <exception cref=\"NotSupportedException\">A Texture Cube must have an array size greater than 1.</exception>\n        /// <exception cref=\"NotSupportedException\">Texture Arrays are not supported for 3D Textures.</exception>\n        private ComPtr<ID3D11UnorderedAccessView> GetUnorderedAccessView(ViewType viewType, int arrayOrDepthSlice, int mipIndex)\n        {\n            if (!IsUnorderedAccess)\n                return null;\n\n            if (IsMultiSampled)\n                throw new NotSupportedException(\"Multi-sampling is not supported for Unordered Access Views\");\n\n            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out var arrayCount, out _);\n\n            var uavDescription = new UnorderedAccessViewDesc { Format = (Format) ViewFormat };\n\n            if (ArraySize > 1)\n            {\n                switch (ViewDimension)\n                {\n                    case TextureDimension.Texture1D:\n                        uavDescription.ViewDimension = UavDimension.Texture1Darray;\n                        break;\n\n                    case TextureDimension.TextureCube:\n                    case TextureDimension.Texture2D:\n                        uavDescription.ViewDimension = UavDimension.Texture2Darray;\n                        break;\n","sourceCodeStart":688,"sourceCodeEnd":724,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs#L688-L724","documentation":"D3D11 unordered access views (UAVs) have no multi-sampled view dimension. Stride throws this NotSupportedException in GetUnorderedAccessView whenever a texture with TextureFlags.UnorderedAccess is multi-sampled, since read-write access to MSAA resources is not possible in Direct3D 11.","triggerScenarios":"Creating a texture with both TextureFlags.UnorderedAccess and MultisampleCount > MultisampleCount.None (e.g., Texture.New2D(..., MultisampleCount.X4, TextureFlags.UnorderedAccess)), which fails during InitializeFromImpl.","commonSituations":"Trying to write to a multi-sampled target from a compute shader; adding the UnorderedAccess flag to an MSAA g-buffer description; porting D3D11.1+ / D3D12 code that supports MSAA UAVs (D3D11 only supports it via explicit decode/encode, not plain UAVs).","solutions":["Set MultisampleCount = MultisampleCount.None on any texture flagged UnorderedAccess.","Resolve the MSAA texture first (multisample resolve to a non-MSAA texture) and bind the resolved texture as UAV.","Compute into a non-MSAA UAV, then multi-sample-aware load it in pixel shaders via Texture2DMS."],"exampleFix":"// before\nvar tex = Texture.New2D(GraphicsDevice, 1024, 1024, PixelFormat.R32G32B32A32_Float,\n    TextureFlags.UnorderedAccess, MultisampleCount.X4);\n// after\nvar tex = Texture.New2D(GraphicsDevice, 1024, 1024, PixelFormat.R32G32B32A32_Float,\n    TextureFlags.UnorderedAccess, MultisampleCount.None);","handlingStrategy":"validation","validationCode":"if (desc.MultisampleCount > MultisampleCount.None && (desc.Flags & TextureFlags.UnorderedAccess) != 0)\n    throw new InvalidOperationException(\"UAV textures cannot be multi-sampled in D3D11\");","typeGuard":"bool SupportsUav(TextureDescription d) =>\n    (d.Flags & TextureFlags.UnorderedAccess) == 0 || d.MultisampleCount == MultisampleCount.None;","tryCatchPattern":"try { var tex = Texture.New2D(...); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"Unordered Access Views\"))\n{\n    // recreate without MSAA or resolve first\n}","preventionTips":["Keep UAV flags and MSAA flags mutually exclusive in texture factory code.","Resolve MSAA textures before compute-shader writes."],"tags":["direct3d11","uav","multisampling","compute-shader"],"backgroundTag":"unsupported-operation","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"}