2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2023-05-19 00:27:44 +08:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2018-09-18 15:11:08 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-07-06 15:07:42 +08:00
|
|
|
#pragma once
|
2021-06-29 01:36:16 +08:00
|
|
|
#include "shared/source/gmm_helper/gmm_lib.h"
|
|
|
|
|
|
|
|
#include <memory>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2021-06-29 01:36:16 +08:00
|
|
|
class GmmClientContext;
|
2022-11-25 15:53:05 +08:00
|
|
|
struct RootDeviceEnvironment;
|
|
|
|
class GmmHandleAllocator;
|
2023-05-19 00:27:44 +08:00
|
|
|
class MapGpuVirtualAddressGmm;
|
|
|
|
class FreeGpuVirtualAddressGmm;
|
2021-06-29 01:36:16 +08:00
|
|
|
|
|
|
|
class GmmClientContext {
|
2018-07-06 15:07:42 +08:00
|
|
|
public:
|
2022-11-25 15:53:05 +08:00
|
|
|
GmmClientContext(const RootDeviceEnvironment &rootDeviceEnvironment);
|
2021-06-29 01:36:16 +08:00
|
|
|
MOCKABLE_VIRTUAL ~GmmClientContext();
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL MEMORY_OBJECT_CONTROL_STATE cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage);
|
2022-09-21 20:49:45 +08:00
|
|
|
MOCKABLE_VIRTUAL uint32_t cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage, bool compressed, bool cachable);
|
2022-02-15 23:07:01 +08:00
|
|
|
|
2021-06-29 01:36:16 +08:00
|
|
|
MOCKABLE_VIRTUAL GMM_RESOURCE_INFO *createResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams);
|
|
|
|
MOCKABLE_VIRTUAL GMM_RESOURCE_INFO *copyResInfoObject(GMM_RESOURCE_INFO *pSrcRes);
|
|
|
|
MOCKABLE_VIRTUAL void destroyResInfoObject(GMM_RESOURCE_INFO *pResInfo);
|
2023-05-19 00:27:44 +08:00
|
|
|
MOCKABLE_VIRTUAL uint64_t mapGpuVirtualAddress(MapGpuVirtualAddressGmm *pMapGpuVa);
|
|
|
|
MOCKABLE_VIRTUAL uint64_t freeGpuVirtualAddress(FreeGpuVirtualAddressGmm *pFreeGpuVa);
|
2021-06-29 01:36:16 +08:00
|
|
|
GMM_CLIENT_CONTEXT *getHandle() const;
|
|
|
|
template <typename T>
|
2022-11-25 15:53:05 +08:00
|
|
|
static std::unique_ptr<GmmClientContext> create(const RootDeviceEnvironment &rootDeviceEnvironment) {
|
|
|
|
return std::make_unique<T>(rootDeviceEnvironment);
|
2021-06-29 01:36:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL uint8_t getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format);
|
|
|
|
MOCKABLE_VIRTUAL uint8_t getMediaSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format);
|
|
|
|
|
2022-11-25 15:53:05 +08:00
|
|
|
void setHandleAllocator(std::unique_ptr<GmmHandleAllocator> allocator);
|
2021-06-29 01:36:16 +08:00
|
|
|
|
2021-09-08 07:30:06 +08:00
|
|
|
MOCKABLE_VIRTUAL void setGmmDeviceInfo(GMM_DEVICE_INFO *deviceInfo);
|
|
|
|
|
2021-06-29 01:36:16 +08:00
|
|
|
GmmHandleAllocator *getHandleAllocator() {
|
|
|
|
return handleAllocator.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GMM_CLIENT_CONTEXT *clientContext;
|
|
|
|
std::unique_ptr<GmmHandleAllocator> handleAllocator;
|
2018-07-06 15:07:42 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|