mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-23 03:33:13 +08:00
Improve Sampler programming
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
54cf561e09
commit
856dee2b08
@@ -239,7 +239,8 @@ size_t HardwareCommandsHelper<GfxFamily>::sendIndirectState(
|
||||
samplerCount = samplerTable.numSamplers;
|
||||
samplerStateOffset = EncodeStates<GfxFamily>::copySamplerState(&dsh, samplerTable.tableOffset,
|
||||
samplerCount, samplerTable.borderColor,
|
||||
kernel.getDynamicStateHeap(), device.getBindlessHeapsHelper());
|
||||
kernel.getDynamicStateHeap(), device.getBindlessHeapsHelper(),
|
||||
device.getHardwareInfo());
|
||||
}
|
||||
|
||||
auto localWorkItems = localWorkSize[0] * localWorkSize[1] * localWorkSize[2];
|
||||
|
||||
@@ -87,7 +87,6 @@ class Sampler : public BaseObject<_cl_sampler> {
|
||||
template <typename GfxFamily>
|
||||
struct SamplerHw : public Sampler {
|
||||
void setArg(void *memory, const HardwareInfo &hwInfo) override;
|
||||
void appendSamplerStateParams(typename GfxFamily::SAMPLER_STATE *state, const HardwareInfo &hwInfo);
|
||||
static constexpr float getGenSamplerMaxLod() {
|
||||
return 14.0f;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/populate_factory.h"
|
||||
#include "shared/source/os_interface/hw_info_config.h"
|
||||
#include "shared/source/utilities/numeric.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -87,11 +88,7 @@ void SamplerHw<GfxFamily>::setArg(void *memory, const HardwareInfo &hwInfo) {
|
||||
samplerState->setMinLod(minLodValue.getRawAccess());
|
||||
samplerState->setMaxLod(maxLodValue.getRawAccess());
|
||||
|
||||
appendSamplerStateParams(samplerState, hwInfo);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void SamplerHw<GfxFamily>::appendSamplerStateParams(typename GfxFamily::SAMPLER_STATE *state, const HardwareInfo &hwInfo) {
|
||||
HwInfoConfig::get(hwInfo.platform.eProductFamily)->adjustSamplerState(samplerState, hwInfo);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
||||
@@ -5,21 +5,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "opencl/source/sampler/sampler.h"
|
||||
#include "opencl/source/sampler/sampler.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
using SAMPLER_STATE = typename Family::SAMPLER_STATE;
|
||||
|
||||
template <>
|
||||
void SamplerHw<Family>::appendSamplerStateParams(SAMPLER_STATE *state, const HardwareInfo &hwInfo) {
|
||||
if (DebugManager.flags.ForceSamplerLowFilteringPrecision.get()) {
|
||||
state->setLowQualityFilter(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE);
|
||||
}
|
||||
}
|
||||
|
||||
#include "opencl/source/sampler/sampler_factory_init.inl"
|
||||
} // namespace NEO
|
||||
|
||||
@@ -8,22 +8,10 @@
|
||||
#include "shared/source/xe_hp_core/hw_cmds_base.h"
|
||||
using Family = NEO::XeHpFamily;
|
||||
constexpr static auto gfxCore = IGFX_XE_HP_CORE;
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "opencl/source/cl_device/cl_device.h"
|
||||
#include "opencl/source/context/context.h"
|
||||
#include "opencl/source/sampler/sampler.h"
|
||||
#include "opencl/source/sampler/sampler.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
using SAMPLER_STATE = typename Family::SAMPLER_STATE;
|
||||
|
||||
template <>
|
||||
void SamplerHw<Family>::appendSamplerStateParams(SAMPLER_STATE *state, const HardwareInfo &hwInfo) {
|
||||
if (DebugManager.flags.ForceSamplerLowFilteringPrecision.get()) {
|
||||
state->setLowQualityFilter(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE);
|
||||
}
|
||||
}
|
||||
|
||||
#include "opencl/source/sampler/sampler_factory_init.inl"
|
||||
} // namespace NEO
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/source/sampler/sampler.h"
|
||||
#include "shared/source/os_interface/hw_info_config.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>
|
||||
@@ -18,11 +18,10 @@ typedef Test<ClDeviceFixture> Gen11SamplerTest;
|
||||
|
||||
GEN11TEST_F(Gen11SamplerTest, WhenAppendingSamplerStateParamsThenStateIsNotChanged) {
|
||||
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
|
||||
std::unique_ptr<MockContext> context(new MockContext());
|
||||
std::unique_ptr<SamplerHw<FamilyType>> sampler(new SamplerHw<FamilyType>(context.get(), CL_FALSE, CL_ADDRESS_NONE, CL_FILTER_NEAREST));
|
||||
|
||||
auto stateWithoutAppendedParams = FamilyType::cmdInitSamplerState;
|
||||
auto stateWithAppendedParams = FamilyType::cmdInitSamplerState;
|
||||
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
|
||||
sampler->appendSamplerStateParams(&stateWithAppendedParams, *defaultHwInfo);
|
||||
HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&stateWithAppendedParams, *defaultHwInfo);
|
||||
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/os_interface/hw_info_config.h"
|
||||
#include "shared/test/common/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>
|
||||
@@ -23,11 +21,9 @@ typedef Test<ClDeviceFixture> Gen12LpSamplerTest;
|
||||
HWTEST2_F(Gen12LpSamplerTest, givenTglLpSamplerWhenUsingDefaultFilteringAndAppendSamplerStateParamsThenDisableLowQualityFilter, IsTGLLP) {
|
||||
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, *defaultHwInfo);
|
||||
HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&state, *defaultHwInfo);
|
||||
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
|
||||
}
|
||||
|
||||
@@ -36,11 +32,9 @@ HWTEST2_F(Gen12LpSamplerTest, givenTglLpSamplerWhenForcingLowQualityFilteringAnd
|
||||
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, *defaultHwInfo);
|
||||
HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&state, *defaultHwInfo);
|
||||
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE, state.getLowQualityFilter());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/source/sampler/sampler.h"
|
||||
#include "shared/source/os_interface/hw_info_config.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>
|
||||
@@ -18,11 +18,9 @@ typedef Test<ClDeviceFixture> Gen8SamplerTest;
|
||||
|
||||
GEN8TEST_F(Gen8SamplerTest, WhenAppendingSamplerStateParamsThenStateIsNotChanged) {
|
||||
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
|
||||
std::unique_ptr<MockContext> context(new MockContext());
|
||||
std::unique_ptr<SamplerHw<FamilyType>> sampler(new SamplerHw<FamilyType>(context.get(), CL_FALSE, CL_ADDRESS_NONE, CL_FILTER_NEAREST));
|
||||
auto stateWithoutAppendedParams = FamilyType::cmdInitSamplerState;
|
||||
auto stateWithAppendedParams = FamilyType::cmdInitSamplerState;
|
||||
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
|
||||
sampler->appendSamplerStateParams(&stateWithAppendedParams, *defaultHwInfo);
|
||||
HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&stateWithAppendedParams, *defaultHwInfo);
|
||||
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/source/sampler/sampler.h"
|
||||
#include "shared/source/os_interface/hw_info_config.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>
|
||||
@@ -18,11 +18,9 @@ typedef Test<ClDeviceFixture> Gen9SamplerTest;
|
||||
|
||||
GEN9TEST_F(Gen9SamplerTest, WhenAppendingSamplerStateParamsThenStateIsNotChanged) {
|
||||
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
|
||||
std::unique_ptr<MockContext> context(new MockContext());
|
||||
std::unique_ptr<SamplerHw<FamilyType>> sampler(new SamplerHw<FamilyType>(context.get(), CL_FALSE, CL_ADDRESS_NONE, CL_FILTER_NEAREST));
|
||||
auto stateWithoutAppendedParams = FamilyType::cmdInitSamplerState;
|
||||
auto stateWithAppendedParams = FamilyType::cmdInitSamplerState;
|
||||
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
|
||||
sampler->appendSamplerStateParams(&stateWithAppendedParams, *defaultHwInfo);
|
||||
HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&stateWithAppendedParams, *defaultHwInfo);
|
||||
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,8 @@
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/test/common/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>
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/os_interface/hw_info_config.h"
|
||||
#include "shared/test/common/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>
|
||||
@@ -23,11 +21,9 @@ typedef Test<ClDeviceFixture> XeHPSamplerTest;
|
||||
XEHPTEST_F(XeHPSamplerTest, givenXeHPSamplerWhenUsingDefaultFilteringAndAppendSamplerStateParamsThenDisableLowQualityFilter) {
|
||||
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, *defaultHwInfo);
|
||||
HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&state, *defaultHwInfo);
|
||||
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
|
||||
}
|
||||
|
||||
@@ -36,10 +32,8 @@ XEHPTEST_F(XeHPSamplerTest, givenXeHPSamplerWhenForcingLowQualityFilteringAndApp
|
||||
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, *defaultHwInfo);
|
||||
HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&state, *defaultHwInfo);
|
||||
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE, state.getLowQualityFilter());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user