Files
compute-runtime/runtime/os_interface/windows/wddm_residency_controller.h
Maciej Dziuban f374696f1d Move MonitoredFence to WddmResidencyController
Change-Id: Iac99e7d730fda26d13feed56d5e4c50adf115e51
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
2018-10-24 09:35:42 +02:00

58 lines
1.8 KiB
C++

/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/memory_manager/residency_container.h"
#include "runtime/os_interface/windows/windows_wrapper.h"
#include "runtime/os_interface/windows/windows_defs.h"
#include <atomic>
namespace OCLRT {
class GraphicsAllocation;
class WddmAllocation;
class WddmResidencyController {
public:
WddmResidencyController(uint32_t osContextId);
void acquireLock();
void releaseLock();
void acquireTrimCallbackLock();
void releaseTrimCallbackLock();
WddmAllocation *getTrimCandidateHead();
void addToTrimCandidateList(GraphicsAllocation *allocation);
void removeFromTrimCandidateList(GraphicsAllocation *allocation, bool compactList);
void removeFromTrimCandidateListIfUsed(WddmAllocation *allocation, bool compactList);
void checkTrimCandidateCount();
bool checkTrimCandidateListCompaction();
void compactTrimCandidateList();
uint64_t getLastTrimFenceValue() { return lastTrimFenceValue; }
void setLastTrimFenceValue(uint64_t value) { lastTrimFenceValue = value; }
const ResidencyContainer &peekTrimCandidateList() const { return trimCandidateList; }
uint32_t peekTrimCandidatesCount() const { return trimCandidatesCount; }
MonitoredFence &getMonitoredFence() { return monitoredFence; }
void resetMonitoredFenceParams(D3DKMT_HANDLE &handle, uint64_t *cpuAddress, D3DGPU_VIRTUAL_ADDRESS &gpuAddress);
protected:
uint32_t osContextId;
std::atomic<bool> lock = false;
std::atomic_flag trimCallbackLock = ATOMIC_FLAG_INIT;
uint64_t lastTrimFenceValue = 0u;
ResidencyContainer trimCandidateList;
uint32_t trimCandidatesCount = 0;
MonitoredFence monitoredFence = {};
};
} // namespace OCLRT