diff --git a/level_zero/core/source/sampler/sampler_hw.inl b/level_zero/core/source/sampler/sampler_hw.inl index d5a568b358..77805e6ec0 100644 --- a/level_zero/core/source/sampler/sampler_hw.inl +++ b/level_zero/core/source/sampler/sampler_hw.inl @@ -7,6 +7,7 @@ #pragma once +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/ptr_math.h" #include "shared/source/helpers/string.h" #include "shared/source/utilities/numeric.h" @@ -110,8 +111,8 @@ ze_result_t SamplerCoreFamily::initialize(Device *device, const z samplerState.setMaxLod(maxLodValue.getRawAccess()); auto &hwInfo = device->getHwInfo(); - - NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily)->adjustSamplerState(&samplerState, hwInfo); + auto &helper = device->getNEODevice()->getRootDeviceEnvironment().getHelper(); + helper.adjustSamplerState(&samplerState, hwInfo); return ZE_RESULT_SUCCESS; } diff --git a/opencl/source/helpers/hardware_commands_helper_base.inl b/opencl/source/helpers/hardware_commands_helper_base.inl index bf4a6d148a..5626927823 100644 --- a/opencl/source/helpers/hardware_commands_helper_base.inl +++ b/opencl/source/helpers/hardware_commands_helper_base.inl @@ -240,7 +240,7 @@ size_t HardwareCommandsHelper::sendIndirectState( samplerStateOffset = EncodeStates::copySamplerState(&dsh, samplerTable.tableOffset, samplerCount, samplerTable.borderColor, kernel.getDynamicStateHeap(), device.getBindlessHeapsHelper(), - device.getHardwareInfo()); + device.getRootDeviceEnvironment()); } auto localWorkItems = localWorkSize[0] * localWorkSize[1] * localWorkSize[2]; diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index ae8cb42702..7a9767de07 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -1248,7 +1248,7 @@ void Kernel::setInlineSamplers() { UNRECOVERABLE_IF(errCode != CL_SUCCESS); auto samplerState = ptrOffset(getDynamicStateHeap(), static_cast(inlineSampler.getSamplerBindfulOffset())); - sampler->setArg(const_cast(samplerState), clDevice.getHardwareInfo()); + sampler->setArg(const_cast(samplerState), clDevice.getRootDeviceEnvironment()); } } @@ -1717,7 +1717,7 @@ cl_int Kernel::setArgSampler(uint32_t argIndex, auto dsh = getDynamicStateHeap(); auto samplerState = ptrOffset(dsh, argAsSmp.bindful); - pSampler->setArg(const_cast(samplerState), clDevice.getHardwareInfo()); + pSampler->setArg(const_cast(samplerState), clDevice.getRootDeviceEnvironment()); patch(pSampler->getSnapWaValue(), crossThreadData, argAsSmp.metadataPayload.samplerSnapWa); patch(getAddrModeEnum(pSampler->addressingMode), crossThreadData, argAsSmp.metadataPayload.samplerAddressingMode); diff --git a/opencl/source/sampler/sampler.h b/opencl/source/sampler/sampler.h index 9659239312..0f997187a6 100644 --- a/opencl/source/sampler/sampler.h +++ b/opencl/source/sampler/sampler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,6 +14,7 @@ namespace NEO { class Context; struct HardwareInfo; +struct RootDeviceEnvironment; template <> struct OpenCLObjectMapper<_cl_sampler> { @@ -50,7 +51,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, const HardwareInfo &hwInfo) = 0; + virtual void setArg(void *memory, const RootDeviceEnvironment &rootDeviceEnvironment) = 0; bool isTransformable() const; @@ -85,7 +86,7 @@ class Sampler : public BaseObject<_cl_sampler> { template struct SamplerHw : public Sampler { - void setArg(void *memory, const HardwareInfo &hwInfo) override; + void setArg(void *memory, const RootDeviceEnvironment &rootDeviceEnvironment) override; static constexpr float getGenSamplerMaxLod() { return 14.0f; } diff --git a/opencl/source/sampler/sampler.inl b/opencl/source/sampler/sampler.inl index 233d45c3ce..633bc3b365 100644 --- a/opencl/source/sampler/sampler.inl +++ b/opencl/source/sampler/sampler.inl @@ -5,6 +5,7 @@ * */ +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/populate_factory.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/utilities/numeric.h" @@ -14,7 +15,7 @@ namespace NEO { template -void SamplerHw::setArg(void *memory, const HardwareInfo &hwInfo) { +void SamplerHw::setArg(void *memory, const RootDeviceEnvironment &rootDeviceEnvironment) { using SAMPLER_STATE = typename GfxFamily::SAMPLER_STATE; auto samplerState = reinterpret_cast(memory); samplerState->setNonNormalizedCoordinateEnable(!this->normalizedCoordinates); @@ -90,6 +91,8 @@ void SamplerHw::setArg(void *memory, const HardwareInfo &hwInfo) { samplerState->setMinLod(minLodValue.getRawAccess()); samplerState->setMaxLod(maxLodValue.getRawAccess()); - HwInfoConfig::get(hwInfo.platform.eProductFamily)->adjustSamplerState(samplerState, hwInfo); + auto &helper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + helper.adjustSamplerState(samplerState, hwInfo); } } // namespace NEO diff --git a/opencl/test/unit_test/fixtures/cl_device_fixture.cpp b/opencl/test/unit_test/fixtures/cl_device_fixture.cpp index d92cdf49e6..862bf7cbaa 100644 --- a/opencl/test/unit_test/fixtures/cl_device_fixture.cpp +++ b/opencl/test/unit_test/fixtures/cl_device_fixture.cpp @@ -41,4 +41,13 @@ MockDevice *ClDeviceFixture::createWithUsDeviceId(unsigned short usDeviceId) { hardwareInfo.platform.usDeviceID = usDeviceId; return MockDevice::createWithNewExecutionEnvironment(&hardwareInfo, rootDeviceIndex); } + +template +HelperType &ClDeviceFixture::getHelper() const { + auto &helper = pClDevice->getRootDeviceEnvironment().getHelper(); + return helper; +} + +template ProductHelper &ClDeviceFixture::getHelper() const; + } // namespace NEO diff --git a/opencl/test/unit_test/fixtures/cl_device_fixture.h b/opencl/test/unit_test/fixtures/cl_device_fixture.h index 56363b401f..87af870e6b 100644 --- a/opencl/test/unit_test/fixtures/cl_device_fixture.h +++ b/opencl/test/unit_test/fixtures/cl_device_fixture.h @@ -20,6 +20,9 @@ struct ClDeviceFixture { MockDevice *createWithUsDeviceId(unsigned short usDeviceId); + template + 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 diff --git a/opencl/test/unit_test/mocks/mock_sampler.h b/opencl/test/unit_test/mocks/mock_sampler.h index 300c927921..362f87cd18 100644 --- a/opencl/test/unit_test/mocks/mock_sampler.h +++ b/opencl/test/unit_test/mocks/mock_sampler.h @@ -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 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 57170a70d5..4dbef3898c 100644 --- a/opencl/test/unit_test/sampler/sampler_set_arg_tests.cpp +++ b/opencl/test/unit_test/sampler/sampler_set_arg_tests.cpp @@ -581,7 +581,7 @@ HWTEST_P(FilterModeTest, WhenSettingKernelArgSamplerThenFiltersAreCorrect) { ptrOffset(pKernel->getDynamicStateHeap(), pKernelInfo->argAsSmp(0).bindful)); - sampler->setArg(const_cast(samplerState), *defaultHwInfo); + sampler->setArg(const_cast(samplerState), pClDevice->getRootDeviceEnvironment()); if (CL_FILTER_NEAREST == filterMode) { EXPECT_EQ(SAMPLER_STATE::MIN_MODE_FILTER_NEAREST, samplerState->getMinModeFilter()); diff --git a/opencl/test/unit_test/xe_hp_core/xehp/sampler_tests_xehp.inl b/opencl/test/unit_test/xe_hp_core/xehp/sampler_tests_xehp.inl index f083cfa99b..a46f9d0784 100644 --- a/opencl/test/unit_test/xe_hp_core/xehp/sampler_tests_xehp.inl +++ b/opencl/test/unit_test/xe_hp_core/xehp/sampler_tests_xehp.inl @@ -16,24 +16,31 @@ using namespace NEO; -typedef Test XeHPSamplerTest; +using XeHPSamplerTest = Test; 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(); + 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(); + helper.adjustSamplerState(&state, *defaultHwInfo); EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE, state.getLowQualityFilter()); } diff --git a/opencl/test/unit_test/xe_hpg_core/dg2/sampler_tests_dg2.cpp b/opencl/test/unit_test/xe_hpg_core/dg2/sampler_tests_dg2.cpp index 0753b65678..7dc087e9a1 100644 --- a/opencl/test/unit_test/xe_hpg_core/dg2/sampler_tests_dg2.cpp +++ b/opencl/test/unit_test/xe_hpg_core/dg2/sampler_tests_dg2.cpp @@ -22,40 +22,46 @@ using namespace NEO; using SamplerTest = Test; HWTEST2_F(SamplerTest, givenDg2SamplerWhenUsingDefaultFilteringAndAppendSamplerStateParamsThenNotEnableLowQualityFilter, IsDG2) { + using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; + auto &helper = getHelper(); + 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(); 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(); 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(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(); 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(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(); 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(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()); } diff --git a/shared/source/command_container/command_encoder.h b/shared/source/command_container/command_encoder.h index c15a83cb02..6d4ecac8fa 100644 --- a/shared/source/command_container/command_encoder.h +++ b/shared/source/command_container/command_encoder.h @@ -149,7 +149,7 @@ struct EncodeStates { uint32_t borderColorOffset, const void *fnDynamicStateHeap, BindlessHeapsHelper *bindlessHeapHelper, - const HardwareInfo &hwInfo); + const RootDeviceEnvironment &rootDeviceEnvironment); }; template diff --git a/shared/source/command_container/command_encoder.inl b/shared/source/command_container/command_encoder.inl index 82a54f56d8..9f83dc9fab 100644 --- a/shared/source/command_container/command_encoder.inl +++ b/shared/source/command_container/command_encoder.inl @@ -42,7 +42,7 @@ uint32_t EncodeStates::copySamplerState(IndirectHeap *dsh, uint32_t borderColorOffset, const void *fnDynamicStateHeap, BindlessHeapsHelper *bindlessHeapHelper, - const HardwareInfo &hwInfo) { + const RootDeviceEnvironment &rootDeviceEnvironment) { auto sizeSamplerState = sizeof(SAMPLER_STATE) * samplerCount; auto borderColorSize = samplerStateOffset - borderColorOffset; @@ -80,14 +80,14 @@ uint32_t EncodeStates::copySamplerState(IndirectHeap *dsh, samplerStateOffsetInDsh = static_cast(samplerStateInDsh.surfaceStateOffset); } + auto &helper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); auto srcSamplerState = reinterpret_cast(ptrOffset(fnDynamicStateHeap, samplerStateOffset)); SAMPLER_STATE state = {}; for (uint32_t i = 0; i < samplerCount; i++) { state = srcSamplerState[i]; state.setIndirectStatePointer(static_cast(borderColorOffsetInDsh)); - - HwInfoConfig::get(hwInfo.platform.eProductFamily)->adjustSamplerState(&state, hwInfo); - + helper.adjustSamplerState(&state, hwInfo); dstSamplerState[i] = state; } diff --git a/shared/source/command_container/command_encoder_bdw_and_later.inl b/shared/source/command_container/command_encoder_bdw_and_later.inl index d512b5a209..f270c2864c 100644 --- a/shared/source/command_container/command_encoder_bdw_and_later.inl +++ b/shared/source/command_container/command_encoder_bdw_and_later.inl @@ -116,7 +116,7 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis kernelDescriptor.payloadMappings.samplerTable.numSamplers, kernelDescriptor.payloadMappings.samplerTable.borderColor, args.dispatchInterface->getDynamicStateHeapData(), - args.device->getBindlessHeapsHelper(), hwInfo); + args.device->getBindlessHeapsHelper(), args.device->getRootDeviceEnvironment()); } idd.setSamplerStatePointer(samplerStateOffset); diff --git a/shared/source/command_container/command_encoder_xehp_and_later.inl b/shared/source/command_container/command_encoder_xehp_and_later.inl index 02658118a1..1773e5535c 100644 --- a/shared/source/command_container/command_encoder_xehp_and_later.inl +++ b/shared/source/command_container/command_encoder_xehp_and_later.inl @@ -141,7 +141,7 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis heap, kernelDescriptor.payloadMappings.samplerTable.tableOffset, kernelDescriptor.payloadMappings.samplerTable.numSamplers, kernelDescriptor.payloadMappings.samplerTable.borderColor, args.dispatchInterface->getDynamicStateHeapData(), - args.device->getBindlessHeapsHelper(), hwInfo); + args.device->getBindlessHeapsHelper(), args.device->getRootDeviceEnvironment()); if (ApiSpecificConfig::getBindlessConfiguration()) { container.getResidencyContainer().push_back(args.device->getBindlessHeapsHelper()->getHeap(NEO::BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH)->getGraphicsAllocation()); } diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index 50b3f14018..7475394299 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -88,7 +88,8 @@ bool Wddm::init() { if (!hardwareInfoTable[productFamily]) { return false; } - auto hardwareInfo = std::make_unique(); + + auto hardwareInfo = rootDeviceEnvironment.getMutableHardwareInfo(); hardwareInfo->platform = *gfxPlatform; hardwareInfo->featureTable = *featureTable; hardwareInfo->workaroundTable = *workaroundTable; @@ -99,17 +100,16 @@ bool Wddm::init() { hardwareInfo->capabilityTable.instrumentationEnabled = (hardwareInfo->capabilityTable.instrumentationEnabled && instrumentationEnabled); - HwInfoConfig *hwConfig = HwInfoConfig::get(productFamily); - - hwConfig->adjustPlatformForProductFamily(hardwareInfo.get()); - if (hwConfig->configureHwInfoWddm(hardwareInfo.get(), hardwareInfo.get(), nullptr)) { + auto &productHelper = rootDeviceEnvironment.getHelper(); + productHelper.adjustPlatformForProductFamily(hardwareInfo); + if (productHelper.configureHwInfoWddm(hardwareInfo, hardwareInfo, nullptr)) { return false; } - setPlatformSupportEvictIfNecessaryFlag(*hwConfig); + setPlatformSupportEvictIfNecessaryFlag(productHelper); auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*hardwareInfo); populateIpVersion(*hardwareInfo); - rootDeviceEnvironment.setHwInfo(hardwareInfo.get()); + rootDeviceEnvironment.initGmm(); this->rootDeviceEnvironment.getGmmClientContext()->setHandleAllocator(this->hwDeviceId->getUmKmDataTranslator()->createGmmHandleAllocator()); diff --git a/shared/test/unit_test/encoders/test_encode_states.cpp b/shared/test/unit_test/encoders/test_encode_states.cpp index fac1287d20..10aec2a754 100644 --- a/shared/test/unit_test/encoders/test_encode_states.cpp +++ b/shared/test/unit_test/encoders/test_encode_states.cpp @@ -35,7 +35,7 @@ HWTEST_F(CommandEncodeStatesTest, GivenCommandStreamWhenEncodeCopySamplerStateTh auto dsh = cmdContainer->getIndirectHeap(HeapType::DYNAMIC_STATE); auto usedBefore = dsh->getUsed(); - auto samplerStateOffset = EncodeStates::copySamplerState(dsh, 0, numSamplers, 0, &samplerState, nullptr, pDevice->getHardwareInfo()); + auto samplerStateOffset = EncodeStates::copySamplerState(dsh, 0, numSamplers, 0, &samplerState, nullptr, pDevice->getRootDeviceEnvironment()); auto pSmplr = reinterpret_cast(ptrOffset(dsh->getCpuBase(), samplerStateOffset)); EXPECT_EQ(pSmplr->getIndirectStatePointer(), usedBefore); @@ -59,7 +59,7 @@ HWTEST2_F(CommandEncodeStatesTest, givenDebugVariableSetWhenCopyingSamplerStateT auto dsh = cmdContainer->getIndirectHeap(HeapType::DYNAMIC_STATE); - auto samplerStateOffset = EncodeStates::copySamplerState(dsh, 0, numSamplers, 0, &samplerState, nullptr, pDevice->getHardwareInfo()); + auto samplerStateOffset = EncodeStates::copySamplerState(dsh, 0, numSamplers, 0, &samplerState, nullptr, pDevice->getRootDeviceEnvironment()); auto pSamplerState = reinterpret_cast(ptrOffset(dsh->getCpuBase(), samplerStateOffset)); EXPECT_EQ(pSamplerState->getLowQualityFilter(), SAMPLER_STATE::LOW_QUALITY_FILTER_ENABLE); @@ -81,7 +81,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWit SAMPLER_BORDER_COLOR_STATE samplerState; samplerState.init(); auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH); - EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getHardwareInfo()); + EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getRootDeviceEnvironment()); auto expectedValue = pDevice->getBindlessHeapsHelper()->getDefaultBorderColorOffset(); auto pSmplr = reinterpret_cast(dsh->getGraphicsAllocation()->getUnderlyingBuffer()); @@ -104,7 +104,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWit samplerState.init(); samplerState.setBorderColorAlpha(1.0); auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH); - EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getHardwareInfo()); + EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getRootDeviceEnvironment()); auto expectedValue = pDevice->getBindlessHeapsHelper()->getAlphaBorderColorOffset(); auto pSmplr = reinterpret_cast(dsh->getGraphicsAllocation()->getUnderlyingBuffer()); @@ -127,7 +127,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsRe samplerState.init(); samplerState.setBorderColorRed(0.5); auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH); - EXPECT_THROW(EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getHardwareInfo()), std::exception); + EXPECT_THROW(EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getRootDeviceEnvironment()), std::exception); } HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsGreenChanelIsNotZeroThenExceptionThrown) { @@ -146,7 +146,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsGr samplerState.init(); samplerState.setBorderColorGreen(0.5); auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH); - EXPECT_THROW(EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getHardwareInfo()), std::exception); + EXPECT_THROW(EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getRootDeviceEnvironment()), std::exception); } HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsBlueChanelIsNotZeroThenExceptionThrown) { @@ -164,7 +164,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsBl samplerState.init(); samplerState.setBorderColorBlue(0.5); auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH); - EXPECT_THROW(EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getHardwareInfo()), std::exception); + EXPECT_THROW(EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getRootDeviceEnvironment()), std::exception); } HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsAlphaChanelIsNotZeroOrOneThenExceptionThrown) { @@ -183,7 +183,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsAl samplerState.init(); samplerState.setBorderColorAlpha(0.5); auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH); - EXPECT_THROW(EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getHardwareInfo()), std::exception); + EXPECT_THROW(EncodeStates::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper(), pDevice->getRootDeviceEnvironment()), std::exception); } HWTEST_F(CommandEncodeStatesTest, givenCreatedSurfaceStateBufferWhenAllocationProvidedThenUseAllocationAsInput) { diff --git a/shared/test/unit_test/gen12lp/windows/hw_info_config_tests_gen12lp.cpp b/shared/test/unit_test/gen12lp/windows/hw_info_config_tests_gen12lp.cpp index ca3c206e78..8ad3c9b4aa 100644 --- a/shared/test/unit_test/gen12lp/windows/hw_info_config_tests_gen12lp.cpp +++ b/shared/test/unit_test/gen12lp/windows/hw_info_config_tests_gen12lp.cpp @@ -13,60 +13,60 @@ using namespace NEO; -using HwInfoConfigTestWindowsGen12lp = HwInfoConfigTestWindows; +using ProductHelperTestWindowsGen12lp = HwInfoConfigTestWindows; -GEN12LPTEST_F(HwInfoConfigTestWindowsGen12lp, givenE2ECSetByKmdWhenConfiguringHwThenAdjustInternalImageFlag) { +GEN12LPTEST_F(ProductHelperTestWindowsGen12lp, givenE2ECSetByKmdWhenConfiguringHwThenAdjustInternalImageFlag) { FeatureTable &localFeatureTable = outHwInfo.featureTable; - auto &hwInfoConfig = rootDeviceEnvironment->getHwInfoConfig(); + auto &helper = getHelper(); localFeatureTable.flags.ftrE2ECompression = true; - hwInfoConfig.configureHardwareCustom(&outHwInfo, nullptr); + helper.configureHardwareCustom(&outHwInfo, nullptr); EXPECT_TRUE(outHwInfo.capabilityTable.ftrRenderCompressedBuffers); EXPECT_TRUE(outHwInfo.capabilityTable.ftrRenderCompressedImages); localFeatureTable.flags.ftrE2ECompression = false; - hwInfoConfig.configureHardwareCustom(&outHwInfo, nullptr); + helper.configureHardwareCustom(&outHwInfo, nullptr); EXPECT_FALSE(outHwInfo.capabilityTable.ftrRenderCompressedBuffers); EXPECT_FALSE(outHwInfo.capabilityTable.ftrRenderCompressedImages); } -GEN12LPTEST_F(HwInfoConfigTestWindowsGen12lp, givenGen12LpProductWhenAdjustPlatformForProductFamilyCalledThenOverrideWithCorrectFamily) { - auto hwInfoConfig = HwInfoConfig::get(productFamily); +GEN12LPTEST_F(ProductHelperTestWindowsGen12lp, givenGen12LpProductWhenAdjustPlatformForProductFamilyCalledThenOverrideWithCorrectFamily) { + auto &helper = getHelper(); PLATFORM *testPlatform = &outHwInfo.platform; testPlatform->eDisplayCoreFamily = IGFX_GEN11_CORE; testPlatform->eRenderCoreFamily = IGFX_GEN11_CORE; - hwInfoConfig->adjustPlatformForProductFamily(&outHwInfo); + helper.adjustPlatformForProductFamily(&outHwInfo); EXPECT_EQ(IGFX_GEN12LP_CORE, testPlatform->eRenderCoreFamily); EXPECT_EQ(IGFX_GEN12LP_CORE, testPlatform->eDisplayCoreFamily); } -GEN12LPTEST_F(HwInfoConfigTestWindowsGen12lp, givenCompressionFtrEnabledWhenAskingForPageTableManagerThenReturnCorrectValue) { - const auto &hwInfoConfig = *HwInfoConfig::get(productFamily); +GEN12LPTEST_F(ProductHelperTestWindowsGen12lp, givenCompressionFtrEnabledWhenAskingForPageTableManagerThenReturnCorrectValue) { + auto &helper = getHelper(); outHwInfo.capabilityTable.ftrRenderCompressedBuffers = false; outHwInfo.capabilityTable.ftrRenderCompressedImages = false; - EXPECT_FALSE(hwInfoConfig.isPageTableManagerSupported(outHwInfo)); + EXPECT_FALSE(helper.isPageTableManagerSupported(outHwInfo)); outHwInfo.capabilityTable.ftrRenderCompressedBuffers = true; outHwInfo.capabilityTable.ftrRenderCompressedImages = false; - EXPECT_TRUE(hwInfoConfig.isPageTableManagerSupported(outHwInfo)); + EXPECT_TRUE(helper.isPageTableManagerSupported(outHwInfo)); outHwInfo.capabilityTable.ftrRenderCompressedBuffers = false; outHwInfo.capabilityTable.ftrRenderCompressedImages = true; - EXPECT_TRUE(hwInfoConfig.isPageTableManagerSupported(outHwInfo)); + EXPECT_TRUE(helper.isPageTableManagerSupported(outHwInfo)); outHwInfo.capabilityTable.ftrRenderCompressedBuffers = true; outHwInfo.capabilityTable.ftrRenderCompressedImages = true; - EXPECT_TRUE(hwInfoConfig.isPageTableManagerSupported(outHwInfo)); + EXPECT_TRUE(helper.isPageTableManagerSupported(outHwInfo)); } -GEN12LPTEST_F(HwInfoConfigTestWindowsGen12lp, givenGen12LpSkuWhenGettingCapabilityCoherencyFlagThenExpectValidValue) { - auto &hwInfoConfig = *HwInfoConfig::get(productFamily); +GEN12LPTEST_F(ProductHelperTestWindowsGen12lp, givenGen12LpSkuWhenGettingCapabilityCoherencyFlagThenExpectValidValue) { + auto &helper = getHelper(); bool coherency = false; - hwInfoConfig.setCapabilityCoherencyFlag(outHwInfo, coherency); + helper.setCapabilityCoherencyFlag(outHwInfo, coherency); const bool checkDone = SpecialUltHelperGen12lp::additionalCoherencyCheck(outHwInfo.platform.eProductFamily, coherency); if (checkDone) { EXPECT_FALSE(coherency); @@ -74,11 +74,11 @@ GEN12LPTEST_F(HwInfoConfigTestWindowsGen12lp, givenGen12LpSkuWhenGettingCapabili } if (SpecialUltHelperGen12lp::isAdditionalCapabilityCoherencyFlagSettingRequired(outHwInfo.platform.eProductFamily)) { - outHwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_A1, outHwInfo); - hwInfoConfig.setCapabilityCoherencyFlag(outHwInfo, coherency); + outHwInfo.platform.usRevId = helper.getHwRevIdFromStepping(REVISION_A1, outHwInfo); + helper.setCapabilityCoherencyFlag(outHwInfo, coherency); EXPECT_TRUE(coherency); - outHwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_A0, outHwInfo); - hwInfoConfig.setCapabilityCoherencyFlag(outHwInfo, coherency); + outHwInfo.platform.usRevId = helper.getHwRevIdFromStepping(REVISION_A0, outHwInfo); + helper.setCapabilityCoherencyFlag(outHwInfo, coherency); EXPECT_FALSE(coherency); } else { EXPECT_TRUE(coherency); diff --git a/shared/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp b/shared/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp index 235ba7f4c1..c561d65c41 100644 --- a/shared/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp @@ -39,6 +39,15 @@ void HwInfoConfigTestWindows::TearDown() { HwInfoConfigTest::TearDown(); } +template +HelperType &HwInfoConfigTestWindows::getHelper() const { + auto &helper = rootDeviceEnvironment->getHelper(); + return helper; +} + +template ProductHelper &HwInfoConfigTestWindows::getHelper() const; +template CoreHelper &HwInfoConfigTestWindows::getHelper() const; + TEST_F(HwInfoConfigTestWindows, givenCorrectParametersWhenConfiguringHwInfoThenReturnSuccess) { int ret = hwConfig.configureHwInfoWddm(&pInHwInfo, &outHwInfo, osInterface.get()); EXPECT_EQ(0, ret); diff --git a/shared/test/unit_test/os_interface/windows/hw_info_config_win_tests.h b/shared/test/unit_test/os_interface/windows/hw_info_config_win_tests.h index 7c08418d9b..82b98dfc89 100644 --- a/shared/test/unit_test/os_interface/windows/hw_info_config_win_tests.h +++ b/shared/test/unit_test/os_interface/windows/hw_info_config_win_tests.h @@ -29,6 +29,9 @@ struct HwInfoConfigTestWindows : public HwInfoConfigTest { MockHwInfoConfigHw hwConfig; std::unique_ptr executionEnvironment; std::unique_ptr rootDeviceEnvironment; + + template + HelperType &getHelper() const; }; } // namespace NEO