Add mechanism to avoid calling gdi calls while process exit

Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
Kamil Diedrich
2022-05-17 15:23:15 +00:00
committed by Compute-Runtime-Automation
parent 673a6244ee
commit ddd8a08fac
49 changed files with 327 additions and 107 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Intel Corporation
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -10,14 +10,42 @@
namespace NEO {
bool Wddm::skipResourceCleanup() const {
NTSTATUS destroyAllocationNoOp(const D3DKMT_DESTROYALLOCATION2 *allocStruct) {
return STATUS_SUCCESS;
}
NTSTATUS waitForSynchronizationObjectFromCpuNoOp(const D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU *waitStruct) {
return STATUS_SUCCESS;
}
NTSTATUS destroyPagingQueueNoOp(D3DDDI_DESTROYPAGINGQUEUE *destroyPagingQueue) {
return STATUS_SUCCESS;
}
NTSTATUS destroyDeviceNoOp(const D3DKMT_DESTROYDEVICE *destroyDevice) {
return STATUS_SUCCESS;
}
NTSTATUS closeAdapterNoOp(const D3DKMT_CLOSEADAPTER *closeAdapter) {
return STATUS_SUCCESS;
}
bool Wddm::isDriverAvaliable() {
D3DKMT_GETDEVICESTATE deviceState = {};
deviceState.hDevice = device;
deviceState.StateType = D3DKMT_DEVICESTATE_PRESENT;
NTSTATUS status = STATUS_SUCCESS;
status = getGdi()->getDeviceState(&deviceState);
return status != STATUS_SUCCESS;
if (status != STATUS_SUCCESS) {
skipResourceCleanupVar = true;
getGdi()->destroyAllocation2 = &destroyAllocationNoOp;
getGdi()->waitForSynchronizationObjectFromCpu = &waitForSynchronizationObjectFromCpuNoOp;
getGdi()->destroyPagingQueue = &destroyPagingQueueNoOp;
getGdi()->destroyDevice = &destroyDeviceNoOp;
getGdi()->closeAdapter = &closeAdapterNoOp;
}
return status == STATUS_SUCCESS;
}
} // namespace NEO

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Intel Corporation
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -9,8 +9,8 @@
namespace NEO {
bool Wddm::skipResourceCleanup() const {
return false;
bool Wddm::isDriverAvaliable() {
return true;
}
} // namespace NEO

View File

@ -937,14 +937,13 @@ bool Wddm::waitOnGPU(D3DKMT_HANDLE context) {
bool Wddm::waitFromCpu(uint64_t lastFenceValue, const MonitoredFence &monitoredFence) {
NTSTATUS status = STATUS_SUCCESS;
if (lastFenceValue > *monitoredFence.cpuAddress) {
if (!skipResourceCleanup() && lastFenceValue > *monitoredFence.cpuAddress) {
D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU waitFromCpu = {};
waitFromCpu.ObjectCount = 1;
waitFromCpu.ObjectHandleArray = &monitoredFence.fenceHandle;
waitFromCpu.FenceValueArray = &lastFenceValue;
waitFromCpu.hDevice = device;
waitFromCpu.hAsyncEvent = NULL_HANDLE;
status = getGdi()->waitForSynchronizationObjectFromCpu(&waitFromCpu);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
}

View File

@ -196,7 +196,7 @@ class Wddm : public DriverModel {
PhysicalDevicePciBusInfo getPciBusInfo() const override;
size_t getMaxMemAllocSize() const override;
bool skipResourceCleanup() const override;
bool isDriverAvaliable() override;
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevices(ExecutionEnvironment &executionEnvironment);