Debian Codegraph @

shared/source/gmm_helper/client_context/gmm_client_context.h

raw
1 /*
2 * Copyright (C) 2018-2023 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #pragma once
9 #include "shared/source/gmm_helper/gmm_lib.h"
10
11 #include <memory>
12
13 namespace NEO {
14 class GmmClientContext;
15 struct RootDeviceEnvironment;
16 class GmmHandleAllocator;
17 class MapGpuVirtualAddressGmm;
18 class FreeGpuVirtualAddressGmm;
19
20 class GmmClientContext {
21 public:
22 GmmClientContext(const RootDeviceEnvironment &rootDeviceEnvironment);
23 MOCKABLE_VIRTUAL ~GmmClientContext();
24
25 MOCKABLE_VIRTUAL MEMORY_OBJECT_CONTROL_STATE cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage);
26 MOCKABLE_VIRTUAL uint32_t cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage, bool compressed, bool cachable);
27
28 MOCKABLE_VIRTUAL GMM_RESOURCE_INFO *createResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams);
29 MOCKABLE_VIRTUAL GMM_RESOURCE_INFO *copyResInfoObject(GMM_RESOURCE_INFO *pSrcRes);
30 MOCKABLE_VIRTUAL void destroyResInfoObject(GMM_RESOURCE_INFO *pResInfo);
31 MOCKABLE_VIRTUAL uint64_t mapGpuVirtualAddress(MapGpuVirtualAddressGmm *pMapGpuVa);
32 MOCKABLE_VIRTUAL uint64_t freeGpuVirtualAddress(FreeGpuVirtualAddressGmm *pFreeGpuVa);
33 GMM_CLIENT_CONTEXT *getHandle() const;
34 template <typename T>
35 static std::unique_ptr<GmmClientContext> create(const RootDeviceEnvironment &rootDeviceEnvironment) {
36 return std::make_unique<T>(rootDeviceEnvironment);
37 }
38
39 MOCKABLE_VIRTUAL uint8_t getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format);
40 MOCKABLE_VIRTUAL uint8_t getMediaSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format);
41
42 void setHandleAllocator(std::unique_ptr<GmmHandleAllocator> allocator);
43
44 MOCKABLE_VIRTUAL void setGmmDeviceInfo(GMM_DEVICE_INFO *deviceInfo);
45
46 GmmHandleAllocator *getHandleAllocator() {
47 return handleAllocator.get();
48 }
49
50 protected:
51 GMM_CLIENT_CONTEXT *clientContext;
52 std::unique_ptr<GmmHandleAllocator> handleAllocator;
53 };
54 } // namespace NEO