DX11: Fixed assert when running with GPA.

This commit is contained in:
bkaradzic 2013-10-02 21:43:09 -07:00
parent 5b415315dc
commit 41d5bcfc1b
2 changed files with 13 additions and 14 deletions

View file

@ -65,26 +65,22 @@ namespace bgfx
BX_CHECK(_expected == count, "RefCount is %d (expected %d).", count, _expected); \
} while (0)
# define DX_RELEASE(_ptr, _expected) \
#else
# define DX_CHECK_REFCOUNT(_ptr, _expected)
#endif // BGFX_CONFIG_DEBUG
#define _DX_RELEASE(_ptr, _expected, _check) \
do { \
if (NULL != _ptr) \
{ \
ULONG count = _ptr->Release(); \
BX_CHECK(_expected == count, "RefCount is %d (expected %d).", count, _expected); \
_check(_expected == count, "RefCount is %d (expected %d).", count, _expected); \
_ptr = NULL; \
} \
} while (0)
#else
# define DX_CHECK_REFCOUNT(_ptr, _expected)
# define DX_RELEASE(_ptr, _expected) \
do { \
if (NULL != _ptr) \
{ \
_ptr->Release(); \
_ptr = NULL; \
} \
} while (0)
#endif // BGFX_CONFIG_DEBUG
#define DX_RELEASE(_ptr, _expected) _DX_RELEASE(_ptr, _expected, BX_CHECK)
#define DX_RELEASE_WARNONLY(_ptr, _expected) _DX_RELEASE(_ptr, _expected, BX_WARN)
inline int getRefCount(IUnknown* _interface)
{

View file

@ -454,7 +454,10 @@ namespace bgfx
hr = device->GetParent(__uuidof(IDXGIAdapter), (void**)&adapter);
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 device.");
DX_RELEASE(device, 2);
// GPA increases device ref count and triggers assert in debug
// build. Warn only instead.
DX_RELEASE_WARNONLY(device, 2);
hr = adapter->GetDesc(&m_adapterDesc);
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 device.");