diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index ccd0d13be0..98d2c8e955 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -72,6 +72,46 @@ TEST_F(HwHelperTest, WhenGettingHelperThenValidHelperReturned) { EXPECT_NE(nullptr, &helper); } +HWTEST_F(HwHelperTest, SetRenderSurfaceStateForBufferIsCalledThenSetL1CachePolicyIsCalled) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE; + class mockHwHelperHw : public HwHelperHw { + public: + bool called = false; + using HwHelperHw::HwHelperHw; + mockHwHelperHw() {} + void setL1CachePolicy(bool useL1Cache, typename FamilyType::RENDER_SURFACE_STATE *surfaceState, const HardwareInfo *hwInfo) override { + HwHelperHw::setL1CachePolicy(useL1Cache, surfaceState, hwInfo); + called = true; + } + }; + + mockHwHelperHw helper; + void *stateBuffer = alignedMalloc(sizeof(RENDER_SURFACE_STATE), sizeof(RENDER_SURFACE_STATE)); + ASSERT_NE(nullptr, stateBuffer); + memset(stateBuffer, 0, sizeof(RENDER_SURFACE_STATE)); + RENDER_SURFACE_STATE state = FamilyType::cmdInitRenderSurfaceState; + auto surfaceState = reinterpret_cast(stateBuffer); + *surfaceState = state; + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); + + size_t size = 0x1000; + uint64_t addr = 0x2000; + size_t offset = 0x1000; + uint32_t pitch = 0x40; + SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; + + helper.setRenderSurfaceStateForBuffer(rootDeviceEnvironment, stateBuffer, size, addr, offset, pitch, nullptr, false, type, false, + false); + ASSERT_EQ(helper.called, true); + helper.called = false; + + helper.setRenderSurfaceStateForBuffer(rootDeviceEnvironment, stateBuffer, size, addr, offset, pitch, nullptr, false, type, false, + true); + ASSERT_EQ(helper.called, true); + alignedFree(stateBuffer); +} + HWTEST_F(HwHelperTest, WhenGettingBindingTableStateSurfaceStatePointerThenCorrectPointerIsReturned) { using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE; BINDING_TABLE_STATE bindingTableState[4]; diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index 85afe2224e..30e5d5f938 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -198,7 +198,7 @@ class HwHelperHw : public HwHelper { bool forceNonAuxMode, bool useL1Cache) override; - void setL1CachePolicy(bool useL1Cache, typename GfxFamily::RENDER_SURFACE_STATE *surfaceState, const HardwareInfo *hwInfo); + MOCKABLE_VIRTUAL void setL1CachePolicy(bool useL1Cache, typename GfxFamily::RENDER_SURFACE_STATE *surfaceState, const HardwareInfo *hwInfo); const EngineInstancesContainer getGpgpuEngineInstances(const HardwareInfo &hwInfo) const override;