From eb435acb2239a1648aae95060c65749e7dca7e95 Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Thu, 7 Nov 2024 15:59:03 +0000 Subject: [PATCH] refactor: reorganize command encode classes 2/n - add new inl files for selected platform families - split image compression methods into correct inl files - remove dedicated compression inl files Signed-off-by: Zbigniew Zdanowicz --- .../source/command_container/CMakeLists.txt | 6 +++ .../command_encoder_pre_xe2_hpg_core.inl | 35 ++++++++++++++++ ...command_encoder_xe2_hpg_core_and_later.inl | 27 ++++++++++++ ...ommand_encoder_xe_hpg_core_and_xe_hpc.inl} | 4 +- .../image_surface_state/CMakeLists.txt | 16 -------- .../compression_params_bdw_and_later.inl | 14 ------- .../compression_params_tgllp_and_later.inl | 41 ------------------- .../gen12lp/command_encoder_gen12lp.cpp | 7 +++- .../command_encoder_xe2_hpg_core.cpp | 25 ----------- .../command_encoder_xe_hpc_core.cpp | 3 +- .../command_encoder_xe_hpg_core.cpp | 3 +- 11 files changed, 78 insertions(+), 103 deletions(-) rename shared/source/command_container/{image_surface_state/compression_params_xehp_and_later.inl => command_encoder_xe_hpg_core_and_xe_hpc.inl} (91%) delete mode 100644 shared/source/command_container/image_surface_state/CMakeLists.txt delete mode 100644 shared/source/command_container/image_surface_state/compression_params_bdw_and_later.inl delete mode 100644 shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl diff --git a/shared/source/command_container/CMakeLists.txt b/shared/source/command_container/CMakeLists.txt index c2324f7e28..ede0f55bb1 100644 --- a/shared/source/command_container/CMakeLists.txt +++ b/shared/source/command_container/CMakeLists.txt @@ -35,6 +35,12 @@ if(SUPPORT_XEHP_AND_LATER) ) endif() +if(SUPPORT_XE_HPG OR SUPPORT_XE_HPC) + list(APPEND NEO_CORE_COMMAND_CONTAINER + ${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_xe_hpg_core_and_xe_hpc.inl + ) +endif() + if(SUPPORT_DG2_AND_LATER) list(APPEND NEO_CORE_COMMAND_CONTAINER ${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_xe_hpg_core_and_later.inl diff --git a/shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl b/shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl index 04c34975e8..cf6561d4ba 100644 --- a/shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl +++ b/shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl @@ -5,6 +5,9 @@ * */ +#include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/release_helper/release_helper.h" + namespace NEO { template size_t EncodeDispatchKernel::getDefaultIOHAlignment() { @@ -27,4 +30,36 @@ void EncodeSurfaceState::disableCompressionFlags(R_SURFACE_STATE *surfac surfaceState->setMemoryCompressionEnable(false); } +template +void EncodeSurfaceState::setAuxParamsForMCSCCS(R_SURFACE_STATE *surfaceState, const ReleaseHelper *releaseHelper) { + if (releaseHelper && releaseHelper->isAuxSurfaceModeOverrideRequired()) + surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); + else + surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_MCS_LCE); +} + +template +void EncodeSurfaceState::setClearColorParams(R_SURFACE_STATE *surfaceState, Gmm *gmm) { + if (gmm->gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor) { + surfaceState->setClearValueAddressEnable(true); + + auto gmmHelper = gmm->getGmmHelper(); + uint64_t clearColorAddress = gmmHelper->decanonize(surfaceState->getSurfaceBaseAddress() + + gmm->gmmResourceInfo->getUnifiedAuxSurfaceOffset(GMM_UNIFIED_AUX_TYPE::GMM_AUX_CC)); + + surfaceState->setClearColorAddress(static_cast(clearColorAddress & 0xFFFFFFFFULL)); + surfaceState->setClearColorAddressHigh(static_cast(clearColorAddress >> 32)); + } +} + +template +void EncodeSurfaceState::setFlagsForMediaCompression(R_SURFACE_STATE *surfaceState, Gmm *gmm) { + if (gmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed) { + surfaceState->setAuxiliarySurfaceMode(Family::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE); + surfaceState->setMemoryCompressionEnable(true); + } else { + surfaceState->setMemoryCompressionEnable(false); + } +} + } // namespace NEO diff --git a/shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl b/shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl index 7a72b405c4..699e74a53e 100644 --- a/shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl +++ b/shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl @@ -5,6 +5,9 @@ * */ +#include "shared/source/gmm_helper/client_context/gmm_client_context.h" +#include "shared/source/gmm_helper/gmm_helper.h" + namespace NEO { template size_t EncodeDispatchKernel::getDefaultIOHAlignment() { @@ -40,4 +43,28 @@ template void EncodeSurfaceState::disableCompressionFlags(R_SURFACE_STATE *surfaceState) { } +template +void EncodeSurfaceState::appendImageCompressionParams(R_SURFACE_STATE *surfaceState, GraphicsAllocation *allocation, + GmmHelper *gmmHelper, bool imageFromBuffer, GMM_YUV_PLANE_ENUM plane) { + if (!allocation->isCompressionEnabled()) { + return; + } + + using COMPRESSION_FORMAT = typename R_SURFACE_STATE::COMPRESSION_FORMAT; + + auto gmmResourceInfo = allocation->getDefaultGmm()->gmmResourceInfo.get(); + + auto compressionFormat = gmmHelper->getClientContext()->getSurfaceStateCompressionFormat(gmmResourceInfo->getResourceFormat()); + + surfaceState->setCompressionFormat(static_cast(compressionFormat)); +} + +template +void EncodeSurfaceState::setClearColorParams(R_SURFACE_STATE *surfaceState, Gmm *gmm) { +} + +template +inline void EncodeSurfaceState::setFlagsForMediaCompression(R_SURFACE_STATE *surfaceState, Gmm *gmm) { +} + } // namespace NEO diff --git a/shared/source/command_container/image_surface_state/compression_params_xehp_and_later.inl b/shared/source/command_container/command_encoder_xe_hpg_core_and_xe_hpc.inl similarity index 91% rename from shared/source/command_container/image_surface_state/compression_params_xehp_and_later.inl rename to shared/source/command_container/command_encoder_xe_hpg_core_and_xe_hpc.inl index c5967295c1..a942f50f25 100644 --- a/shared/source/command_container/image_surface_state/compression_params_xehp_and_later.inl +++ b/shared/source/command_container/command_encoder_xe_hpg_core_and_xe_hpc.inl @@ -1,10 +1,12 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/gmm_helper/client_context/gmm_client_context.h" +#include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/gmm_helper/resource_info.h" namespace NEO { diff --git a/shared/source/command_container/image_surface_state/CMakeLists.txt b/shared/source/command_container/image_surface_state/CMakeLists.txt deleted file mode 100644 index 304cda90b7..0000000000 --- a/shared/source/command_container/image_surface_state/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# -# Copyright (C) 2021 Intel Corporation -# -# SPDX-License-Identifier: MIT -# - -set(NEO_CORE_COMMAND_CONTAINER_IMAGE_SURFACE_STATE - ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/compression_params_bdw_and_later.inl - ${CMAKE_CURRENT_SOURCE_DIR}/compression_params_tgllp_and_later.inl - ${CMAKE_CURRENT_SOURCE_DIR}/compression_params_xehp_and_later.inl -) - -set_property(GLOBAL APPEND PROPERTY NEO_CORE_COMMAND_CONTAINER ${NEO_CORE_COMMAND_CONTAINER_IMAGE_SURFACE_STATE}) - -add_subdirectories() diff --git a/shared/source/command_container/image_surface_state/compression_params_bdw_and_later.inl b/shared/source/command_container/image_surface_state/compression_params_bdw_and_later.inl deleted file mode 100644 index dac2483091..0000000000 --- a/shared/source/command_container/image_surface_state/compression_params_bdw_and_later.inl +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (C) 2021-2022 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -namespace NEO { -template -void EncodeSurfaceState::appendImageCompressionParams(R_SURFACE_STATE *surfaceState, GraphicsAllocation *allocation, - GmmHelper *gmmHelper, bool imageFromBuffer, GMM_YUV_PLANE_ENUM plane) { -} - -} // namespace NEO diff --git a/shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl b/shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl deleted file mode 100644 index d1b3f13ff9..0000000000 --- a/shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2021-2023 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -namespace NEO { -template -void EncodeSurfaceState::setAuxParamsForMCSCCS(R_SURFACE_STATE *surfaceState, const ReleaseHelper *releaseHelper) { - if (releaseHelper && releaseHelper->isAuxSurfaceModeOverrideRequired()) - surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); - else - surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_MCS_LCE); -} - -template -void EncodeSurfaceState::setClearColorParams(R_SURFACE_STATE *surfaceState, Gmm *gmm) { - if (gmm->gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor) { - surfaceState->setClearValueAddressEnable(true); - - auto gmmHelper = gmm->getGmmHelper(); - uint64_t clearColorAddress = gmmHelper->decanonize(surfaceState->getSurfaceBaseAddress() + - gmm->gmmResourceInfo->getUnifiedAuxSurfaceOffset(GMM_UNIFIED_AUX_TYPE::GMM_AUX_CC)); - - surfaceState->setClearColorAddress(static_cast(clearColorAddress & 0xFFFFFFFFULL)); - surfaceState->setClearColorAddressHigh(static_cast(clearColorAddress >> 32)); - } -} - -template -void EncodeSurfaceState::setFlagsForMediaCompression(R_SURFACE_STATE *surfaceState, Gmm *gmm) { - if (gmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed) { - surfaceState->setAuxiliarySurfaceMode(Family::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE); - surfaceState->setMemoryCompressionEnable(true); - } else { - surfaceState->setMemoryCompressionEnable(false); - } -} - -} // namespace NEO diff --git a/shared/source/gen12lp/command_encoder_gen12lp.cpp b/shared/source/gen12lp/command_encoder_gen12lp.cpp index b32cdfb965..46cefb3c38 100644 --- a/shared/source/gen12lp/command_encoder_gen12lp.cpp +++ b/shared/source/gen12lp/command_encoder_gen12lp.cpp @@ -23,8 +23,6 @@ using Family = NEO::Gen12LpFamily; #include "shared/source/command_container/command_encoder_heap_addressing.inl" -#include "shared/source/command_container/image_surface_state/compression_params_bdw_and_later.inl" -#include "shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl" #include "shared/source/command_stream/command_stream_receiver.h" namespace NEO { @@ -113,6 +111,11 @@ void EncodeComputeMode::adjustPipelineSelect(CommandContainer &container container.getDevice()->getRootDeviceEnvironment()); } +template <> +void EncodeSurfaceState::appendImageCompressionParams(R_SURFACE_STATE *surfaceState, GraphicsAllocation *allocation, + GmmHelper *gmmHelper, bool imageFromBuffer, GMM_YUV_PLANE_ENUM plane) { +} + } // namespace NEO #include "shared/source/command_container/command_encoder_enablers.inl" diff --git a/shared/source/xe2_hpg_core/command_encoder_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/command_encoder_xe2_hpg_core.cpp index 6cb4af8dd1..3229fa1259 100644 --- a/shared/source/xe2_hpg_core/command_encoder_xe2_hpg_core.cpp +++ b/shared/source/xe2_hpg_core/command_encoder_xe2_hpg_core.cpp @@ -23,7 +23,6 @@ using Family = NEO::Xe2HpgCoreFamily; #include "shared/source/command_container/command_encoder_xe_hpc_core_and_later.inl" #include "shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl" -#include "shared/source/command_container/image_surface_state/compression_params_xehp_and_later.inl" namespace NEO { @@ -195,36 +194,12 @@ bool EncodeSurfaceState::isAuxModeEnabled(R_SURFACE_STATE *surfaceState, return gmm && gmm->isCompressionEnabled(); } -template <> -void EncodeSurfaceState::appendImageCompressionParams(R_SURFACE_STATE *surfaceState, GraphicsAllocation *allocation, - GmmHelper *gmmHelper, bool imageFromBuffer, GMM_YUV_PLANE_ENUM plane) { - if (!allocation->isCompressionEnabled()) { - return; - } - - using COMPRESSION_FORMAT = typename R_SURFACE_STATE::COMPRESSION_FORMAT; - - auto gmmResourceInfo = allocation->getDefaultGmm()->gmmResourceInfo.get(); - - auto compressionFormat = gmmHelper->getClientContext()->getSurfaceStateCompressionFormat(gmmResourceInfo->getResourceFormat()); - - surfaceState->setCompressionFormat(static_cast(compressionFormat)); -} - template <> void EncodeSurfaceState::setAuxParamsForMCSCCS(R_SURFACE_STATE *surfaceState, const ReleaseHelper *releaseHelper) { if (releaseHelper && releaseHelper->isAuxSurfaceModeOverrideRequired()) surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_MCS); } -template <> -void EncodeSurfaceState::setClearColorParams(R_SURFACE_STATE *surfaceState, Gmm *gmm) { -} - -template <> -inline void EncodeSurfaceState::setFlagsForMediaCompression(R_SURFACE_STATE *surfaceState, Gmm *gmm) { -} - template <> template void EncodeDispatchKernel::setGrfInfo(InterfaceDescriptorType *pInterfaceDescriptor, uint32_t grfCount, diff --git a/shared/source/xe_hpc_core/command_encoder_xe_hpc_core.cpp b/shared/source/xe_hpc_core/command_encoder_xe_hpc_core.cpp index d3b4cdcb51..1c43d697ef 100644 --- a/shared/source/xe_hpc_core/command_encoder_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/command_encoder_xe_hpc_core.cpp @@ -10,6 +10,7 @@ #include "shared/source/command_container/command_encoder_from_gen12lp_to_xe2_hpg.inl" #include "shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl" #include "shared/source/command_container/command_encoder_tgllp_and_later.inl" +#include "shared/source/command_container/command_encoder_xe_hpg_core_and_xe_hpc.inl" #include "shared/source/command_container/command_encoder_xehp_and_later.inl" #include "shared/source/command_stream/stream_properties.h" #include "shared/source/helpers/constants.h" @@ -23,8 +24,6 @@ using Family = NEO::XeHpcCoreFamily; #include "shared/source/command_container/command_encoder_heap_addressing.inl" #include "shared/source/command_container/command_encoder_xe_hpc_core_and_later.inl" #include "shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl" -#include "shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl" -#include "shared/source/command_container/image_surface_state/compression_params_xehp_and_later.inl" namespace NEO { diff --git a/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp b/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp index f65f8727e4..cfb8c43521 100644 --- a/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp @@ -10,6 +10,7 @@ #include "shared/source/command_container/command_encoder_from_gen12lp_to_xe2_hpg.inl" #include "shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl" #include "shared/source/command_container/command_encoder_tgllp_and_later.inl" +#include "shared/source/command_container/command_encoder_xe_hpg_core_and_xe_hpc.inl" #include "shared/source/command_container/command_encoder_xehp_and_later.inl" #include "shared/source/command_stream/stream_properties.h" #include "shared/source/helpers/cache_flush_xehp_and_later.inl" @@ -22,8 +23,6 @@ using Family = NEO::XeHpgCoreFamily; #include "shared/source/command_container/command_encoder_heap_addressing.inl" #include "shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl" -#include "shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl" -#include "shared/source/command_container/image_surface_state/compression_params_xehp_and_later.inl" namespace NEO {