LOCI-3365: Cleanup MediaInterfaceDescriptorLoad logic in command encoder

Add a patch to command encoder when DSH is dirty.

Signed-off-by: Tratnack, Geoffrey <geoffrey.tratnack@intel.com>
Related-To: LOCI-3365
This commit is contained in:
Tratnack, Geoffrey 2022-11-07 20:01:57 +00:00 committed by Compute-Runtime-Automation
parent db24428cd3
commit 818db03a68
5 changed files with 17 additions and 32 deletions

View File

@ -189,10 +189,14 @@ size_t CommandContainer::getTotalCmdBufferSize() {
void *CommandContainer::getHeapSpaceAllowGrow(HeapType heapType,
size_t size) {
return getHeapWithRequiredSizeAndAlignment(heapType, size, 0)->getSpace(size);
return getHeapWithRequiredSize(heapType, size, 0, true)->getSpace(size);
}
IndirectHeap *CommandContainer::getHeapWithRequiredSizeAndAlignment(HeapType heapType, size_t sizeRequired, size_t alignment) {
return getHeapWithRequiredSize(heapType, sizeRequired, alignment, false);
}
IndirectHeap *CommandContainer::getHeapWithRequiredSize(HeapType heapType, size_t sizeRequired, size_t alignment, bool allowGrow) {
auto indirectHeap = getIndirectHeap(heapType);
UNRECOVERABLE_IF(indirectHeap == nullptr);
auto sizeRequested = sizeRequired;
@ -207,7 +211,9 @@ IndirectHeap *CommandContainer::getHeapWithRequiredSizeAndAlignment(HeapType hea
} else {
if (indirectHeap->getAvailableSpace() < sizeRequested) {
size_t newSize = indirectHeap->getUsed() + indirectHeap->getAvailableSpace();
newSize = std::max(newSize, indirectHeap->getAvailableSpace() + sizeRequested);
if (allowGrow) {
newSize = std::max(newSize, indirectHeap->getAvailableSpace() + sizeRequested);
}
newSize = alignUp(newSize, MemoryConstants::pageSize);
auto oldAlloc = getIndirectHeapAllocation(heapType);
this->createAndAssignNewHeap(heapType, newSize);

View File

@ -129,6 +129,7 @@ class CommandContainer : public NonCopyableOrMovableClass {
protected:
size_t getTotalCmdBufferSize();
IndirectHeap *getHeapWithRequiredSize(HeapType heapType, size_t sizeRequired, size_t alignment, bool allowGrow);
void createAndAssignNewHeap(HeapType heapType, size_t size);
GraphicsAllocation *allocationIndirectHeaps[HeapType::NUM_TYPES] = {};
std::unique_ptr<IndirectHeap> indirectHeaps[HeapType::NUM_TYPES];

View File

@ -89,7 +89,7 @@ struct EncodeDispatchKernel {
static void setGrfInfo(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, uint32_t numGrf, const size_t &sizeCrossThreadData,
const size_t &sizePerThreadData, const HardwareInfo &hwInfo);
static void *getInterfaceDescriptor(CommandContainer &container, uint32_t &iddOffset, const HardwareInfo &hwInfo);
static void *getInterfaceDescriptor(CommandContainer &container, uint32_t &iddOffset);
static bool isRuntimeLocalIdsGenerationRequired(uint32_t activeChannels,
const size_t *lws,

View File

@ -542,9 +542,7 @@ template <typename Family>
void EncodeSurfaceState<Family>::encodeImplicitScalingParams(const EncodeSurfaceStateArgs &args) {}
template <typename Family>
void *EncodeDispatchKernel<Family>::getInterfaceDescriptor(CommandContainer &container, uint32_t &iddOffset, const HardwareInfo &hwInfo) {
using STATE_BASE_ADDRESS = typename Family::STATE_BASE_ADDRESS;
void *EncodeDispatchKernel<Family>::getInterfaceDescriptor(CommandContainer &container, uint32_t &iddOffset) {
if (container.nextIddInBlock == container.getNumIddPerBlock()) {
if (ApiSpecificConfig::getBindlessConfiguration()) {
@ -556,26 +554,6 @@ void *EncodeDispatchKernel<Family>::getInterfaceDescriptor(CommandContainer &con
sizeof(INTERFACE_DESCRIPTOR_DATA) * container.getNumIddPerBlock()));
}
container.nextIddInBlock = 0;
if (container.isHeapDirty(HeapType::DYNAMIC_STATE)) {
PipeControlArgs syncArgs;
syncArgs.dcFlushEnable = MemorySynchronizationCommands<Family>::getDcFlushEnable(true, hwInfo);
syncArgs.hdcPipelineFlush = true;
MemorySynchronizationCommands<Family>::addSingleBarrier(*container.getCommandStream(), syncArgs);
STATE_BASE_ADDRESS sba;
EncodeStateBaseAddressArgs<Family> encodeStateBaseAddressArgs = {
&container,
sba,
0,
false,
false,
false};
EncodeStateBaseAddress<Family>::encode(encodeStateBaseAddressArgs);
container.setDirtyStateForAllHeaps(false);
}
EncodeMediaInterfaceDescriptorLoad<Family>::encode(container);
}
iddOffset = container.nextIddInBlock;

View File

@ -167,6 +167,9 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container, EncodeDis
args.dispatchInterface->getPerThreadData(), sizePerThreadDataForWholeGroup);
}
uint32_t numIDD = 0u;
void *iddPtr = getInterfaceDescriptor(container, numIDD);
auto slmSizeNew = args.dispatchInterface->getSlmTotalSize();
bool dirtyHeaps = container.isAnyHeapDirty();
bool flush = container.slmSize != slmSizeNew || dirtyHeaps || args.requiresUncachedMocs;
@ -200,15 +203,12 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container, EncodeDis
if (container.slmSize != slmSizeNew) {
EncodeL3State<Family>::encode(container, slmSizeNew != 0u);
container.slmSize = slmSizeNew;
if (container.nextIddInBlock != container.getNumIddPerBlock()) {
EncodeMediaInterfaceDescriptorLoad<Family>::encode(container);
}
}
}
uint32_t numIDD = 0u;
void *iddPtr = getInterfaceDescriptor(container, numIDD, hwInfo);
if (numIDD == 0 || flush) {
EncodeMediaInterfaceDescriptorLoad<Family>::encode(container);
}
cmd.setIndirectDataStartAddress(static_cast<uint32_t>(offsetThreadData));
cmd.setIndirectDataLength(sizeThreadData);