Add hwInfo to sampler setArg and appendSamplerStateParams

Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
Katarzyna Cencelewska
2021-02-05 01:58:42 +00:00
committed by Compute-Runtime-Automation
parent 7dad49ccf4
commit 9d0422cf69
15 changed files with 51 additions and 25 deletions

View File

@@ -1731,7 +1731,7 @@ cl_int Kernel::setArgSampler(uint32_t argIndex,
auto dsh = getDynamicStateHeap(rootDeviceIndex);
auto samplerState = ptrOffset(dsh, kernelArgInfo.offsetHeap);
pSampler->setArg(const_cast<void *>(samplerState));
pSampler->setArg(const_cast<void *>(samplerState), getProgram()->getDevices()[0]->getHardwareInfo());
auto crossThreadData = reinterpret_cast<uint32_t *>(getCrossThreadData(rootDeviceIndex));
patch<uint32_t, unsigned int>(pSampler->getSnapWaValue(), crossThreadData, kernelArgInfo.offsetSamplerSnapWa);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -50,7 +50,7 @@ class Sampler : public BaseObject<_cl_sampler> {
cl_int getInfo(cl_sampler_info paramName, size_t paramValueSize,
void *paramValue, size_t *paramValueSizeRet);
virtual void setArg(void *memory) = 0;
virtual void setArg(void *memory, const HardwareInfo &hwInfo) = 0;
static size_t getSamplerStateSize(const HardwareInfo &hwInfo);
bool isTransformable() const;
@@ -86,8 +86,8 @@ class Sampler : public BaseObject<_cl_sampler> {
template <typename GfxFamily>
struct SamplerHw : public Sampler {
void setArg(void *memory) override;
void appendSamplerStateParams(typename GfxFamily::SAMPLER_STATE *state);
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;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -13,7 +13,7 @@
namespace NEO {
template <typename GfxFamily>
void SamplerHw<GfxFamily>::setArg(void *memory) {
void SamplerHw<GfxFamily>::setArg(void *memory, const HardwareInfo &hwInfo) {
using SAMPLER_STATE = typename GfxFamily::SAMPLER_STATE;
auto samplerState = reinterpret_cast<SAMPLER_STATE *>(memory);
samplerState->setNonNormalizedCoordinateEnable(!this->normalizedCoordinates);
@@ -87,11 +87,11 @@ void SamplerHw<GfxFamily>::setArg(void *memory) {
samplerState->setMinLod(minLodValue.getRawAccess());
samplerState->setMaxLod(maxLodValue.getRawAccess());
appendSamplerStateParams(samplerState);
appendSamplerStateParams(samplerState, hwInfo);
}
template <typename GfxFamily>
void SamplerHw<GfxFamily>::appendSamplerStateParams(typename GfxFamily::SAMPLER_STATE *state) {
void SamplerHw<GfxFamily>::appendSamplerStateParams(typename GfxFamily::SAMPLER_STATE *state, const HardwareInfo &hwInfo) {
}
template <typename GfxFamily>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -15,7 +15,7 @@ namespace NEO {
using SAMPLER_STATE = typename Family::SAMPLER_STATE;
template <>
void SamplerHw<Family>::appendSamplerStateParams(SAMPLER_STATE *state) {
void SamplerHw<Family>::appendSamplerStateParams(SAMPLER_STATE *state, const HardwareInfo &hwInfo) {
if (DebugManager.flags.ForceSamplerLowFilteringPrecision.get()) {
state->setLowQualityFilter(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -23,6 +23,6 @@ GEN11TEST_F(Gen11SamplerTest, WhenAppendingSamplerStateParamsThenStateIsNotChang
auto stateWithoutAppendedParams = FamilyType::cmdInitSamplerState;
auto stateWithAppendedParams = FamilyType::cmdInitSamplerState;
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
sampler->appendSamplerStateParams(&stateWithAppendedParams);
sampler->appendSamplerStateParams(&stateWithAppendedParams, *defaultHwInfo);
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
}

View File

@@ -27,7 +27,7 @@ HWTEST2_F(Gen12LpSamplerTest, givenTglLpSamplerWhenUsingDefaultFilteringAndAppen
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);
sampler->appendSamplerStateParams(&state, *defaultHwInfo);
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
}
@@ -40,7 +40,7 @@ HWTEST2_F(Gen12LpSamplerTest, givenTglLpSamplerWhenForcingLowQualityFilteringAnd
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);
sampler->appendSamplerStateParams(&state, *defaultHwInfo);
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE, state.getLowQualityFilter());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -23,6 +23,6 @@ GEN8TEST_F(Gen8SamplerTest, WhenAppendingSamplerStateParamsThenStateIsNotChanged
auto stateWithoutAppendedParams = FamilyType::cmdInitSamplerState;
auto stateWithAppendedParams = FamilyType::cmdInitSamplerState;
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
sampler->appendSamplerStateParams(&stateWithAppendedParams);
sampler->appendSamplerStateParams(&stateWithAppendedParams, *defaultHwInfo);
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -23,6 +23,6 @@ GEN9TEST_F(Gen9SamplerTest, WhenAppendingSamplerStateParamsThenStateIsNotChanged
auto stateWithoutAppendedParams = FamilyType::cmdInitSamplerState;
auto stateWithAppendedParams = FamilyType::cmdInitSamplerState;
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
sampler->appendSamplerStateParams(&stateWithAppendedParams);
sampler->appendSamplerStateParams(&stateWithAppendedParams, *defaultHwInfo);
EXPECT_TRUE(memcmp(&stateWithoutAppendedParams, &stateWithAppendedParams, sizeof(SAMPLER_STATE)) == 0);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -38,7 +38,7 @@ struct MockSampler : public Sampler {
return filterMode;
}
void setArg(void *memory) override {
void setArg(void *memory, const HardwareInfo &hwInfo) override {
}
};
} // namespace NEO

View File

@@ -10,8 +10,11 @@
#include "shared/source/helpers/hw_helper.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/cl_device/cl_device.h"
#include "opencl/source/sampler/sampler.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
using namespace NEO;
@@ -119,3 +122,15 @@ HWTEST_F(HwInfoConfigTest, whenConvertingTimestampsToCsDomainThenNothingIsChange
hwInfoConfig->convertTimestampsFromOaToCsDomain(timestampData);
EXPECT_EQ(initialData, timestampData);
}
HWTEST_F(HwInfoConfigTest, givenSamplerStateWhenAdjustSamplerStateThenNothingIsChanged) {
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
auto hwInfoConfig = HwInfoConfig::get(pInHwInfo.platform.eProductFamily);
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;
auto initialState = state;
hwInfoConfig->adjustSamplerState(&state);
EXPECT_EQ(0, memcmp(&initialState, &state, sizeof(SAMPLER_STATE)));
}

View File

@@ -79,6 +79,9 @@ bool HwInfoConfigHw<IGFX_UNKNOWN>::isEvenContextCountRequired() {
return false;
}
template <>
void HwInfoConfigHw<IGFX_UNKNOWN>::adjustSamplerState(void *sampler){};
template <>
void HwInfoConfigHw<IGFX_UNKNOWN>::convertTimestampsFromOaToCsDomain(uint64_t &timestampData){};
} // namespace NEO

View File

@@ -60,6 +60,9 @@ bool HwInfoConfigHw<IGFX_UNKNOWN>::isEvenContextCountRequired() {
template <>
void HwInfoConfigHw<IGFX_UNKNOWN>::convertTimestampsFromOaToCsDomain(uint64_t &timestampData){};
template <>
void HwInfoConfigHw<IGFX_UNKNOWN>::adjustSamplerState(void *sampler){};
HwInfoConfigTestWindows::HwInfoConfigTestWindows() {
this->executionEnvironment = std::make_unique<MockExecutionEnvironment>();
this->rootDeviceEnvironment = std::make_unique<RootDeviceEnvironment>(*executionEnvironment);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -592,7 +592,7 @@ HWTEST_P(FilterModeTest, WhenSettingKernelArgSamplerThenFiltersAreCorrect) {
ptrOffset(pKernel->getDynamicStateHeap(rootDeviceIndex),
pKernelInfo->kernelArgInfo[0].offsetHeap));
sampler->setArg(const_cast<SAMPLER_STATE *>(samplerState));
sampler->setArg(const_cast<SAMPLER_STATE *>(samplerState), *defaultHwInfo);
if (CL_FILTER_NEAREST == filterMode) {
EXPECT_EQ(SAMPLER_STATE::MIN_MODE_FILTER_NEAREST, samplerState->getMinModeFilter());

View File

@@ -28,6 +28,7 @@ class HwInfoConfig {
int configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface);
virtual int configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) = 0;
virtual void adjustPlatformForProductFamily(HardwareInfo *hwInfo) = 0;
virtual void adjustSamplerState(void *sampler) = 0;
virtual uint64_t getHostMemCapabilities(const HardwareInfo *hwInfo) = 0;
virtual uint64_t getDeviceMemCapabilities() = 0;
virtual uint64_t getSingleDeviceSharedMemCapabilities() = 0;
@@ -47,6 +48,7 @@ class HwInfoConfigHw : public HwInfoConfig {
}
int configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) override;
void adjustPlatformForProductFamily(HardwareInfo *hwInfo) override;
void adjustSamplerState(void *sampler) override;
uint64_t getHostMemCapabilities(const HardwareInfo *hwInfo) override;
uint64_t getDeviceMemCapabilities() override;
uint64_t getSingleDeviceSharedMemCapabilities() override;

View File

@@ -35,6 +35,9 @@ void HwInfoConfigHw<gfxProduct>::convertTimestampsFromOaToCsDomain(uint64_t &tim
template <PRODUCT_FAMILY gfxProduct>
void HwInfoConfigHw<gfxProduct>::adjustPlatformForProductFamily(HardwareInfo *hwInfo) {}
template <PRODUCT_FAMILY gfxProduct>
void HwInfoConfigHw<gfxProduct>::adjustSamplerState(void *sampler) {}
template <PRODUCT_FAMILY gfxProduct>
void HwInfoConfigHw<gfxProduct>::enableRenderCompression(HardwareInfo *hwInfo) {
hwInfo->capabilityTable.ftrRenderCompressedImages = hwInfo->featureTable.ftrE2ECompression;