Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/gpgmm/d3d12/DebugResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "gpgmm/common/EventMessage.h"
#include "gpgmm/d3d12/BackendD3D12.h"
#include "gpgmm/d3d12/ErrorD3D12.h"
#include "gpgmm/d3d12/JSONSerializerD3D12.h"
#include "gpgmm/d3d12/ResourceAllocationD3D12.h"
#include "gpgmm/utils/Utils.h"

Expand Down Expand Up @@ -52,7 +53,7 @@ namespace gpgmm::d3d12 {
const ResourceAllocation* allocation = allocationEntry->GetValue().GetAllocation();
gpgmm::WarnEvent(allocation->GetAllocator()->GetTypename())
<< "Live ResourceAllocation at " << ToString(allocation) << ", "
<< "RefCount: " << allocation->GetRefCount();
<< JSONSerializer::Serialize(allocation->GetInfo()).ToString();
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/gpgmm/d3d12/IUnknownImplD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "gpgmm/d3d12/IUnknownImplD3D12.h"

namespace gpgmm::d3d12 {
IUnknownImpl::IUnknownImpl() : RefCounted(1) {
IUnknownImpl::IUnknownImpl() : mRefs(1) {
}

HRESULT IUnknownImpl::QueryInterface(REFIID riid, void** ppvObject) {
Expand All @@ -29,19 +29,20 @@ namespace gpgmm::d3d12 {
if (riid == IID_IUnknown) {
// Increment reference and return pointer.
*ppvObject = this;
Ref();
mRefs.Ref();
return S_OK;
}

return E_NOINTERFACE;
}

ULONG IUnknownImpl::AddRef() {
Ref();
return GetRefCount();
mRefs.Ref();
return mRefs.GetRefCount();
}

ULONG IUnknownImpl::Release() {
const ULONG refCount = Unref() ? 0 : GetRefCount();
const ULONG refCount = mRefs.Unref() ? 0 : mRefs.GetRefCount();
if (refCount == 0) {
DeleteThis();
}
Expand Down
6 changes: 5 additions & 1 deletion src/gpgmm/d3d12/IUnknownImplD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace gpgmm::d3d12 {

class GPGMM_EXPORT IUnknownImpl : public IUnknown, public RefCounted {
class GPGMM_EXPORT IUnknownImpl : public IUnknown {
public:
IUnknownImpl();
virtual ~IUnknownImpl() = default;
Expand All @@ -31,8 +31,12 @@ namespace gpgmm::d3d12 {
ULONG STDMETHODCALLTYPE AddRef() override;
ULONG STDMETHODCALLTYPE Release() override;

protected:
// Derived class may override this if they require a custom deleter.
virtual void DeleteThis();

private:
RefCounted mRefs; // Maintains the COM ref-count of this object.
};

} // namespace gpgmm::d3d12
Expand Down