6d913bfc23
EPR #419347 - Fix a d3d9 memory leak. According to https://msdn.microsoft.com/en-us/library/windows/desktop/bb174386(v=vs.85).aspx: Calling IDirect3DDevice9::GetDirect3D will increase the internal reference count on the IDirect3D9 interface. Failure to call IUnknown::Release when finished using this IDirect3D9 interface results in a memory leak.. Although p3d9devEx->Release() has the same effect as p3d9dev->Release(), for clarification we better use p3d9dev->Release() instead. Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDeviceD3D9.cpp#13 edit
58 řádky
1.8 KiB
C++
58 řádky
1.8 KiB
C++
#include "gsl_ctx.h"
|
|
#include "GSLDevice.h"
|
|
|
|
#if defined(ATI_OS_WIN)
|
|
|
|
#include <d3d9.h>
|
|
#include <dxgi.h>
|
|
|
|
/**************************************************************************************************************
|
|
* Note: ideally the DXX extension interfaces should be mapped from the DXX perforce branch.
|
|
* This means CAL client spec will need to change to include headers directly from the DXX perforce tree.
|
|
* However, CAL only cares about the DXX OpenCL extension interface class. The spec cannot change
|
|
* without notification. So it is safe to use a local copy of the relevant DXX extension interface classes.
|
|
**************************************************************************************************************/
|
|
#include "DxxOpenCLInteropExt.h"
|
|
|
|
|
|
bool
|
|
CALGSLDevice::associateD3D9Device(void* d3d9Device)
|
|
{
|
|
bool canInteroperate = false;
|
|
D3DCAPS9 pCaps;
|
|
LUID calDevAdapterLuid = {0, 0};
|
|
UINT calDevChainBitMask = 0;
|
|
IDirect3D9* p3d9dev;
|
|
LUID d3d9deviceLuid = {0, 0};
|
|
|
|
IDirect3DDevice9* pd3d9Device = static_cast<IDirect3DDevice9*>(d3d9Device);
|
|
|
|
// Get D3D9 Device caps
|
|
pd3d9Device->GetDeviceCaps(&pCaps);
|
|
// Get 3D9 Device
|
|
pd3d9Device->GetDirect3D(&p3d9dev);
|
|
|
|
IDirect3D9Ex* p3d9devEx = static_cast<IDirect3D9Ex*>(p3d9dev);
|
|
p3d9devEx->GetAdapterLUID(pCaps.AdapterOrdinal, &d3d9deviceLuid);
|
|
p3d9dev->Release();
|
|
|
|
// match the adapter
|
|
if (m_adp->getMVPUinfo(&calDevAdapterLuid, &calDevChainBitMask))
|
|
{
|
|
canInteroperate = ((calDevAdapterLuid.HighPart == d3d9deviceLuid.HighPart) &&
|
|
(calDevAdapterLuid.LowPart == d3d9deviceLuid.LowPart));
|
|
}
|
|
|
|
return canInteroperate;
|
|
}
|
|
|
|
#else // !ATI_OS_WIN
|
|
|
|
bool
|
|
CALGSLDevice::associateD3D9Device(void* d3dDevice)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
#endif // !ATI_OS_WIN
|