2019-07-12 22:50:14 +08:00
|
|
|
/*
|
2024-12-31 21:48:34 +08:00
|
|
|
* Copyright (C) 2019-2025 Intel Corporation
|
2019-07-12 22:50:14 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/memory_manager/memory_operations_status.h"
|
|
|
|
#include "shared/source/os_interface/windows/windows_defs.h"
|
|
|
|
#include "shared/source/utilities/spinlock.h"
|
2019-07-12 22:50:14 +08:00
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
class Wddm;
|
|
|
|
|
|
|
|
class WddmResidentAllocationsContainer {
|
|
|
|
public:
|
|
|
|
WddmResidentAllocationsContainer(Wddm *wddm) : wddm(wddm) {}
|
2021-06-09 21:53:41 +08:00
|
|
|
MOCKABLE_VIRTUAL ~WddmResidentAllocationsContainer();
|
2019-07-12 22:50:14 +08:00
|
|
|
|
2019-08-29 19:46:49 +08:00
|
|
|
MemoryOperationsStatus isAllocationResident(const D3DKMT_HANDLE &handle);
|
|
|
|
MOCKABLE_VIRTUAL MemoryOperationsStatus evictAllResources();
|
|
|
|
MOCKABLE_VIRTUAL MemoryOperationsStatus evictResource(const D3DKMT_HANDLE &handle);
|
|
|
|
MemoryOperationsStatus evictResources(const D3DKMT_HANDLE *handles, const uint32_t count);
|
2020-03-17 19:19:38 +08:00
|
|
|
MOCKABLE_VIRTUAL MemoryOperationsStatus makeResidentResource(const D3DKMT_HANDLE &handle, size_t size);
|
2025-02-05 14:40:13 +08:00
|
|
|
MemoryOperationsStatus makeResidentResources(const D3DKMT_HANDLE *handles, const uint32_t count, size_t size, const bool forcePagingFence);
|
2019-07-12 22:50:14 +08:00
|
|
|
MOCKABLE_VIRTUAL void removeResource(const D3DKMT_HANDLE &handle);
|
|
|
|
|
|
|
|
protected:
|
2022-09-01 23:54:57 +08:00
|
|
|
[[nodiscard]] MOCKABLE_VIRTUAL std::unique_lock<SpinLock> acquireLock(SpinLock &lock) {
|
2019-07-12 22:50:14 +08:00
|
|
|
return std::unique_lock<SpinLock>{lock};
|
|
|
|
}
|
|
|
|
|
2021-06-09 21:53:41 +08:00
|
|
|
MemoryOperationsStatus evictAllResourcesNoLock();
|
|
|
|
|
2019-07-12 22:50:14 +08:00
|
|
|
Wddm *wddm;
|
|
|
|
std::vector<D3DKMT_HANDLE> resourceHandles;
|
|
|
|
SpinLock resourcesLock;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace NEO
|