From 5ef1ff574b33d03255f14894a6acbd7b3e4276b5 Mon Sep 17 00:00:00 2001 From: Maciej Plewka Date: Fri, 7 Feb 2025 14:52:21 +0000 Subject: [PATCH] fix: Don't check aux capable in case of MSAA surface on xe2 and later Related-To: NEO-13290 Signed-off-by: Maciej Plewka --- opencl/source/mem_obj/image.inl | 2 +- .../mem_obj/image_tests_xehp_and_later.cpp | 32 ++++++++++++++++++- .../command_encoder_pre_xe2_hpg_core.inl | 5 +++ ...command_encoder_xe2_hpg_core_and_later.inl | 5 +++ .../command_container/encode_surface_state.h | 3 +- 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/opencl/source/mem_obj/image.inl b/opencl/source/mem_obj/image.inl index c2bf104df3..659c276689 100644 --- a/opencl/source/mem_obj/image.inl +++ b/opencl/source/mem_obj/image.inl @@ -113,7 +113,7 @@ void ImageHw::setAuxParamsForMultisamples(RENDER_SURFACE_STATE *surfa if (getMcsAllocation()) { auto mcsGmm = getMcsAllocation()->getDefaultGmm(); - if (mcsGmm->unifiedAuxTranslationCapable() && mcsGmm->hasMultisampleControlSurface()) { + if (EncodeSurfaceState::shouldProgramAuxForMcs(mcsGmm->unifiedAuxTranslationCapable(), mcsGmm->hasMultisampleControlSurface())) { auto *releaseHelper = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getReleaseHelper(); DEBUG_BREAK_IF(releaseHelper == nullptr); EncodeSurfaceState::setAuxParamsForMCSCCS(surfaceState, releaseHelper); diff --git a/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp b/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp index 306e294774..2fdd8b6370 100644 --- a/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2024 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -462,3 +462,33 @@ HWTEST2_F(XeHPAndLaterImageHelperTests, givenAuxModeMcsLceWhenAppendingSurfaceSt EXPECT_EQ(expectedGetSurfaceStateCompressionFormatCalled, gmmClientContext->getSurfaceStateCompressionFormatCalled); EXPECT_EQ(expectedGetMediaSurfaceStateCompressionFormatCalled, gmmClientContext->getMediaSurfaceStateCompressionFormatCalled); } + +HWTEST2_F(XeHPAndLaterImageTests, givenMcsAllocationWhenAuxCapableIsNotSetThenProgramAuxBaseAddressAnyway, IsAtLeastBmg) { + MockContext context; + McsSurfaceInfo msi = {10, 20, 3}; + auto mcsAlloc = context.getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{context.getDevice(0)->getRootDeviceIndex(), MemoryConstants::pageSize}); + + cl_image_desc imgDesc = Image2dDefaults::imageDesc; + imgDesc.num_samples = 8; + std::unique_ptr image(Image2dHelper<>::create(&context, &imgDesc)); + + auto pClDevice = context.getDevice(0); + + auto surfaceState = FamilyType::cmdInitRenderSurfaceState; + auto imageHw = static_cast *>(image.get()); + GmmRequirements gmmRequirements{}; + gmmRequirements.allowLargePages = true; + gmmRequirements.preferCompressed = false; + mcsAlloc->setDefaultGmm(new Gmm(pClDevice->getRootDeviceEnvironment().getGmmHelper(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements)); + surfaceState.setSurfaceBaseAddress(0xABCDEF1000); + imageHw->setMcsSurfaceInfo(msi); + imageHw->setMcsAllocation(mcsAlloc); + auto mockResource = static_cast(mcsAlloc->getDefaultGmm()->gmmResourceInfo.get()); + mockResource->setMultisampleControlSurface(); + + EXPECT_EQ(0u, surfaceState.getAuxiliarySurfaceBaseAddress()); + + imageHw->setAuxParamsForMultisamples(&surfaceState, pClDevice->getRootDeviceIndex()); + + EXPECT_NE(0u, surfaceState.getAuxiliarySurfaceBaseAddress()); +} 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 1c41d792d4..fe1c497cd3 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 @@ -92,4 +92,9 @@ bool EncodeSurfaceState::isAuxModeEnabled(R_SURFACE_STATE *surfaceState, template void EncodeEnableRayTracing::append3dStateBtd(void *ptr3dStateBtd) {} +template +bool EncodeSurfaceState::shouldProgramAuxForMcs(bool isAuxCapable, bool hasMcsSurface) { + return isAuxCapable && hasMcsSurface; +} + } // 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 43b635dbea..1368015c35 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 @@ -128,4 +128,9 @@ inline void EncodeMiFlushDW::adjust(MI_FLUSH_DW *miFlushDwCmd, const Pro } } +template +bool EncodeSurfaceState::shouldProgramAuxForMcs(bool isAuxCapable, bool hasMcsSurface) { + return hasMcsSurface; +} + } // namespace NEO diff --git a/shared/source/command_container/encode_surface_state.h b/shared/source/command_container/encode_surface_state.h index fae692921a..1df850a73f 100644 --- a/shared/source/command_container/encode_surface_state.h +++ b/shared/source/command_container/encode_surface_state.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Intel Corporation + * Copyright (C) 2023-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -71,6 +71,7 @@ struct EncodeSurfaceState { static void appendParamsForImageFromBuffer(R_SURFACE_STATE *surfaceState); static void setPitchForScratch(R_SURFACE_STATE *surfaceState, uint32_t pitch, const ProductHelper &productHelper); static uint32_t getPitchForScratchInBytes(R_SURFACE_STATE *surfaceState, const ProductHelper &productHelper); + static bool shouldProgramAuxForMcs(bool isAuxCapable, bool hasMcsSurface); }; } // namespace NEO