DXIFRShim Sample does not work?

Hello,

I am trying out the DXIFRShim sample included in the Capture SDK 5.0, and I do not get a video produced, and the game that I run (Guild Wars 1) falls back to DirectX 8.

I’m going to share the steps I took, and maybe someone could see if I did anything wrong?

I’ve tried NvFBCToSys and NvFBCHWEncode without issues, but I want to do render window capture instead of desktop.

  1. I opened DXIFRShim_VS2013.sln in VS2013.
  2. I switched the build to Release, and built the solution using Win32 and x64 configurations.
  3. I placed the generated Win32 d3d9.dll into the System32 folder, and the generated x64 d3d9.dll into the SysWOW64 folder, renaming the original .dll to _d3d9.dll. The sample description docs say to do this renaming.
  4. (I tested doing this step and skipping this step, neither worked) I did the above with the DXGI.dll files.
  5. (I did this step with both Win32 and x64 configurations, neither worked) I launched StartApp.exe using the following command:
    StartApp.exe -r 800x600 -gpu 0 -audio 0 D:\User\Guild Wars\Gw.exe
    
  6. I checked the settings page of the game and it said it was using DirectX 8. It uses DirectX 9 without the above modifications.
  7. Closed the game
  8. Ctrl+C in the command line for StartApp.exe
  9. There is no .h264 video file produced anywhere (not surprising considering the issue in step 6). The sample description docs says there should be a file named NvIFR.h264.

Does anyone know where I went wrong?

Additional info if needed:
Windows 8 64 bit
Nvidia GRID K520

Hi bloodelves88,

According to the doc,

In the 32-bit WOW system folder (which is usually C:\Windows\SysWOW64)
For 64-bit build, the system folder is usually C:\Windows\System32.

I think you may have misplaced the shim DLLs.

Gary

I’ve enabled the logs and it didn’t output anything before Gary’s fix.

I’ll take a look at the session and see if I can learn anything more from it. Thanks.

Hi Gary, which doc is that from? I don’t see it. I’m using the docs provided in the capture SDK. Are there more docs I’m not aware of?

Aside from that, thanks, that seemed to solve the issue.

This doc is in Usage.txt, which resides in the folder SDK\samples\DirectxIFR\DXIFRShim.

Gary

Hi Gary, that file does not exist in my folder. Is there any way I could obtain it? I’m having quite a bit of trouble getting the program to work with DirectX 10/11 games.

While the sample program produces a d3d9.dll file, it does not produce a d3d10.dll or d3d11.dll file. Does it not work for DirectX 10 and 11? The sample description docs does say it is for DirectX 9/9Ex/10.0/10.1/11.0.

DXGI.shim.log produces these 3 lines (among many others) when I run a DirectX 11 game:

[ERROR][17:38:45] failed to create pSharedTexture
[ERROR][17:38:45] Failed to setup NvIFR.
[WARN ][17:38:45] failed to start d3d11 encoder

Am I missing something again? I appreciate any help I can get.

What’s your OS?

Gary

Windows 8.1 Pro 64 bit. DxDiag says I do have DirectX 11.

I’m getting different results in DXGI.shim.log when running World of Tanks and Wildstar.

World of Tanks:

[DEBUG][12:57:53] CreateDXGIFactory_Proxy
[DEBUG][12:57:53] CreateDXGIFactory1_Proxy
[DEBUG][12:57:53] IDXGIFactory_EnumAdapters_Proxy
[INFO ][12:57:53] (DXGI) Using adapter: coordinate ordinal=0, D3D ordinal=0
[DEBUG][12:57:54] IDXGIFactory_EnumAdapters_Proxy
[DEBUG][12:57:54] IDXGIFactory_EnumAdapters_Proxy
[INFO ][12:57:54] (DXGI) Using adapter: coordinate ordinal=0, D3D ordinal=0
[DEBUG][12:57:54] IDXGIFactory_EnumAdapters_Proxy
[INFO ][12:57:54] (DXGI) Using adapter: coordinate ordinal=0, D3D ordinal=0
[DEBUG][12:57:54] IDXGIFactory_EnumAdapters_Proxy
[INFO ][12:57:54] (DXGI) Using adapter: coordinate ordinal=0, D3D ordinal=0
[DEBUG][12:57:54] IDXGIFactory_EnumAdapters_Proxy
[INFO ][12:57:54] (DXGI) Using adapter: coordinate ordinal=0, D3D ordinal=0
[DEBUG][12:57:54] IDXGIFactory_EnumAdapters_Proxy
[INFO ][12:57:54] (DXGI) Using adapter: coordinate ordinal=0, D3D ordinal=0
[INFO ][12:57:54] IDXGIFactory_CreateSwapChain_Proxy: 0x0, windowed
[DEBUG][12:57:54] IDXGIFactory_CreateSwapChain_Proxy: This=0032BBF8, pDevice=08FF26CC, *pDesc=[BufferDesc=[Width=0, Height=0, RefreshRate=0/1, Format=87, ScanlineOrdering=1, Scaling=0], SampleDesc=[Width=1, Height=0], BufferUsage=112, BufferCount=2, OutputWindow=012A0A6E, Windowed=1, SwapEffect=0, Flags=2]
[DEBUG][12:57:54] IDXGIFactory_EnumAdapters_Proxy
[INFO ][12:57:54] (DXGI) Using adapter: coordinate ordinal=0, D3D ordinal=0
[DEBUG][12:57:54] IDXGIFactory_EnumAdapters_Proxy
[INFO ][12:57:54] (DXGI) Using adapter: coordinate ordinal=0, D3D ordinal=0
[DEBUG][12:57:55] IDXGIFactory_EnumAdapters_Proxy
[INFO ][12:57:55] (DXGI) Using adapter: coordinate ordinal=0, D3D ordinal=0
[DEBUG][12:57:57] NvIFREncoderDXGIBase::SetupNvIFR
[INFO ][12:57:57] IDXGIFactory_CreateSwapChain_Proxy: 1024x768, windowed
[DEBUG][12:57:57] IDXGIFactory_CreateSwapChain_Proxy: This=0C18BA10, pDevice=0D59C014, *pDesc=[BufferDesc=[Width=1024, Height=768, RefreshRate=0/1, Format=87, ScanlineOrdering=0, Scaling=0], SampleDesc=[Width=1, Height=0], BufferUsage=32, BufferCount=1, OutputWindow=00520AD8, Windowed=1, SwapEffect=0, Flags=0]
[ERROR][12:57:57] failed to create pSharedTexture
[ERROR][12:57:57] Failed to setup NvIFR.
[WARN ][12:57:57] failed to start d3d11 encoder

The last 6 lines then goes on to repeat until I close the game.

Wildstar:

[ERROR][12:59:32] OpenFileMapping() #1 fails.
[DEBUG][12:59:32] CreateDXGIFactory1_Proxy
[DEBUG][12:59:32] IDXGIFactory1_EnumAdapters1_ProxyAdapter=0, ppAdapter=0000006E3464F290
[INFO ][12:59:32] Grid adapter found (DXGI): NVIDIA GRID K520, coordinate ordinal=0, D3D ordinal=0
[DEBUG][12:59:32] IDXGIFactory1_EnumAdapters1_ProxyAdapter=1, ppAdapter=0000006E3464F290
[DEBUG][12:59:32] CreateDXGIFactory_Proxy
[DEBUG][12:59:32] CreateDXGIFactory1_Proxy
[DEBUG][12:59:32] IDXGIFactory_EnumAdapters_Proxy
[INFO ][12:59:32] Grid adapter found (DXGI): NVIDIA GRID K520, coordinate ordinal=0, D3D ordinal=0

I’m going to take a look at the errors starting from the OpenFileMapping() error, but if there’s something someone knows that can speed up my debugging process, that would be great.


Edit: The error from Wildstar is probably because the launcher starts before the client. I’m going to ignore this and work on the other errors.

The error about "failed to create pSharedTexture" seems to have something to do with invalid/incorrect parameters. My debugging continues…

Please change DXIFRShim/DXGI/IDXGISwapChain.cpp line 138 "TRUE" to "FALSE" and try again. Thanks.

Gary

Do you mean this line? It was on line 98 for me:

pEncoder = new NvIFREncoderDXGI<ID3D11Device, ID3D11Texture2D>(This, desc.Width, desc.Height, desc.Format, FALSE, pAppParam);

I too, found out that "td.MiscFlags" governing the use of mutex in NvIFREncoderDXGIBase.cpp was causing the issue.

That fixed one problem, and now there is another:

[DEBUG][20:16:45] Opening shared memory: GRID_AppParam_0x29B3C
[DEBUG][20:16:46] CreateDXGIFactory1_Proxy
[DEBUG][20:16:46] CreateDXGIFactory1_Proxy
[INFO ][20:16:46] IDXGIFactory1_CreateSwapChain_Proxy: 1400x875, windowed
[DEBUG][20:16:46] IDXGIFactory1_CreateSwapChain_Proxy: This=0000006AFFBBEA10, pDevice=0000006AF6AD2238, *pDesc=[BufferDesc=[Width=1400, Height=875, RefreshRate=0/0, Format=24, ScanlineOrdering=0, Scaling=0], SampleDesc=[Width=1, Height=0], BufferUsage=48, BufferCount=1, OutputWindow=0000000000370BA0, Windowed=1, SwapEffect=0, Flags=2]
[DEBUG][20:16:46] NvIFREncoderDXGIBase::SetupNvIFR
[DEBUG][20:16:46] IDXGIFactory1_EnumAdapters1_ProxyAdapter=0, ppAdapter=0000006A88B7BB20
[INFO ][20:16:46] (DXGI) Using adapter: coordinate ordinal=1, D3D ordinal=1
[INFO ][20:16:46] IDXGIFactory1_CreateSwapChain_Proxy: 1400x875, windowed
[DEBUG][20:16:46] IDXGIFactory1_CreateSwapChain_Proxy: This=0000006A8494A780, pDevice=0000006A849B7E80, *pDesc=[BufferDesc=[Width=1400, Height=875, RefreshRate=0/1, Format=24, ScanlineOrdering=0, Scaling=0], SampleDesc=[Width=1, Height=0], BufferUsage=32, BufferCount=1, OutputWindow=00000000043A0B0E, Windowed=1, SwapEffect=0, Flags=0]
[DEBUG][20:16:46] succeeded to create NvIFRToH264HWEncoder
[DEBUG][20:16:46] Codec (H264=4, HEVC=7): 4
[DEBUG][20:16:46] Encoding Parameters:
Average Bit Rate: 10.7288MB
Peak Bit Rate: 10.7288MB
Frame Rate: 50/1
GOP Length: 250
VBV Buffer Size: 1800000B
VBV Initial Delay: 225000B
Enable YUV444 Encoding: 0
Rate Control: 2
Preset: 0
[DEBUG][20:16:46] NvIFRSetUpH264HWEncoder succeeded, target size: 1920x1080
[INFO ][20:16:46] DXGI: to open shared resource
[ERROR][20:16:46] failed to open shared resource, hr=-2147024809
[WARN ][20:16:46] d3d11 UpdateSharedSurface failed
[DEBUG][20:16:46] No sleep to catch up frame rate, delta=-31
[DEBUG][20:16:46] No sleep to catch up frame rate, delta=-22
[DEBUG][20:16:46] No sleep to catch up frame rate, delta=-12
[INFO ][20:16:46] DXGI: to open shared resource
[ERROR][20:16:46] failed to open shared resource, hr=-2147024809
[WARN ][20:16:46] d3d11 UpdateSharedSurface failed
[INFO ][20:16:46] DXGI: to open shared resource
[ERROR][20:16:46] failed to open shared resource, hr=-2147024809
...
// This goes on until I close the game
...
[DEBUG][20:16:50] delete pEncoder in Release(), pEncoder=0000006A803F2AA0
[DEBUG][20:16:50] Quit encoding loop

The debugging continues…

Thanks for the help so far Gary.

I’m not able to reproduce the problem you are seeing. After the change as you did, DX SDK sample BasicHLSL11 works well on Windows 10 Anniversay edition. Currently I don’t have a Windows 8 setup.

I’m wondering if it’s caused by different behavior DX exhibits on different versions of Windows. Can you have a test on Windows 7 or Windows 10, and see the result? (If you don’t have either of these OS readily installed, just let me know.)

Gary

I did some further testing, and it seems the problem occurs on 64-bit games (Unreal Engine). It works perfectly on a 32-bit game (World of Tanks). BasicHLSL11 happens to be 32-bit as well.

I’m trying to find another 64-bit game to test this theory to make sure it’s not some quirk with Unreal Engine.

I don’t have another OS installed, but I may be able to get one installed. It may take some time though since I’m working on a server machine and I don’t have full access to it.

Strange. It now seems to work on both 32 and 64-bit. I’m not sure what I did wrong earlier.

Everything works perfectly now! Thanks for all the help Gary, you’ve been very helpful.

You’re welcome.

Hi, it seems that I’m now unable to replace or delete the d3d9.dll and dxgi.dll files. They are always in use by dwm.exe, Windows Explorer, or some other system process. I’m not sure why they’re suddenly in use, but this never happened a few months ago.

Is there a way to reliably replace the files now? I’ve tried these so far and none of them worked:

  • Killing the processes (dwm.exe just comes back)
  • Using the command line (del /F dxgi.dll). Access is denied.
  • Using a registry setting to delete the file on next restart.
  • Booting into safe mode to try to delete the file.

Or perhaps, is there any other way to get the shim layer working?

Hi, if you’re using Windows 7, you can use

sc stop uxsms

to stop DWM from using dxgi.dll.
After replacing the file, you can restart DWM by

sc start uxsms

With Window 8 and above, there’s no way to stop DWM. You can place the shim DLL in the game folder instead.

Gary