diff --git a/runtime/gmm_helper/gmm.cpp b/runtime/gmm_helper/gmm.cpp index 4ea103a878..bf9089e922 100644 --- a/runtime/gmm_helper/gmm.cpp +++ b/runtime/gmm_helper/gmm.cpp @@ -200,14 +200,6 @@ uint32_t Gmm::queryQPitch(GMM_RESOURCE_TYPE resType) { return gmmResourceInfo->getQPitch(); } -uint32_t Gmm::getRenderHAlignment() { - return GmmHelper::getRenderAlignment(gmmResourceInfo->getHAlign()); -} - -uint32_t Gmm::getRenderVAlignment() { - return GmmHelper::getRenderAlignment(gmmResourceInfo->getVAlign()); -} - void Gmm::updateImgInfo(ImageInfo &imgInfo, cl_image_desc &imgDesc, cl_uint arrayIndex) { imgDesc.image_width = gmmResourceInfo->getBaseWidth(); imgDesc.image_row_pitch = gmmResourceInfo->getRenderPitch(); diff --git a/runtime/gmm_helper/gmm.h b/runtime/gmm_helper/gmm.h index dc49ccfd89..b3bc5049fa 100644 --- a/runtime/gmm_helper/gmm.h +++ b/runtime/gmm_helper/gmm.h @@ -32,9 +32,6 @@ class Gmm { void queryImageParams(ImageInfo &inputOutputImgInfo); - uint32_t getRenderHAlignment(); - uint32_t getRenderVAlignment(); - void applyAuxFlagsForBuffer(bool preferRenderCompression); void applyMemoryFlags(bool systemMemoryPool, StorageInfo &storageInfo); diff --git a/runtime/gmm_helper/gmm_helper.cpp b/runtime/gmm_helper/gmm_helper.cpp index 9119a7b18a..55d2cd56c6 100644 --- a/runtime/gmm_helper/gmm_helper.cpp +++ b/runtime/gmm_helper/gmm_helper.cpp @@ -106,18 +106,6 @@ uint64_t GmmHelper::decanonize(uint64_t address) { return (uint64_t)(address & 0xFFFFFFFFFFFF); } -uint32_t GmmHelper::getRenderAlignment(uint32_t alignment) { - uint32_t returnAlign = 0; - if (alignment == 8) { - returnAlign = 2; - } else if (alignment == 16) { - returnAlign = 3; - } else { - returnAlign = 1; - } - return returnAlign; -} - uint32_t GmmHelper::getRenderMultisamplesCount(uint32_t numSamples) { if (numSamples == 2) { return 1; diff --git a/runtime/gmm_helper/gmm_helper.h b/runtime/gmm_helper/gmm_helper.h index ef60e65bf0..8f91f0ba39 100644 --- a/runtime/gmm_helper/gmm_helper.h +++ b/runtime/gmm_helper/gmm_helper.h @@ -47,7 +47,6 @@ class GmmHelper { static void queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation *gfxAlloc); static GMM_CUBE_FACE_ENUM getCubeFaceIndex(uint32_t target); static bool allowTiling(const cl_image_desc &imageDesc); - static uint32_t getRenderAlignment(uint32_t alignment); static uint32_t getRenderMultisamplesCount(uint32_t numSamples); static GMM_YUV_PLANE convertPlane(OCLPlane oclPlane); diff --git a/runtime/gmm_helper/resource_info.h b/runtime/gmm_helper/resource_info.h index 1c45ec9078..22be27704d 100644 --- a/runtime/gmm_helper/resource_info.h +++ b/runtime/gmm_helper/resource_info.h @@ -42,6 +42,10 @@ class GmmResourceInfo { MOCKABLE_VIRTUAL uint32_t getVAlign() { return resourceInfo->GetVAlign(); } + MOCKABLE_VIRTUAL uint32_t getHAlignSurfaceState() { return resourceInfo->GetHAlignSurfaceState(); } + + MOCKABLE_VIRTUAL uint32_t getVAlignSurfaceState() { return resourceInfo->GetVAlignSurfaceState(); } + MOCKABLE_VIRTUAL uint32_t getMaxLod() { return resourceInfo->GetMaxLod(); } MOCKABLE_VIRTUAL uint32_t getTileModeSurfaceState() { return resourceInfo->GetTileModeSurfaceState(); } diff --git a/runtime/mem_obj/image.inl b/runtime/mem_obj/image.inl index 20633111e3..42920ff041 100644 --- a/runtime/mem_obj/image.inl +++ b/runtime/mem_obj/image.inl @@ -48,8 +48,8 @@ void ImageHw::setImageArg(void *memory, bool setAsMediaBlockImage, ui auto vAlign = RENDER_SURFACE_STATE::SURFACE_VERTICAL_ALIGNMENT_VALIGN_4; if (gmm) { - hAlign = static_cast(gmm->getRenderHAlignment()); - vAlign = static_cast(gmm->getRenderVAlignment()); + hAlign = static_cast(gmm->gmmResourceInfo->getHAlignSurfaceState()); + vAlign = static_cast(gmm->gmmResourceInfo->getVAlignSurfaceState()); } if (cubeFaceIndex != __GMM_NO_CUBE_MAP) { diff --git a/unit_tests/gmm_helper/gmm_helper_tests.cpp b/unit_tests/gmm_helper/gmm_helper_tests.cpp index 33b6c338f2..3e692b4d7e 100644 --- a/unit_tests/gmm_helper/gmm_helper_tests.cpp +++ b/unit_tests/gmm_helper/gmm_helper_tests.cpp @@ -375,13 +375,6 @@ TEST_F(GmmTests, decanonize) { EXPECT_EQ(GmmHelper::decanonize(addr2), addrExpected2); } -TEST_F(GmmTests, returnRenderTileMode) { - uint32_t alignments[5][2] = {{0, 1}, {4, 1}, {8, 2}, {16, 3}, {20, 1}}; // {given, expected} - for (uint32_t i = 0; i < 5; i++) { - EXPECT_EQ(GmmHelper::getRenderAlignment(alignments[i][0]), alignments[i][1]); - } -} - TEST_F(GmmTests, givenMipmapedInputWhenAskedForHalingThenNonDefaultValueIsReturned) { cl_image_desc imgDesc{}; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; diff --git a/unit_tests/mem_obj/image_tests.cpp b/unit_tests/mem_obj/image_tests.cpp index 3fd0371016..081dc0183e 100644 --- a/unit_tests/mem_obj/image_tests.cpp +++ b/unit_tests/mem_obj/image_tests.cpp @@ -7,6 +7,7 @@ #include "runtime/built_ins/built_ins.h" #include "runtime/compiler_interface/compiler_interface.h" +#include "runtime/gmm_helper/resource_info.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/mipmap.h" #include "runtime/mem_obj/image.h" @@ -1452,7 +1453,22 @@ HWTEST_F(HwImageTest, givenImageHwWhenSettingCCSParamsThenSetClearColorParamsIsC EXPECT_TRUE(mockImage->setClearColorParamsCalled); } -using HwImageTest = ::testing::Test; +HWTEST_F(HwImageTest, givenImageHwWhenSettingAlignmentThenUseGmmValues) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + MockContext context; + OsAgnosticMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment()); + context.setMemoryManager(&memoryManager); + + std::unique_ptr image(ImageHelper::create(&context)); + + auto surfaceState = FamilyType::cmdInitRenderSurfaceState; + + image->setImageArg(&surfaceState, false, 0); + auto resourceInfo = image->getGraphicsAllocation()->getDefaultGmm()->gmmResourceInfo.get(); + EXPECT_EQ(resourceInfo->getHAlignSurfaceState(), surfaceState.getSurfaceHorizontalAlignment()); + EXPECT_EQ(resourceInfo->getVAlignSurfaceState(), surfaceState.getSurfaceVerticalAlignment()); +} + HWTEST_F(HwImageTest, givenImageHwWithUnifiedSurfaceAndMcsWhenSettingParamsForMultisampleImageThenSetParamsForCcsMcsIsCalled) { MockContext context; diff --git a/unit_tests/mocks/mock_gmm_resource_info.h b/unit_tests/mocks/mock_gmm_resource_info.h index a64787d3ea..dd686465d6 100644 --- a/unit_tests/mocks/mock_gmm_resource_info.h +++ b/unit_tests/mocks/mock_gmm_resource_info.h @@ -49,6 +49,10 @@ class MockGmmResourceInfo : public GmmResourceInfo { uint32_t getVAlign() override { return 4u; } + uint32_t getHAlignSurfaceState() override { return 1u; } + + uint32_t getVAlignSurfaceState() override { return 1u; } + uint32_t getMaxLod() override { return 7u; } uint32_t getTileModeSurfaceState() override;