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
22 changes: 10 additions & 12 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ namespace gpgmm::d3d12 {
// If the memory allocation was successful, the resource will be created using it.
// Else, if the resource creation fails, the memory allocation will be cleaned up.
template <typename CreateResourceFn>
HRESULT TryAllocateResource(ID3D12Device* device,
MemoryAllocator* allocator,
HRESULT TryAllocateResource(MemoryAllocator* allocator,
const MemoryAllocationRequest& request,
CreateResourceFn&& createResourceFn) {
ResultOrError<std::unique_ptr<MemoryAllocation>> result =
Expand Down Expand Up @@ -1183,8 +1182,8 @@ namespace gpgmm::d3d12 {
// CreateResource().
request.AlwaysPrefetch = false;

GPGMM_RETURN_IF_SUCCEEDED_OR_FATAL(TryAllocateResource(
mDevice, allocator, request, [&](const auto& subAllocation) -> HRESULT {
GPGMM_RETURN_IF_SUCCEEDED_OR_FATAL(
TryAllocateResource(allocator, request, [&](const auto& subAllocation) -> HRESULT {
// Committed resource implicitly creates a resource heap which can be
// used for sub-allocation.
ComPtr<ID3D12Resource> committedResource;
Expand Down Expand Up @@ -1220,8 +1219,8 @@ namespace gpgmm::d3d12 {

request.Alignment = resourceInfo.Alignment;

GPGMM_RETURN_IF_SUCCEEDED_OR_FATAL(TryAllocateResource(
mDevice, allocator, request, [&](const auto& subAllocation) -> HRESULT {
GPGMM_RETURN_IF_SUCCEEDED_OR_FATAL(
TryAllocateResource(allocator, request, [&](const auto& subAllocation) -> HRESULT {
// Resource is placed at an offset corresponding to the allocation offset.
// Each allocation maps to a disjoint (physical) address range so no physical
// memory is can be aliased or will overlap.
Expand Down Expand Up @@ -1264,8 +1263,8 @@ namespace gpgmm::d3d12 {

request.Alignment = allocator->GetMemoryAlignment();

GPGMM_RETURN_IF_SUCCEEDED_OR_FATAL(TryAllocateResource(
mDevice, allocator, request, [&](const auto& allocation) -> HRESULT {
GPGMM_RETURN_IF_SUCCEEDED_OR_FATAL(
TryAllocateResource(allocator, request, [&](const auto& allocation) -> HRESULT {
Heap* resourceHeap = static_cast<Heap*>(allocation.GetMemory());
ComPtr<ID3D12Resource> placedResource;
GPGMM_RETURN_IF_FAILED(
Expand Down Expand Up @@ -1600,19 +1599,18 @@ namespace gpgmm::d3d12 {
return S_OK;
}

// static
HRESULT ResourceAllocator::ReportLiveDeviceObjects(ComPtr<ID3D12Device> device) {
HRESULT ResourceAllocator::ReportLiveDeviceObjects() const {
// Debug layer was never enabled.
ComPtr<ID3D12DebugDevice> debugDevice;
if (FAILED(device.As(&debugDevice))) {
if (FAILED(mDevice->QueryInterface(IID_PPV_ARGS(&debugDevice)))) {
return S_OK;
}

const D3D12_RLDO_FLAGS rldoFlags = D3D12_RLDO_DETAIL | D3D12_RLDO_IGNORE_INTERNAL;
GPGMM_RETURN_IF_FAILED(debugDevice->ReportLiveDeviceObjects(rldoFlags));

ComPtr<ID3D12InfoQueue> leakMessageQueue;
GPGMM_RETURN_IF_FAILED(device.As(&leakMessageQueue));
GPGMM_RETURN_IF_FAILED(mDevice->QueryInterface(IID_PPV_ARGS(&leakMessageQueue)));

// Report live device objects that could be created by GPGMM by checking the global filter.
// This is because the allowList filter cannot easily be made exclusive to these IDs.
Expand Down
2 changes: 1 addition & 1 deletion src/gpgmm/d3d12/ResourceAllocatorD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace gpgmm::d3d12 {
ID3D12Resource** commitedResourceOut,
Heap** resourceHeapOut);

static HRESULT ReportLiveDeviceObjects(ComPtr<ID3D12Device> device);
HRESULT ReportLiveDeviceObjects() const;

bool IsCreateHeapNotResident() const;
bool IsResidencyEnabled() const;
Expand Down