diff --git a/level_zero/core/test/unit_tests/sources/sampler/test_sampler.cpp b/level_zero/core/test/unit_tests/sources/sampler/test_sampler.cpp index 3bfb14c1fc..0b7c3b90b8 100644 --- a/level_zero/core/test/unit_tests/sources/sampler/test_sampler.cpp +++ b/level_zero/core/test/unit_tests/sources/sampler/test_sampler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Intel Corporation + * Copyright (C) 2020-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -222,5 +222,71 @@ HWTEST2_F(ContextCreateSamplerTest, givenInvalidFilterModeThenSamplerIsNotCreate EXPECT_EQ(nullptr, sampler); } +using SamplerInitTest = Test; +HWTEST2_F(SamplerInitTest, givenValidHandleReturnUnitialized, IsXeHpcCore) { + ze_sampler_address_mode_t addressMode = ZE_SAMPLER_ADDRESS_MODE_NONE; + ze_sampler_filter_mode_t filterMode = ZE_SAMPLER_FILTER_MODE_LINEAR; + ze_bool_t isNormalized = false; + + ze_sampler_desc_t desc = {}; + desc.addressMode = addressMode; + desc.filterMode = filterMode; + desc.isNormalized = isNormalized; + + ze_sampler_handle_t hSampler; + ze_result_t res = context->createSampler(device, &desc, &hSampler); + + EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, res); +} + +struct SupportsLowQualityFilterSampler { + template + static constexpr bool isMatched() { + return NEO::ToGfxCoreFamily::get() >= IGFX_GEN12LP_CORE && NEO::ToGfxCoreFamily::get() != IGFX_XE_HPC_CORE; + } +}; + +HWTEST2_F(SamplerInitTest, whenInitializeSamplerAndForceSamplerLowFilteringPrecisionIsFalseThenLowQualityFilterIsDisabled, SupportsLowQualityFilterSampler) { + using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; + EXPECT_FALSE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get()); + ze_sampler_address_mode_t addressMode = ZE_SAMPLER_ADDRESS_MODE_REPEAT; + ze_sampler_filter_mode_t filterMode = ZE_SAMPLER_FILTER_MODE_NEAREST; + ze_bool_t isNormalized = true; + + ze_sampler_desc_t desc = {}; + desc.addressMode = addressMode; + desc.filterMode = filterMode; + desc.isNormalized = isNormalized; + + auto sampler = static_cast *>((*samplerFactory[productFamily])()); + sampler->initialize(device, &desc); + + EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, sampler->samplerState.getLowQualityFilter()); + + sampler->destroy(); +} + +HWTEST2_F(SamplerInitTest, whenInitializeSamplerAndForceSamplerLowFilteringPrecisionIsTrueThenLowQualityFilterIsEnabled, SupportsLowQualityFilterSampler) { + using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; + DebugManagerStateRestore dbgRestore; + DebugManager.flags.ForceSamplerLowFilteringPrecision.set(true); + EXPECT_TRUE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get()); + ze_sampler_address_mode_t addressMode = ZE_SAMPLER_ADDRESS_MODE_REPEAT; + ze_sampler_filter_mode_t filterMode = ZE_SAMPLER_FILTER_MODE_NEAREST; + ze_bool_t isNormalized = true; + + ze_sampler_desc_t desc = {}; + desc.addressMode = addressMode; + desc.filterMode = filterMode; + desc.isNormalized = isNormalized; + + auto sampler = static_cast *>((*samplerFactory[productFamily])()); + sampler->initialize(device, &desc); + + EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE, sampler->samplerState.getLowQualityFilter()); + + sampler->destroy(); +} + } // namespace ult } // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/pvc/CMakeLists.txt b/level_zero/core/test/unit_tests/xe_hpc_core/pvc/CMakeLists.txt index a6f3a23839..174bed5eac 100644 --- a/level_zero/core/test/unit_tests/xe_hpc_core/pvc/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/xe_hpc_core/pvc/CMakeLists.txt @@ -10,6 +10,5 @@ if(TESTS_PVC) ${CMAKE_CURRENT_SOURCE_DIR}/test_device_pvc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_pvc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_kernel_pvc.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_sampler_pvc.cpp ) endif() diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/pvc/test_sampler_pvc.cpp b/level_zero/core/test/unit_tests/xe_hpc_core/pvc/test_sampler_pvc.cpp deleted file mode 100644 index 20c10a6855..0000000000 --- a/level_zero/core/test/unit_tests/xe_hpc_core/pvc/test_sampler_pvc.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2022 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "shared/source/utilities/numeric.h" -#include "shared/test/common/test_macros/hw_test.h" - -#include "level_zero/core/source/sampler/sampler_hw.h" -#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" -#include "level_zero/core/test/unit_tests/mocks/mock_sampler.h" - -namespace L0 { -namespace ult { - -using ContextCreateSamplerTestPVC = Test; - -PVCTEST_F(ContextCreateSamplerTestPVC, givenValidHandleReturnUnitialized) { - ze_sampler_address_mode_t addressMode = ZE_SAMPLER_ADDRESS_MODE_NONE; - ze_sampler_filter_mode_t filterMode = ZE_SAMPLER_FILTER_MODE_LINEAR; - ze_bool_t isNormalized = false; - - ze_sampler_desc_t desc = {}; - desc.addressMode = addressMode; - desc.filterMode = filterMode; - desc.isNormalized = isNormalized; - - ze_sampler_handle_t hSampler; - ze_result_t res = context->createSampler(device, &desc, &hSampler); - - EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, res); -} - -} // namespace ult -} // namespace L0 \ No newline at end of file diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt index 0b74c60313..cf5c91ff1b 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2021-2022 Intel Corporation +# Copyright (C) 2021-2023 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -13,7 +13,6 @@ if(TESTS_DG2) ${CMAKE_CURRENT_SOURCE_DIR}/test_excludes_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_kernel_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_module_dg2.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_sampler_dg2.cpp ) add_subdirectories() endif() diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_sampler_dg2.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_sampler_dg2.cpp deleted file mode 100644 index ae5dba22e1..0000000000 --- a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_sampler_dg2.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2021-2022 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "shared/source/utilities/numeric.h" -#include "shared/test/common/test_macros/hw_test.h" - -#include "level_zero/core/source/sampler/sampler_hw.h" -#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" -#include "level_zero/core/test/unit_tests/mocks/mock_sampler.h" - -namespace L0 { -namespace ult { - -using SamplerCreateTest = Test; - -HWTEST2_F(SamplerCreateTest, givenDg2WhenInitializeSamplerAndForceSamplerLowFilteringPrecisionIsFalseThenLowQualityFilterIsDisabled, IsDG2) { - using SAMPLER_STATE = typename NEO::XeHpgCoreFamily::SAMPLER_STATE; - EXPECT_FALSE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get()); - ze_sampler_address_mode_t addressMode = ZE_SAMPLER_ADDRESS_MODE_REPEAT; - ze_sampler_filter_mode_t filterMode = ZE_SAMPLER_FILTER_MODE_NEAREST; - ze_bool_t isNormalized = true; - - ze_sampler_desc_t desc = {}; - desc.addressMode = addressMode; - desc.filterMode = filterMode; - desc.isNormalized = isNormalized; - - auto sampler = static_cast *>((*samplerFactory[IGFX_DG2])()); - sampler->initialize(device, &desc); - - EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, sampler->samplerState.getLowQualityFilter()); - - sampler->destroy(); -} - -HWTEST2_F(SamplerCreateTest, givenDg2WhenInitializeSamplerAndForceSamplerLowFilteringPrecisionIsTrueThenLowQualityFilterIsEnabled, IsDG2) { - using SAMPLER_STATE = typename NEO::XeHpgCoreFamily::SAMPLER_STATE; - DebugManagerStateRestore dbgRestore; - DebugManager.flags.ForceSamplerLowFilteringPrecision.set(true); - EXPECT_TRUE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get()); - ze_sampler_address_mode_t addressMode = ZE_SAMPLER_ADDRESS_MODE_REPEAT; - ze_sampler_filter_mode_t filterMode = ZE_SAMPLER_FILTER_MODE_NEAREST; - ze_bool_t isNormalized = true; - - ze_sampler_desc_t desc = {}; - desc.addressMode = addressMode; - desc.filterMode = filterMode; - desc.isNormalized = isNormalized; - - auto sampler = static_cast *>((*samplerFactory[IGFX_DG2])()); - sampler->initialize(device, &desc); - - EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE, sampler->samplerState.getLowQualityFilter()); - - sampler->destroy(); -} - -} // namespace ult -} // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/mtl/CMakeLists.txt b/level_zero/core/test/unit_tests/xe_hpg_core/mtl/CMakeLists.txt index fe6229d8ae..74e468d74e 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/mtl/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/xe_hpg_core/mtl/CMakeLists.txt @@ -8,6 +8,5 @@ if(TESTS_MTL) target_sources(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_mtl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_sampler_mtl.cpp ) endif() diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/mtl/test_sampler_mtl.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/mtl/test_sampler_mtl.cpp deleted file mode 100644 index 0fff317aa9..0000000000 --- a/level_zero/core/test/unit_tests/xe_hpg_core/mtl/test_sampler_mtl.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2022 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "shared/source/utilities/numeric.h" -#include "shared/test/common/test_macros/hw_test.h" - -#include "level_zero/core/source/sampler/sampler_hw.h" -#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" -#include "level_zero/core/test/unit_tests/mocks/mock_sampler.h" - -namespace L0 { -namespace ult { - -using SamplerCreateTest = Test; - -HWTEST2_F(SamplerCreateTest, givenMtlWhenInitializeSamplerThenLowQualityFilterIsDisabled, IsMTL) { - using SAMPLER_STATE = typename NEO::XeHpgCoreFamily::SAMPLER_STATE; - - ze_sampler_address_mode_t addressMode = ZE_SAMPLER_ADDRESS_MODE_REPEAT; - ze_sampler_filter_mode_t filterMode = ZE_SAMPLER_FILTER_MODE_NEAREST; - ze_bool_t isNormalized = true; - - ze_sampler_desc_t desc = {}; - desc.addressMode = addressMode; - desc.filterMode = filterMode; - desc.isNormalized = isNormalized; - - auto sampler = static_cast *>((*samplerFactory[IGFX_METEORLAKE])()); - sampler->initialize(device, &desc); - - EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, sampler->samplerState.getLowQualityFilter()); - - sampler->destroy(); -} - -HWTEST2_F(SamplerCreateTest, givenMtlAndDebugFlagSetWhenInitializingSamplerThenLowQualityFilterIsEnabled, IsMTL) { - using SAMPLER_STATE = typename NEO::XeHpgCoreFamily::SAMPLER_STATE; - DebugManagerStateRestore dbgRestore; - DebugManager.flags.ForceSamplerLowFilteringPrecision.set(true); - - ze_sampler_desc_t desc = {}; - desc.addressMode = ZE_SAMPLER_ADDRESS_MODE_REPEAT; - desc.filterMode = ZE_SAMPLER_FILTER_MODE_NEAREST; - desc.isNormalized = true; - - auto sampler = static_cast *>((*samplerFactory[IGFX_METEORLAKE])()); - sampler->initialize(device, &desc); - - EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE, sampler->samplerState.getLowQualityFilter()); - - sampler->destroy(); -} - -} // namespace ult -} // namespace L0 \ No newline at end of file