2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-05-06 03:30:37 +08:00
|
|
|
* Copyright (c) 2017 - 2018, Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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;
|
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;
|
|
|
|
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
|
|
|
|
2018-05-17 17:47:35 +08:00
|
|
|
static void loadLib();
|
2018-06-21 17:36:47 +08:00
|
|
|
static bool initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo);
|
2018-05-06 03:30:37 +08:00
|
|
|
static void destroyContext();
|
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-06-21 17:36:47 +08:00
|
|
|
static uint32_t getMOCS(uint32_t type);
|
|
|
|
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-05-17 17:47:35 +08:00
|
|
|
static decltype(&GmmInitGlobalContext) initGlobalContextFunc;
|
|
|
|
static decltype(&GmmDestroyGlobalContext) destroyGlobalContextFunc;
|
|
|
|
static decltype(&GmmCreateClientContext) createClientContextFunc;
|
|
|
|
static decltype(&GmmDeleteClientContext) deleteClientContextFunc;
|
|
|
|
|
2018-01-25 15:30:57 +08:00
|
|
|
static bool useSimplifiedMocsTable;
|
2018-06-21 22:14:12 +08:00
|
|
|
static GMM_CLIENT_CONTEXT *gmmClientContext;
|
2018-06-28 19:38:15 +08:00
|
|
|
static const HardwareInfo *hwInfo;
|
2018-05-17 17:47:35 +08:00
|
|
|
static bool isLoaded;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
} // namespace OCLRT
|