1/*
2 * Copyright (C) 2019-2021 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8#include "shared/source/debug_settings/debug_settings_manager.h"
9#include "shared/source/os_interface/hw_info_config.h"
10#include "shared/test/common/helpers/debug_manager_state_restore.h"
11#include "shared/test/common/test_macros/test.h"
12
13#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
14
15#include <memory>
16
17using namespace NEO;
18
19typedef Test<ClDeviceFixture> Gen12LpSamplerTest;
20
21HWTEST2_F(Gen12LpSamplerTest, givenTglLpSamplerWhenUsingDefaultFilteringAndAppendSamplerStateParamsThenDisableLowQualityFilter, IsTGLLP) {
22    EXPECT_FALSE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get());
23    typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
24    auto state = FamilyType::cmdInitSamplerState;
25    EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
26    HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&state, *defaultHwInfo);
27    EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
28}
29
30HWTEST2_F(Gen12LpSamplerTest, givenTglLpSamplerWhenForcingLowQualityFilteringAndAppendSamplerStateParamsThenEnableLowQualityFilter, IsTGLLP) {
31    DebugManagerStateRestore dbgRestore;
32    DebugManager.flags.ForceSamplerLowFilteringPrecision.set(true);
33    EXPECT_TRUE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get());
34    typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
35    auto state = FamilyType::cmdInitSamplerState;
36    EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
37    HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&state, *defaultHwInfo);
38    EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE, state.getLowQualityFilter());
39}
40
41GEN12LPTEST_F(Gen12LpSamplerTest, GivenDefaultWhenGettingLowLowQualityFilterStateThenItIsDisabled) {
42    typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
43    auto state = FamilyType::cmdInitSamplerState;
44    EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
45}
46
47GEN12LPTEST_F(Gen12LpSamplerTest, givenGen12LpSamplerWhenProgrammingLowQualityCubeCornerModeThenTheModeChangesAppropriately) {
48    typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
49    auto state = FamilyType::cmdInitSamplerState;
50    EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_CUBE_CORNER_MODE_ENABLE, state.getLowQualityCubeCornerMode());
51    state.setLowQualityCubeCornerMode(SAMPLER_STATE::LOW_QUALITY_CUBE_CORNER_MODE_DISABLE);
52    EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_CUBE_CORNER_MODE_DISABLE, state.getLowQualityCubeCornerMode());
53}
54