Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] Fix failure to initialize ddagrab if adapter ID is specified
@ 2023-06-01 14:18 Jøger Hansegård
  0 siblings, 0 replies; 3+ messages in thread
From: Jøger Hansegård @ 2023-06-01 14:18 UTC (permalink / raw)
  To: ffmpeg-devel

From dd7208b1edd0d7efcde1a12fd468a180737ad9cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B8ger=20Hanseg=C3=A5rd?= <joger.hansegard@qt.io>
Date: Thu, 1 Jun 2023 15:30:48 +0200
Subject: [PATCH] Fix failure to initialize ddagrab if adapter ID is specified

If an adapter ID is specified when initializing hw device for d3d11va,
ddagrab does not work on Windows 11. This prevents capturing screens
connected to a secondary adapter.

Failing command:
    ffmpeg -init_hw_device d3d11va:0 -filter_complex ddagrab=0,hwdownload,format=bgra -c:v h264_mf output.mkv

The reason is that d3d11va_device_create uses CreateDXGIFactory to
create a DXGIFactory 1.0. This causes init_dxgi_dda's call to
IDXGIOutput5_DuplicateOutput1 to fail because it is only supported on
DXGI 1.1 and higher.

The fix is to always crate DXGI factory using CreateDXGIFactory1 as
proposed in this patch.

Fixes: #10385
---
 libavutil/hwcontext_d3d11va.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index aa50538d64..fa8d5410f2 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -62,7 +62,7 @@ static av_cold void load_functions(void)
         return;

     mD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE) GetProcAddress(d3dlib, "D3D11CreateDevice");
-    mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory");
+    mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory1");
 #else
     // In UWP (which lacks LoadLibrary), CreateDXGIFactory isn't available,
     // only CreateDXGIFactory1
--
2.40.1.windows.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] Fix failure to initialize ddagrab if adapter ID is specified
  2023-08-08 17:52 Jøger Hansegård
@ 2023-08-08 18:34 ` James Almer
  0 siblings, 0 replies; 3+ messages in thread
From: James Almer @ 2023-08-08 18:34 UTC (permalink / raw)
  To: ffmpeg-devel

On 8/8/2023 2:52 PM, Jøger Hansegård wrote:
> Fix failure to initialize ddagrab if adapter ID is specified.
> 
> If an adapter ID is specified when initializing hw device for d3d11va,
> ddagrab does not work on Windows 11. This prevents capturing screens
> connected to a secondary adapter.
> 
> Failing command:
>      ffmpeg -init_hw_device d3d11va:0 -filter_complex ddagrab=0,hwdownload,format=bgra -c:v h264_mf output.mkv
> 
> The reason is that d3d11va_device_create uses CreateDXGIFactory to
> create a DXGIFactory 1.0. This causes init_dxgi_dda's call to
> IDXGIOutput5_DuplicateOutput1 to fail because it is only supported on
> DXGI 1.1 and higher.
> 
> The fix is to always crate DXGI factory using CreateDXGIFactory1 as
> proposed in this patch.
> 
> Fixes: #10385
> ---
>   libavutil/hwcontext_d3d11va.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
> index aa50538d64..fa8d5410f2 100644
> --- a/libavutil/hwcontext_d3d11va.c
> +++ b/libavutil/hwcontext_d3d11va.c
> @@ -62,7 +62,7 @@ static av_cold void load_functions(void)
>           return;
> 
>       mD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE) GetProcAddress(d3dlib, "D3D11CreateDevice");
> -    mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory");
> +    mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory1");
>   #else
>       // In UWP (which lacks LoadLibrary), CreateDXGIFactory isn't available,
>       // only CreateDXGIFactory1
> --
> 2.40.1.windows.1

LGTM, but i wonder why are we using IDXGIFactory2 and its functions in 
hwcontext_d3d11va if we use DXGI 1.1?

Maybe we could do the following:

> diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
> index aa50538d64..fb6f240c56 100644
> --- a/libavutil/hwcontext_d3d11va.c
> +++ b/libavutil/hwcontext_d3d11va.c
> @@ -24,7 +24,7 @@
> 
>  #include <initguid.h>
>  #include <d3d11.h>
> -#include <dxgi1_2.h>
> +#include <dxgi.h>
> 
>  #if HAVE_DXGIDEBUG_H
>  #include <dxgidebug.h>
> @@ -62,7 +62,7 @@ static av_cold void load_functions(void)
>          return;
> 
>      mD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE) GetProcAddress(d3dlib, "D3D11CreateDevice");
> -    mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory");
> +    mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory1");
>  #else
>      // In UWP (which lacks LoadLibrary), CreateDXGIFactory isn't available,
>      // only CreateDXGIFactory1
> @@ -581,19 +581,19 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device,
>      }
> 
>      if (device) {
> -        IDXGIFactory2 *pDXGIFactory;
> -        hr = mCreateDXGIFactory(&IID_IDXGIFactory2, (void **)&pDXGIFactory);
> +        IDXGIFactory1 *pDXGIFactory;
> +        hr = mCreateDXGIFactory(&IID_IDXGIFactory1, (void **)&pDXGIFactory);
>          if (SUCCEEDED(hr)) {
>              int adapter = atoi(device);
> -            if (FAILED(IDXGIFactory2_EnumAdapters(pDXGIFactory, adapter, &pAdapter)))
> +            if (FAILED(IDXGIFactory1_EnumAdapters(pDXGIFactory, adapter, &pAdapter)))
>                  pAdapter = NULL;
> -            IDXGIFactory2_Release(pDXGIFactory);
> +            IDXGIFactory1_Release(pDXGIFactory);
>          }
>      }
> 
>      if (pAdapter) {
>          DXGI_ADAPTER_DESC desc;
> -        hr = IDXGIAdapter2_GetDesc(pAdapter, &desc);
> +        hr = IDXGIAdapter1_GetDesc(pAdapter, &desc);
>          if (!FAILED(hr)) {
>              av_log(ctx, AV_LOG_INFO, "Using device %04x:%04x (%ls).\n",
>                     desc.VendorId, desc.DeviceId, desc.Description);

Not sure what Martin thinks.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [FFmpeg-devel] [PATCH] Fix failure to initialize ddagrab if adapter ID is specified
@ 2023-08-08 17:52 Jøger Hansegård
  2023-08-08 18:34 ` James Almer
  0 siblings, 1 reply; 3+ messages in thread
From: Jøger Hansegård @ 2023-08-08 17:52 UTC (permalink / raw)
  To: ffmpeg-devel


[-- Attachment #1.1: Type: text/plain, Size: 2064 bytes --]

Fix failure to initialize ddagrab if adapter ID is specified.

If an adapter ID is specified when initializing hw device for d3d11va,
ddagrab does not work on Windows 11. This prevents capturing screens
connected to a secondary adapter.

Failing command:
    ffmpeg -init_hw_device d3d11va:0 -filter_complex ddagrab=0,hwdownload,format=bgra -c:v h264_mf output.mkv

The reason is that d3d11va_device_create uses CreateDXGIFactory to
create a DXGIFactory 1.0. This causes init_dxgi_dda's call to
IDXGIOutput5_DuplicateOutput1 to fail because it is only supported on
DXGI 1.1 and higher.

The fix is to always crate DXGI factory using CreateDXGIFactory1 as
proposed in this patch.

Fixes: #10385
---
 libavutil/hwcontext_d3d11va.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index aa50538d64..fa8d5410f2 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -62,7 +62,7 @@ static av_cold void load_functions(void)
         return;

     mD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE) GetProcAddress(d3dlib, "D3D11CreateDevice");
-    mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory");
+    mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory1");
 #else
     // In UWP (which lacks LoadLibrary), CreateDXGIFactory isn't available,
     // only CreateDXGIFactory1
--
2.40.1.windows.1



Jøger Hansegård
PhD
Senior R&D Manager
The Qt Company
Sandakerveien 116
0484 Oslo
Norway
joger.hansegard@qt.io<mailto:joger.hansegard@qt.io>
+4792642127
www.qt.io<https://www.qt.io>

[cid:image001.png@01D9CA31.9D2C6180]<https://www.qt.io/>
[cid:image002.png@01D9CA31.9D2C6180]<https://www.facebook.com/qt/>
[cid:image003.png@01D9CA31.9D2C6180]<https://twitter.com/qtproject>
[cid:image004.png@01D9CA31.9D2C6180]<https://www.linkedin.com/company/qtgroup/>
[cid:image005.png@01D9CA31.9D2C6180]<https://www.youtube.com/QtStudios>



[-- Attachment #1.2: image001.png --]
[-- Type: image/png, Size: 3186 bytes --]

[-- Attachment #1.3: image002.png --]
[-- Type: image/png, Size: 460 bytes --]

[-- Attachment #1.4: image003.png --]
[-- Type: image/png, Size: 890 bytes --]

[-- Attachment #1.5: image004.png --]
[-- Type: image/png, Size: 626 bytes --]

[-- Attachment #1.6: image005.png --]
[-- Type: image/png, Size: 656 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-08 18:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-01 14:18 [FFmpeg-devel] [PATCH] Fix failure to initialize ddagrab if adapter ID is specified Jøger Hansegård
2023-08-08 17:52 Jøger Hansegård
2023-08-08 18:34 ` James Almer

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git