60 lines
2.8 KiB
C++
60 lines
2.8 KiB
C++
/*
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
|
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
|
|
#include "shared/test/unit_test/utilities/base_object_utils.h"
|
|
|
|
#include "opencl/source/sampler/sampler.h"
|
|
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
|
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
|
#include "test.h"
|
|
|
|
#include <memory>
|
|
|
|
using namespace NEO;
|
|
|
|
typedef Test<ClDeviceFixture> Gen12LpSamplerTest;
|
|
|
|
TGLLPTEST_F(Gen12LpSamplerTest, givenTglLpSamplerWhenUsingDefaultFilteringAndAppendSamplerStateParamsThenDisableLowQualityFilter) {
|
|
EXPECT_FALSE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get());
|
|
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
|
|
auto context = clUniquePtr(new MockContext());
|
|
auto sampler = clUniquePtr(new SamplerHw<FamilyType>(context.get(), CL_FALSE, CL_ADDRESS_NONE, CL_FILTER_NEAREST));
|
|
auto state = FamilyType::cmdInitSamplerState;
|
|
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
|
|
sampler->appendSamplerStateParams(&state);
|
|
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
|
|
}
|
|
|
|
TGLLPTEST_F(Gen12LpSamplerTest, givenTglLpSamplerWhenForcingLowQualityFilteringAndAppendSamplerStateParamsThenEnableLowQualityFilter) {
|
|
DebugManagerStateRestore dbgRestore;
|
|
DebugManager.flags.ForceSamplerLowFilteringPrecision.set(true);
|
|
EXPECT_TRUE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get());
|
|
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
|
|
auto context = clUniquePtr(new MockContext());
|
|
auto sampler = clUniquePtr(new SamplerHw<FamilyType>(context.get(), CL_FALSE, CL_ADDRESS_NONE, CL_FILTER_NEAREST));
|
|
auto state = FamilyType::cmdInitSamplerState;
|
|
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
|
|
sampler->appendSamplerStateParams(&state);
|
|
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE, state.getLowQualityFilter());
|
|
}
|
|
|
|
GEN12LPTEST_F(Gen12LpSamplerTest, defaultLowQualityFilter) {
|
|
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
|
|
auto state = FamilyType::cmdInitSamplerState;
|
|
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
|
|
}
|
|
|
|
GEN12LPTEST_F(Gen12LpSamplerTest, givenGen12LpSamplerWhenProgrammingLowQualityCubeCornerModeThenTheModeChangesAppropriately) {
|
|
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
|
|
auto state = FamilyType::cmdInitSamplerState;
|
|
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_CUBE_CORNER_MODE_ENABLE, state.getLowQualityCubeCornerMode());
|
|
state.setLowQualityCubeCornerMode(SAMPLER_STATE::LOW_QUALITY_CUBE_CORNER_MODE_DISABLE);
|
|
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_CUBE_CORNER_MODE_DISABLE, state.getLowQualityCubeCornerMode());
|
|
}
|