From 05a066472038d073f1beceeb9bf6244e22219202 Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Tue, 22 Mar 2022 10:24:18 +0000 Subject: [PATCH] Change default lod preclamp mode in sampler_state Signed-off-by: Bartosz Dunajski --- level_zero/core/source/sampler/sampler_hw.inl | 2 ++ .../core/test/unit_tests/sources/sampler/test_sampler.cpp | 2 ++ opencl/source/sampler/sampler.inl | 4 +++- opencl/test/unit_test/sampler/sampler_set_arg_tests.cpp | 3 ++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/level_zero/core/source/sampler/sampler_hw.inl b/level_zero/core/source/sampler/sampler_hw.inl index dccba3440c..d220c2205e 100644 --- a/level_zero/core/source/sampler/sampler_hw.inl +++ b/level_zero/core/source/sampler/sampler_hw.inl @@ -21,6 +21,8 @@ ze_result_t SamplerCoreFamily::initialize(Device *device, const z samplerState.setNonNormalizedCoordinateEnable(!desc->isNormalized); + samplerState.setLodPreclampMode(SAMPLER_STATE::LOD_PRECLAMP_MODE::LOD_PRECLAMP_MODE_OGL); + auto addressControlModeX = SAMPLER_STATE::TEXTURE_COORDINATE_MODE_CLAMP_BORDER; auto addressControlModeY = SAMPLER_STATE::TEXTURE_COORDINATE_MODE_CLAMP_BORDER; auto addressControlModeZ = SAMPLER_STATE::TEXTURE_COORDINATE_MODE_CLAMP_BORDER; 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 cf6234f986..fd5db1cc0e 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 @@ -63,6 +63,8 @@ HWTEST2_P(SamplerCreateTest, givenDifferentDescriptorValuesThenSamplerIsCorrectl sampler->initialize(device, &desc); + EXPECT_EQ(SAMPLER_STATE::LOD_PRECLAMP_MODE::LOD_PRECLAMP_MODE_OGL, sampler->samplerState.getLodPreclampMode()); + if (isNormalized == static_cast(true)) { EXPECT_FALSE(sampler->samplerState.getNonNormalizedCoordinateEnable()); } else { diff --git a/opencl/source/sampler/sampler.inl b/opencl/source/sampler/sampler.inl index e70fde0338..233d45c3ce 100644 --- a/opencl/source/sampler/sampler.inl +++ b/opencl/source/sampler/sampler.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -19,6 +19,8 @@ void SamplerHw::setArg(void *memory, const HardwareInfo &hwInfo) { auto samplerState = reinterpret_cast(memory); samplerState->setNonNormalizedCoordinateEnable(!this->normalizedCoordinates); + samplerState->setLodPreclampMode(SAMPLER_STATE::LOD_PRECLAMP_MODE::LOD_PRECLAMP_MODE_OGL); + auto addressControlModeX = SAMPLER_STATE::TEXTURE_COORDINATE_MODE_CLAMP; auto addressControlModeY = SAMPLER_STATE::TEXTURE_COORDINATE_MODE_CLAMP; auto addressControlModeZ = SAMPLER_STATE::TEXTURE_COORDINATE_MODE_CLAMP; diff --git a/opencl/test/unit_test/sampler/sampler_set_arg_tests.cpp b/opencl/test/unit_test/sampler/sampler_set_arg_tests.cpp index f9ec025886..71d3b67686 100644 --- a/opencl/test/unit_test/sampler/sampler_set_arg_tests.cpp +++ b/opencl/test/unit_test/sampler/sampler_set_arg_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -127,6 +127,7 @@ HWTEST_F(SamplerSetArgTest, WhenSettingKernelArgSamplerThenSamplerStatesAreCorre EXPECT_EQ(SAMPLER_STATE::MIN_MODE_FILTER_NEAREST, samplerState->getMinModeFilter()); EXPECT_EQ(SAMPLER_STATE::MAG_MODE_FILTER_NEAREST, samplerState->getMagModeFilter()); EXPECT_EQ(SAMPLER_STATE::MIP_MODE_FILTER_NEAREST, samplerState->getMipModeFilter()); + EXPECT_EQ(SAMPLER_STATE::LOD_PRECLAMP_MODE::LOD_PRECLAMP_MODE_OGL, samplerState->getLodPreclampMode()); std::vector surfaces; pKernel->getResidency(surfaces);