Move hwInfoConfig ownership to RootDeviceEnvironment 2/n

Related-To: NEO-6853
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>

Use RootDeviceEnvironment getHelper<ProductHelper> for
- adjustSamplerState
- adjustPlatformForProductFamily.
This commit is contained in:
Kamil Kopryk
2022-11-10 00:05:51 +00:00
committed by Compute-Runtime-Automation
parent 77b6918f30
commit 4aa1697e3c
20 changed files with 121 additions and 77 deletions

View File

@ -41,4 +41,13 @@ MockDevice *ClDeviceFixture::createWithUsDeviceId(unsigned short usDeviceId) {
hardwareInfo.platform.usDeviceID = usDeviceId;
return MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hardwareInfo, rootDeviceIndex);
}
template <typename HelperType>
HelperType &ClDeviceFixture::getHelper() const {
auto &helper = pClDevice->getRootDeviceEnvironment().getHelper<HelperType>();
return helper;
}
template ProductHelper &ClDeviceFixture::getHelper() const;
} // namespace NEO

View File

@ -20,6 +20,9 @@ struct ClDeviceFixture {
MockDevice *createWithUsDeviceId(unsigned short usDeviceId);
template <typename HelperType>
HelperType &getHelper() const;
MockDevice *pDevice = nullptr;
MockClDevice *pClDevice = nullptr;
volatile uint32_t *pTagMemory = nullptr;
@ -29,4 +32,5 @@ struct ClDeviceFixture {
const uint32_t rootDeviceIndex = 0u;
MockClExecutionEnvironment *pClExecutionEnvironment = nullptr;
};
} // namespace NEO

View File

@ -1,11 +1,12 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "opencl/source/sampler/sampler.h"
namespace NEO {
@ -38,7 +39,7 @@ struct MockSampler : public Sampler {
return filterMode;
}
void setArg(void *memory, const HardwareInfo &hwInfo) override {
void setArg(void *memory, const RootDeviceEnvironment &rootDeviceEnvironment) override {
}
};
} // namespace NEO

View File

@ -581,7 +581,7 @@ HWTEST_P(FilterModeTest, WhenSettingKernelArgSamplerThenFiltersAreCorrect) {
ptrOffset(pKernel->getDynamicStateHeap(),
pKernelInfo->argAsSmp(0).bindful));
sampler->setArg(const_cast<SAMPLER_STATE *>(samplerState), *defaultHwInfo);
sampler->setArg(const_cast<SAMPLER_STATE *>(samplerState), pClDevice->getRootDeviceEnvironment());
if (CL_FILTER_NEAREST == filterMode) {
EXPECT_EQ(SAMPLER_STATE::MIN_MODE_FILTER_NEAREST, samplerState->getMinModeFilter());

View File

@ -16,24 +16,31 @@
using namespace NEO;
typedef Test<ClDeviceFixture> XeHPSamplerTest;
using XeHPSamplerTest = Test<ClDeviceFixture>;
XEHPTEST_F(XeHPSamplerTest, givenXeHPSamplerWhenUsingDefaultFilteringAndAppendSamplerStateParamsThenDisableLowQualityFilter) {
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
EXPECT_FALSE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get());
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
auto state = FamilyType::cmdInitSamplerState;
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&state, *defaultHwInfo);
auto &helper = getHelper<ProductHelper>();
helper.adjustSamplerState(&state, *defaultHwInfo);
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
}
XEHPTEST_F(XeHPSamplerTest, givenXeHPSamplerWhenForcingLowQualityFilteringAndAppendSamplerStateParamsThenEnableLowQualityFilter) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.ForceSamplerLowFilteringPrecision.set(true);
EXPECT_TRUE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get());
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
auto state = FamilyType::cmdInitSamplerState;
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&state, *defaultHwInfo);
auto &helper = getHelper<ProductHelper>();
helper.adjustSamplerState(&state, *defaultHwInfo);
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE, state.getLowQualityFilter());
}

View File

@ -22,40 +22,46 @@ using namespace NEO;
using SamplerTest = Test<ClDeviceFixture>;
HWTEST2_F(SamplerTest, givenDg2SamplerWhenUsingDefaultFilteringAndAppendSamplerStateParamsThenNotEnableLowQualityFilter, IsDG2) {
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
auto &helper = getHelper<ProductHelper>();
EXPECT_FALSE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get());
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
auto state = FamilyType::cmdInitSamplerState;
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&state, *defaultHwInfo);
helper.adjustSamplerState(&state, *defaultHwInfo);
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
}
HWTEST2_F(SamplerTest, givenDg2SamplerWhenForcingLowQualityFilteringAndAppendSamplerStateParamsThenEnableLowQualityFilter, IsDG2) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.ForceSamplerLowFilteringPrecision.set(true);
EXPECT_TRUE(DebugManager.flags.ForceSamplerLowFilteringPrecision.get());
typedef typename FamilyType::SAMPLER_STATE SAMPLER_STATE;
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
auto &helper = getHelper<ProductHelper>();
auto state = FamilyType::cmdInitSamplerState;
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->adjustSamplerState(&state, *defaultHwInfo);
helper.adjustSamplerState(&state, *defaultHwInfo);
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE, state.getLowQualityFilter());
}
HWTEST2_F(SamplerTest, givenDg2BelowC0WhenProgrammingSamplerForNearestFilterWithMirrorAddressThenRoundEnableForRDirectionIsEnabled, IsDG2) {
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
auto &helper = getHelper<ProductHelper>();
uint32_t revisions[] = {REVISION_A0, REVISION_B, REVISION_C};
for (auto &revision : revisions) {
pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(revision, *defaultHwInfo);
pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->platform.usRevId = helper.getHwRevIdFromStepping(revision, *defaultHwInfo);
auto context = clUniquePtr(new MockContext());
auto sampler = clUniquePtr(new SamplerHw<FamilyType>(context.get(), CL_FALSE, CL_ADDRESS_MIRRORED_REPEAT, CL_FILTER_NEAREST));
auto state = FamilyType::cmdInitSamplerState;
EXPECT_FALSE(state.getRAddressMinFilterRoundingEnable());
EXPECT_FALSE(state.getRAddressMagFilterRoundingEnable());
sampler->setArg(&state, pDevice->getHardwareInfo());
sampler->setArg(&state, pDevice->getRootDeviceEnvironment());
if (REVISION_C == revision) {
EXPECT_FALSE(state.getRAddressMinFilterRoundingEnable());
EXPECT_FALSE(state.getRAddressMagFilterRoundingEnable());
@ -66,20 +72,20 @@ HWTEST2_F(SamplerTest, givenDg2BelowC0WhenProgrammingSamplerForNearestFilterWith
}
}
HWTEST2_F(SamplerTest, givenDg2BelowC0WhenProgrammingSamplerForNearestFilterWitouthMirrorAddressThenRoundEnableForRDirectionIsDisabled, IsDG2) {
HWTEST2_F(SamplerTest, givenDg2BelowC0WhenProgrammingSamplerForNearestFilterWithoutMirrorAddressThenRoundEnableForRDirectionIsDisabled, IsDG2) {
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
auto &helper = getHelper<ProductHelper>();
uint32_t revisions[] = {REVISION_A0, REVISION_B, REVISION_C};
for (auto &revision : revisions) {
pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(revision, *defaultHwInfo);
pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->platform.usRevId = helper.getHwRevIdFromStepping(revision, *defaultHwInfo);
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_FALSE(state.getRAddressMinFilterRoundingEnable());
EXPECT_FALSE(state.getRAddressMagFilterRoundingEnable());
sampler->setArg(&state, pDevice->getHardwareInfo());
sampler->setArg(&state, pDevice->getRootDeviceEnvironment());
EXPECT_FALSE(state.getRAddressMinFilterRoundingEnable());
EXPECT_FALSE(state.getRAddressMagFilterRoundingEnable());
}
@ -88,17 +94,17 @@ HWTEST2_F(SamplerTest, givenDg2BelowC0WhenProgrammingSamplerForNearestFilterWito
HWTEST2_F(SamplerTest, givenDg2BelowC0WhenProgrammingSamplerForLinearFilterWithMirrorAddressThenRoundEnableForRDirectionIsEnabled, IsDG2) {
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
auto &helper = getHelper<ProductHelper>();
uint32_t revisions[] = {REVISION_A0, REVISION_B, REVISION_C};
for (auto &revision : revisions) {
pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(revision, *defaultHwInfo);
pDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->platform.usRevId = helper.getHwRevIdFromStepping(revision, *defaultHwInfo);
auto context = clUniquePtr(new MockContext());
auto sampler = clUniquePtr(new SamplerHw<FamilyType>(context.get(), CL_FALSE, CL_ADDRESS_MIRRORED_REPEAT, CL_FILTER_LINEAR));
auto state = FamilyType::cmdInitSamplerState;
EXPECT_FALSE(state.getRAddressMinFilterRoundingEnable());
EXPECT_FALSE(state.getRAddressMagFilterRoundingEnable());
sampler->setArg(&state, pDevice->getHardwareInfo());
sampler->setArg(&state, pDevice->getRootDeviceEnvironment());
EXPECT_TRUE(state.getRAddressMinFilterRoundingEnable());
EXPECT_TRUE(state.getRAddressMagFilterRoundingEnable());
}