diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index 8cb29870bb..449d00c89c 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -552,6 +552,40 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionDisabledA alignedFree(stateBuffer); } +HWTEST_F(HwHelperTest, givenOverrideMocsIndexForScratchSpaceWhenSurfaceStateIsProgrammedForScratchSpaceThenOverrideMocsIndexWithCorrectValue) { + DebugManagerStateRestore restore; + DebugManager.flags.OverrideMocsIndexForScratchSpace.set(1); + + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE; + + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); + void *stateBuffer = alignedMalloc(sizeof(RENDER_SURFACE_STATE), sizeof(RENDER_SURFACE_STATE)); + ASSERT_NE(nullptr, stateBuffer); + RENDER_SURFACE_STATE *state = reinterpret_cast(stateBuffer); + + memset(stateBuffer, 0, sizeof(RENDER_SURFACE_STATE)); + auto &helper = HwHelper::get(renderCoreFamily); + + size_t size = 0x1000; + uint64_t addr = 0x2000; + uint32_t pitch = 0; + + void *cpuAddr = reinterpret_cast(0x4000); + uint64_t gpuAddr = 0x4000u; + size_t allocSize = size; + GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::BUFFER, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 1); + allocation.setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), 0, false)); + SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; + helper.setRenderSurfaceStateForBuffer(rootDeviceEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, false, false); + + auto mocsProgrammed = state->getMemoryObjectControlState() >> 1; + EXPECT_EQ(1u, mocsProgrammed); + + delete allocation.getDefaultGmm(); + alignedFree(stateBuffer); +} + HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompressionEnabledAnNonAuxEnabledThenSetCoherencyToIaAndAuxModeToNone) { using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE; diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index 8d04f2d6ba..bf87b42d3a 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -41,6 +41,7 @@ SchedulerSimulationReturnInstance = 0 SchedulerGWS = 0 EnableExperimentalCommandBuffer = 0 OverrideStatelessMocsIndex = -1 +OverrideMocsIndexForScratchSpace = -1 CFEFusedEUDispatch = -1 ForceAuxTranslationMode = -1 OverrideGpuAddressSpace = -1 diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 8a69361de9..2fcb3555bd 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -84,7 +84,8 @@ DECLARE_DEBUG_VARIABLE(int32_t, ForceAuxTranslationEnabled, -1, "-1: default, 0: DECLARE_DEBUG_VARIABLE(int32_t, SchedulerSimulationReturnInstance, 0, "prints execution model related debug information") DECLARE_DEBUG_VARIABLE(int32_t, SchedulerGWS, 0, "Forces gws of scheduler kernel, only multiple of 24 allowed or 0 - default selected") DECLARE_DEBUG_VARIABLE(int32_t, EnableExperimentalCommandBuffer, 0, "Enables injection of experimental command buffer") -DECLARE_DEBUG_VARIABLE(int32_t, OverrideStatelessMocsIndex, -1, "-1: feature inactive, >=0 : following MOCS index will be programmed for stateless accesses in state base address") +DECLARE_DEBUG_VARIABLE(int32_t, OverrideStatelessMocsIndex, -1, "-1: feature inactive, >=0 : following MOCS index will be programmed for stateless accesses in state base address (for regular buffers)") +DECLARE_DEBUG_VARIABLE(int32_t, OverrideMocsIndexForScratchSpace, -1, "-1: feature inactive, >=0 : following MOCS index will be programmed for stateful accesses in surface state for scratch space") DECLARE_DEBUG_VARIABLE(int32_t, CFEFusedEUDispatch, -1, "Set Fused EU dispatch in FrontEnd State command. -1 - default, 0 - enabled, 1 - disabled") DECLARE_DEBUG_VARIABLE(int32_t, ForceAuxTranslationMode, -1, "-1: Default, 0: None, 1: Builtin, 2: Blit") DECLARE_DEBUG_VARIABLE(int32_t, OverrideGpuAddressSpace, -1, "-1: Default, !=-1: GPU address space range in bits") diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index 18ccd60bbd..62434f74ae 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -155,6 +155,10 @@ void HwHelperHw::setRenderSurfaceStateForBuffer(const RootDeviceEnvironm } else { state.setMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED)); } + if (DebugManager.flags.OverrideMocsIndexForScratchSpace.get() != -1) { + auto mocsIndex = static_cast(DebugManager.flags.OverrideMocsIndexForScratchSpace.get()) << 1; + state.setMemoryObjectControlState(mocsIndex); + } state.setSurfaceBaseAddress(bufferStateAddress);