diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp index 9edab6fd16..3f540e3149 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp @@ -201,7 +201,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverHwTestXeHPAndLater, givenScrat EXPECT_EQ(length.surfaceState.depth + 1u, scratchState->getDepth()); EXPECT_EQ(length.surfaceState.width + 1u, scratchState->getWidth()); EXPECT_EQ(length.surfaceState.height + 1u, scratchState->getHeight()); - EXPECT_EQ(kernel.kernelInfo.kernelDescriptor.kernelAttributes.perThreadScratchSize[0], scratchState->getSurfacePitch()); + EXPECT_EQ(kernel.kernelInfo.kernelDescriptor.kernelAttributes.perThreadScratchSize[0], EncodeSurfaceState::getPitchForScratchInBytes(scratchState)); } HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverHwTestXeHPAndLater, givenScratchSpaceSurfaceStateEnabledWhenNewSshProvidedAndNoScratchAllocationExistThenNoDirtyBitSet) { diff --git a/shared/source/command_container/command_encoder.inl b/shared/source/command_container/command_encoder.inl index 59421e8425..28775c2c7c 100644 --- a/shared/source/command_container/command_encoder.inl +++ b/shared/source/command_container/command_encoder.inl @@ -719,6 +719,16 @@ bool EncodeSurfaceState::doBindingTablePrefetch() { return enableBindingTablePrefetech; } +template +void EncodeSurfaceState::setPitchForScratch(R_SURFACE_STATE *surfaceState, uint32_t pitch) { + surfaceState->setSurfacePitch(pitch); +} + +template +uint32_t EncodeSurfaceState::getPitchForScratchInBytes(R_SURFACE_STATE *surfaceState) { + return surfaceState->getSurfacePitch(); +} + template void EncodeDispatchKernel::adjustBindingTablePrefetch(INTERFACE_DESCRIPTOR_DATA &interfaceDescriptor, uint32_t samplerCount, uint32_t bindingTableEntryCount) { auto enablePrefetch = EncodeSurfaceState::doBindingTablePrefetch(); diff --git a/shared/source/command_container/encode_surface_state.h b/shared/source/command_container/encode_surface_state.h index 655556a376..5c6e1bdda4 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 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -68,6 +68,8 @@ 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 setPitchForScratch(R_SURFACE_STATE *surfaceState, uint32_t pitch); + static uint32_t getPitchForScratchInBytes(R_SURFACE_STATE *surfaceState); }; } // namespace NEO diff --git a/shared/source/helpers/gfx_core_helper.h b/shared/source/helpers/gfx_core_helper.h index 4bc4530c01..b30badcd5a 100644 --- a/shared/source/helpers/gfx_core_helper.h +++ b/shared/source/helpers/gfx_core_helper.h @@ -230,9 +230,7 @@ class GfxCoreHelperHw : public GfxCoreHelper { return reinterpret_cast(renderSurfaceState)->getSurfaceBaseAddress(); } - uint32_t getRenderSurfaceStatePitch(void *renderSurfaceState) const override { - return reinterpret_cast(renderSurfaceState)->getSurfacePitch(); - } + uint32_t getRenderSurfaceStatePitch(void *renderSurfaceState) const override; const AubMemDump::LrcaHelper &getCsTraits(aub_stream::EngineType engineType) const override; diff --git a/shared/source/helpers/gfx_core_helper_base.inl b/shared/source/helpers/gfx_core_helper_base.inl index ef4e888463..d98594cfbd 100644 --- a/shared/source/helpers/gfx_core_helper_base.inl +++ b/shared/source/helpers/gfx_core_helper_base.inl @@ -113,7 +113,7 @@ void GfxCoreHelperHw::setRenderSurfaceStateForScratchResource(const Root state.setHeight(length.surfaceState.height + 1); state.setDepth(length.surfaceState.depth + 1); if (pitch) { - state.setSurfacePitch(pitch); + EncodeSurfaceState::setPitchForScratch(&state, pitch); } // The graphics allocation for Host Ptr surface will be created in makeResident call and GPU address is expected to be the same as CPU address @@ -766,6 +766,13 @@ bool GfxCoreHelperHw::inOrderAtomicSignallingEnabled(const RootDevice return (debugManager.flags.InOrderAtomicSignallingEnabled.get() == 1); } +template +uint32_t GfxCoreHelperHw::getRenderSurfaceStatePitch(void *renderSurfaceState) const { + using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE; + auto surfaceState = reinterpret_cast(renderSurfaceState); + return EncodeSurfaceState::getPitchForScratchInBytes(surfaceState); +} + template bool GfxCoreHelperHw::isRuntimeLocalIdsGenerationRequired(uint32_t activeChannels, const size_t *lws, diff --git a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp index af277d2c8c..e6b99e92f2 100644 --- a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp +++ b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp @@ -467,7 +467,7 @@ HWTEST_F(GfxCoreHelperTest, givenCreatedSurfaceStateBufferWhenNoAllocationProvid EXPECT_EQ(length.surfaceState.depth + 1u, state->getDepth()); EXPECT_EQ(length.surfaceState.width + 1u, state->getWidth()); EXPECT_EQ(length.surfaceState.height + 1u, state->getHeight()); - EXPECT_EQ(pitch, state->getSurfacePitch()); + EXPECT_EQ(pitch, EncodeSurfaceState::getPitchForScratchInBytes(state)); addr += offset; EXPECT_EQ(addr, state->getSurfaceBaseAddress()); EXPECT_EQ(type, state->getSurfaceType()); @@ -1293,7 +1293,7 @@ HWTEST_F(GfxCoreHelperTest, givenGetRenderSurfaceStatePitchCalledThenCorrectValu RENDER_SURFACE_STATE renderSurfaceState; uint32_t expectedPitch = 0x400; - renderSurfaceState.setSurfacePitch(expectedPitch); + EncodeSurfaceState::setPitchForScratch(&renderSurfaceState, expectedPitch); const auto &gfxCoreHelper = getHelper(); EXPECT_EQ(expectedPitch, gfxCoreHelper.getRenderSurfaceStatePitch(&renderSurfaceState)); }