diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index 0b697c5ea..6d41df238 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -1256,15 +1256,13 @@ namespace gpgmm::d3d12 { std::lock_guard lock(mMutex); - ComPtr resource(pCommittedResource); - - D3D12_RESOURCE_DESC desc = resource->GetDesc(); + D3D12_RESOURCE_DESC desc = pCommittedResource->GetDesc(); const D3D12_RESOURCE_ALLOCATION_INFO resourceInfo = GetResourceAllocationInfo(mDevice, desc); D3D12_HEAP_PROPERTIES heapProperties; D3D12_HEAP_FLAGS heapFlags; - ReturnIfFailed(resource->GetHeapProperties(&heapProperties, &heapFlags)); + ReturnIfFailed(pCommittedResource->GetHeapProperties(&heapProperties, &heapFlags)); // TODO: enable validation conditionally? if (allocationDescriptor.HeapType != 0 && @@ -1306,7 +1304,7 @@ namespace gpgmm::d3d12 { resourceHeapDesc.SizeInBytes = resourceInfo.SizeInBytes; resourceHeapDesc.Alignment = resourceInfo.Alignment; - ImportResourceCallbackContext importResourceCallbackContext(resource); + ImportResourceCallbackContext importResourceCallbackContext(pCommittedResource); ComPtr resourceHeap; ReturnIfFailed(Heap::CreateHeap( @@ -1328,7 +1326,7 @@ namespace gpgmm::d3d12 { *ppResourceAllocationOut = new ResourceAllocation(allocationDesc, nullptr, this, static_cast(resourceHeap.Detach()), - nullptr, std::move(resource)); + nullptr, pCommittedResource); return S_OK; } @@ -1534,7 +1532,7 @@ namespace gpgmm::d3d12 { return E_INVALIDARG; } - ImportResourceCallbackContext::ImportResourceCallbackContext(ComPtr resource) + ImportResourceCallbackContext::ImportResourceCallbackContext(ID3D12Resource* resource) : mResource(resource) { } @@ -1544,12 +1542,7 @@ namespace gpgmm::d3d12 { } HRESULT ImportResourceCallbackContext::GetHeap(ID3D12Pageable** ppPageableOut) { - ComPtr pageable; - ReturnIfFailed(mResource.As(&pageable)); - - *ppPageableOut = pageable.Detach(); - - return S_OK; + return mResource->QueryInterface(IID_PPV_ARGS(ppPageableOut)); } CreateCommittedResourceCallbackContext::CreateCommittedResourceCallbackContext( diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h index 359cc245a..7385d18b0 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h @@ -37,13 +37,13 @@ namespace gpgmm::d3d12 { class ImportResourceCallbackContext { public: - ImportResourceCallbackContext(ComPtr resource); + ImportResourceCallbackContext(ID3D12Resource* resource); static HRESULT GetHeap(void* pContext, ID3D12Pageable** ppPageableOut); private: HRESULT GetHeap(ID3D12Pageable** ppPageableOut); - ComPtr mResource; + ID3D12Resource* mResource = nullptr; }; class CreateCommittedResourceCallbackContext {