2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-01-18 16:44:52 +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-09-17 18:53:37 +08:00
|
|
|
#include "core/memory_manager/memory_constants.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "runtime/gmm_helper/gmm_lib.h"
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <memory>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-06-21 17:36:47 +08:00
|
|
|
enum class OCLPlane;
|
2019-10-21 20:54:08 +08:00
|
|
|
class GmmClientContext;
|
|
|
|
class GraphicsAllocation;
|
|
|
|
class OsLibrary;
|
2018-01-12 16:08:49 +08:00
|
|
|
struct HardwareInfo;
|
2017-12-21 07:45:38 +08:00
|
|
|
struct FeatureTable;
|
|
|
|
struct WorkaroundTable;
|
|
|
|
struct ImageInfo;
|
|
|
|
|
2018-06-21 17:36:47 +08:00
|
|
|
class GmmHelper {
|
2017-12-21 07:45:38 +08:00
|
|
|
public:
|
2018-06-21 17:36:47 +08:00
|
|
|
GmmHelper() = delete;
|
2018-07-03 16:00:12 +08:00
|
|
|
GmmHelper(const HardwareInfo *hwInfo);
|
2018-07-13 13:42:18 +08:00
|
|
|
MOCKABLE_VIRTUAL ~GmmHelper();
|
2018-07-23 18:23:48 +08:00
|
|
|
|
2018-07-27 19:59:39 +08:00
|
|
|
const HardwareInfo *getHardwareInfo();
|
2018-07-23 18:23:48 +08:00
|
|
|
uint32_t getMOCS(uint32_t type);
|
|
|
|
|
2019-01-18 16:44:52 +08:00
|
|
|
static constexpr uint64_t maxPossiblePitch = 2147483648;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-09-17 18:53:37 +08:00
|
|
|
template <uint8_t addressWidth = 48>
|
|
|
|
static uint64_t canonize(uint64_t address) {
|
|
|
|
return ((int64_t)(address << (64 - addressWidth))) >> (64 - addressWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <uint8_t addressWidth = 48>
|
|
|
|
static uint64_t decanonize(uint64_t address) {
|
|
|
|
return (address & maxNBitValue<addressWidth>);
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-07-23 18:23:48 +08:00
|
|
|
static GmmClientContext *getClientContext();
|
|
|
|
static GmmHelper *getInstance();
|
2018-07-27 19:59:39 +08:00
|
|
|
|
2018-06-21 17:36:47 +08:00
|
|
|
static void queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation *gfxAlloc);
|
2017-12-21 07:45:38 +08:00
|
|
|
static GMM_CUBE_FACE_ENUM getCubeFaceIndex(uint32_t target);
|
|
|
|
static uint32_t getRenderMultisamplesCount(uint32_t numSamples);
|
|
|
|
static GMM_YUV_PLANE convertPlane(OCLPlane oclPlane);
|
|
|
|
|
2018-07-31 15:00:31 +08:00
|
|
|
static std::unique_ptr<GmmClientContext> (*createGmmContextWrapperFunc)(GMM_CLIENT, GmmExportEntries &);
|
2018-05-17 17:47:35 +08:00
|
|
|
|
2018-07-03 16:00:12 +08:00
|
|
|
protected:
|
|
|
|
void loadLib();
|
2019-05-08 22:00:24 +08:00
|
|
|
void initContext(const PLATFORM *platform, const FeatureTable *featureTable, const WorkaroundTable *workaroundTable, const GT_SYSTEM_INFO *pGtSysInfo);
|
2018-07-03 16:00:12 +08:00
|
|
|
|
2018-07-27 19:59:39 +08:00
|
|
|
const HardwareInfo *hwInfo = nullptr;
|
2018-07-23 18:23:48 +08:00
|
|
|
std::unique_ptr<OsLibrary> gmmLib;
|
|
|
|
std::unique_ptr<GmmClientContext> gmmClientContext;
|
2018-07-31 15:00:31 +08:00
|
|
|
GmmExportEntries gmmEntries = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|