GL/DX linking error

Hey Lynn, hope you’re well!

I’m updating my application StageFlow to use the latest 2.0.0.7 build. I love using the new Spout.dll. makes everything much cleaner and less prone to user error!

I am however running into a strange issue. I’m developing on a little Microsoft Surface laptop with an integrated Intel HD 620.

On the master branch, when I run Demo Sender, it reports:

Not compatible for OpenGL texture sharing. CPU system memory used as backup

However, when I switch to the 2.0.0.6 branch, Demo Sender reports that everything is fine:

NV_DX_interop extension available, DirectX 11 Texture share mode

My code, using a simple draw routine based on SpoutGL::BindSharedTexture works if using the 2.0.0.6 branch. On the master branch, BindSharedTexture never returns true, I assume because the GL/DX interop is reported as not working.

When I check the logs, it mentions an error in spoutGL::LinkGLDXtextures.

[notice] spoutGL::OpenSpout - 64bit 2.007 - this 0xB34DC070
[notice] spoutGL::OpenDirectX
[notice] spoutDirectX::OpenDirectX11()
[notice] Device already initialized 0xB35A8F78
[notice] spoutGL::GLDXready - testing for GL/DX interop compatibility
[notice] GL/DX interop extensions available
[notice] spoutGL::GLDXready - testing GL/DX interop functions
[notice] spoutDirectX::CreateSharedDX11Texture
[notice] pDevice = 0xB35A8F78, width = 256, height = 256, format = 87
[notice] pTexture = 0xAAC3F378 : dxShareHandle = 0x0008502
[notice] Linking test - OpenGL texture (0x0000002) DX11 texture (0xAAC3F378)
[error] spoutGL::LinkGLDXtextures - wglDXRegisterObjectNV :error 13, (0xD)
Incorrect GL name, type or access parameters.
[notice] spoutDirectX::ReleaseDX11Texture (0xB35A8F78)
[warning] spoutGL::GLDXready - GL/DX interop functions failed
[warning] spoutGL::OpenSpout - system is not compatible with GL/DX interop
[warning] Using CPU DirectX methods
[notice] spoutGL::CloseDirectX()
[notice] spoutDirectX::CloseDirectX11()

Is this differing behavior between versions expected? And if I am indeed CPU bound, what is the recommended way for me to address that?

Hi Joris, All is well.

The error definitely means that the interop handle returned is null and BindSharedTexture would not work.

The thing that comes to mind right away is that 2.006 is using DirectX 9, but then the demo sender reports using DirectX 11. You can test any difference with with 2.006 SpoutSettings. 2.007 uses DirectX 11 only.

2.007 SpoutSettings has a more comprehensive diagnostic with log. If that says “Compatible for OpenGL texture sharing” there is something else going on. Paste he diagnostics here so we can see the result.

I will think a little more about it.

Edit: Forgot to ask - is this receiving or sending? Does the error occur for both?

It’s amazing how quick you are with replies, Lynn!

The error occurs when using Spout Demo Sender to send to my own application StageFlow as well as to Spout Demo Receiver. Demo Receiver reports the same error.

When switching to the 2.0.0.6 branch, sending from Demo Sender to Demo Receiver defaults to DX11 mode and works as expected, as well as after swtiching to DX9 using SpoutSettings.

Here is the SpoutSettings log from the master branch.

========================
Spout log file

2021-12-13 10:29:28
[notice] SpoutSettings : SpoutPanel already registered
[notice] spoutGL::OpenDirectX
[notice] spoutDirectX::OpenDirectX11()
[notice] spoutDirectX::CreateDX11device - pAdapterDX11 (0x0000000)
[notice] device (0x3E6BD628)
[notice] spoutGL::CleanupDX11()
[notice] spoutDirectX::CloseDirectX11()
[warning] spoutGL::LoadGLextensions - pbo extensions not available
[notice] spoutGL::OpenDirectX11
[notice] spoutDirectX::OpenDirectX11()
[notice] spoutDirectX::CreateDX11device - pAdapterDX11 (0x0000000)
[notice] device (0x3E78EE08)
[notice] spoutGL::GLDXready - testing for GL/DX interop compatibility
[notice] GL/DX interop extensions available
[notice] spoutGL::GLDXready - testing GL/DX interop functions
[notice] spoutDirectX::CreateSharedDX11Texture
[notice] pDevice = 0x3E78EE08, width = 256, height = 256, format = 87
[notice] pTexture = 0x3E835578 : dxShareHandle = 0x0005DC2
[notice] Linking test - OpenGL texture (0x0000001) DX11 texture (0x3E835578)
[error] spoutGL::LinkGLDXtextures - wglDXRegisterObjectNV :error 13, (0xD)
Incorrect GL name, type or access parameters.
[notice] spoutDirectX::ReleaseDX11Texture (0x3E78EE08)
[warning] spoutGL::GLDXready - GL/DX interop functions failed
[notice] spoutGL::CleanupDX11()
[notice] spoutDirectX::CloseDirectX11()

I found an error that could be the cause of your problem. In the GLDXready() function an OpenGL texture to be used in the test is generated, then deleted. As it happens, deleting it does not change the “name” so wglDXRegisterObjectNV passes and the interop handle is returned. Thereafter it is unregistered, so is never used and the error has not been detected. It could be that your Intel driver is more particular. I have updated beta branch so you can rebuild the library and test it. I will leave the master branch for now so that you can compare.

The other difference is that in 2.007, the OpenGL texture used for the interop link is created with glTexImage2D, whereas in 2.006 it is only generated. The NV_DX_interop2 specification simply generates the texture. I will go back to that after you try the current change.

Awesome. That sounds promising!

Unfortunately, on the beta branch, I get an unresolved external error for Spout::~Spout. It looks like you made this virtual at some point in the beta branch. Could it be that the provided Spout.dll from Binaries does not include this change yet?

After building Spout.lib and Spout.dll from source, I can confirm that Spout::GetSenderCPU no longer returns true and BindSharedTexture works as expected! Awesome sauce! Thank you so much for the quick work!

I was about to reply that you had to re-build the dll. Anyway, I am happy that this has solved your problem and that the Intel GPU is now working. I am still going through the beta branch, but it’s getting close to completion.

I updated master branch to remove the texture delete error while beta is under completion.
I am glad you like it. The question is do you want onion with that.