stride3d/stride · error · NotSupportedException

Multi-sampling is not supported for Unordered Access Views

Error message

Multi-sampling is not supported for Unordered Access Views

What it means

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.

Solutions

  1. Set MultisampleCount = MultisampleCount.None on any texture flagged UnorderedAccess.
  2. Resolve the MSAA texture first (multisample resolve to a non-MSAA texture) and bind the resolved texture as UAV.
  3. Compute into a non-MSAA UAV, then multi-sample-aware load it in pixel shaders via Texture2DMS.

Example fix

// before
var tex = Texture.New2D(GraphicsDevice, 1024, 1024, PixelFormat.R32G32B32A32_Float,
    TextureFlags.UnorderedAccess, MultisampleCount.X4);
// after
var tex = Texture.New2D(GraphicsDevice, 1024, 1024, PixelFormat.R32G32B32A32_Float,
    TextureFlags.UnorderedAccess, MultisampleCount.None);
Defensive patterns

Strategy: validation

Validate before calling

if (desc.MultisampleCount > MultisampleCount.None && (desc.Flags & TextureFlags.UnorderedAccess) != 0)
    throw new InvalidOperationException("UAV textures cannot be multi-sampled in D3D11");

Type guard

bool SupportsUav(TextureDescription d) =>
    (d.Flags & TextureFlags.UnorderedAccess) == 0 || d.MultisampleCount == MultisampleCount.None;

Try / catch

try { var tex = Texture.New2D(...); }
catch (NotSupportedException ex) when (ex.Message.Contains("Unordered Access Views"))
{
    // recreate without MSAA or resolve first
}

Prevention

When it happens

Trigger: Creating a texture with both TextureFlags.UnorderedAccess and MultisampleCount > MultisampleCount.None (e.g., Texture.New2D(..., MultisampleCount.X4, TextureFlags.UnorderedAccess)), which fails during InitializeFromImpl.

Common situations: 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).

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/40952f6847b0853c. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs:706

        }

        /// <summary>
        ///   Gets a specific <see cref="ID3D11UnorderedAccessView"/> from the Texture.
        /// </summary>
        /// <param name="viewType">The desired View type of the Unordered Access View.</param>
        /// <param name="arrayOrDepthSlice">The index of the Texture array or depth slice.</param>
        /// <param name="mipIndex">The index of the mip-level.</param>
        /// <returns>An <see cref="ID3D11UnorderedAccessView"/> for the Texture.</returns>
        /// <exception cref="NotSupportedException">Multi-sampling is not supported for Unordered Access Views.</exception>
        /// <exception cref="NotSupportedException">A Texture Cube must have an array size greater than 1.</exception>
        /// <exception cref="NotSupportedException">Texture Arrays are not supported for 3D Textures.</exception>
        private ComPtr<ID3D11UnorderedAccessView> GetUnorderedAccessView(ViewType viewType, int arrayOrDepthSlice, int mipIndex)
        {
            if (!IsUnorderedAccess)
                return null;

            if (IsMultiSampled)
                throw new NotSupportedException("Multi-sampling is not supported for Unordered Access Views");

            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out var arrayCount, out _);

            var uavDescription = new UnorderedAccessViewDesc { Format = (Format) ViewFormat };

            if (ArraySize > 1)
            {
                switch (ViewDimension)
                {
                    case TextureDimension.Texture1D:
                        uavDescription.ViewDimension = UavDimension.Texture1Darray;
                        break;

                    case TextureDimension.TextureCube:
                    case TextureDimension.Texture2D:
                        uavDescription.ViewDimension = UavDimension.Texture2Darray;
                        break;

View on GitHub (pinned to 96fad776d2)