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
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <memory>
|
|
|
|
#include "runtime/gmm_helper/gmm_lib.h"
|
|
|
|
#include "runtime/api/cl_types.h"
|
|
|
|
|
|
|
|
namespace OCLRT {
|
2018-06-21 17:36:47 +08:00
|
|
|
enum class OCLPlane;
|
2018-01-12 16:08:49 +08:00
|
|
|
struct HardwareInfo;
|
2017-12-21 07:45:38 +08:00
|
|
|
struct FeatureTable;
|
|
|
|
struct WorkaroundTable;
|
|
|
|
struct ImageInfo;
|
|
|
|
class GraphicsAllocation;
|
2018-06-21 17:36:47 +08:00
|
|
|
class Gmm;
|
2018-07-03 16:00:12 +08:00
|
|
|
class OsLibrary;
|
2018-07-06 15:07:42 +08:00
|
|
|
class GmmClientContext;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
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);
|
2018-07-27 19:59:39 +08:00
|
|
|
void setSimplifiedMocsTableUsage(bool value);
|
2018-07-23 18:23:48 +08:00
|
|
|
|
2018-06-21 17:36:47 +08:00
|
|
|
static constexpr uint32_t cacheDisabledIndex = 0;
|
|
|
|
static constexpr uint32_t cacheEnabledIndex = 4;
|
|
|
|
static constexpr uint32_t maxPossiblePitch = 2147483648;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
static uint64_t canonize(uint64_t address);
|
2018-01-31 18:22:13 +08:00
|
|
|
static uint64_t decanonize(uint64_t address);
|
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);
|
2018-06-21 17:36:47 +08:00
|
|
|
static bool allowTiling(const cl_image_desc &imageDesc);
|
2017-12-21 07:45:38 +08:00
|
|
|
static uint32_t getRenderTileMode(uint32_t tileWalk);
|
2018-06-21 17:36:47 +08:00
|
|
|
static uint32_t getRenderAlignment(uint32_t alignment);
|
2017-12-21 07:45:38 +08:00
|
|
|
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();
|
|
|
|
void initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo);
|
|
|
|
|
2018-07-27 19:59:39 +08:00
|
|
|
bool useSimplifiedMocsTable = false;
|
|
|
|
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
|
|
|
};
|
|
|
|
} // namespace OCLRT
|