2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-31 21:35:46 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 01:46:50 +08:00
|
|
|
#include "os_interface/windows/deferrable_deletion_win.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-02-24 01:46:50 +08:00
|
|
|
#include "os_interface/windows/wddm/wddm.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
DeferrableDeletion *DeferrableDeletion::create(Args... args) {
|
|
|
|
return new DeferrableDeletionImpl(std::forward<Args>(args)...);
|
|
|
|
}
|
2019-03-05 21:21:57 +08:00
|
|
|
template DeferrableDeletion *DeferrableDeletion::create(Wddm *wddm, const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-11-30 00:35:31 +08:00
|
|
|
DeferrableDeletionImpl::DeferrableDeletionImpl(Wddm *wddm, const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle)
|
|
|
|
: wddm(wddm), allocationCount(allocationCount), resourceHandle(resourceHandle) {
|
2017-12-21 07:45:38 +08:00
|
|
|
if (handles) {
|
|
|
|
this->handles = new D3DKMT_HANDLE[allocationCount];
|
|
|
|
for (uint32_t i = 0; i < allocationCount; i++) {
|
|
|
|
this->handles[i] = handles[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-29 18:20:02 +08:00
|
|
|
bool DeferrableDeletionImpl::apply() {
|
2018-09-06 23:58:32 +08:00
|
|
|
bool destroyStatus = wddm->destroyAllocations(handles, allocationCount, resourceHandle);
|
2017-12-21 07:45:38 +08:00
|
|
|
DEBUG_BREAK_IF(!destroyStatus);
|
2018-11-29 18:20:02 +08:00
|
|
|
return true;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
DeferrableDeletionImpl::~DeferrableDeletionImpl() {
|
|
|
|
if (handles) {
|
|
|
|
delete[] handles;
|
|
|
|
}
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|