Genvid Forum

Genvid Technologies

SetParameterPointer may hang indefinitely


Short version: When you submit a D3D11Texture2D from one GraphicsDevice, dispose that, create a second Graphics Device with a new D3D11Texture2D, and try to call SetParameterPointer with that, the call might not return.

We submit a D3D11Texture2D regularly. Sometimes the underlying DX11 graphics-device changes (Even the underlying adapter might even change, for example when the window is moved across screen boundaries).

This of course leads also to the creation of a new D3D11Texture2D. We then (and only then) try to update to the pointer to the Texture, by calling SetParameterPointer a 2nd time:

if (TextureHandle != LastTextureHandle)
    LastTextureHandle= TextureHandle;
    Check(GenvidHacks.SetParameterPointer(VideoStream, "Video.Source.ID3D11Texture2D", TextureHandle));

However, SetParameterPointer never returns in this case, and hangs forever.

I am definitely not an expert on DirectX - far from it - so my approach of recreating the graphics-device might be entirely wrong. We use the Desktop Duplication API to create the submitted texture (for multiple reasons that is the most performant way to submit our game), and the documentation is specific that you need to pass a pointer to the correct graphics device from the correct adapter:

pDevice [in]
A pointer to the Direct3D device interface that you can use to process the desktop image. This device must be created from the adapter to which the output is connected.

So when the captured window is moved from one monitor to another we recreate a new graphics-device (for simplicity reasons, even if it moved between two monitors on the same adapter), and discard the old one, along with the old Texture.

If this kind of action is supposed to be impossible, SetParameterPointer should at least return with a non-OK status instead of hanging / blocking.

This is not a critical issue at all, since this sort of issue will never occur in a production-envrionment - only affected my dev-machine. :slight_smile:

For reference:

[DllImport("Genvid.dll", EntryPoint = "Genvid_SetParameterPointer", CallingConvention = CallingConvention.Cdecl)]
public static extern GenvidSDK.Status SetParameterPointer(string streamID, string paramKey, IntPtr parameter);


Hi Moritz,

Our team is currently investigating this behavior and we will have an answer for you shortly.