2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-01-10 20:57:40 +08:00
|
|
|
* Copyright (C) 2017-2019 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
|
2019-08-22 22:51:02 +08:00
|
|
|
#include "core/command_stream/linear_stream.h"
|
2019-02-05 22:11:38 +08:00
|
|
|
#include "runtime/built_ins/sip.h"
|
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"
|
2019-03-29 18:48:32 +08:00
|
|
|
#include "runtime/mem_obj/buffer.h"
|
2019-02-05 22:11:38 +08:00
|
|
|
|
|
|
|
#include "CL/cl.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
#include <cstdint>
|
2019-03-25 19:44:40 +08:00
|
|
|
#include <string>
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <type_traits>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-11-22 22:16:20 +08:00
|
|
|
class ExecutionEnvironment;
|
|
|
|
class GraphicsAllocation;
|
2018-02-19 16:50:17 +08:00
|
|
|
struct HardwareCapabilities;
|
2019-08-23 20:50:23 +08:00
|
|
|
class GmmHelper;
|
2018-02-19 16:50:17 +08:00
|
|
|
|
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;
|
2019-08-23 06:23:10 +08:00
|
|
|
virtual uint32_t getPitchAlignmentForImage(const HardwareInfo *hwInfo) = 0;
|
2018-02-23 14:37:47 +08:00
|
|
|
virtual void setCapabilityCoherencyFlag(const HardwareInfo *pHwInfo, bool &coherencyFlag) = 0;
|
|
|
|
virtual void adjustDefaultEngineType(HardwareInfo *pHwInfo) = 0;
|
2018-08-23 23:42:35 +08:00
|
|
|
virtual void setupHardwareCapabilities(HardwareCapabilities *caps, const HardwareInfo &hwInfo) = 0;
|
2019-08-29 11:46:37 +08:00
|
|
|
virtual bool isL3Configurable(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;
|
2019-02-12 17:56:27 +08:00
|
|
|
virtual bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) const = 0;
|
2018-10-03 01:10:29 +08:00
|
|
|
virtual bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const = 0;
|
2019-03-27 17:06:29 +08:00
|
|
|
virtual const AubMemDump::LrcaHelper &getCsTraits(aub_stream::EngineType engineType) const = 0;
|
2019-08-22 21:21:02 +08:00
|
|
|
virtual bool hvAlign4Required() const = 0;
|
2019-04-17 18:56:54 +08:00
|
|
|
virtual bool obtainRenderBufferCompressionPreference(const size_t size) const = 0;
|
2019-03-29 18:48:32 +08:00
|
|
|
virtual void checkResourceCompatibility(Buffer *buffer, cl_int &errorCode) = 0;
|
2018-12-14 23:00:43 +08:00
|
|
|
static bool renderCompressedBuffersSupported(const HardwareInfo &hwInfo);
|
|
|
|
static bool renderCompressedImagesSupported(const HardwareInfo &hwInfo);
|
2019-02-05 22:11:38 +08:00
|
|
|
static bool cacheFlushAfterWalkerSupported(const HardwareInfo &hwInfo);
|
2018-10-18 19:40:53 +08:00
|
|
|
virtual bool timestampPacketWriteSupported() const = 0;
|
2018-11-22 22:16:20 +08:00
|
|
|
virtual size_t getRenderSurfaceStateSize() const = 0;
|
|
|
|
virtual void setRenderSurfaceStateForBuffer(ExecutionEnvironment &executionEnvironment,
|
|
|
|
void *surfaceStateBuffer,
|
|
|
|
size_t bufferSize,
|
|
|
|
uint64_t gpuVa,
|
|
|
|
size_t offset,
|
|
|
|
uint32_t pitch,
|
|
|
|
GraphicsAllocation *gfxAlloc,
|
|
|
|
cl_mem_flags flags,
|
|
|
|
uint32_t surfaceType,
|
|
|
|
bool forceNonAuxMode) = 0;
|
2019-03-27 17:06:29 +08:00
|
|
|
virtual const std::vector<aub_stream::EngineType> getGpgpuEngineInstances() const = 0;
|
2019-02-12 17:56:27 +08:00
|
|
|
virtual bool getEnableLocalMemory(const HardwareInfo &hwInfo) const = 0;
|
2019-03-25 19:44:40 +08:00
|
|
|
virtual std::string getExtensions() const = 0;
|
2019-05-16 23:17:53 +08:00
|
|
|
static uint32_t getMaxThreadsForVfe(const HardwareInfo &hwInfo);
|
2019-05-20 17:19:27 +08:00
|
|
|
virtual uint32_t getMetricsLibraryGenId() const = 0;
|
2019-08-23 20:50:23 +08:00
|
|
|
virtual uint32_t getMocsIndex(GmmHelper &gmmHelper, bool l3enabled, bool l1enabled) const = 0;
|
2019-09-05 14:24:22 +08:00
|
|
|
virtual bool requiresAuxResolves() const = 0;
|
2019-09-06 16:25:14 +08:00
|
|
|
virtual bool tilingAllowed(bool isSharedContext, const cl_image_desc &imgDesc, bool forceLinearStorage) = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-25 20:21:48 +08:00
|
|
|
static constexpr uint32_t lowPriorityGpgpuEngineIndex = 1;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-08-27 16:15:03 +08:00
|
|
|
static const aub_stream::EngineType lowPriorityEngineType;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
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-11-22 22:16:20 +08:00
|
|
|
size_t getRenderSurfaceStateSize() const override {
|
|
|
|
using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE;
|
|
|
|
return sizeof(RENDER_SURFACE_STATE);
|
|
|
|
}
|
|
|
|
|
2019-03-27 17:06:29 +08:00
|
|
|
const AubMemDump::LrcaHelper &getCsTraits(aub_stream::EngineType engineType) const override;
|
2018-09-26 03:44:36 +08:00
|
|
|
|
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;
|
|
|
|
|
2019-08-23 06:23:10 +08:00
|
|
|
uint32_t getPitchAlignmentForImage(const HardwareInfo *hwInfo) override;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
void setCapabilityCoherencyFlag(const HardwareInfo *pHwInfo, bool &coherencyFlag) 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
|
|
|
|
2019-08-29 11:46:37 +08:00
|
|
|
bool isL3Configurable(const HardwareInfo &hwInfo) override;
|
|
|
|
|
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;
|
|
|
|
|
2019-02-12 17:56:27 +08:00
|
|
|
bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) const override;
|
2018-09-06 22:41:50 +08:00
|
|
|
|
2019-08-22 21:21:02 +08:00
|
|
|
bool hvAlign4Required() const override;
|
|
|
|
|
2019-04-17 18:56:54 +08:00
|
|
|
bool obtainRenderBufferCompressionPreference(const size_t size) const override;
|
2019-03-19 19:57:47 +08:00
|
|
|
|
2019-03-29 18:48:32 +08:00
|
|
|
void checkResourceCompatibility(Buffer *buffer, cl_int &errorCode) override;
|
|
|
|
|
2018-10-18 19:40:53 +08:00
|
|
|
bool timestampPacketWriteSupported() const override;
|
|
|
|
|
2018-10-03 01:10:29 +08:00
|
|
|
bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const override;
|
|
|
|
|
2018-11-22 22:16:20 +08:00
|
|
|
void setRenderSurfaceStateForBuffer(ExecutionEnvironment &executionEnvironment,
|
|
|
|
void *surfaceStateBuffer,
|
|
|
|
size_t bufferSize,
|
|
|
|
uint64_t gpuVa,
|
|
|
|
size_t offset,
|
|
|
|
uint32_t pitch,
|
|
|
|
GraphicsAllocation *gfxAlloc,
|
|
|
|
cl_mem_flags flags,
|
|
|
|
uint32_t surfaceType,
|
|
|
|
bool forceNonAuxMode) override;
|
|
|
|
|
2019-03-27 17:06:29 +08:00
|
|
|
const std::vector<aub_stream::EngineType> getGpgpuEngineInstances() const override;
|
2019-01-10 20:57:40 +08:00
|
|
|
|
2019-02-12 17:56:27 +08:00
|
|
|
bool getEnableLocalMemory(const HardwareInfo &hwInfo) const override;
|
|
|
|
|
2019-03-25 19:44:40 +08:00
|
|
|
std::string getExtensions() const override;
|
|
|
|
|
2019-05-20 17:19:27 +08:00
|
|
|
uint32_t getMetricsLibraryGenId() const override;
|
|
|
|
|
2019-08-23 20:50:23 +08:00
|
|
|
uint32_t getMocsIndex(GmmHelper &gmmHelper, bool l3enabled, bool l1enabled) const override;
|
|
|
|
|
2019-09-05 14:24:22 +08:00
|
|
|
bool requiresAuxResolves() const override;
|
|
|
|
|
2019-09-06 16:25:14 +08:00
|
|
|
bool tilingAllowed(bool isSharedContext, const cl_image_desc &imgDesc, bool forceLinearStorage) override;
|
|
|
|
|
2018-10-03 01:10:29 +08:00
|
|
|
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));
|
2019-01-18 00:10:12 +08:00
|
|
|
*lri = GfxFamily::cmdInitLoadRegisterImm;
|
2017-12-21 07:45:38 +08:00
|
|
|
lri->setRegisterOffset(address);
|
|
|
|
lri->setDataDword(value);
|
2018-02-05 18:48:58 +08:00
|
|
|
return lri;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
};
|
2018-11-23 17:32:15 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
struct PipeControlHelper {
|
|
|
|
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
|
|
|
|
using POST_SYNC_OPERATION = typename GfxFamily::PIPE_CONTROL::POST_SYNC_OPERATION;
|
2019-07-11 20:35:40 +08:00
|
|
|
static PIPE_CONTROL *obtainPipeControlAndProgramPostSyncOperation(LinearStream &commandStream,
|
2018-11-23 17:32:15 +08:00
|
|
|
POST_SYNC_OPERATION operation,
|
|
|
|
uint64_t gpuAddress,
|
2019-03-21 00:08:05 +08:00
|
|
|
uint64_t immediateData,
|
2019-08-14 15:33:51 +08:00
|
|
|
bool dcFlush, const HardwareInfo &hwInfo);
|
|
|
|
static void addPipeControlWA(LinearStream &commandStream, const HardwareInfo &hwInfo);
|
2019-07-11 20:35:40 +08:00
|
|
|
static PIPE_CONTROL *addPipeControl(LinearStream &commandStream, bool dcFlush);
|
2019-08-14 15:33:51 +08:00
|
|
|
static size_t getSizeForPipeControlWithPostSyncOperation(const HardwareInfo &hwInfo);
|
2019-07-11 20:35:40 +08:00
|
|
|
static size_t getSizeForSinglePipeControl();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static PIPE_CONTROL *obtainPipeControl(LinearStream &commandStream, bool dcFlush);
|
2018-11-23 17:32:15 +08:00
|
|
|
};
|
|
|
|
|
2018-11-22 22:16:20 +08:00
|
|
|
union SURFACE_STATE_BUFFER_LENGTH {
|
|
|
|
uint32_t Length;
|
|
|
|
struct SurfaceState {
|
|
|
|
uint32_t Width : BITFIELD_RANGE(0, 6);
|
|
|
|
uint32_t Height : BITFIELD_RANGE(7, 20);
|
|
|
|
uint32_t Depth : BITFIELD_RANGE(21, 31);
|
|
|
|
} SurfaceState;
|
|
|
|
};
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|