[vlc-commits] d3d11: use the stored DXGI Adpater Description
Steve Lhomme
git at videolan.org
Mon Feb 3 16:59:02 CET 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Feb 3 15:12:55 2020 +0100| [25640567c2e8726539b9eb0656505f13cbe245a2] | committer: Steve Lhomme
d3d11: use the stored DXGI Adpater Description
Instead of reading it each time.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=25640567c2e8726539b9eb0656505f13cbe245a2
---
modules/codec/avcodec/d3d11va.c | 44 +++++++--------------------------
modules/video_chroma/d3d11_fmt.c | 33 ++++++-------------------
modules/video_chroma/d3d11_fmt.h | 4 +--
modules/video_output/win32/direct3d11.c | 15 +++--------
4 files changed, 22 insertions(+), 74 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 77218b0275..1a5e689f1a 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -308,7 +308,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat hwfmt, const
video_format_t final_fmt = *fmt_out;
static const directx_sys_t dx_sys = { DxGetInputList, DxSetupOutput };
- sys->selected_decoder = directx_va_Setup(va, &dx_sys, ctx, desc, fmt_in, isXboxHardware(sys->d3d_dev.d3ddevice),
+ sys->selected_decoder = directx_va_Setup(va, &dx_sys, ctx, desc, fmt_in, isXboxHardware(&sys->d3d_dev),
&final_fmt, &sys->hw.surface_count);
if (sys->selected_decoder == NULL)
{
@@ -321,16 +321,10 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat hwfmt, const
if (err != VLC_SUCCESS)
goto error;
- IDXGIAdapter *p_adapter = D3D11DeviceAdapter(sys->d3d_dev.d3ddevice);
- if (p_adapter) {
- DXGI_ADAPTER_DESC adapterDesc;
- if (SUCCEEDED(IDXGIAdapter_GetDesc(p_adapter, &adapterDesc))) {
- msg_Info(va, "Using D3D11VA (%ls, vendor %x(%s), device %x, revision %x)",
- adapterDesc.Description,
- adapterDesc.VendorId, DxgiVendorStr(adapterDesc.VendorId), adapterDesc.DeviceId, adapterDesc.Revision);
- }
- IDXGIAdapter_Release(p_adapter);
- }
+ msg_Info(va, "Using D3D11VA (%ls, vendor %x(%s), device %x, revision %x)",
+ sys->d3d_dev.adapterDesc.Description,
+ sys->d3d_dev.adapterDesc.VendorId, DxgiVendorStr(sys->d3d_dev.adapterDesc.VendorId),
+ sys->d3d_dev.adapterDesc.DeviceId, sys->d3d_dev.adapterDesc.Revision);
sys->vctx = vlc_video_context_Create( dec_device, VLC_VIDEO_CONTEXT_D3D11VA,
sizeof(d3d11_video_context_t), &d3d11_vctx_ops );
@@ -445,17 +439,7 @@ static int DxSetupOutput(vlc_va_t *va, const directx_va_mode_t *mode, const vide
}
#endif
- IDXGIAdapter *pAdapter = D3D11DeviceAdapter(sys->d3d_dev.d3ddevice);
- if (!pAdapter)
- return VLC_EGENERIC;
-
- DXGI_ADAPTER_DESC adapterDesc;
- hr = IDXGIAdapter_GetDesc(pAdapter, &adapterDesc);
- IDXGIAdapter_Release(pAdapter);
- if (FAILED(hr))
- return VLC_EGENERIC;
-
- if (!directx_va_canUseDecoder(va, adapterDesc.VendorId, adapterDesc.DeviceId,
+ if (!directx_va_canUseDecoder(va, sys->d3d_dev.adapterDesc.VendorId, sys->d3d_dev.adapterDesc.DeviceId,
mode->guid, sys->d3d_dev.WDDM.build))
{
msg_Warn(va, "GPU blacklisted for %s codec", mode->name);
@@ -551,21 +535,11 @@ static int DxSetupOutput(vlc_va_t *va, const directx_va_mode_t *mode, const vide
return VLC_EGENERIC;
}
-static bool CanUseDecoderPadding(vlc_va_sys_t *sys)
+static bool CanUseDecoderPadding(const vlc_va_sys_t *sys)
{
- IDXGIAdapter *pAdapter = D3D11DeviceAdapter(sys->d3d_dev.d3ddevice);
- if (!pAdapter)
- return false;
-
- DXGI_ADAPTER_DESC adapterDesc;
- HRESULT hr = IDXGIAdapter_GetDesc(pAdapter, &adapterDesc);
- IDXGIAdapter_Release(pAdapter);
- if (FAILED(hr))
- return false;
-
/* Qualcomm hardware has issues with textures and pixels that should not be
* part of the decoded area */
- return adapterDesc.VendorId != GPU_MANUFACTURER_QUALCOMM;
+ return sys->d3d_dev.adapterDesc.VendorId != GPU_MANUFACTURER_QUALCOMM;
}
/**
@@ -589,7 +563,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
* crashes totally the device */
if (codec_id == AV_CODEC_ID_H264 &&
(fmt->i_width > 2304 || fmt->i_height > 2304) &&
- isXboxHardware(sys->d3d_dev.d3ddevice))
+ isXboxHardware(&sys->d3d_dev))
{
msg_Warn(va, "%dx%d resolution not supported by your hardware", fmt->i_width, fmt->i_height);
return VLC_EGENERIC;
diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c
index cf4f3ea402..805382977b 100644
--- a/modules/video_chroma/d3d11_fmt.c
+++ b/modules/video_chroma/d3d11_fmt.c
@@ -404,22 +404,15 @@ IDXGIAdapter *D3D11DeviceAdapter(ID3D11Device *d3ddev)
return p_adapter;
}
-bool isXboxHardware(ID3D11Device *d3ddev)
+bool isXboxHardware(const d3d11_device_t *d3ddev)
{
- IDXGIAdapter *p_adapter = D3D11DeviceAdapter(d3ddev);
- if (!p_adapter)
- return NULL;
-
bool result = false;
- DXGI_ADAPTER_DESC adapterDesc;
- if (SUCCEEDED(IDXGIAdapter_GetDesc(p_adapter, &adapterDesc))) {
- if (adapterDesc.VendorId == 0 &&
- adapterDesc.DeviceId == 0 &&
- !wcscmp(L"ROOT\\SraKmd\\0000", adapterDesc.Description))
- result = true;
- }
- IDXGIAdapter_Release(p_adapter);
+ if (d3ddev->adapterDesc.VendorId == 0 &&
+ d3ddev->adapterDesc.DeviceId == 0 &&
+ !wcscmp(L"ROOT\\SraKmd\\0000", d3ddev->adapterDesc.Description))
+ result = true;
+
return result;
}
@@ -427,19 +420,9 @@ bool isXboxHardware(ID3D11Device *d3ddev)
* Performs a check on each value of the WDDM version. Any value that is OK will
* consider the driver valid (OR on each value)
*/
-int D3D11CheckDriverVersion(d3d11_device_t *d3d_dev, UINT vendorId, const struct wddm_version *min_ver)
+int D3D11CheckDriverVersion(const d3d11_device_t *d3d_dev, UINT vendorId, const struct wddm_version *min_ver)
{
- IDXGIAdapter *pAdapter = D3D11DeviceAdapter(d3d_dev->d3ddevice);
- if (!pAdapter)
- return VLC_EGENERIC;
-
- DXGI_ADAPTER_DESC adapterDesc;
- HRESULT hr = IDXGIAdapter_GetDesc(pAdapter, &adapterDesc);
- IDXGIAdapter_Release(pAdapter);
- if (FAILED(hr))
- return VLC_EGENERIC;
-
- if (vendorId && adapterDesc.VendorId != vendorId)
+ if (vendorId && d3d_dev->adapterDesc.VendorId != vendorId)
return VLC_SUCCESS;
if (min_ver->wddm)
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index 350b6e0744..287bc4eb3a 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -167,9 +167,9 @@ int D3D11_Create(vlc_object_t *, d3d11_handle_t *, bool with_shaders);
void D3D11_Destroy(d3d11_handle_t *);
void D3D11_LogResources(d3d11_handle_t *);
-bool isXboxHardware(ID3D11Device *d3ddev);
+bool isXboxHardware(const d3d11_device_t *);
IDXGIAdapter *D3D11DeviceAdapter(ID3D11Device *d3ddev);
-int D3D11CheckDriverVersion(d3d11_device_t *, UINT vendorId,
+int D3D11CheckDriverVersion(const d3d11_device_t *, UINT vendorId,
const struct wddm_version *min_ver);
static inline bool DeviceSupportsFormat(ID3D11Device *d3ddevice,
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index ce6dd960bd..c5f6a63fcd 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1035,21 +1035,12 @@ static bool CanUseTextureArray(vout_display_t *vd)
#endif
}
-static bool BogusZeroCopy(vout_display_t *vd)
+static bool BogusZeroCopy(const vout_display_t *vd)
{
- IDXGIAdapter *p_adapter = D3D11DeviceAdapter(vd->sys->d3d_dev.d3ddevice);
- if (!p_adapter)
+ if (vd->sys->d3d_dev.adapterDesc.VendorId != GPU_MANUFACTURER_AMD)
return false;
- DXGI_ADAPTER_DESC adapterDesc;
- if (FAILED(IDXGIAdapter_GetDesc(p_adapter, &adapterDesc)))
- return false;
- IDXGIAdapter_Release(p_adapter);
-
- if (adapterDesc.VendorId != GPU_MANUFACTURER_AMD)
- return false;
-
- switch (adapterDesc.DeviceId)
+ switch (vd->sys->d3d_dev.adapterDesc.DeviceId)
{
case 0x687F: // RX Vega 56/64
case 0x6863: // RX Vega Frontier Edition
More information about the vlc-commits
mailing list