2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-22 23:39:40 +08:00
|
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 01:46:50 +08:00
|
|
|
#include "gmm_helper/gmm_helper.h"
|
|
|
|
#include "helpers/cache_policy.h"
|
|
|
|
#include "helpers/hw_cmds.h"
|
|
|
|
#include "helpers/state_base_address.h"
|
|
|
|
#include "indirect_heap/indirect_heap.h"
|
|
|
|
#include "memory_manager/memory_constants.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void StateBaseAddressHelper<GfxFamily>::programStateBaseAddress(
|
|
|
|
LinearStream &commandStream,
|
2019-12-06 16:50:33 +08:00
|
|
|
const IndirectHeap *dsh,
|
|
|
|
const IndirectHeap *ioh,
|
|
|
|
const IndirectHeap *ssh,
|
2017-12-21 07:45:38 +08:00
|
|
|
uint64_t generalStateBase,
|
2020-01-22 23:39:40 +08:00
|
|
|
bool setGeneralStateBaseAddress,
|
2018-03-27 18:55:20 +08:00
|
|
|
uint32_t statelessMocsIndex,
|
2018-07-23 18:23:48 +08:00
|
|
|
uint64_t internalHeapBase,
|
2020-01-22 23:39:40 +08:00
|
|
|
bool setInstructionStateBaseAddress,
|
2019-02-15 00:12:15 +08:00
|
|
|
GmmHelper *gmmHelper,
|
2019-12-06 20:28:25 +08:00
|
|
|
bool isMultiOsContextCapable) {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-07-19 20:25:27 +08:00
|
|
|
auto pCmd = static_cast<STATE_BASE_ADDRESS *>(commandStream.getSpace(sizeof(STATE_BASE_ADDRESS)));
|
2019-01-18 00:10:12 +08:00
|
|
|
*pCmd = GfxFamily::cmdInitStateBaseAddress;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-12-06 16:50:33 +08:00
|
|
|
if (dsh) {
|
|
|
|
pCmd->setDynamicStateBaseAddressModifyEnable(true);
|
|
|
|
pCmd->setDynamicStateBufferSizeModifyEnable(true);
|
|
|
|
pCmd->setDynamicStateBaseAddress(dsh->getHeapGpuBase());
|
|
|
|
pCmd->setDynamicStateBufferSize(dsh->getHeapSizeInPages());
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-12-06 16:50:33 +08:00
|
|
|
if (ioh) {
|
|
|
|
pCmd->setIndirectObjectBaseAddressModifyEnable(true);
|
|
|
|
pCmd->setIndirectObjectBufferSizeModifyEnable(true);
|
|
|
|
pCmd->setIndirectObjectBaseAddress(ioh->getHeapGpuBase());
|
|
|
|
pCmd->setIndirectObjectBufferSize(ioh->getHeapSizeInPages());
|
|
|
|
}
|
2018-12-04 22:33:48 +08:00
|
|
|
|
2019-12-06 16:50:33 +08:00
|
|
|
if (ssh) {
|
|
|
|
pCmd->setSurfaceStateBaseAddressModifyEnable(true);
|
|
|
|
pCmd->setSurfaceStateBaseAddress(ssh->getHeapGpuBase());
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-22 23:39:40 +08:00
|
|
|
if (setInstructionStateBaseAddress) {
|
|
|
|
pCmd->setInstructionBaseAddressModifyEnable(true);
|
|
|
|
pCmd->setInstructionBaseAddress(internalHeapBase);
|
|
|
|
pCmd->setInstructionBufferSizeModifyEnable(true);
|
|
|
|
pCmd->setInstructionBufferSize(MemoryConstants::sizeOf4GBinPageEntities);
|
|
|
|
pCmd->setInstructionMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER));
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-22 23:39:40 +08:00
|
|
|
if (setGeneralStateBaseAddress) {
|
|
|
|
pCmd->setGeneralStateBaseAddressModifyEnable(true);
|
|
|
|
pCmd->setGeneralStateBufferSizeModifyEnable(true);
|
|
|
|
// GSH must be set to 0 for stateless
|
|
|
|
pCmd->setGeneralStateBaseAddress(GmmHelper::decanonize(generalStateBase));
|
|
|
|
pCmd->setGeneralStateBufferSize(0xfffff);
|
|
|
|
}
|
2018-04-18 18:42:08 +08:00
|
|
|
|
2019-08-21 20:19:46 +08:00
|
|
|
if (DebugManager.flags.OverrideStatelessMocsIndex.get() != -1) {
|
2019-08-26 21:15:22 +08:00
|
|
|
statelessMocsIndex = DebugManager.flags.OverrideStatelessMocsIndex.get();
|
2019-08-21 20:19:46 +08:00
|
|
|
}
|
2019-08-26 21:15:22 +08:00
|
|
|
|
|
|
|
statelessMocsIndex = statelessMocsIndex << 1;
|
|
|
|
|
|
|
|
pCmd->setStatelessDataPortAccessMemoryObjectControlState(statelessMocsIndex);
|
2018-07-19 20:25:27 +08:00
|
|
|
|
2020-01-22 23:39:40 +08:00
|
|
|
appendStateBaseAddressParameters(pCmd, ssh, setGeneralStateBaseAddress, internalHeapBase, gmmHelper, isMultiOsContextCapable);
|
2018-07-19 20:25:27 +08:00
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|