diff --git a/opencl/source/mem_obj/image.cpp b/opencl/source/mem_obj/image.cpp index f16d224663..d194479966 100644 --- a/opencl/source/mem_obj/image.cpp +++ b/opencl/source/mem_obj/image.cpp @@ -389,7 +389,7 @@ Image *Image::createImageHw(Context *context, const MemoryProperties &memoryProp Image *Image::createSharedImage(Context *context, SharingHandler *sharingHandler, const McsSurfaceInfo &mcsSurfaceInfo, MultiGraphicsAllocation multiGraphicsAllocation, GraphicsAllocation *mcsAllocation, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const ClSurfaceFormatInfo *surfaceFormat, - ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount) { + ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount, bool hasUnifiedMcsSurface) { auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex(); auto size = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex)->getUnderlyingBufferSize(); auto sharedImage = createImageHw( @@ -407,6 +407,7 @@ Image *Image::createSharedImage(Context *context, SharingHandler *sharingHandler sharedImage->setMcsSurfaceInfo(mcsSurfaceInfo); sharedImage->setPlane(imgInfo.plane); sharedImage->setIsDisplayable(imgInfo.isDisplayable); + sharedImage->setIsUnifiedMcsSurface(hasUnifiedMcsSurface); return sharedImage; } diff --git a/opencl/source/mem_obj/image.h b/opencl/source/mem_obj/image.h index bcdde6fdfa..cfcb428b2a 100644 --- a/opencl/source/mem_obj/image.h +++ b/opencl/source/mem_obj/image.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -87,7 +87,7 @@ class Image : public MemObj { static Image *createSharedImage(Context *context, SharingHandler *sharingHandler, const McsSurfaceInfo &mcsSurfaceInfo, MultiGraphicsAllocation multiGraphicsAllocation, GraphicsAllocation *mcsAllocation, - cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const ClSurfaceFormatInfo *surfaceFormat, ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount); + cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const ClSurfaceFormatInfo *surfaceFormat, ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount, bool hasUnifiedMcsSurface); static cl_int validate(Context *context, const MemoryProperties &memoryProperties, diff --git a/opencl/source/mem_obj/image_xe2_and_later.inl b/opencl/source/mem_obj/image_xe2_and_later.inl index eccfb3ba62..823746226b 100644 --- a/opencl/source/mem_obj/image_xe2_and_later.inl +++ b/opencl/source/mem_obj/image_xe2_and_later.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,4 +15,22 @@ void ImageHw::adjustDepthLimitations(RENDER_SURFACE_STATE *surfaceState, surfaceState->setDepth(newDepth); } } + +template <> +void ImageHw::setAuxParamsForMultisamples(RENDER_SURFACE_STATE *surfaceState, uint32_t rootDeviceIndex) { + using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT; + if (getMcsAllocation() || getIsUnifiedMcsSurface()) { + auto mcsGmm = getMcsAllocation() ? getMcsAllocation()->getDefaultGmm() : getMultiGraphicsAllocation().getDefaultGraphicsAllocation()->getDefaultGmm(); + auto *releaseHelper = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getReleaseHelper(); + DEBUG_BREAK_IF(releaseHelper == nullptr); + EncodeSurfaceState::setAuxParamsForMCSCCS(surfaceState, releaseHelper); + surfaceState->setAuxiliarySurfacePitch(mcsGmm->getUnifiedAuxPitchTiles()); + surfaceState->setAuxiliarySurfaceQPitch(mcsGmm->getAuxQPitch()); + EncodeSurfaceState::setClearColorParams(surfaceState, mcsGmm); + ImageSurfaceStateHelper::setUnifiedAuxBaseAddress(surfaceState, mcsGmm); + } else if (isDepthFormat(imageFormat) && surfaceState->getSurfaceFormat() != SURFACE_FORMAT::SURFACE_FORMAT_R32_FLOAT_X8X24_TYPELESS) { + surfaceState->setMultisampledSurfaceStorageFormat(RENDER_SURFACE_STATE::MULTISAMPLED_SURFACE_STORAGE_FORMAT::MULTISAMPLED_SURFACE_STORAGE_FORMAT_DEPTH_STENCIL); + } +} + } // namespace NEO \ No newline at end of file diff --git a/opencl/source/mem_obj/mem_obj.h b/opencl/source/mem_obj/mem_obj.h index 852d6ce8d6..1a12219fa9 100644 --- a/opencl/source/mem_obj/mem_obj.h +++ b/opencl/source/mem_obj/mem_obj.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -167,6 +167,12 @@ class MemObj : public BaseObject<_cl_mem> { void setSizeInPoolAllocator(size_t size) { this->sizeInPoolAllocator = size; } + bool getIsUnifiedMcsSurface() { + return isMcsSurfaceUnified; + } + void setIsUnifiedMcsSurface(bool isMcsSurfaceUnified) { + this->isMcsSurfaceUnified = isMcsSurfaceUnified; + } protected: void getOsSpecificMemObjectInfo(const cl_mem_info ¶mName, size_t *srcParamSize, void **srcParam); @@ -192,6 +198,7 @@ class MemObj : public BaseObject<_cl_mem> { bool isHostPtrSVM; bool isObjectRedescribed; bool isDisplayable{false}; + bool isMcsSurfaceUnified = false; MemoryManager *memoryManager = nullptr; MultiGraphicsAllocation multiGraphicsAllocation; GraphicsAllocation *mcsAllocation = nullptr; diff --git a/opencl/source/sharings/d3d/d3d_surface.cpp b/opencl/source/sharings/d3d/d3d_surface.cpp index 4b684d885e..f63eb800f9 100644 --- a/opencl/source/sharings/d3d/d3d_surface.cpp +++ b/opencl/source/sharings/d3d/d3d_surface.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -122,7 +122,7 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex); multiGraphicsAllocation.addAllocation(alloc); - return Image::createSharedImage(context, surface, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0); + return Image::createSharedImage(context, surface, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0, false); } void D3DSurface::synchronizeObject(UpdateData &updateData) { diff --git a/opencl/source/sharings/d3d/d3d_texture.cpp b/opencl/source/sharings/d3d/d3d_texture.cpp index 8b5fc6a446..9f917abb9f 100644 --- a/opencl/source/sharings/d3d/d3d_texture.cpp +++ b/opencl/source/sharings/d3d/d3d_texture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -119,7 +119,7 @@ Image *D3DTexture::create2d(Context *context, D3DTexture2d *d3dTexture, cl_ auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex); multiGraphicsAllocation.addAllocation(alloc); - return Image::createSharedImage(context, d3dTextureObj, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0); + return Image::createSharedImage(context, d3dTextureObj, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0, false); } template @@ -204,7 +204,7 @@ Image *D3DTexture::create3d(Context *context, D3DTexture3d *d3dTexture, cl_ auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex); multiGraphicsAllocation.addAllocation(alloc); - auto image = Image::createSharedImage(context, d3dTextureObj, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0); + auto image = Image::createSharedImage(context, d3dTextureObj, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, 0, 0, false); image->setAs3DUavOrRtvImage(is3DUavOrRtv); return image; } diff --git a/opencl/source/sharings/gl/linux/gl_texture_linux.cpp b/opencl/source/sharings/gl/linux/gl_texture_linux.cpp index 1743262d46..47f3ae0a54 100644 --- a/opencl/source/sharings/gl/linux/gl_texture_linux.cpp +++ b/opencl/source/sharings/gl/linux/gl_texture_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Intel Corporation + * Copyright (C) 2023-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -245,7 +245,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl multiGraphicsAllocation.addAllocation(alloc); return Image::createSharedImage(context, glTexture, mcsSurfaceInfo, std::move(multiGraphicsAllocation), mcsAlloc, flags, 0, &surfaceFormatInfo, imgInfo, cubeFaceIndex, - std::max(miplevel, 0), imgInfo.imgDesc.numMipLevels); + std::max(miplevel, 0), imgInfo.imgDesc.numMipLevels, false); } void GlTexture::synchronizeObject(UpdateData &updateData) { diff --git a/opencl/source/sharings/gl/windows/gl_texture_windows.cpp b/opencl/source/sharings/gl/windows/gl_texture_windows.cpp index 9d3f4648ae..0b46fcd51f 100644 --- a/opencl/source/sharings/gl/windows/gl_texture_windows.cpp +++ b/opencl/source/sharings/gl/windows/gl_texture_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -125,6 +125,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl if (texInfo.glInternalFormat != GL_RGB10) { surfaceFormatInfo.surfaceFormat.genxSurfaceFormat = (SurfaceFormat)texInfo.glHWFormat; } + bool hasUnifiedMcsSurface = texInfo.numberOfSamples > 1 && texInfo.globalShareHandleMCS == NULL && gmm->hasMultisampleControlSurface(); GraphicsAllocation *mcsAlloc = nullptr; if (texInfo.globalShareHandleMCS) { @@ -137,6 +138,9 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl } mcsSurfaceInfo.pitch = getValidParam(static_cast(mcsAlloc->getDefaultGmm()->gmmResourceInfo->getRenderPitch() / 128)); mcsSurfaceInfo.qPitch = mcsAlloc->getDefaultGmm()->gmmResourceInfo->getQPitch(); + } else if (hasUnifiedMcsSurface) { + mcsSurfaceInfo.pitch = getValidParam(static_cast(gmm->gmmResourceInfo->getRenderPitch() / 128)); + mcsSurfaceInfo.qPitch = gmm->gmmResourceInfo->getQPitch(); } mcsSurfaceInfo.multisampleCount = GmmTypesConverter::getRenderMultisamplesCount(static_cast(imgDesc.num_samples)); @@ -162,7 +166,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl multiGraphicsAllocation.addAllocation(alloc); return Image::createSharedImage(context, glTexture, mcsSurfaceInfo, std::move(multiGraphicsAllocation), mcsAlloc, flags, 0, &surfaceFormatInfo, imgInfo, cubeFaceIndex, - std::max(miplevel, 0), imgInfo.imgDesc.numMipLevels); + std::max(miplevel, 0), imgInfo.imgDesc.numMipLevels, hasUnifiedMcsSurface); } // namespace NEO void GlTexture::synchronizeObject(UpdateData &updateData) { diff --git a/opencl/source/sharings/unified/unified_image.cpp b/opencl/source/sharings/unified/unified_image.cpp index 58e16ef0cd..43f1f1cdc4 100644 --- a/opencl/source/sharings/unified/unified_image.cpp +++ b/opencl/source/sharings/unified/unified_image.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -53,7 +53,7 @@ Image *UnifiedImage::createSharedUnifiedImage(Context *context, cl_mem_flags fla multiGraphicsAllocation.addAllocation(graphicsAllocation); return Image::createSharedImage(context, sharingHandler, McsSurfaceInfo{}, std::move(multiGraphicsAllocation), nullptr, - flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, baseMipmapIndex, sharedMipmapsCount); + flags, 0, clSurfaceFormat, imgInfo, __GMM_NO_CUBE_MAP, baseMipmapIndex, sharedMipmapsCount, false); } } // namespace NEO diff --git a/opencl/source/sharings/va/va_surface.cpp b/opencl/source/sharings/va/va_surface.cpp index e4f4b1433a..bf36d12a98 100644 --- a/opencl/source/sharings/va/va_surface.cpp +++ b/opencl/source/sharings/va/va_surface.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -232,7 +232,7 @@ Image *VASurface::createSharedVaSurface(Context *context, VASharingFunctions *sh auto multiGraphicsAllocation = MultiGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex()); multiGraphicsAllocation.addAllocation(alloc); - auto image = Image::createSharedImage(context, vaSurface, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, flagsIntel, imgSurfaceFormat, sharedSurfaceInfo.imgInfo, __GMM_NO_CUBE_MAP, 0, 0); + auto image = Image::createSharedImage(context, vaSurface, mcsSurfaceInfo, std::move(multiGraphicsAllocation), nullptr, flags, flagsIntel, imgSurfaceFormat, sharedSurfaceInfo.imgInfo, __GMM_NO_CUBE_MAP, 0, 0, false); image->setMediaPlaneType(plane); return image; } diff --git a/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp b/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp index c21a25bcf5..a82da32144 100644 --- a/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp @@ -284,7 +284,7 @@ HWTEST_F(ImageSetArgTest, givenImageArraySizeGreaterThanOneButTypeIsNotImageArra 0, &surfaceFormatInfo, imageInfo, - 0, 0, 0)}; + 0, 0, 0, false)}; image->setCubeFaceIndex(__GMM_NO_CUBE_MAP); typename FamilyType::RENDER_SURFACE_STATE surfaceState{}; @@ -510,7 +510,7 @@ HWTEST_F(ImageSetArgTest, Given1dArrayWhenSettingKernelArgThenPropertiesAreSetCo delete image1Darray; } -HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithoutUnifiedAuxCapabilityThenProgramAuxFieldsForMultisamples) { +HWTEST2_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithoutUnifiedAuxCapabilityThenProgramAuxFieldsForMultisamples, IsAtMostArl) { typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); @@ -551,7 +551,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithoutUnifiedAuxC delete image; } -HWTEST_F(ImageSetArgTest, givenDepthFormatWhenSetArgIsCalledThenProgramAuxFields) { +HWTEST2_F(ImageSetArgTest, givenDepthFormatWhenSetArgIsCalledThenProgramAuxFields, IsAtMostArl) { using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE; @@ -612,7 +612,7 @@ HWTEST_F(ImageSetArgTest, givenMultisampledR32Floatx8x24DepthStencilFormatWhenSe RENDER_SURFACE_STATE::MULTISAMPLED_SURFACE_STORAGE_FORMAT::MULTISAMPLED_SURFACE_STORAGE_FORMAT_MSS); } -HWTEST_F(ImageSetArgTest, givenMcsAllocationAndCompressionWhenSetArgOnMultisampledImgIsCalledThenProgramAuxFieldsWithMcsParams) { +HWTEST2_F(ImageSetArgTest, givenMcsAllocationAndCompressionWhenSetArgOnMultisampledImgIsCalledThenProgramAuxFieldsWithMcsParams, IsAtMostArl) { typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); @@ -645,7 +645,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationAndCompressionWhenSetArgOnMultisampl EXPECT_EQ(mcsAlloc->getGpuAddress(), surfaceState->getAuxiliarySurfaceBaseAddress()); } -HWTEST_F(ImageSetArgTest, givenDepthFormatAndCompressionWhenSetArgOnMultisampledImgIsCalledThenDontProgramAuxFields) { +HWTEST2_F(ImageSetArgTest, givenDepthFormatAndCompressionWhenSetArgOnMultisampledImgIsCalledThenDontProgramAuxFields, IsAtMostArl) { using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE; 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 2fdd8b6370..7abb36d9c5 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 @@ -205,6 +205,145 @@ HWTEST2_F(XeHPAndLaterImageTests, givenMcsAllocationWhenSetArgIsCalledWithUnifie EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), expectedMode); } +HWTEST2_F(XeHPAndLaterImageTests, givenMcsAllocationWhenSetAuxParamsForMultisampleCalledThenAuxModeIsExpected, IsAtLeastBmg) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + + 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); + + EXPECT_EQ(0u, surfaceState.getAuxiliarySurfaceBaseAddress()); + + imageHw->setAuxParamsForMultisamples(&surfaceState, pClDevice->getRootDeviceIndex()); + + auto releaseHelper = pClDevice->getDevice().getReleaseHelper(); + RENDER_SURFACE_STATE expectedSS = {}; + EncodeSurfaceState::setAuxParamsForMCSCCS(&expectedSS, releaseHelper); + + EXPECT_NE(0u, surfaceState.getAuxiliarySurfaceBaseAddress()); + EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), expectedSS.getAuxiliarySurfaceMode()); +} + +HWTEST2_F(XeHPAndLaterImageTests, givenImageWithUnifiedMcsWhenSetAuxParamsForMultisampleThenAuxModeIsExpected, IsAtLeastBmg) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + + MockContext context; + McsSurfaceInfo msi = {10, 20, 3}; + + 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()); + surfaceState.setSurfaceBaseAddress(0xABCDEF1000); + imageHw->setMcsSurfaceInfo(msi); + imageHw->setIsUnifiedMcsSurface(true); + + EXPECT_EQ(0u, surfaceState.getAuxiliarySurfaceBaseAddress()); + + imageHw->setAuxParamsForMultisamples(&surfaceState, pClDevice->getRootDeviceIndex()); + + auto releaseHelper = pClDevice->getDevice().getReleaseHelper(); + RENDER_SURFACE_STATE expectedSS = {}; + EncodeSurfaceState::setAuxParamsForMCSCCS(&expectedSS, releaseHelper); + EXPECT_NE(0u, surfaceState.getAuxiliarySurfaceBaseAddress()); + EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), expectedSS.getAuxiliarySurfaceMode()); +} + +HWTEST2_F(XeHPAndLaterImageTests, givenImageWithoutMcsWhenSetAuxParamsForMultisampleThenAuxSurfBaseAddredssIsZero, IsAtLeastBmg) { + MockContext context; + 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()); + imageHw->setAuxParamsForMultisamples(&surfaceState, pClDevice->getRootDeviceIndex()); + + EXPECT_EQ(0u, surfaceState.getAuxiliarySurfaceBaseAddress()); +} + +HWTEST2_F(XeHPAndLaterImageTests, givenImageWithoutMcsWithDepthFormatWhenSetAuxParamsForMultisampleThenStorageFormatIsSetToDepthStencil, IsAtLeastBmg) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + + MockContext context; + cl_image_desc imgDesc = Image2dDefaults::imageDesc; + cl_image_format imgFormat = {CL_DEPTH, CL_FLOAT}; + imgDesc.num_samples = 8; + std::unique_ptr image(Image2dHelper<>::create(&context, &imgDesc, &imgFormat)); + + auto pClDevice = context.getDevice(0); + + auto surfaceState = FamilyType::cmdInitRenderSurfaceState; + auto imageHw = static_cast *>(image.get()); + surfaceState.setSurfaceFormat(RENDER_SURFACE_STATE::SURFACE_FORMAT::SURFACE_FORMAT_R8G8B8A8_UINT); + imageHw->setAuxParamsForMultisamples(&surfaceState, pClDevice->getRootDeviceIndex()); + + EXPECT_EQ(surfaceState.getMultisampledSurfaceStorageFormat(), + RENDER_SURFACE_STATE::MULTISAMPLED_SURFACE_STORAGE_FORMAT::MULTISAMPLED_SURFACE_STORAGE_FORMAT_DEPTH_STENCIL); +} + +HWTEST2_F(XeHPAndLaterImageTests, givenImageWithoutMcsWithNotDepthFormatWhenSetAuxParamsForMultisampleThenStorageFormatIsSetToMSS, IsAtLeastBmg) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + + MockContext context; + cl_image_desc imgDesc = Image2dDefaults::imageDesc; + cl_image_format imgFormat = {CL_RGBA, CL_FLOAT}; + imgDesc.num_samples = 8; + std::unique_ptr image(Image2dHelper<>::create(&context, &imgDesc, &imgFormat)); + + auto pClDevice = context.getDevice(0); + + auto surfaceState = FamilyType::cmdInitRenderSurfaceState; + auto imageHw = static_cast *>(image.get()); + surfaceState.setSurfaceFormat(RENDER_SURFACE_STATE::SURFACE_FORMAT::SURFACE_FORMAT_R8G8B8A8_UINT); + imageHw->setAuxParamsForMultisamples(&surfaceState, pClDevice->getRootDeviceIndex()); + + EXPECT_EQ(surfaceState.getMultisampledSurfaceStorageFormat(), + RENDER_SURFACE_STATE::MULTISAMPLED_SURFACE_STORAGE_FORMAT::MULTISAMPLED_SURFACE_STORAGE_FORMAT_MSS); +} + +HWTEST2_F(XeHPAndLaterImageTests, givenImageWithoutMcsWithTypelessSurfaceStateFormatWhenSetAuxParamsForMultisampleThenStorageFormatIsSetToMSS, IsAtLeastBmg) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + + MockContext context; + cl_image_desc imgDesc = Image2dDefaults::imageDesc; + cl_image_format imgFormat = {CL_DEPTH, CL_FLOAT}; + imgDesc.num_samples = 8; + std::unique_ptr image(Image2dHelper<>::create(&context, &imgDesc, &imgFormat)); + + auto pClDevice = context.getDevice(0); + + auto surfaceState = FamilyType::cmdInitRenderSurfaceState; + auto imageHw = static_cast *>(image.get()); + surfaceState.setSurfaceFormat(RENDER_SURFACE_STATE::SURFACE_FORMAT::SURFACE_FORMAT_R32_FLOAT_X8X24_TYPELESS); + imageHw->setAuxParamsForMultisamples(&surfaceState, pClDevice->getRootDeviceIndex()); + + EXPECT_EQ(surfaceState.getMultisampledSurfaceStorageFormat(), + RENDER_SURFACE_STATE::MULTISAMPLED_SURFACE_STORAGE_FORMAT::MULTISAMPLED_SURFACE_STORAGE_FORMAT_MSS); +} + HWTEST2_F(ImageClearColorFixture, givenImageForXeHPAndLaterWhenClearColorParametersAreSetThenClearColorSurfaceInSurfaceStateIsSet, CompressionParamsSupportedMatcher) { this->setUpImpl(); auto surfaceState = this->getSurfaceState(); diff --git a/opencl/test/unit_test/mem_obj/image_tiled_tests.cpp b/opencl/test/unit_test/mem_obj/image_tiled_tests.cpp index dcbf344992..13885ba524 100644 --- a/opencl/test/unit_test/mem_obj/image_tiled_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image_tiled_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -114,7 +114,7 @@ TEST_P(CreateTiledImageTest, GivenSharedTiledImageWhenCheckingIsTiledThenTrueRet 0, &surfaceFormat, info, - 0, 0, 0); + 0, 0, 0, false); ASSERT_NE(nullptr, image); @@ -155,7 +155,7 @@ TEST_P(CreateNonTiledImageTest, GivenSharedNonTiledImageWhenCheckingIsTiledThenF 0, &surfaceFormat, info, - 0, 0, 0); + 0, 0, 0, false); ASSERT_NE(nullptr, image); diff --git a/opencl/test/unit_test/sharings/gl/windows/gl_texture_tests.cpp b/opencl/test/unit_test/sharings/gl/windows/gl_texture_tests.cpp index 7c4bde9e51..9cf1a6eb47 100644 --- a/opencl/test/unit_test/sharings/gl/windows/gl_texture_tests.cpp +++ b/opencl/test/unit_test/sharings/gl/windows/gl_texture_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -79,6 +79,11 @@ class GlSharingTextureTests : public ::testing::Test { auto mockGmmResInfo = static_cast(tempMM->forceGmm->gmmResourceInfo.get()); mockGmmResInfo->setUnifiedAuxTranslationCapable(); } + void setMcsSurf() { + tempMM->useForcedGmm = true; + auto mockGmmResInfo = static_cast(tempMM->forceGmm->gmmResourceInfo.get()); + mockGmmResInfo->setMultisampleControlSurface(); + } ExecutionEnvironment *executionEnvironment; ImageDescriptor imgDesc; @@ -211,6 +216,24 @@ TEST_F(GlSharingTextureTests, givenGmmResourceAsInputWhenTextureIsCreatedThenItH delete glTexture; } +TEST_F(GlSharingTextureTests, givenGmmResourceInfoWithMcsWhenMcsHandleIsNullAndMultisampleCountIsGreaterThanOneThenImageHasUnifiedMcs) { + cl_int retVal = CL_INVALID_VALUE; + + setMcsSurf(); + glSharing->textureInfoOutput.globalShareHandleMCS = NULL; + glSharing->textureInfoOutput.numberOfSamples = 16; + glSharing->textureInfoOutput.globalShareHandle = textureId; + glSharing->textureInfoOutput.pGmmResInfo = this->tempMM->forceGmm->gmmResourceInfo->peekGmmResourceInfo(); + this->tempMM->useForcedGmm = false; + glSharing->textureInfoOutput.pGmmResInfo = this->tempMM->forceGmm->gmmResourceInfo->peekGmmResourceInfo(); + + glSharing->uploadDataToTextureInfo(); + + auto glTexture = GlTexture::createSharedGlTexture(clContext.get(), (cl_mem_flags)0, GL_TEXTURE_1D, 0, textureId, &retVal); + EXPECT_TRUE(glTexture->getIsUnifiedMcsSurface()); + delete glTexture; +} + TEST_F(GlSharingTextureTests, givenDifferentHwFormatWhenSurfaceFormatInfoIsSetThenOverwrite) { cl_int retVal = CL_INVALID_VALUE; cl_image_format imageFormat = {};