2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-04-19 20:11:45 +08:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2018-09-18 15:11:08 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/gmm_helper/gmm_lib.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2018-05-06 03:30:37 +08:00
|
|
|
#include <functional>
|
2019-02-27 18:39:32 +08:00
|
|
|
#include <memory>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2019-12-30 21:14:27 +08:00
|
|
|
class GmmClientContext;
|
2017-12-21 07:45:38 +08:00
|
|
|
class GmmResourceInfo {
|
|
|
|
public:
|
2019-12-30 21:14:27 +08:00
|
|
|
static GmmResourceInfo *create(GmmClientContext *clientContext, GMM_RESCREATE_PARAMS *resourceCreateParams);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-12-30 21:14:27 +08:00
|
|
|
static GmmResourceInfo *create(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-04-19 20:11:45 +08:00
|
|
|
static GmmResourceInfo *create(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo, bool openingHandle);
|
|
|
|
|
2021-05-03 04:41:01 +08:00
|
|
|
MOCKABLE_VIRTUAL ~GmmResourceInfo();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-05-09 16:55:57 +08:00
|
|
|
MOCKABLE_VIRTUAL size_t getSizeAllocation() { return static_cast<size_t>(resourceInfo->GetSize(GMM_TOTAL_SURF)); }
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL size_t getBaseWidth() { return static_cast<size_t>(resourceInfo->GetBaseWidth()); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL size_t getBaseHeight() { return static_cast<size_t>(resourceInfo->GetBaseHeight()); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL size_t getBaseDepth() { return static_cast<size_t>(resourceInfo->GetBaseDepth()); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL size_t getArraySize() { return static_cast<size_t>(resourceInfo->GetArraySize()); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL size_t getRenderPitch() { return static_cast<size_t>(resourceInfo->GetRenderPitch()); }
|
|
|
|
|
2021-08-06 18:46:00 +08:00
|
|
|
MOCKABLE_VIRTUAL uint64_t getDriverProtectionBits();
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
MOCKABLE_VIRTUAL uint32_t getNumSamples() { return resourceInfo->GetNumSamples(); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL uint32_t getQPitch() { return resourceInfo->GetQPitch(); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL uint32_t getBitsPerPixel() { return resourceInfo->GetBitsPerPixel(); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL uint32_t getHAlign() { return resourceInfo->GetHAlign(); }
|
|
|
|
|
2019-08-22 14:20:42 +08:00
|
|
|
MOCKABLE_VIRTUAL uint32_t getHAlignSurfaceState() { return resourceInfo->GetHAlignSurfaceState(); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL uint32_t getVAlignSurfaceState() { return resourceInfo->GetVAlignSurfaceState(); }
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-10 20:13:31 +08:00
|
|
|
MOCKABLE_VIRTUAL uint32_t getMaxLod() { return resourceInfo->GetMaxLod(); }
|
|
|
|
|
2019-01-22 17:24:28 +08:00
|
|
|
MOCKABLE_VIRTUAL uint32_t getTileModeSurfaceState() { return resourceInfo->GetTileModeSurfaceState(); }
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL GMM_RESOURCE_FORMAT getResourceFormat() { return resourceInfo->GetResourceFormat(); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL GMM_SURFACESTATE_FORMAT getResourceFormatSurfaceState() { return resourceInfo->GetResourceFormatSurfaceState(); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL GMM_RESOURCE_TYPE getResourceType() { return resourceInfo->GetResourceType(); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL GMM_RESOURCE_FLAG *getResourceFlags() { return &resourceInfo->GetResFlags(); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL GMM_STATUS getOffset(GMM_REQ_OFFSET_INFO &reqOffsetInfo) { return resourceInfo->GetOffset(reqOffsetInfo); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL uint8_t cpuBlt(GMM_RES_COPY_BLT *resCopyBlt) { return resourceInfo->CpuBlt(resCopyBlt); }
|
|
|
|
|
2020-03-19 21:49:05 +08:00
|
|
|
MOCKABLE_VIRTUAL void *getSystemMemPointer() { return resourceInfo->GetSystemMemPointer(true); }
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL uint32_t getRenderAuxPitchTiles() { return resourceInfo->GetRenderAuxPitchTiles(); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL uint32_t getAuxQPitch() { return resourceInfo->GetAuxQPitch(); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL uint64_t getUnifiedAuxSurfaceOffset(GMM_UNIFIED_AUX_TYPE auxType) { return resourceInfo->GetUnifiedAuxSurfaceOffset(auxType); }
|
|
|
|
|
2019-10-28 15:11:18 +08:00
|
|
|
MOCKABLE_VIRTUAL uint32_t getMipTailStartLodSurfaceState() { return resourceInfo->GetMipTailStartLodSurfaceState(); }
|
|
|
|
|
2019-02-19 23:14:18 +08:00
|
|
|
MOCKABLE_VIRTUAL bool is64KBPageSuitable() const { return resourceInfo->Is64KBPageSuitable(); }
|
|
|
|
|
2021-05-03 04:41:01 +08:00
|
|
|
MOCKABLE_VIRTUAL GMM_RESOURCE_INFO *peekGmmResourceInfo() const { return resourceInfo.get(); }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL void *peekHandle() const { return handle; }
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL size_t peekHandleSize() const { return handleSize; }
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-06-08 19:52:47 +08:00
|
|
|
MOCKABLE_VIRTUAL void refreshHandle();
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
2018-05-06 03:30:37 +08:00
|
|
|
using UniquePtrType = std::unique_ptr<GMM_RESOURCE_INFO, std::function<void(GMM_RESOURCE_INFO *)>>;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
GmmResourceInfo() = default;
|
|
|
|
|
2019-12-30 21:14:27 +08:00
|
|
|
GmmResourceInfo(GmmClientContext *clientContext, GMM_RESCREATE_PARAMS *resourceCreateParams);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-12-30 21:14:27 +08:00
|
|
|
GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-04-19 20:11:45 +08:00
|
|
|
GmmResourceInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo, bool openingHandle);
|
|
|
|
|
2019-09-20 21:37:58 +08:00
|
|
|
void createResourceInfo(GMM_RESOURCE_INFO *resourceInfoPtr);
|
2022-07-01 17:38:41 +08:00
|
|
|
void decodeResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo);
|
2019-09-20 21:37:58 +08:00
|
|
|
|
2018-05-06 03:30:37 +08:00
|
|
|
UniquePtrType resourceInfo;
|
2019-12-30 21:14:27 +08:00
|
|
|
|
|
|
|
GmmClientContext *clientContext = nullptr;
|
2021-05-03 04:41:01 +08:00
|
|
|
|
|
|
|
void *handle = nullptr;
|
|
|
|
size_t handleSize = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|