2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-09-18 15:11:08 +08:00
|
|
|
* Copyright (C) 2017-2018 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2018-09-26 03:44:36 +08:00
|
|
|
#include "runtime/gen_common/aub_mapper.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/gen_common/hw_cmds.h"
|
|
|
|
#include "runtime/command_stream/linear_stream.h"
|
2018-04-06 20:25:22 +08:00
|
|
|
#include "runtime/built_ins/sip.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
namespace OCLRT {
|
2018-02-19 16:50:17 +08:00
|
|
|
struct HardwareCapabilities;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
class HwHelper {
|
|
|
|
public:
|
|
|
|
static HwHelper &get(GFXCORE_FAMILY gfxCore);
|
2018-02-23 14:37:47 +08:00
|
|
|
virtual uint32_t getBindingTableStateSurfaceStatePointer(void *pBindingTable, uint32_t index) = 0;
|
|
|
|
virtual size_t getBindingTableStateSize() const = 0;
|
|
|
|
virtual uint32_t getBindingTableStateAlignement() const = 0;
|
|
|
|
virtual size_t getInterfaceDescriptorDataSize() const = 0;
|
|
|
|
virtual size_t getMaxBarrierRegisterPerSlice() const = 0;
|
2018-06-06 14:45:45 +08:00
|
|
|
virtual uint32_t getComputeUnitsUsedForScratch(const HardwareInfo *pHwInfo) const = 0;
|
2018-02-23 14:37:47 +08:00
|
|
|
virtual void setCapabilityCoherencyFlag(const HardwareInfo *pHwInfo, bool &coherencyFlag) = 0;
|
|
|
|
virtual bool setupPreemptionRegisters(HardwareInfo *pHwInfo, bool enable) = 0;
|
|
|
|
virtual void adjustDefaultEngineType(HardwareInfo *pHwInfo) = 0;
|
2018-08-23 23:42:35 +08:00
|
|
|
virtual void setupHardwareCapabilities(HardwareCapabilities *caps, const HardwareInfo &hwInfo) = 0;
|
2018-04-06 20:25:22 +08:00
|
|
|
virtual SipKernelType getSipKernelType(bool debuggingActive) = 0;
|
2018-08-23 17:29:39 +08:00
|
|
|
virtual uint32_t getConfigureAddressSpaceMode() = 0;
|
2018-09-14 20:31:37 +08:00
|
|
|
virtual bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) = 0;
|
2018-10-03 01:10:29 +08:00
|
|
|
virtual bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const = 0;
|
2018-09-26 03:44:36 +08:00
|
|
|
virtual const AubMemDump::LrcaHelper &getCsTraits(EngineType engineType) const = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
protected:
|
2018-10-03 01:10:29 +08:00
|
|
|
HwHelper() = default;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
class HwHelperHw : public HwHelper {
|
|
|
|
public:
|
|
|
|
static HwHelper &get() {
|
|
|
|
static HwHelperHw<GfxFamily> hwHelper;
|
|
|
|
return hwHelper;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t getBindingTableStateSurfaceStatePointer(void *pBindingTable, uint32_t index) override {
|
|
|
|
using BINDING_TABLE_STATE = typename GfxFamily::BINDING_TABLE_STATE;
|
|
|
|
|
|
|
|
BINDING_TABLE_STATE *bindingTableState = static_cast<BINDING_TABLE_STATE *>(pBindingTable);
|
|
|
|
return bindingTableState[index].getRawData(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t getBindingTableStateSize() const override {
|
|
|
|
using BINDING_TABLE_STATE = typename GfxFamily::BINDING_TABLE_STATE;
|
|
|
|
return sizeof(BINDING_TABLE_STATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t getBindingTableStateAlignement() const override {
|
|
|
|
using BINDING_TABLE_STATE = typename GfxFamily::BINDING_TABLE_STATE;
|
|
|
|
return BINDING_TABLE_STATE::SURFACESTATEPOINTER_ALIGN_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t getInterfaceDescriptorDataSize() const override {
|
|
|
|
using INTERFACE_DESCRIPTOR_DATA = typename GfxFamily::INTERFACE_DESCRIPTOR_DATA;
|
|
|
|
return sizeof(INTERFACE_DESCRIPTOR_DATA);
|
|
|
|
}
|
|
|
|
|
2018-09-26 03:44:36 +08:00
|
|
|
const AubMemDump::LrcaHelper &getCsTraits(EngineType engineType) const override;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t getMaxBarrierRegisterPerSlice() const override;
|
|
|
|
|
2018-06-06 14:45:45 +08:00
|
|
|
uint32_t getComputeUnitsUsedForScratch(const HardwareInfo *pHwInfo) const override;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
void setCapabilityCoherencyFlag(const HardwareInfo *pHwInfo, bool &coherencyFlag) override;
|
|
|
|
|
|
|
|
bool setupPreemptionRegisters(HardwareInfo *pHwInfo, bool enable) override;
|
|
|
|
|
2018-01-09 21:25:30 +08:00
|
|
|
void adjustDefaultEngineType(HardwareInfo *pHwInfo) override;
|
|
|
|
|
2018-08-23 23:42:35 +08:00
|
|
|
void setupHardwareCapabilities(HardwareCapabilities *caps, const HardwareInfo &hwInfo) override;
|
2018-02-19 16:50:17 +08:00
|
|
|
|
2018-04-06 20:25:22 +08:00
|
|
|
SipKernelType getSipKernelType(bool debuggingActive) override;
|
|
|
|
|
2018-08-23 17:29:39 +08:00
|
|
|
uint32_t getConfigureAddressSpaceMode() override;
|
|
|
|
|
2018-09-06 22:41:50 +08:00
|
|
|
bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) override;
|
|
|
|
|
2018-10-03 01:10:29 +08:00
|
|
|
bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
HwHelperHw() = default;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DwordBuilder {
|
|
|
|
static uint32_t build(uint32_t bitNumberToSet, bool masked, bool set = true, uint32_t initValue = 0) {
|
|
|
|
uint32_t dword = initValue;
|
|
|
|
if (set) {
|
|
|
|
dword |= (1 << bitNumberToSet);
|
|
|
|
}
|
|
|
|
if (masked) {
|
|
|
|
dword |= (1 << (bitNumberToSet + 16));
|
|
|
|
}
|
|
|
|
return dword;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
struct LriHelper {
|
2018-02-05 18:48:58 +08:00
|
|
|
using MI_LOAD_REGISTER_IMM = typename GfxFamily::MI_LOAD_REGISTER_IMM;
|
|
|
|
|
|
|
|
static MI_LOAD_REGISTER_IMM *program(LinearStream *cmdStream, uint32_t address, uint32_t value) {
|
2017-12-21 07:45:38 +08:00
|
|
|
auto lri = (MI_LOAD_REGISTER_IMM *)cmdStream->getSpace(sizeof(MI_LOAD_REGISTER_IMM));
|
|
|
|
*lri = MI_LOAD_REGISTER_IMM::sInit();
|
|
|
|
lri->setRegisterOffset(address);
|
|
|
|
lri->setDataDword(value);
|
2018-02-05 18:48:58 +08:00
|
|
|
return lri;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace OCLRT
|