Debian Codegraph @

shared/source/gmm_helper/client_context/gmm_client_context.cpp

raw
1 /*
2 * Copyright (C) 2018-2024 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "shared/source/gmm_helper/client_context/gmm_client_context.h"
9
10 #include "shared/source/debug_settings/debug_settings_manager.h"
11 #include "shared/source/execution_environment/root_device_environment.h"
12 #include "shared/source/gmm_helper/client_context/gmm_handle_allocator.h"
13 #include "shared/source/gmm_helper/gmm_interface.h"
14 #include "shared/source/helpers/debug_helpers.h"
15 #include "shared/source/helpers/hw_info.h"
16 #include "shared/source/os_interface/os_interface.h"
17 #include "shared/source/sku_info/operations/sku_info_transfer.h"
18
19 namespace NEO {
20 GmmClientContext::GmmClientContext(const RootDeviceEnvironment &rootDeviceEnvironment) {
21 auto hardwareInfo = rootDeviceEnvironment.getHardwareInfo();
22 _SKU_FEATURE_TABLE gmmFtrTable = {};
23 _WA_TABLE gmmWaTable = {};
24 SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, &hardwareInfo->featureTable);
25 SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, &hardwareInfo->workaroundTable);
26
27 GMM_INIT_IN_ARGS inArgs{};
28 GMM_INIT_OUT_ARGS outArgs{};
29
30 const auto &gtSystemInfo = hardwareInfo->gtSystemInfo;
31 inArgs.ClientType = GMM_CLIENT::GMM_OCL_VISTA;
32 inArgs.pGtSysInfo = const_cast<GT_SYSTEM_INFO *>(&gtSystemInfo);
33 inArgs.pSkuTable = &gmmFtrTable;
34 inArgs.pWaTable = &gmmWaTable;
35 inArgs.Platform = hardwareInfo->platform;
36
37 auto osInterface = rootDeviceEnvironment.osInterface.get();
38 if (osInterface && osInterface->getDriverModel()) {
39 osInterface->getDriverModel()->setGmmInputArgs(&inArgs);
40 }
41 if (debugManager.flags.EnableFtrTile64Optimization.get() != -1) {
42 reinterpret_cast<_SKU_FEATURE_TABLE *>(inArgs.pSkuTable)->FtrTile64Optimization = debugManager.flags.EnableFtrTile64Optimization.get();
43 }
44
45 auto ret = GmmInterface::initialize(&inArgs, &outArgs);
46
47 UNRECOVERABLE_IF(ret != GMM_SUCCESS);
48
49 clientContext = outArgs.pGmmClientContext;
50 }
51 GmmClientContext::~GmmClientContext() {
52 GMM_INIT_OUT_ARGS outArgs;
53 outArgs.pGmmClientContext = clientContext;
54
55 GmmInterface::destroy(&outArgs);
56 };
57
58 MEMORY_OBJECT_CONTROL_STATE GmmClientContext::cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage) {
59 return clientContext->CachePolicyGetMemoryObject(pResInfo, usage);
60 }
61
62 GMM_RESOURCE_INFO *GmmClientContext::createResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams) {
63 return clientContext->CreateResInfoObject(pCreateParams);
64 }
65
66 GMM_RESOURCE_INFO *GmmClientContext::copyResInfoObject(GMM_RESOURCE_INFO *pSrcRes) {
67 return clientContext->CopyResInfoObject(pSrcRes);
68 }
69
70 void GmmClientContext::destroyResInfoObject(GMM_RESOURCE_INFO *pResInfo) {
71 clientContext->DestroyResInfoObject(pResInfo);
72 }
73
74 GMM_CLIENT_CONTEXT *GmmClientContext::getHandle() const {
75 return clientContext;
76 }
77
78 uint8_t GmmClientContext::getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format) {
79 return clientContext->GetSurfaceStateCompressionFormat(format);
80 }
81
82 uint8_t GmmClientContext::getMediaSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format) {
83 return clientContext->GetMediaSurfaceStateCompressionFormat(format);
84 }
85
86 void GmmClientContext::setGmmDeviceInfo(GMM_DEVICE_INFO *deviceInfo) {
87 clientContext->GmmSetDeviceInfo(deviceInfo);
88 }
89
90 uint32_t GmmClientContext::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage, bool compressed, bool cachable) {
91 bool outValue = compressed;
92 uint32_t patIndex = clientContext->CachePolicyGetPATIndex(gmmResourceInfo, usage, &outValue, cachable);
93
94 DEBUG_BREAK_IF(outValue != compressed);
95
96 return patIndex;
97 }
98 void GmmClientContext::setHandleAllocator(std::unique_ptr<GmmHandleAllocator> allocator) {
99 this->handleAllocator = std::move(allocator);
100 }
101
102 } // namespace NEO