1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-13 07:08:50 +01:00
dxvk/src/d3d9/d3d9_device_child.h
Joshie 54ed8f0bb0 [d3d9] Implement Direct3D9 Frontend (#1275)
Co-authored-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Co-authored-by: Robin Kertels <robin.kertels@gmail.com>
Co-authored-by: pchome <pchome@users.noreply.github.com>
Co-authored-by: Christopher Egert <cme3000@gmail.com>
Co-authored-by: Derek Lesho <dereklesho52@Gmail.com>
Co-authored-by: Luis Cáceres <lacaceres97@gmail.com>
Co-authored-by: Nelson Chen <crazysim@gmail.com>
Co-authored-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Co-authored-by: Riesi <riesi@opentrash.com>
Co-authored-by: gbMichelle <gbmichelle.dev@gmail.com>
2019-12-16 04:28:01 +01:00

61 lines
1.2 KiB
C++

#pragma once
#include "d3d9_include.h"
namespace dxvk {
class D3D9DeviceEx;
template <typename Base>
class D3D9DeviceChild : public ComObjectClamp<Base> {
public:
D3D9DeviceChild(D3D9DeviceEx* pDevice)
: m_parent( pDevice ) { }
ULONG STDMETHODCALLTYPE AddRef() {
uint32_t refCount = this->m_refCount++;
if (unlikely(!refCount)) {
this->AddRefPrivate();
GetDevice()->AddRef();
}
return refCount + 1;
}
ULONG STDMETHODCALLTYPE Release() {
uint32_t refCount = --this->m_refCount;
if (unlikely(!refCount)) {
auto* pDevice = GetDevice();
this->ReleasePrivate();
pDevice->Release();
}
return refCount;
}
HRESULT STDMETHODCALLTYPE GetDevice(IDirect3DDevice9** ppDevice) {
InitReturnPtr(ppDevice);
if (ppDevice == nullptr)
return D3DERR_INVALIDCALL;
*ppDevice = ref(GetDevice());
return D3D_OK;
}
IDirect3DDevice9Ex* GetDevice() {
return reinterpret_cast<IDirect3DDevice9Ex*>(m_parent);
}
D3D9DeviceEx* GetParent() {
return m_parent;
}
protected:
D3D9DeviceEx* m_parent;
};
}