2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2021-05-16 20:51:16 +02:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2021-05-21 01:17:57 +02:00
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
|
|
|
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
|
|
|
|
2019-12-11 11:38:44 +01:00
|
|
|
#include <cstdint>
|
2020-02-13 13:26:40 +01:00
|
|
|
#include <memory>
|
2020-02-17 16:14:22 +01:00
|
|
|
#include <vector>
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2020-03-17 07:26:46 +01:00
|
|
|
class ExecutionEnvironment;
|
2021-05-21 01:17:57 +02:00
|
|
|
class MemoryManager;
|
|
|
|
enum class DriverModelType { WDDM,
|
|
|
|
DRM };
|
|
|
|
|
2021-05-24 17:34:55 +00:00
|
|
|
class HwDeviceId : public NonCopyableClass {
|
|
|
|
public:
|
|
|
|
HwDeviceId(DriverModelType driverModel) : driverModelType(driverModel) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~HwDeviceId() = default;
|
|
|
|
|
|
|
|
DriverModelType getDriverModelType() const {
|
|
|
|
return driverModelType;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename DerivedType>
|
|
|
|
DerivedType *as() {
|
|
|
|
UNRECOVERABLE_IF(DerivedType::driverModelType != this->driverModelType);
|
|
|
|
return static_cast<DerivedType *>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename DerivedType>
|
|
|
|
DerivedType *as() const {
|
|
|
|
UNRECOVERABLE_IF(DerivedType::driverModelType != this->driverModelType);
|
|
|
|
return static_cast<const DerivedType *>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DriverModelType driverModelType;
|
|
|
|
};
|
|
|
|
|
2021-05-21 01:17:57 +02:00
|
|
|
class DriverModel : public NonCopyableClass {
|
|
|
|
public:
|
|
|
|
DriverModel(DriverModelType driverModelType)
|
|
|
|
: driverModelType(driverModelType) {
|
|
|
|
}
|
|
|
|
|
2021-05-24 17:34:55 +00:00
|
|
|
virtual ~DriverModel() = default;
|
|
|
|
|
2021-05-21 01:17:57 +02:00
|
|
|
template <typename DerivedType>
|
|
|
|
DerivedType *as() {
|
|
|
|
UNRECOVERABLE_IF(DerivedType::driverModelType != this->driverModelType);
|
|
|
|
return static_cast<DerivedType *>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename DerivedType>
|
|
|
|
DerivedType *as() const {
|
|
|
|
UNRECOVERABLE_IF(DerivedType::driverModelType != this->driverModelType);
|
|
|
|
return static_cast<const DerivedType *>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void setGmmInputArgs(void *args) = 0;
|
|
|
|
|
|
|
|
virtual uint32_t getDeviceHandle() const = 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-05-21 01:17:57 +02:00
|
|
|
DriverModelType getDriverModelType() const {
|
|
|
|
return driverModelType;
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-05-21 01:17:57 +02:00
|
|
|
protected:
|
|
|
|
DriverModelType driverModelType;
|
|
|
|
};
|
|
|
|
|
|
|
|
class OSInterface : public NonCopyableClass {
|
2017-12-21 00:45:38 +01:00
|
|
|
public:
|
2021-05-21 01:17:57 +02:00
|
|
|
virtual ~OSInterface() = default;
|
|
|
|
DriverModel *getDriverModel() const {
|
|
|
|
return driverModel.get();
|
|
|
|
};
|
|
|
|
|
|
|
|
void setDriverModel(std::unique_ptr<DriverModel> driverModel) {
|
|
|
|
this->driverModel = std::move(driverModel);
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
2021-02-23 17:57:27 +00:00
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL bool isDebugAttachAvailable() const;
|
2017-12-21 00:45:38 +01:00
|
|
|
static bool osEnabled64kbPages;
|
2018-10-12 15:20:02 +02:00
|
|
|
static bool osEnableLocalMemory;
|
2021-05-21 01:17:57 +02:00
|
|
|
static bool are64kbPagesEnabled() {
|
|
|
|
return osEnabled64kbPages;
|
|
|
|
}
|
2020-09-22 16:29:34 +02:00
|
|
|
static bool newResourceImplicitFlush;
|
|
|
|
static bool gpuIdleImplicitFlush;
|
2021-05-19 20:12:09 +00:00
|
|
|
static bool requiresSupportForWddmTrimNotification;
|
2020-03-17 07:26:46 +01:00
|
|
|
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevices(ExecutionEnvironment &executionEnvironment);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
protected:
|
2021-05-21 01:17:57 +02:00
|
|
|
std::unique_ptr<DriverModel> driverModel = nullptr;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|