sskodje / ScreenRecorderLib

A .NET library for screen recording in Windows, using native Microsoft Media Foundation for realtime encoding to h264 video or PNG images.
MIT License
414 stars 94 forks source link

D3D11 ERROR: ID3D11Device::CreateTexture2D #280

Closed NotBadCoderr closed 10 months ago

NotBadCoderr commented 10 months ago

Hi! My computer has dual monitors. There is no issue when recording the primary screen, but an error occurs when trying to record the secondary screen. image

The error message seems to indicate an issue with BindFlags, and I have attempted to modify BindFlags=0. However, when attempting to CopyResource this time, another error occurs. image

secondary screen info

DXGI_OUTPUT_DESC

  Name Value Type
DeviceName 0x000000ad09ffe3f8 L"\\.\DISPLAY1" wchar_t[32]
DesktopCoordinates {LT(1920, 0) RB(3840, 1080) [1920 x 1080]} tagRECT
AttachedToDesktop 1 int
Rotation DXGI_MODE_ROTATION_IDENTITY (1) DXGI_MODE_ROTATION
Monitor 0x0000000000010003 {unused=??? } HMONITOR__ *

DXGI_ADAPTER_DESC

  Name Value Type
Description 0x000000ad0dffec30 L"AMD Radeon(TM) Graphics" wchar_t[128]
  VendorId 4098 unsigned int
  DeviceId 5686 unsigned int
  SubSysId 977213354 unsigned int
  Revision 199 unsigned int
  DedicatedVideoMemory 520724480 unsigned __int64
  DedicatedSystemMemory 0 unsigned __int64
  SharedSystemMemory 8252983296 unsigned __int64
AdapterLuid {LowPart=73001 HighPart=0 } _LUID

primary screen info

DXGI_OUTPUT_DESC

  Name Value Type
DeviceName 0x00000017a0ffdf58 L"\\.\DISPLAY1" wchar_t[32]
DesktopCoordinates {LT(1920, 0) RB(3840, 1080) [1920 x 1080]} tagRECT
AttachedToDesktop 1 int
Rotation DXGI_MODE_ROTATION_IDENTITY (1) DXGI_MODE_ROTATION
Monitor 0x0000000000010003 {unused=??? } HMONITOR__ *

DXGI_ADAPTER_DESC

  Name Value Type
Description 0x00000017a492e7b0 L"NVIDIA GeForce GTX 1650" wchar_t[128]
VendorId 4318 unsigned int
DeviceId 8089 unsigned int
SubSysId 977475498 unsigned int
Revision 161 unsigned int
DedicatedVideoMemory 4154458112 unsigned __int64
DedicatedSystemMemory 0 unsigned __int64
SharedSystemMemory 8252983296 unsigned __int64
AdapterLuid {LowPart=75237 HighPart=0 } _LUID
sskodje commented 10 months ago

I believe the issue was that the texture was created on the ID3D11Device of the wrong monitor. Since you are recording from the outputs of two different video cards, there are also two ID3D11Devices, and textures have to be copied with the CPU between them. I pushed a fix with 805abff, let me know if it fixes the issue :)

NotBadCoderr commented 10 months ago

Yes, it has been fixed. Thank you for your support.