From 44b3f18567cdeb64cca8fa508b06396f26e58b94 Mon Sep 17 00:00:00 2001 From: Maciej Plewka Date: Wed, 13 Sep 2023 13:42:15 +0000 Subject: [PATCH] refactor: Use release helper for adjusting depth Related-To: NEO-8295, HSD-14019991753 Signed-off-by: Maciej Plewka --- opencl/source/mem_obj/image.inl | 4 +++- .../command_container/command_encoder.inl | 2 +- .../command_container/encode_surface_state.h | 3 ++- shared/source/release_helper/release_helper.h | 4 +++- .../release_helper/release_helper_base.inl | 5 +++++ .../command_encoder_tests.cpp | 6 +++++- .../release_helper_12_55_tests.cpp | 4 ++++ .../release_helper_12_56_tests.cpp | 4 ++++ .../release_helper_12_57_tests.cpp | 4 ++++ .../release_helper_tests_base.cpp | 19 +++++++++++++++++++ .../release_helper_tests_base.h | 2 ++ 11 files changed, 52 insertions(+), 5 deletions(-) diff --git a/opencl/source/mem_obj/image.inl b/opencl/source/mem_obj/image.inl index 5d468bbf56..ad43d66a58 100644 --- a/opencl/source/mem_obj/image.inl +++ b/opencl/source/mem_obj/image.inl @@ -108,7 +108,9 @@ void ImageHw::setImageArg(void *memory, bool setAsMediaBlockImage, ui appendSurfaceStateDepthParams(surfaceState, gmm); EncodeSurfaceState::appendImageCompressionParams(surfaceState, graphicsAllocation, gmmHelper, isImageFromBuffer(), this->plane); - EncodeSurfaceState::adjustDepthLimitations(surfaceState, minArrayElement, renderTargetViewExtent, depth, mipCount, is3DUAVOrRTV); + auto releaseHelper = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getReleaseHelper(); + + EncodeSurfaceState::adjustDepthLimitations(surfaceState, minArrayElement, renderTargetViewExtent, depth, mipCount, is3DUAVOrRTV, releaseHelper); appendSurfaceStateParams(surfaceState, rootDeviceIndex, useGlobalAtomics); appendSurfaceStateExt(surfaceState); } diff --git a/shared/source/command_container/command_encoder.inl b/shared/source/command_container/command_encoder.inl index e6ab82a306..a5797662a2 100644 --- a/shared/source/command_container/command_encoder.inl +++ b/shared/source/command_container/command_encoder.inl @@ -538,7 +538,7 @@ void EncodeSurfaceState::appendParamsForImageFromBuffer(R_SURFACE_STATE } template -void EncodeSurfaceState::adjustDepthLimitations(R_SURFACE_STATE *surfaceState, uint32_t minArrayElement, uint32_t renderTargetViewExtent, uint32_t depth, uint32_t mipCount, bool is3DUavOrRtv) { +void EncodeSurfaceState::adjustDepthLimitations(R_SURFACE_STATE *surfaceState, uint32_t minArrayElement, uint32_t renderTargetViewExtent, uint32_t depth, uint32_t mipCount, bool is3DUavOrRtv, ReleaseHelper *releaseHelper) { } template diff --git a/shared/source/command_container/encode_surface_state.h b/shared/source/command_container/encode_surface_state.h index 23daeffeda..6e44d34519 100644 --- a/shared/source/command_container/encode_surface_state.h +++ b/shared/source/command_container/encode_surface_state.h @@ -15,6 +15,7 @@ class GmmHelper; class GraphicsAllocation; class IndirectHeap; class LinearStream; +class ReleaseHelper; struct EncodeSurfaceStateArgs; struct HardwareInfo; struct PipeControlArgs; @@ -59,7 +60,7 @@ struct EncodeSurfaceState { static void setFlagsForMediaCompression(R_SURFACE_STATE *surfaceState, Gmm *gmm); static void disableCompressionFlags(R_SURFACE_STATE *surfaceState); static void appendParamsForImageFromBuffer(R_SURFACE_STATE *surfaceState); - static void adjustDepthLimitations(R_SURFACE_STATE *surfaceState, uint32_t minArrayElement, uint32_t renderTargetViewExtent, uint32_t depth, uint32_t mipCount, bool is3DUavOrRtv); + static void adjustDepthLimitations(R_SURFACE_STATE *surfaceState, uint32_t minArrayElement, uint32_t renderTargetViewExtent, uint32_t depth, uint32_t mipCount, bool is3DUavOrRtv, ReleaseHelper *releaseHelper); }; } // namespace NEO \ No newline at end of file diff --git a/shared/source/release_helper/release_helper.h b/shared/source/release_helper/release_helper.h index 40bfac0f99..5f5cc53b52 100644 --- a/shared/source/release_helper/release_helper.h +++ b/shared/source/release_helper/release_helper.h @@ -38,6 +38,7 @@ class ReleaseHelper { virtual bool getMediaFrequencyTileIndex(uint32_t &tileIndex) const = 0; virtual bool isResolvingSubDeviceIDNeeded() const = 0; virtual bool isCachingOnCpuAvailable() const = 0; + virtual bool shouldAdjustDepth() const = 0; virtual std::optional getPreferredAllocationMethod(AllocationType allocationType) const = 0; protected: @@ -63,9 +64,10 @@ class ReleaseHelperHw : public ReleaseHelper { bool getMediaFrequencyTileIndex(uint32_t &tileIndex) const override; bool isResolvingSubDeviceIDNeeded() const override; bool isCachingOnCpuAvailable() const override; + bool shouldAdjustDepth() const override; std::optional getPreferredAllocationMethod(AllocationType allocationType) const override; - private: + protected: ReleaseHelperHw(HardwareIpVersion hardwareIpVersion) : ReleaseHelper(hardwareIpVersion) {} }; diff --git a/shared/source/release_helper/release_helper_base.inl b/shared/source/release_helper/release_helper_base.inl index cd7cebbeb9..029ef2ee4a 100644 --- a/shared/source/release_helper/release_helper_base.inl +++ b/shared/source/release_helper/release_helper_base.inl @@ -67,4 +67,9 @@ template std::optional ReleaseHelperHw::getPreferredAllocationMethod(AllocationType allocationType) const { return {}; } + +template +bool ReleaseHelperHw::shouldAdjustDepth() const { + return false; +} } // namespace NEO diff --git a/shared/test/unit_test/command_container/command_encoder_tests.cpp b/shared/test/unit_test/command_container/command_encoder_tests.cpp index 470d075ca6..6cadc0ef0c 100644 --- a/shared/test/unit_test/command_container/command_encoder_tests.cpp +++ b/shared/test/unit_test/command_container/command_encoder_tests.cpp @@ -303,8 +303,12 @@ HWTEST_F(CommandEncoderTests, givenSurfaceStateWhenAdjustDepthLimitationsCalledT uint32_t renderTargetViewExtent = 1; uint32_t originalDepth = 10; uint32_t mipCount = 1; + + MockExecutionEnvironment mockExecutionEnvironment{}; + auto releaseHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getReleaseHelper(); + ss.setDepth(originalDepth); auto origSS = ss; - EncodeSurfaceState::adjustDepthLimitations(&ss, minArrayElement, renderTargetViewExtent, originalDepth, mipCount, true); + EncodeSurfaceState::adjustDepthLimitations(&ss, minArrayElement, renderTargetViewExtent, originalDepth, mipCount, true, releaseHelper); EXPECT_EQ(memcmp(&ss, &origSS, sizeof(typename FamilyType::RENDER_SURFACE_STATE)), 0); } diff --git a/shared/test/unit_test/release_helper/release_helper_12_55_tests.cpp b/shared/test/unit_test/release_helper/release_helper_12_55_tests.cpp index 4c4a904ee8..24435c6b80 100644 --- a/shared/test/unit_test/release_helper/release_helper_12_55_tests.cpp +++ b/shared/test/unit_test/release_helper/release_helper_12_55_tests.cpp @@ -45,4 +45,8 @@ TEST_F(ReleaseHelper1255Tests, whenGettingMediaFrequencyTileIndexThenFalseIsRetu TEST_F(ReleaseHelper1255Tests, whenGettingPreferredAllocationMethodThenNoPreferenceIsReturned) { whenGettingPreferredAllocationMethodThenNoPreferenceIsReturned(); +} + +TEST_F(ReleaseHelper1255Tests, whenShouldAdjustCalledThenFalseReturned) { + whenShouldAdjustCalledThenFalseReturned(); } \ No newline at end of file diff --git a/shared/test/unit_test/release_helper/release_helper_12_56_tests.cpp b/shared/test/unit_test/release_helper/release_helper_12_56_tests.cpp index 9504cdee16..0e7fdc9d2d 100644 --- a/shared/test/unit_test/release_helper/release_helper_12_56_tests.cpp +++ b/shared/test/unit_test/release_helper/release_helper_12_56_tests.cpp @@ -45,4 +45,8 @@ TEST_F(ReleaseHelper1256Tests, whenGettingMediaFrequencyTileIndexThenFalseIsRetu TEST_F(ReleaseHelper1256Tests, whenGettingPreferredAllocationMethodThenNoPreferenceIsReturned) { whenGettingPreferredAllocationMethodThenNoPreferenceIsReturned(); +} + +TEST_F(ReleaseHelper1256Tests, whenShouldAdjustCalledThenFalseReturned) { + whenShouldAdjustCalledThenFalseReturned(); } \ No newline at end of file diff --git a/shared/test/unit_test/release_helper/release_helper_12_57_tests.cpp b/shared/test/unit_test/release_helper/release_helper_12_57_tests.cpp index 02c766aeb1..10335820c2 100644 --- a/shared/test/unit_test/release_helper/release_helper_12_57_tests.cpp +++ b/shared/test/unit_test/release_helper/release_helper_12_57_tests.cpp @@ -45,4 +45,8 @@ TEST_F(ReleaseHelper1257Tests, whenGettingMediaFrequencyTileIndexThenFalseIsRetu TEST_F(ReleaseHelper1257Tests, whenGettingPreferredAllocationMethodThenNoPreferenceIsReturned) { whenGettingPreferredAllocationMethodThenNoPreferenceIsReturned(); +} + +TEST_F(ReleaseHelper1257Tests, whenShouldAdjustCalledThenFalseReturned) { + whenShouldAdjustCalledThenFalseReturned(); } \ No newline at end of file diff --git a/shared/test/unit_test/release_helper/release_helper_tests_base.cpp b/shared/test/unit_test/release_helper/release_helper_tests_base.cpp index 2bad5277e6..326e310d91 100644 --- a/shared/test/unit_test/release_helper/release_helper_tests_base.cpp +++ b/shared/test/unit_test/release_helper/release_helper_tests_base.cpp @@ -85,4 +85,23 @@ void ReleaseHelperTestsBase::whenCheckPreferredAllocationMethodThenAllocateByKmd } } } +} + +void ReleaseHelperTestsBase::whenShouldAdjustCalledThenTrueReturned() { + for (auto &revision : getRevisions()) { + ipVersion.revision = revision; + releaseHelper = ReleaseHelper::create(ipVersion); + ASSERT_NE(nullptr, releaseHelper); + + EXPECT_TRUE(releaseHelper->shouldAdjustDepth()); + } +} +void ReleaseHelperTestsBase::whenShouldAdjustCalledThenFalseReturned() { + for (auto &revision : getRevisions()) { + ipVersion.revision = revision; + releaseHelper = ReleaseHelper::create(ipVersion); + ASSERT_NE(nullptr, releaseHelper); + + EXPECT_FALSE(releaseHelper->shouldAdjustDepth()); + } } \ No newline at end of file diff --git a/shared/test/unit_test/release_helper/release_helper_tests_base.h b/shared/test/unit_test/release_helper/release_helper_tests_base.h index 578737a4c6..34fe850080 100644 --- a/shared/test/unit_test/release_helper/release_helper_tests_base.h +++ b/shared/test/unit_test/release_helper/release_helper_tests_base.h @@ -26,6 +26,8 @@ struct ReleaseHelperTestsBase : public ::testing::Test { void whenGettingMaxPreferredSlmSizeThenSizeIsNotModified(); void whenGettingMediaFrequencyTileIndexThenOneIsReturned(); void whenCheckPreferredAllocationMethodThenAllocateByKmdIsReturnedExceptTagBufferAndTimestapPacketTagBuffer(); + void whenShouldAdjustCalledThenTrueReturned(); + void whenShouldAdjustCalledThenFalseReturned(); virtual std::vector getRevisions() = 0;