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
4 changes: 2 additions & 2 deletions src/gpgmm/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ source_set("gpgmm_sources") {
"d3d12/FenceD3D12.h",
"d3d12/HeapD3D12.cpp",
"d3d12/HeapD3D12.h",
"d3d12/IUnknownImplD3D12.cpp",
"d3d12/IUnknownImplD3D12.h",
"d3d12/JSONSerializerD3D12.cpp",
"d3d12/JSONSerializerD3D12.h",
"d3d12/ResidencyListD3D12.cpp",
Expand All @@ -142,6 +140,8 @@ source_set("gpgmm_sources") {
"d3d12/ResourceHeapAllocatorD3D12.cpp",
"d3d12/ResourceHeapAllocatorD3D12.h",
"d3d12/ResourceSizeD3D12.h",
"d3d12/UnknownD3D12.cpp",
"d3d12/UnknownD3D12.h",
"d3d12/UtilsD3D12.cpp",
"d3d12/UtilsD3D12.h",
"d3d12/d3d12_platform.h",
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ if (GPGMM_ENABLE_D3D12)
"d3d12/FenceD3D12.h"
"d3d12/HeapD3D12.cpp"
"d3d12/HeapD3D12.h"
"d3d12/IUnknownImplD3D12.cpp"
"d3d12/IUnknownImplD3D12.h"
"d3d12/JSONSerializerD3D12.cpp"
"d3d12/JSONSerializerD3D12.h"
"d3d12/ResidencyListD3D12.cpp"
Expand All @@ -83,6 +81,8 @@ if (GPGMM_ENABLE_D3D12)
"d3d12/ResourceAllocatorD3D12.h"
"d3d12/ResourceHeapAllocatorD3D12.cpp"
"d3d12/ResourceHeapAllocatorD3D12.h"
"d3d12/UnknownD3D12.cpp"
"d3d12/UnknownD3D12.h"
"d3d12/UtilsD3D12.cpp"
"d3d12/UtilsD3D12.h"
"d3d12/d3d12_platform.h"
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/d3d12/DebugObjectD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
#ifndef GPGMM_D3D12_DEBUGOBJECTD3D12_H_
#define GPGMM_D3D12_DEBUGOBJECTD3D12_H_

#include "gpgmm/d3d12/IUnknownImplD3D12.h"
#include "gpgmm/d3d12/UnknownD3D12.h"

#include "gpgmm/d3d12/d3d12_platform.h"

#include <string>

namespace gpgmm::d3d12 {
class DebugObject : public IUnknownImpl {
class DebugObject : public Unknown {
public:
virtual ~DebugObject() override = default;

Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/d3d12/HeapD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ namespace gpgmm::d3d12 {
}

ULONG STDMETHODCALLTYPE Heap::AddRef() {
return IUnknownImpl::AddRef();
return Unknown::AddRef();
}

ULONG STDMETHODCALLTYPE Heap::Release() {
return IUnknownImpl::Release();
return Unknown::Release();
}

void Heap::SetResidencyState(RESIDENCY_STATUS newStatus) {
Expand Down
2 changes: 1 addition & 1 deletion src/gpgmm/d3d12/HeapD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "gpgmm/common/Memory.h"
#include "gpgmm/d3d12/DebugObjectD3D12.h"
#include "gpgmm/d3d12/IUnknownImplD3D12.h"
#include "gpgmm/d3d12/UnknownD3D12.h"
#include "gpgmm/utils/Limits.h"
#include "gpgmm/utils/LinkedList.h"

Expand Down
9 changes: 4 additions & 5 deletions src/gpgmm/d3d12/ResidencyListD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef GPGMM_D3D12_RESIDENCYLISTD3D12_H_
#define GPGMM_D3D12_RESIDENCYLISTD3D12_H_

#include "gpgmm/d3d12/IUnknownImplD3D12.h"
#include "gpgmm/d3d12/UnknownD3D12.h"
#include "gpgmm/d3d12/d3d12_platform.h"

#include <gpgmm_d3d12.h>
Expand All @@ -28,18 +28,17 @@ namespace gpgmm::d3d12 {
class JSONSerializer;
class ResidencyManager;

class ResidencyList final : public IResidencyList, public IUnknownImpl {
class ResidencyList final : public IResidencyList, public Unknown {
public:
ResidencyList();
~ResidencyList() override;

HRESULT Add(IHeap* pHeap) override;
HRESULT Reset() override;

DEFINE_IUNKNOWNIMPL_OVERRIDES()
DEFINE_Unknown_OVERRIDES()

private:
friend JSONSerializer;
private : friend JSONSerializer;
friend ResidencyManager;

using UnderlyingType = std::vector<Heap*>;
Expand Down
9 changes: 4 additions & 5 deletions src/gpgmm/d3d12/ResidencyManagerD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define GPGMM_D3D12_RESIDENCYMANAGERD3D12_H_

#include "gpgmm/common/Object.h"
#include "gpgmm/d3d12/IUnknownImplD3D12.h"
#include "gpgmm/d3d12/UnknownD3D12.h"
#include "gpgmm/utils/EnumFlags.h"
#include "gpgmm/utils/LinkedList.h"

Expand All @@ -39,7 +39,7 @@ namespace gpgmm::d3d12 {
class ResourceAllocator;
class ResourceHeapAllocator;

class ResidencyManager final : public IUnknownImpl, public IResidencyManager, ObjectBase {
class ResidencyManager final : public Unknown, public IResidencyManager, ObjectBase {
public:
static HRESULT CreateResidencyManager(const RESIDENCY_DESC& descriptor,
IResidencyManager** ppResidencyManagerOut);
Expand All @@ -63,10 +63,9 @@ namespace gpgmm::d3d12 {

RESIDENCY_STATS GetStats() const override;

DEFINE_IUNKNOWNIMPL_OVERRIDES()
DEFINE_Unknown_OVERRIDES()

private:
friend Heap;
private : friend Heap;
friend ResourceAllocator;
friend ResourceHeapAllocator;

Expand Down
8 changes: 4 additions & 4 deletions src/gpgmm/d3d12/ResourceAllocationD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "gpgmm/common/MemoryAllocation.h"
#include "gpgmm/d3d12/DebugObjectD3D12.h"
#include "gpgmm/d3d12/IUnknownImplD3D12.h"
#include "gpgmm/d3d12/UnknownD3D12.h"
#include "gpgmm/d3d12/d3d12_platform.h"

#include <gpgmm_d3d12.h>
Expand All @@ -45,10 +45,10 @@ namespace gpgmm::d3d12 {
RESOURCE_ALLOCATION_INFO GetInfo() const override;
IHeap* GetMemory() const override;

DEFINE_IUNKNOWNIMPL_OVERRIDES()
DEFINE_Unknown_OVERRIDES()

// IDebugObject interface
LPCWSTR GetDebugName() const override;
// IDebugObject interface
LPCWSTR GetDebugName() const override;
HRESULT SetDebugName(LPCWSTR Name) override;

private:
Expand Down
9 changes: 4 additions & 5 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define GPGMM_D3D12_RESOURCEALLOCATORD3D12_H_

#include "gpgmm/common/MemoryAllocator.h"
#include "gpgmm/d3d12/IUnknownImplD3D12.h"
#include "gpgmm/d3d12/UnknownD3D12.h"
#include "gpgmm/utils/EnumFlags.h"

#include <gpgmm_d3d12.h>
Expand Down Expand Up @@ -70,7 +70,7 @@ namespace gpgmm::d3d12 {
const D3D12_RESOURCE_DESC* mResourceDescriptor;
};

class ResourceAllocator final : public IUnknownImpl,
class ResourceAllocator final : public Unknown,
public IResourceAllocator,
public MemoryAllocator {
public:
Expand Down Expand Up @@ -99,10 +99,9 @@ namespace gpgmm::d3d12 {
void* pFeatureSupportData,
uint32_t featureSupportDataSize) const override;

DEFINE_IUNKNOWNIMPL_OVERRIDES()
DEFINE_Unknown_OVERRIDES()

private:
friend BufferAllocator;
private : friend BufferAllocator;
friend ResourceAllocation;

// ObjectBase interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "gpgmm/d3d12/IUnknownImplD3D12.h"
#include "gpgmm/d3d12/UnknownD3D12.h"

namespace gpgmm::d3d12 {
IUnknownImpl::IUnknownImpl() : mRefCount(1) {
Unknown::Unknown() : mRefCount(1) {
}

HRESULT IUnknownImpl::QueryInterface(REFIID riid, void** ppvObject) {
HRESULT Unknown::QueryInterface(REFIID riid, void** ppvObject) {
// Always set out parameter to nullptr, validating it first.
if (ppvObject == nullptr) {
return E_INVALIDARG;
Expand All @@ -36,20 +36,20 @@ namespace gpgmm::d3d12 {
return E_NOINTERFACE;
}

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

ULONG IUnknownImpl::Release() {
ULONG Unknown::Release() {
const ULONG refCount = mRefCount.Unref() ? 0 : mRefCount.GetRefCount();
if (refCount == 0) {
DeleteThis();
}
return refCount;
}

void IUnknownImpl::DeleteThis() {
void Unknown::DeleteThis() {
delete this;
}
} // namespace gpgmm::d3d12
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef GPGMM_D3D12_IUNKNOWNIMPLD3D12_H_
#define GPGMM_D3D12_IUNKNOWNIMPLD3D12_H_
#ifndef GPGMM_D3D12_UnknownD3D12_H_
#define GPGMM_D3D12_UnknownD3D12_H_

#include "gpgmm/d3d12/d3d12_platform.h"
#include "gpgmm/utils/NonCopyable.h"

#ifndef GPGMM_REFCOUNT_TYPE
# include "gpgmm/utils/RefCount.h"
/** \brief Defines the atomic-type to use for ref-counting the COM object.
*/
*/
# define GPGMM_REFCOUNT_TYPE RefCounted
#endif

namespace gpgmm::d3d12 {

/** \brief IUnknownImpl is a thread-safe ref-count implementation for custom COM based objects.
/** \brief Unknown is a thread-safe ref-count implementation for custom COM based objects.

The custom COM based object must override DeleteThis() if they require a custom-deleter.
*/
class IUnknownImpl : public IUnknown, public NonCopyable {
class Unknown : public IUnknown, public NonCopyable {
public:
IUnknownImpl();
virtual ~IUnknownImpl() = default;
Unknown();
virtual ~Unknown() = default;

// IUnknown interface
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override;
Expand All @@ -49,14 +49,14 @@ namespace gpgmm::d3d12 {
GPGMM_REFCOUNT_TYPE mRefCount; // Maintains the COM ref-count of this object.
};

// Helper to provide IUnknown-based object types the required overrides to use IUnknownImpl.
#define DEFINE_IUNKNOWNIMPL_OVERRIDES() \
// Helper to provide IUnknown-based object types the required overrides to use Unknown.
#define DEFINE_Unknown_OVERRIDES() \
inline HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override { \
return IUnknownImpl::QueryInterface(riid, ppvObject); \
return Unknown::QueryInterface(riid, ppvObject); \
} \
inline ULONG STDMETHODCALLTYPE AddRef() override { return IUnknownImpl::AddRef(); } \
inline ULONG STDMETHODCALLTYPE Release() override { return IUnknownImpl::Release(); }
inline ULONG STDMETHODCALLTYPE AddRef() override { return Unknown::AddRef(); } \
inline ULONG STDMETHODCALLTYPE Release() override { return Unknown::Release(); }

} // namespace gpgmm::d3d12

#endif // GPGMM_D3D12_IUNKNOWNIMPLD3D12_H_
#endif // GPGMM_D3D12_UnknownD3D12_H_
Loading