d3d11: disable IDXGIInfoQueue usage if dxgidebug.h is incomplete

Older MinGW-w64 doesn't define IDXGIInfoQueue in dxgidebug.h.
This commit is contained in:
Kacper Michajłow 2023-05-01 17:43:25 +02:00
parent 19a9164e24
commit 1a495451ab
4 changed files with 20 additions and 0 deletions

View File

@ -995,6 +995,7 @@ if features['d3d11']
sources += files('video/out/d3d11/context.c',
'video/out/d3d11/ra_d3d11.c')
features += {'dxgi-debug-d3d11': cc.has_header_symbol('d3d11sdklayers.h', 'DXGI_DEBUG_D3D11')}
features += {'dxgi-debug': cc.has_header_symbol('dxgidebug.h', 'IID_IDXGIInfoQueue')}
endif
wayland = {

View File

@ -44,9 +44,11 @@ struct ra_d3d11 {
struct dll_version d3d_compiler_ver;
#if HAVE_DXGI_DEBUG
// Debug interfaces (--gpu-debug)
IDXGIDebug *debug;
IDXGIInfoQueue *iqueue;
#endif
// Device capabilities
D3D_FEATURE_LEVEL fl;
@ -2095,6 +2097,7 @@ static uint64_t timer_stop(struct ra *ra, ra_timer *ratimer)
return timer->result;
}
#if HAVE_DXGI_DEBUG
static int map_msg_severity(DXGI_INFO_QUEUE_MESSAGE_SEVERITY sev)
{
switch (sev) {
@ -2169,9 +2172,11 @@ static int map_msg_severity_by_id(D3D11_MESSAGE_ID id,
return map_msg_severity(sev);
}
}
#endif
static void debug_marker(struct ra *ra, const char *msg)
{
#if HAVE_DXGI_DEBUG
struct ra_d3d11 *p = ra->priv;
void *talloc_ctx = talloc_new(NULL);
HRESULT hr;
@ -2212,6 +2217,7 @@ static void debug_marker(struct ra *ra, const char *msg)
IDXGIInfoQueue_ClearStoredMessages(p->iqueue, DXGI_DEBUG_ALL);
done:
talloc_free(talloc_ctx);
#endif
}
static void destroy(struct ra *ra)
@ -2242,6 +2248,7 @@ static void destroy(struct ra *ra)
}
SAFE_RELEASE(p->ctx);
#if HAVE_DXGI_DEBUG
if (p->debug) {
// Report any leaked objects
debug_marker(ra, "after destroy");
@ -2252,6 +2259,7 @@ static void destroy(struct ra *ra)
}
SAFE_RELEASE(p->debug);
SAFE_RELEASE(p->iqueue);
#endif
talloc_free(ra);
}
@ -2443,8 +2451,10 @@ struct ra *ra_d3d11_create(ID3D11Device *dev, struct mp_log *log,
p->max_uavs = D3D11_PS_CS_UAV_REGISTER_COUNT;
}
#if HAVE_DXGI_DEBUG
if (ID3D11Device_GetCreationFlags(p->dev) & D3D11_CREATE_DEVICE_DEBUG)
mp_d3d11_get_debug_interfaces(ra->log, &p->debug, &p->iqueue);
#endif
// Some level 9_x devices don't have timestamp queries
hr = ID3D11Device_CreateQuery(p->dev,
@ -2458,9 +2468,11 @@ struct ra *ra_d3d11_create(ID3D11Device *dev, struct mp_log *log,
// https://msdn.microsoft.com/en-us/library/windows/desktop/ff476874.aspx
find_max_texture_dimension(ra);
#if HAVE_DXGI_DEBUG
// Ignore any messages during find_max_texture_dimension
if (p->iqueue)
IDXGIInfoQueue_ClearStoredMessages(p->iqueue, DXGI_DEBUG_ALL);
#endif
MP_VERBOSE(ra, "Maximum Texture2D size: %dx%d\n", ra->max_texture_wh,
ra->max_texture_wh);

View File

@ -1003,6 +1003,7 @@ done:
return ret;
}
#if HAVE_DXGI_DEBUG
void mp_d3d11_get_debug_interfaces(struct mp_log *log, IDXGIDebug **debug,
IDXGIInfoQueue **iqueue)
{
@ -1037,3 +1038,4 @@ void mp_d3d11_get_debug_interfaces(struct mp_log *log, IDXGIDebug **debug,
return;
}
}
#endif

View File

@ -23,7 +23,10 @@
#include <d3d11.h>
#include <dxgi1_2.h>
#include <dxgi1_6.h>
#if HAVE_DXGI_DEBUG
#include <dxgidebug.h>
#endif
#include "video/mp_image.h"
@ -114,7 +117,9 @@ bool mp_d3d11_create_swapchain(ID3D11Device *dev, struct mp_log *log,
struct d3d11_swapchain_opts *opts,
IDXGISwapChain **swapchain_out);
#if HAVE_DXGI_DEBUG
void mp_d3d11_get_debug_interfaces(struct mp_log *log, IDXGIDebug **debug,
IDXGIInfoQueue **iqueue);
#endif
#endif