Create IDXGISurface from array ID3D11Texture2D

Lukas F 6 Reputation points
2020-08-10T20:15:30.447+00:00

I am trying to get HW accelerated video decoding to work in an UWP app. When using D3D11, my decoder will return a ID3D11Texture2D and an index. The texture has an ArraySize of 28. For rendering samples into UWP, I need to convert the texture to a IDXGISurface, call CreateDirect3DSurface to get an IDirect3D11Surface, and finally create a sample using MediaStreamSample.CreateFromDirect3D11Surface().

The problem is now: A IDXGISurface, according to msdn docs, is only implicitly created for textures with ArraySize=1. Then I can QueryInterface the texture for IDXGISurface. But my texture has ArraySize=28, so I get E_NOINTERFACE. I tried to use CreateSubresourceSurface with an index. This gets me a IDXGISurface. But when I try to create a sample from it using MediaStreamSample.CreateFromDirect3D11Surface(), I get an exception, again E_NOINTERFACE. I guess this is because the IDXGISurface does not implement ID3D11Texture2D (this seems to be required, although not documented. I checked, this IDXGISurface really does not return ID3D11Texture2D on QueryInterface).

Is there any way to create a IDXGISurface from an array texture? Create a texture or surface that points to the sub area of the array texture? I cannot really change the decoder since it's a 3rd party library.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,430 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rita Han - MSFT 2,161 Reputation points
    2020-08-11T02:46:46.69+00:00

    Hello,

    If the 2D texture has only a single MIP-map level and does not consist of an array of textures, QueryInterface succeeds and returns a pointer to the IDXGISurface interface pointer. Otherwise, QueryInterface fails and does not return the pointer to IDXGISurface.

    So it seems by design not supporting an array of textures.

    The following is a workaround you can check to see if it helps:

    Create a staging texture with one layer to render to and copy the result into the texture array using ID3D11DeviceContext::CopySubresourceRegion.

    Thank you!

    0 comments No comments