From cf4e6858facb8ca040f467dc3a89e7fd14c3b2a1 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Fri, 24 Oct 2025 10:42:02 +0000 Subject: [PATCH] refactor: move gmm client context initialization to separate file Related-To: NEO-11080 Signed-off-by: Mateusz Jablonski --- .../gmm_helper/client_context/CMakeLists.txt | 3 +- .../client_context/gmm_client_context.cpp | 43 -------------- .../gmm_client_context_base.cpp | 56 +++++++++++++++++++ .../gmm_helper/client_context/CMakeLists.txt | 2 +- 4 files changed, 59 insertions(+), 45 deletions(-) create mode 100644 shared/source/gmm_helper/client_context/gmm_client_context_base.cpp diff --git a/shared/source/gmm_helper/client_context/CMakeLists.txt b/shared/source/gmm_helper/client_context/CMakeLists.txt index bef1815e93..c507a4d1ba 100644 --- a/shared/source/gmm_helper/client_context/CMakeLists.txt +++ b/shared/source/gmm_helper/client_context/CMakeLists.txt @@ -6,7 +6,8 @@ set(NEO_CORE_GMM_HELPER_CLIENT_CONTEXT ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/gmm_client_context.cpp + ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}gmm_client_context.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gmm_client_context_base.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gmm_client_context_${DRIVER_MODEL}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gmm_client_context.h ${CMAKE_CURRENT_SOURCE_DIR}/map_gpu_va_gmm.h diff --git a/shared/source/gmm_helper/client_context/gmm_client_context.cpp b/shared/source/gmm_helper/client_context/gmm_client_context.cpp index 22e1a57a9d..42c46ef15b 100644 --- a/shared/source/gmm_helper/client_context/gmm_client_context.cpp +++ b/shared/source/gmm_helper/client_context/gmm_client_context.cpp @@ -9,7 +9,6 @@ #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/execution_environment/root_device_environment.h" -#include "shared/source/gmm_helper/client_context/gmm_handle_allocator.h" #include "shared/source/gmm_helper/gmm_interface.h" #include "shared/source/helpers/debug_helpers.h" #include "shared/source/helpers/hw_info.h" @@ -17,8 +16,6 @@ #include "shared/source/sku_info/operations/sku_info_transfer.h" namespace NEO { -GmmClientContext::GmmClientContext() = default; -GmmClientContext::~GmmClientContext() = default; void GmmClientContext::initialize(const RootDeviceEnvironment &rootDeviceEnvironment) { auto hardwareInfo = rootDeviceEnvironment.getHardwareInfo(); @@ -57,44 +54,4 @@ void GmmClientContext::initialize(const RootDeviceEnvironment &rootDeviceEnviron clientContext = {outArgs.pGmmClientContext, deleter}; } -MEMORY_OBJECT_CONTROL_STATE GmmClientContext::cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage) { - return clientContext->CachePolicyGetMemoryObject(pResInfo, usage); -} - -GMM_RESOURCE_INFO *GmmClientContext::createResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams) { - return clientContext->CreateResInfoObject(pCreateParams); -} - -GMM_RESOURCE_INFO *GmmClientContext::copyResInfoObject(GMM_RESOURCE_INFO *pSrcRes) { - return clientContext->CopyResInfoObject(pSrcRes); -} - -void GmmClientContext::destroyResInfoObject(GMM_RESOURCE_INFO *pResInfo) { - clientContext->DestroyResInfoObject(pResInfo); -} - -GMM_CLIENT_CONTEXT *GmmClientContext::getHandle() const { - return clientContext.get(); -} - -uint8_t GmmClientContext::getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format) { - return clientContext->GetSurfaceStateCompressionFormat(format); -} - -uint8_t GmmClientContext::getMediaSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format) { - return clientContext->GetMediaSurfaceStateCompressionFormat(format); -} - -uint32_t GmmClientContext::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage, bool compressed, bool cacheable) { - bool outValue = compressed; - uint32_t patIndex = clientContext->CachePolicyGetPATIndex(gmmResourceInfo, usage, &outValue, cacheable); - - DEBUG_BREAK_IF(outValue != compressed); - - return patIndex; -} -void GmmClientContext::setHandleAllocator(std::unique_ptr allocator) { - this->handleAllocator = std::move(allocator); -} - } // namespace NEO diff --git a/shared/source/gmm_helper/client_context/gmm_client_context_base.cpp b/shared/source/gmm_helper/client_context/gmm_client_context_base.cpp new file mode 100644 index 0000000000..4d33933f69 --- /dev/null +++ b/shared/source/gmm_helper/client_context/gmm_client_context_base.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/gmm_helper/client_context/gmm_client_context.h" +#include "shared/source/gmm_helper/client_context/gmm_handle_allocator.h" +#include "shared/source/helpers/debug_helpers.h" + +namespace NEO { +GmmClientContext::GmmClientContext() = default; +GmmClientContext::~GmmClientContext() = default; + +MEMORY_OBJECT_CONTROL_STATE GmmClientContext::cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage) { + return clientContext->CachePolicyGetMemoryObject(pResInfo, usage); +} + +GMM_RESOURCE_INFO *GmmClientContext::createResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams) { + return clientContext->CreateResInfoObject(pCreateParams); +} + +GMM_RESOURCE_INFO *GmmClientContext::copyResInfoObject(GMM_RESOURCE_INFO *pSrcRes) { + return clientContext->CopyResInfoObject(pSrcRes); +} + +void GmmClientContext::destroyResInfoObject(GMM_RESOURCE_INFO *pResInfo) { + clientContext->DestroyResInfoObject(pResInfo); +} + +GMM_CLIENT_CONTEXT *GmmClientContext::getHandle() const { + return clientContext.get(); +} + +uint8_t GmmClientContext::getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format) { + return clientContext->GetSurfaceStateCompressionFormat(format); +} + +uint8_t GmmClientContext::getMediaSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format) { + return clientContext->GetMediaSurfaceStateCompressionFormat(format); +} + +uint32_t GmmClientContext::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage, bool compressed, bool cacheable) { + bool outValue = compressed; + uint32_t patIndex = clientContext->CachePolicyGetPATIndex(gmmResourceInfo, usage, &outValue, cacheable); + + DEBUG_BREAK_IF(outValue != compressed); + + return patIndex; +} +void GmmClientContext::setHandleAllocator(std::unique_ptr allocator) { + this->handleAllocator = std::move(allocator); +} + +} // namespace NEO diff --git a/shared/test/unit_test/gmm_helper/client_context/CMakeLists.txt b/shared/test/unit_test/gmm_helper/client_context/CMakeLists.txt index 6162870679..04070997ff 100644 --- a/shared/test/unit_test/gmm_helper/client_context/CMakeLists.txt +++ b/shared/test/unit_test/gmm_helper/client_context/CMakeLists.txt @@ -6,7 +6,7 @@ target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/gmm_client_context_initialize_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}gmm_client_context_initialize_tests.cpp ) add_subdirectories()