[vlc-commits] [Git][videolan/vlc][master] 2 commits: d3d11: always link with d3d11.dll
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Aug 15 15:26:12 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
a8d52300 by Steve Lhomme at 2024-08-15T15:11:33+00:00
d3d11: always link with d3d11.dll
We only support up to date Windows 7 with some Direct3D11 support.
Direct3D 11.1 was added in Windows 7 Platform Update [1], aka KB2670838 [2].
The screen capture and MediaFoundation plugins won't work on Win7/2008
without the platform update.
[1] https://learn.microsoft.com/en-us/windows/win32/direct3darticles/platform-update-for-windows-7
[2] https://support.microsoft.com/kb/2670838
- - - - -
16a7437e by Steve Lhomme at 2024-08-15T15:11:33+00:00
d3d11_fmt: move the DXGI debug code in a structure
And use a single define to turn it on/off.
- - - - -
6 changed files:
- modules/access/Makefile.am
- modules/codec/Makefile.am
- modules/hw/d3d11/Makefile.am
- modules/video_chroma/d3d11_fmt.cpp
- modules/video_filter/Makefile.am
- modules/video_output/Makefile.am
Changes:
=====================================
modules/access/Makefile.am
=====================================
@@ -202,10 +202,7 @@ endif
libscreen_win_plugin_la_SOURCES = access/screen/screen.c access/screen/screen.h \
access/screen/dxgi.cpp
libscreen_win_plugin_la_CXXFLAGS = $(AM_CXXFLAGS) $(LIBCOMCXXFLAGS)
-libscreen_win_plugin_la_LIBADD = libd3d11_common.la $(LIBCOM) -luuid
-if HAVE_WINSTORE
-libscreen_win_plugin_la_LIBADD += -ld3d11
-endif
+libscreen_win_plugin_la_LIBADD = libd3d11_common.la $(LIBCOM) -luuid -ld3d11
if HAVE_WIN32_DESKTOP
libscreen_win_plugin_la_SOURCES += access/screen/win32.c
libscreen_win_plugin_la_LIBADD += -lgdi32
=====================================
modules/codec/Makefile.am
=====================================
@@ -477,10 +477,7 @@ libd3d11va_plugin_la_SOURCES = \
packetizer/hevc_nal.c packetizer/hevc_nal.h \
packetizer/h26x_nal_common.h \
codec/avcodec/dxva_blocklist.c
-libd3d11va_plugin_la_LIBADD = libd3d11_common.la $(LIBCOM) -luuid
-if HAVE_WINSTORE
-libd3d11va_plugin_la_LIBADD += -ld3d11
-endif
+libd3d11va_plugin_la_LIBADD = libd3d11_common.la $(LIBCOM) -luuid -ld3d11
if HAVE_AVCODEC_D3D11VA
codec_LTLIBRARIES += libd3d11va_plugin.la
endif
@@ -596,10 +593,7 @@ codec_LTLIBRARIES += $(LTLIBvpx)
libvpx_alpha_plugin_la_SOURCES = codec/vpx_alpha.c codec/alpha_combine.h
if HAVE_WIN32
libvpx_alpha_plugin_la_SOURCES += codec/alpha_d3d11.cpp
-libvpx_alpha_plugin_la_LIBADD = $(LIBCOM) libd3d11_common.la
-if HAVE_WINSTORE
-libvpx_alpha_plugin_la_LIBADD += -ld3d11
-endif
+libvpx_alpha_plugin_la_LIBADD = $(LIBCOM) libd3d11_common.la -ld3d11
endif
codec_LTLIBRARIES += libvpx_alpha_plugin.la
@@ -666,11 +660,8 @@ libmft_plugin_la_SOURCES = codec/mft.cpp \
codec/mft_d3d11.cpp codec/mft_d3d11.h
libmft_plugin_la_CXXFLAGS = $(AM_CXXFLAGS) $(LIBCOMCXXFLAGS)
if HAVE_WIN32
-libmft_plugin_la_LIBADD = $(LIBCOM) -luuid -lmfplat libvlc_hxxxhelper.la libd3d11_common.la
+libmft_plugin_la_LIBADD = $(LIBCOM) -luuid -lmfplat libvlc_hxxxhelper.la libd3d11_common.la -ld3d11
codec_LTLIBRARIES += libmft_plugin.la
-if HAVE_WINSTORE
-libmft_plugin_la_LIBADD += -ld3d11
-endif
endif
libgstdecode_plugin_la_SOURCES = codec/gstreamer/gstdecode.c \
=====================================
modules/hw/d3d11/Makefile.am
=====================================
@@ -9,10 +9,7 @@ libdirect3d11_filters_plugin_la_SOURCES = hw/d3d11/d3d11_filters.h \
hw/d3d11/d3d11_processor.c hw/d3d11/d3d11_processor.h
libdirect3d11_filters_plugin_la_CXXFLAGS = $(AM_CXXFLAGS) $(LIBCOMCXXFLAGS)
libdirect3d11_filters_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(d3d11dir)'
-libdirect3d11_filters_plugin_la_LIBADD = libchroma_copy.la libdeinterlace_common.la libd3d11_common.la $(LIBCOM)
-if HAVE_WINSTORE
-libdirect3d11_filters_plugin_la_LIBADD += -ld3d11
-endif
+libdirect3d11_filters_plugin_la_LIBADD = libchroma_copy.la libdeinterlace_common.la libd3d11_common.la $(LIBCOM) -ld3d11
d3d11_LTLIBRARIES = $(LTLIBdirect3d11_filters)
EXTRA_LTLIBRARIES += libdirect3d11_filters_plugin.la
=====================================
modules/video_chroma/d3d11_fmt.cpp
=====================================
@@ -35,6 +35,12 @@
# include "config.h"
#endif
+#if !BUILD_FOR_UAP
+#if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
+#define HAVE_DXGI_DEBUG 1
+#endif
+#endif
+
#include <vlc_common.h>
#include <vlc_picture.h>
#include <vlc_charset.h>
@@ -48,7 +54,7 @@
#include <initguid.h>
#include <d3d11.h>
#include <dxgi1_2.h>
-#if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
+#ifdef HAVE_DXGI_DEBUG
# include <dxgidebug.h>
#endif
#include <assert.h>
@@ -282,71 +288,64 @@ done:
CoUninitialize();
}
-typedef struct
+#ifdef HAVE_DXGI_DEBUG
+struct dxgi_debug_handle_t
{
-#if !BUILD_FOR_UAP
- HINSTANCE hdll; /* handle of the opened d3d11 dll */
-#if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
HINSTANCE dxgidebug_dll;
HRESULT (WINAPI * pf_DXGIGetDebugInterface)(const GUID *riid, void **ppDebug);
-#endif
-#endif
-} d3d11_handle_t;
-
-typedef struct {
- struct {
- void *opaque;
- libvlc_video_output_cleanup_cb cleanupDeviceCb;
- } external;
- d3d11_handle_t hd3d;
- d3d11_decoder_device_t dec_device;
-} d3d11_decoder_device;
+ void Init()
+ {
+ dxgidebug_dll = nullptr;
+ pf_DXGIGetDebugInterface = nullptr;
+ if (IsDebuggerPresent())
+ {
+ dxgidebug_dll = LoadLibrary(TEXT("DXGIDEBUG.DLL"));
+ if (dxgidebug_dll)
+ {
+ pf_DXGIGetDebugInterface =
+ reinterpret_cast<decltype(pf_DXGIGetDebugInterface)>(GetProcAddress(dxgidebug_dll, "DXGIGetDebugInterface"));
+ if (unlikely(!pf_DXGIGetDebugInterface))
+ {
+ FreeLibrary(dxgidebug_dll);
+ dxgidebug_dll = nullptr;
+ }
+ }
+ }
+ }
-static int D3D11_Create(vlc_object_t *obj, d3d11_handle_t *hd3d)
-{
-#if !BUILD_FOR_UAP
- hd3d->hdll = LoadLibrary(TEXT("D3D11.DLL"));
- if (!hd3d->hdll)
+ void Release()
{
- msg_Warn(obj, "cannot load d3d11.dll, aborting");
- return VLC_EGENERIC;
+ if (dxgidebug_dll)
+ FreeLibrary(dxgidebug_dll);
}
-# if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
- hd3d->dxgidebug_dll = NULL;
- hd3d->pf_DXGIGetDebugInterface = NULL;
- if (IsDebuggerPresent())
+ void LogResource()
{
- hd3d->dxgidebug_dll = LoadLibrary(TEXT("DXGIDEBUG.DLL"));
- if (hd3d->dxgidebug_dll)
+ if (pf_DXGIGetDebugInterface)
{
- hd3d->pf_DXGIGetDebugInterface =
- reinterpret_cast<decltype(hd3d->pf_DXGIGetDebugInterface)>(GetProcAddress(hd3d->dxgidebug_dll, "DXGIGetDebugInterface"));
- if (unlikely(!hd3d->pf_DXGIGetDebugInterface))
+ IDXGIDebug *pDXGIDebug;
+ if (SUCCEEDED(pf_DXGIGetDebugInterface(&IID_GRAPHICS_PPV_ARGS(&pDXGIDebug))))
{
- FreeLibrary(hd3d->dxgidebug_dll);
- hd3d->dxgidebug_dll = NULL;
+ pDXGIDebug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL);
+ pDXGIDebug->Release();
}
}
}
-# endif // !NDEBUG && HAVE_DXGIDEBUG_H
-#endif // !BUILD_FOR_UAP
- return VLC_SUCCESS;
-}
+};
+#endif
-static void D3D11_Destroy(d3d11_handle_t *hd3d)
-{
-#if !BUILD_FOR_UAP
- if (hd3d->hdll)
- FreeLibrary(hd3d->hdll);
+typedef struct {
+ struct {
+ void *opaque;
+ libvlc_video_output_cleanup_cb cleanupDeviceCb;
+ } external;
-#if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
- if (hd3d->dxgidebug_dll)
- FreeLibrary(hd3d->dxgidebug_dll);
-#endif
+#ifdef HAVE_DXGI_DEBUG
+ dxgi_debug_handle_t dxgi_debug;
#endif
-}
+ d3d11_decoder_device_t dec_device;
+} d3d11_decoder_device;
void D3D11_ReleaseDevice(d3d11_decoder_device_t *dev_sys)
{
@@ -372,8 +371,10 @@ void D3D11_ReleaseDevice(d3d11_decoder_device_t *dev_sys)
if ( sys->external.cleanupDeviceCb )
sys->external.cleanupDeviceCb( sys->external.opaque );
- D3D11_LogResources( &sys->dec_device );
- D3D11_Destroy( &sys->hd3d );
+#ifdef HAVE_DXGI_DEBUG
+ sys->dxgi_debug.LogResource();
+ sys->dxgi_debug.Release();
+#endif
}
static HRESULT D3D11_CreateDeviceExternal(vlc_object_t *obj, ID3D11DeviceContext *d3d11ctx,
@@ -423,21 +424,10 @@ static HRESULT D3D11_CreateDeviceExternal(vlc_object_t *obj, ID3D11DeviceContext
return S_OK;
}
-static HRESULT CreateDevice(vlc_object_t *obj, d3d11_handle_t *hd3d,
+static HRESULT CreateDevice(vlc_object_t *obj,
IDXGIAdapter *adapter,
bool hw_decoding, d3d11_device_t *out)
{
-#if !BUILD_FOR_UAP
-# define D3D11CreateDevice(a,b,c,d,e,f,g,h,i,j) pf_CreateDevice(a,b,c,d,e,f,g,h,i,j)
- /* */
- PFN_D3D11_CREATE_DEVICE pf_CreateDevice;
- pf_CreateDevice = reinterpret_cast<PFN_D3D11_CREATE_DEVICE>(GetProcAddress(hd3d->hdll, "D3D11CreateDevice"));
- if (!pf_CreateDevice) {
- msg_Err(obj, "Cannot locate reference to D3D11CreateDevice ABI in DLL");
- return E_NOINTERFACE;
- }
-#endif
-
HRESULT hr = E_NOTIMPL;
UINT creationFlags = 0;
@@ -524,12 +514,9 @@ d3d11_decoder_device_t *(D3D11_CreateDevice)(vlc_object_t *obj,
if (unlikely(sys==NULL))
return NULL;
- int ret = D3D11_Create(obj, &sys->hd3d);
- if (ret != VLC_SUCCESS)
- {
- vlc_obj_free( obj, sys );
- return NULL;
- }
+#ifdef HAVE_DXGI_DEBUG
+ sys->dxgi_debug.Init();
+#endif
sys->external.cleanupDeviceCb = NULL;
HRESULT hr = E_FAIL;
@@ -573,7 +560,7 @@ d3d11_decoder_device_t *(D3D11_CreateDevice)(vlc_object_t *obj,
}
#endif
- hr = CreateDevice( obj, &sys->hd3d, adapter, hw_decoding, &sys->dec_device.d3d_dev );
+ hr = CreateDevice( obj, adapter, hw_decoding, &sys->dec_device.d3d_dev );
}
else
goto error;
@@ -582,8 +569,10 @@ d3d11_decoder_device_t *(D3D11_CreateDevice)(vlc_object_t *obj,
error:
if (FAILED(hr))
{
- D3D11_LogResources( &sys->dec_device );
- D3D11_Destroy(&sys->hd3d);
+#ifdef HAVE_DXGI_DEBUG
+ sys->dxgi_debug.LogResource();
+ sys->dxgi_debug.Release();
+#endif
vlc_obj_free( obj, sys );
return NULL;
}
@@ -930,22 +919,11 @@ error:
return VLC_EGENERIC;
}
-void D3D11_LogResources(d3d11_decoder_device_t *dev_sys)
+void D3D11_LogResources([[maybe_unused]] d3d11_decoder_device_t *dev_sys)
{
-#if !BUILD_FOR_UAP
-# if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
+#ifdef HAVE_DXGI_DEBUG
d3d11_decoder_device *sys = container_of(dev_sys, d3d11_decoder_device, dec_device);
- d3d11_handle_t *hd3d = &sys->hd3d;
- if (hd3d->pf_DXGIGetDebugInterface)
- {
- IDXGIDebug *pDXGIDebug;
- if (SUCCEEDED(hd3d->pf_DXGIGetDebugInterface(&IID_GRAPHICS_PPV_ARGS(&pDXGIDebug))))
- {
- pDXGIDebug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL);
- pDXGIDebug->Release();
- }
- }
-# endif
+ sys->dxgi_debug.LogResource();
#endif
}
=====================================
modules/video_filter/Makefile.am
=====================================
@@ -224,10 +224,7 @@ if HAVE_AMF_ENHANCER
libamf_vqenhancer_plugin_la_SOURCES = video_filter/amf_vqenhancer.c \
hw/amf/amf_helper.c hw/amf/amf_helper.h
if HAVE_WIN32
-libamf_vqenhancer_plugin_la_LIBADD = $(LIBCOM) libd3d11_common.la
-if HAVE_WINSTORE
-libamf_vqenhancer_plugin_la_LIBADD += -ld3d11
-endif
+libamf_vqenhancer_plugin_la_LIBADD = $(LIBCOM) libd3d11_common.la -ld3d11
video_filter_LTLIBRARIES += libamf_vqenhancer_plugin.la
endif
endif
=====================================
modules/video_output/Makefile.am
=====================================
@@ -206,7 +206,7 @@ libdirect3d11_plugin_la_SOURCES = video_output/win32/direct3d11.cpp \
video_output/win32/d3d_dynamic_shader.c video_output/win32/d3d_dynamic_shader.h \
video_output/win32/common.c video_output/win32/common.h
libdirect3d11_plugin_la_CXXFLAGS = $(AM_CXXFLAGS) $(LIBCOMCXXFLAGS)
-libdirect3d11_plugin_la_LIBADD = libchroma_copy.la libd3d11_common.la $(LIBCOM) -luuid -ldxgi
+libdirect3d11_plugin_la_LIBADD = libchroma_copy.la libd3d11_common.la $(LIBCOM) -luuid -ldxgi -ld3d11
libdirect3d11_plugin_la_CPPFLAGS = $(AM_CPPFLAGS)
if !HAVE_WINSTORE
libdirect3d11_plugin_la_CPPFLAGS += -DHAVE_WIN32_SENSORS
@@ -218,7 +218,6 @@ libdirect3d11_plugin_la_SOURCES += video_output/win32/events.c \
video_output/win32/win32touch.c video_output/win32/win32touch.h
libdirect3d11_plugin_la_LIBADD += -lgdi32 -luser32
else
-libdirect3d11_plugin_la_LIBADD += -ld3d11
libdirect3d11_plugin_la_LIBADD += -ld3dcompiler_47
endif
if HAVE_NVDEC
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/03625632442e029760f6ada5dde28f7a85087f03...16a7437e820f6dfff39a3afcb1a6b5b57a9a2512
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/03625632442e029760f6ada5dde28f7a85087f03...16a7437e820f6dfff39a3afcb1a6b5b57a9a2512
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list