diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index e084566751..ea53728699 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -363,4 +363,5 @@ AddStatePrefetchCmdToMemoryPrefetchAPI = -1 UpdateCrossThreadDataSize = 0 ForceBcsEngineIndex = -1 ResolveDependenciesViaPipeControls = -1 -ExperimentalEnableSourceLevelDebugger = 0 \ No newline at end of file +ExperimentalEnableSourceLevelDebugger = 0 +Force2dImageAsArray = -1 \ No newline at end of file diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 78989113b8..eb656a0f82 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -178,6 +178,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, ForceTile0PlacementForTile1ResourcesWaActive, -1 DECLARE_DEBUG_VARIABLE(int32_t, ClosEnabled, -1, "-1: default, 0: disabled, 1: enabled. Enable CLOS based cache reservation") DECLARE_DEBUG_VARIABLE(int32_t, EngineUsageHint, -1, "-1: default, >=0: engine usage value to use when creating command queue on user selected engine") DECLARE_DEBUG_VARIABLE(int32_t, ForceBcsEngineIndex, -1, "-1: default, >=0 Copy Engine index") +DECLARE_DEBUG_VARIABLE(int32_t, Force2dImageAsArray, -1, "-1: default, 0: WA Disabled, 1: Forces surface state of 2dImage to array") /*LOGGING FLAGS*/ DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level") diff --git a/shared/source/image/image_surface_state.h b/shared/source/image/image_surface_state.h index efc3e95517..6b5696f1b0 100644 --- a/shared/source/image/image_surface_state.h +++ b/shared/source/image/image_surface_state.h @@ -7,6 +7,7 @@ #pragma once +#include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/gmm_helper/gmm.h" #include "shared/source/gmm_helper/gmm_helper.h" @@ -33,6 +34,8 @@ inline void setImageSurfaceState(typename GfxFamily::RENDER_SURFACE_STATE *surfa (imageInfo.imgDesc.imageType == ImageType::Image2DArray || imageInfo.imgDesc.imageType == ImageType::Image1DArray); + isImageArray |= (imageInfo.imgDesc.imageType == ImageType::Image2D || imageInfo.imgDesc.imageType == ImageType::Image2DArray) && DebugManager.flags.Force2dImageAsArray.get() == 1; + uint32_t renderTargetViewExtent = static_cast(imageCount); uint32_t minimumArrayElement = 0; auto hAlign = RENDER_SURFACE_STATE::SURFACE_HORIZONTAL_ALIGNMENT_HALIGN_4; diff --git a/shared/test/unit_test/image/image_surface_state_tests.cpp b/shared/test/unit_test/image/image_surface_state_tests.cpp index 3b1a819e52..ac02d43b6e 100644 --- a/shared/test/unit_test/image/image_surface_state_tests.cpp +++ b/shared/test/unit_test/image/image_surface_state_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/unit_test/image/image_surface_state_fixture.h" using namespace NEO; @@ -105,4 +106,119 @@ HWTEST_F(ImageSurfaceStateTests, givenGmmWhenSetAuxParamsForCCSThenAuxiliarySurf mockGmm->isCompressionEnabled = true; EXPECT_TRUE(EncodeSurfaceState::isAuxModeEnabled(castSurfaceState, mockGmm.get())); -} \ No newline at end of file +} + +HWTEST_F(ImageSurfaceStateTests, givenImage2DWhen2dImageWAIsEnabledThenArrayFlagIsSet) { + DebugManagerStateRestore debugSettingsRestore; + DebugManager.flags.Force2dImageAsArray.set(1); + auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE); + auto surfaceState = std::make_unique(size); + auto castSurfaceState = reinterpret_cast(surfaceState.get()); + + imageInfo.imgDesc.imageType = ImageType::Image2D; + imageInfo.imgDesc.imageDepth = 1; + imageInfo.imgDesc.imageArraySize = 1; + imageInfo.qPitch = 0; + SurfaceOffsets surfaceOffsets = {0, 0, 0, 0}; + const uint32_t cubeFaceIndex = __GMM_NO_CUBE_MAP; + SurfaceFormatInfo surfaceFormatInfo; + surfaceFormatInfo.GenxSurfaceFormat = GFX3DSTATE_SURFACEFORMAT::GFX3DSTATE_SURFACEFORMAT_A32_FLOAT; + imageInfo.surfaceFormat = &surfaceFormatInfo; + + const uint64_t gpuAddress = 0x000001a78a8a8000; + + setImageSurfaceState(castSurfaceState, imageInfo, mockGmm.get(), *gmmHelper, cubeFaceIndex, gpuAddress, surfaceOffsets, true); + EXPECT_TRUE(castSurfaceState->getSurfaceArray()); +} + +HWTEST_F(ImageSurfaceStateTests, givenImage2DWhen2dImageWAIsDisabledThenArrayFlagIsNotSet) { + DebugManagerStateRestore debugSettingsRestore; + DebugManager.flags.Force2dImageAsArray.set(0); + auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE); + auto surfaceState = std::make_unique(size); + auto castSurfaceState = reinterpret_cast(surfaceState.get()); + + imageInfo.imgDesc.imageType = ImageType::Image2D; + imageInfo.imgDesc.imageDepth = 1; + imageInfo.imgDesc.imageArraySize = 1; + imageInfo.qPitch = 0; + SurfaceOffsets surfaceOffsets = {0, 0, 0, 0}; + const uint32_t cubeFaceIndex = __GMM_NO_CUBE_MAP; + SurfaceFormatInfo surfaceFormatInfo; + surfaceFormatInfo.GenxSurfaceFormat = GFX3DSTATE_SURFACEFORMAT::GFX3DSTATE_SURFACEFORMAT_A32_FLOAT; + imageInfo.surfaceFormat = &surfaceFormatInfo; + + const uint64_t gpuAddress = 0x000001a78a8a8000; + + setImageSurfaceState(castSurfaceState, imageInfo, mockGmm.get(), *gmmHelper, cubeFaceIndex, gpuAddress, surfaceOffsets, true); + EXPECT_FALSE(castSurfaceState->getSurfaceArray()); +} + +HWTEST_F(ImageSurfaceStateTests, givenImage2DArrayOfSize1When2dImageWAIsEnabledThenArrayFlagIsSet) { + DebugManagerStateRestore debugSettingsRestore; + DebugManager.flags.Force2dImageAsArray.set(1); + auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE); + auto surfaceState = std::make_unique(size); + auto castSurfaceState = reinterpret_cast(surfaceState.get()); + + imageInfo.imgDesc.imageType = ImageType::Image2DArray; + imageInfo.imgDesc.imageDepth = 1; + imageInfo.imgDesc.imageArraySize = 1; + imageInfo.qPitch = 0; + SurfaceOffsets surfaceOffsets = {0, 0, 0, 0}; + const uint32_t cubeFaceIndex = __GMM_NO_CUBE_MAP; + SurfaceFormatInfo surfaceFormatInfo; + surfaceFormatInfo.GenxSurfaceFormat = GFX3DSTATE_SURFACEFORMAT::GFX3DSTATE_SURFACEFORMAT_A32_FLOAT; + imageInfo.surfaceFormat = &surfaceFormatInfo; + + const uint64_t gpuAddress = 0x000001a78a8a8000; + + setImageSurfaceState(castSurfaceState, imageInfo, mockGmm.get(), *gmmHelper, cubeFaceIndex, gpuAddress, surfaceOffsets, true); + EXPECT_TRUE(castSurfaceState->getSurfaceArray()); +} + +HWTEST_F(ImageSurfaceStateTests, givenImage2DArrayOfSize1When2dImageWAIsDisabledThenArrayFlagIsNotSet) { + DebugManagerStateRestore debugSettingsRestore; + DebugManager.flags.Force2dImageAsArray.set(0); + auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE); + auto surfaceState = std::make_unique(size); + auto castSurfaceState = reinterpret_cast(surfaceState.get()); + + imageInfo.imgDesc.imageType = ImageType::Image2DArray; + imageInfo.imgDesc.imageDepth = 1; + imageInfo.imgDesc.imageArraySize = 1; + imageInfo.qPitch = 0; + SurfaceOffsets surfaceOffsets = {0, 0, 0, 0}; + const uint32_t cubeFaceIndex = __GMM_NO_CUBE_MAP; + SurfaceFormatInfo surfaceFormatInfo; + surfaceFormatInfo.GenxSurfaceFormat = GFX3DSTATE_SURFACEFORMAT::GFX3DSTATE_SURFACEFORMAT_A32_FLOAT; + imageInfo.surfaceFormat = &surfaceFormatInfo; + + const uint64_t gpuAddress = 0x000001a78a8a8000; + + setImageSurfaceState(castSurfaceState, imageInfo, mockGmm.get(), *gmmHelper, cubeFaceIndex, gpuAddress, surfaceOffsets, true); + EXPECT_FALSE(castSurfaceState->getSurfaceArray()); +} + +HWTEST_F(ImageSurfaceStateTests, givenImage1DWhen2dImageWAIsEnabledThenArrayFlagIsNotSet) { + DebugManagerStateRestore debugSettingsRestore; + DebugManager.flags.Force2dImageAsArray.set(1); + auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE); + auto surfaceState = std::make_unique(size); + auto castSurfaceState = reinterpret_cast(surfaceState.get()); + + imageInfo.imgDesc.imageType = ImageType::Image1D; + imageInfo.imgDesc.imageDepth = 1; + imageInfo.imgDesc.imageArraySize = 1; + imageInfo.qPitch = 0; + SurfaceOffsets surfaceOffsets = {0, 0, 0, 0}; + const uint32_t cubeFaceIndex = __GMM_NO_CUBE_MAP; + SurfaceFormatInfo surfaceFormatInfo; + surfaceFormatInfo.GenxSurfaceFormat = GFX3DSTATE_SURFACEFORMAT::GFX3DSTATE_SURFACEFORMAT_A32_FLOAT; + imageInfo.surfaceFormat = &surfaceFormatInfo; + + const uint64_t gpuAddress = 0x000001a78a8a8000; + + setImageSurfaceState(castSurfaceState, imageInfo, mockGmm.get(), *gmmHelper, cubeFaceIndex, gpuAddress, surfaceOffsets, true); + EXPECT_FALSE(castSurfaceState->getSurfaceArray()); +}