Search code examples
c#directxsharpdx

Texture for UnorderedAccessView


I would need to create an UnorderedAccessView for use as output of a compute shader:

  var target = new Texture2D(device, new Texture2DDescription() {
    Width = bitmap.PixelWidth,
    Height = bitmap.PixelHeight,
    ArraySize = 1,
    MipLevels = 1,
    Format = Format.R8G8B8A8_UNorm,
    SampleDescription = new SampleDescription() { Count = 1, Quality = 0 },
    BindFlags = BindFlags.UnorderedAccess | BindFlags.ShaderResource,
    Usage = ResourceUsage.Dynamic
  });
  var targetView = new UnorderedAccessView(device, target);

The first line keeps resulting in a Parameter is incorrect exception. Debug device and layer are switched on, there is no more useful debug or error message. Creating the texture without BindFlags.UnorderedAccess works but that's not what I need.

I tried all possible combinations of the flags, including but not limited to:

    Format = Format.B8G8R8A8_UNorm,
    BindFlags = BindFlags.UnorderedAccess,
    Usage = ResourceUsage.Default

Nothing runs if BindFlags.UnorderedAccess is asked for.

DX11.2, Shader 5.


Solution

  • The device was created at Feature Level 9_3 which does not support UAVs or Compute Shaders.