mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Cleanup Wddm interface 1/n
pass const D3DKMT_HANDLE * to makeResident/evict/destroyAllocation calls remove gpuPtr from WddmAllocation Change-Id: Ia5ca162946a2d893d4f56c37f8027eab02af90b0 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
28279bddd5
commit
03527f496d
@@ -15,9 +15,9 @@ template <typename... Args>
|
||||
DeferrableDeletion *DeferrableDeletion::create(Args... args) {
|
||||
return new DeferrableDeletionImpl(std::forward<Args>(args)...);
|
||||
}
|
||||
template DeferrableDeletion *DeferrableDeletion::create(Wddm *wddm, D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
||||
template DeferrableDeletion *DeferrableDeletion::create(Wddm *wddm, const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
||||
|
||||
DeferrableDeletionImpl::DeferrableDeletionImpl(Wddm *wddm, D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) {
|
||||
DeferrableDeletionImpl::DeferrableDeletionImpl(Wddm *wddm, const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) {
|
||||
this->wddm = wddm;
|
||||
if (handles) {
|
||||
this->handles = new D3DKMT_HANDLE[allocationCount];
|
||||
|
||||
@@ -19,7 +19,7 @@ class Wddm;
|
||||
|
||||
class DeferrableDeletionImpl : public DeferrableDeletion {
|
||||
public:
|
||||
DeferrableDeletionImpl(Wddm *wddm, D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
||||
DeferrableDeletionImpl(Wddm *wddm, const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
||||
bool apply() override;
|
||||
~DeferrableDeletionImpl();
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ bool Wddm::openAdapter() {
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool Wddm::evict(D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim) {
|
||||
bool Wddm::evict(const D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim) {
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
D3DKMT_EVICT Evict = {0};
|
||||
Evict.AllocationList = handleList;
|
||||
@@ -256,7 +256,7 @@ bool Wddm::evict(D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &siz
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool Wddm::makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) {
|
||||
bool Wddm::makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) {
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
D3DDDI_MAKERESIDENT makeResident = {0};
|
||||
UINT priority = 0;
|
||||
@@ -290,7 +290,7 @@ bool Wddm::makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFur
|
||||
|
||||
bool Wddm::mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr) {
|
||||
void *mapPtr = allocation->getReservedAddress() != nullptr ? allocation->getReservedAddress() : cpuPtr;
|
||||
return mapGpuVirtualAddressImpl(allocation->gmm, allocation->handle, mapPtr, allocation->gpuPtr,
|
||||
return mapGpuVirtualAddressImpl(allocation->gmm, allocation->handle, mapPtr, allocation->getGpuAddressToModify(),
|
||||
MemoryManager::selectHeap(allocation, mapPtr, *hardwareInfoTable[gfxPlatform->eProductFamily]));
|
||||
}
|
||||
|
||||
@@ -545,7 +545,7 @@ NTSTATUS Wddm::createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) {
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Wddm::destroyAllocations(D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) {
|
||||
bool Wddm::destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) {
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
D3DKMT_DESTROYALLOCATION2 DestroyAllocation = {0};
|
||||
DEBUG_BREAK_IF(!(allocationCount <= 1 || resourceHandle == 0));
|
||||
|
||||
@@ -55,8 +55,8 @@ class Wddm {
|
||||
static Wddm *createWddm();
|
||||
bool enumAdapters(HardwareInfo &outHardwareInfo);
|
||||
|
||||
MOCKABLE_VIRTUAL bool evict(D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim);
|
||||
MOCKABLE_VIRTUAL bool makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim);
|
||||
MOCKABLE_VIRTUAL bool evict(const D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim);
|
||||
MOCKABLE_VIRTUAL bool makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim);
|
||||
bool mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr);
|
||||
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData);
|
||||
D3DGPU_VIRTUAL_ADDRESS reserveGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS minimumAddress, D3DGPU_VIRTUAL_ADDRESS maximumAddress, D3DGPU_SIZE_T size);
|
||||
@@ -66,7 +66,7 @@ class Wddm {
|
||||
MOCKABLE_VIRTUAL NTSTATUS createAllocation(WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL bool createAllocation64k(WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL NTSTATUS createAllocationsAndMapGpuVa(OsHandleStorage &osHandles);
|
||||
MOCKABLE_VIRTUAL bool destroyAllocations(D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
||||
MOCKABLE_VIRTUAL bool destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
||||
MOCKABLE_VIRTUAL bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc);
|
||||
bool openNTHandle(HANDLE handle, WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL void *lockResource(WddmAllocation &wddmAllocation);
|
||||
|
||||
@@ -15,38 +15,28 @@
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
class Gmm;
|
||||
|
||||
struct OsHandle {
|
||||
D3DKMT_HANDLE handle;
|
||||
D3DGPU_VIRTUAL_ADDRESS gpuPtr;
|
||||
Gmm *gmm;
|
||||
};
|
||||
|
||||
const size_t trimListUnusedPosition = (size_t)-1;
|
||||
constexpr size_t trimListUnusedPosition = std::numeric_limits<size_t>::max();
|
||||
|
||||
class WddmAllocation : public GraphicsAllocation {
|
||||
public:
|
||||
// OS assigned fields
|
||||
D3DKMT_HANDLE handle; // set by createAllocation
|
||||
D3DKMT_HANDLE handle = 0u; // set by createAllocation
|
||||
D3DKMT_HANDLE resourceHandle = 0u; // used by shared resources
|
||||
|
||||
D3DGPU_VIRTUAL_ADDRESS gpuPtr; // set by mapGpuVA
|
||||
|
||||
WddmAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: GraphicsAllocation(allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool, multiOsContextCapable),
|
||||
handle(0),
|
||||
gpuPtr(0),
|
||||
trimCandidateListPositions(maxOsContextCount, trimListUnusedPosition) {
|
||||
reservedAddressSpace = reservedAddr;
|
||||
: GraphicsAllocation(allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool, multiOsContextCapable), reservedAddressSpace(reservedAddr) {
|
||||
trimCandidateListPositions.fill(trimListUnusedPosition);
|
||||
}
|
||||
|
||||
WddmAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: GraphicsAllocation(allocationType, cpuPtrIn, sizeIn, sharedHandle, pool, multiOsContextCapable),
|
||||
handle(0),
|
||||
gpuPtr(0),
|
||||
trimCandidateListPositions(maxOsContextCount, trimListUnusedPosition) {
|
||||
reservedAddressSpace = nullptr;
|
||||
: GraphicsAllocation(allocationType, cpuPtrIn, sizeIn, sharedHandle, pool, multiOsContextCapable) {
|
||||
trimCandidateListPositions.fill(trimListUnusedPosition);
|
||||
}
|
||||
|
||||
void *getAlignedCpuPtr() const {
|
||||
@@ -84,10 +74,11 @@ class WddmAllocation : public GraphicsAllocation {
|
||||
bool needsMakeResidentBeforeLock = false;
|
||||
|
||||
std::string getAllocationInfoString() const override;
|
||||
uint64_t &getGpuAddressToModify() { return gpuAddress; }
|
||||
|
||||
protected:
|
||||
ResidencyData residency;
|
||||
std::vector<size_t> trimCandidateListPositions;
|
||||
void *reservedAddressSpace;
|
||||
std::array<size_t, maxOsContextCount> trimCandidateListPositions;
|
||||
void *reservedAddressSpace = nullptr;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -77,7 +77,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(const Allocati
|
||||
// 64kb map is not needed
|
||||
auto status = wddm->mapGpuVirtualAddress(wddmAllocation.get(), cpuPtr);
|
||||
DEBUG_BREAK_IF(!status);
|
||||
wddmAllocation->setCpuPtrAndGpuAddress(cpuPtr, wddmAllocation->gpuPtr);
|
||||
wddmAllocation->setCpuAddress(cpuPtr);
|
||||
|
||||
DebugManager.logAllocation(wddmAllocation.get());
|
||||
return wddmAllocation.release();
|
||||
@@ -236,7 +236,6 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
|
||||
}
|
||||
status = wddm->mapGpuVirtualAddress(allocation.get(), ptr);
|
||||
DEBUG_BREAK_IF(!status);
|
||||
allocation->setGpuAddress(allocation->gpuPtr);
|
||||
|
||||
DebugManager.logAllocation(allocation.get());
|
||||
return allocation.release();
|
||||
@@ -305,7 +304,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
|
||||
|
||||
if (input->gmm) {
|
||||
if (input->gmm->isRenderCompressed && wddm->getPageTableManager()) {
|
||||
auto status = wddm->updateAuxTable(input->gpuPtr, input->gmm, false);
|
||||
auto status = wddm->updateAuxTable(input->getGpuAddress(), input->gmm, false);
|
||||
DEBUG_BREAK_IF(!status);
|
||||
}
|
||||
delete input->gmm;
|
||||
@@ -333,7 +332,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
|
||||
delete gfxAllocation;
|
||||
}
|
||||
|
||||
bool WddmMemoryManager::tryDeferDeletions(D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) {
|
||||
bool WddmMemoryManager::tryDeferDeletions(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) {
|
||||
bool status = true;
|
||||
if (deferredDeleter) {
|
||||
deferredDeleter->deferDeletion(DeferrableDeletion::create(wddm, handles, allocationCount, resourceHandle));
|
||||
@@ -476,7 +475,6 @@ bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation) {
|
||||
wddm->destroyAllocations(&allocation->handle, 1, allocation->resourceHandle);
|
||||
wddmSuccess = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
allocation->setGpuAddress(allocation->gpuPtr);
|
||||
}
|
||||
return (wddmSuccess == STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
uint64_t getMaxApplicationAddress() override;
|
||||
uint64_t getInternalHeapBaseAddress() override;
|
||||
|
||||
bool tryDeferDeletions(D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
||||
bool tryDeferDeletions(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
||||
|
||||
bool isMemoryBudgetExhausted() const override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user