diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index afb57cba13..19d953db1d 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -2026,8 +2026,9 @@ size_t CommandListCoreFamilyImmediate::estimateAdditionalSizeAppe totalNoopSpace += cmdList->getInOrderExecDeviceRequiredSize(); totalNoopSpace += cmdList->getInOrderExecHostRequiredSize(); } - const size_t noopEncodeSize = NEO::EncodeDataMemory::getCommandSizeForEncode(totalNoopSpace); - additionalSize += noopEncodeSize; + if (totalNoopSpace > 0) { + additionalSize += NEO::EncodeDataMemory::getCommandSizeForEncode(totalNoopSpace); + } } return additionalSize; } diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl index 806c07e876..af068ad0bf 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl @@ -921,11 +921,14 @@ template size_t CommandQueueHw::estimateCommandListPatchPreambleFrontEndCmd(CommandListExecutionContext &ctx, CommandList *commandList) { size_t encodeSize = 0; if (this->patchingPreamble) { - const size_t feCmdSize = NEO::PreambleHelper::getVFECommandsSize(); - size_t singleFeCmdEncodeSize = NEO::EncodeDataMemory::getCommandSizeForEncode(feCmdSize); + uint32_t feCmdCount = commandList->getFrontEndPatchListCount(); + if (feCmdCount > 0) { + const size_t feCmdSize = NEO::PreambleHelper::getVFECommandsSize(); + size_t singleFeCmdEncodeSize = NEO::EncodeDataMemory::getCommandSizeForEncode(feCmdSize); - encodeSize = singleFeCmdEncodeSize * commandList->getFrontEndPatchListCount(); - ctx.bufferSpaceForPatchPreamble += encodeSize; + encodeSize = singleFeCmdEncodeSize * feCmdCount; + ctx.bufferSpaceForPatchPreamble += encodeSize; + } } return encodeSize; } @@ -950,12 +953,16 @@ template inline size_t CommandQueueHw::estimateTotalPatchPreambleData(CommandListExecutionContext &ctx) { size_t encodeSize = 0; if (this->patchingPreamble) { - encodeSize = NEO::EncodeDataMemory::getCommandSizeForEncode(ctx.totalNoopSpaceForPatchPreamble); + if (ctx.totalNoopSpaceForPatchPreamble > 0) { + encodeSize = NEO::EncodeDataMemory::getCommandSizeForEncode(ctx.totalNoopSpaceForPatchPreamble); + } - const size_t qwordEncodeSize = NEO::EncodeDataMemory::getCommandSizeForEncode(sizeof(uint64_t)); - size_t patchScratchElemsEncodeSize = qwordEncodeSize * ctx.totalActiveScratchPatchElements; + if (ctx.totalActiveScratchPatchElements > 0) { + const size_t qwordEncodeSize = NEO::EncodeDataMemory::getCommandSizeForEncode(sizeof(uint64_t)); + size_t patchScratchElemsEncodeSize = qwordEncodeSize * ctx.totalActiveScratchPatchElements; - encodeSize += patchScratchElemsEncodeSize; + encodeSize += patchScratchElemsEncodeSize; + } ctx.bufferSpaceForPatchPreamble += encodeSize; } return encodeSize; @@ -964,9 +971,7 @@ inline size_t CommandQueueHw::estimateTotalPatchPreambleData(Comm template inline void CommandQueueHw::getCommandListPatchPreambleData(CommandListExecutionContext &ctx, CommandList *commandList) { if (this->patchingPreamble) { - const size_t totalNoopSize = commandList->getTotalNoopSpace(); - ctx.totalNoopSpaceForPatchPreamble += totalNoopSize; - + ctx.totalNoopSpaceForPatchPreamble += commandList->getTotalNoopSpace(); ctx.totalActiveScratchPatchElements += commandList->getActiveScratchPatchElements(); } }