Fix overestimation of MediaVfeState in CommandStreamReceiver

Change-Id: I38fd00f6b994f6a62921bcc09f293cabc95773d4
This commit is contained in:
Maciej Dziuban
2018-05-15 09:46:22 +02:00
committed by sys_ocldev
parent e4857867a9
commit 41f570ab50
2 changed files with 32 additions and 12 deletions

View File

@ -85,8 +85,11 @@ inline void CommandStreamReceiverHw<GfxFamily>::alignToCacheLine(LinearStream &c
template <typename GfxFamily>
inline size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdSizeForPreamble() const {
size_t size = sizeof(typename GfxFamily::PIPE_CONTROL) + sizeof(typename GfxFamily::MEDIA_VFE_STATE);
size_t size = 0;
if (mediaVfeStateDirty) {
size += sizeof(typename GfxFamily::PIPE_CONTROL) + sizeof(typename GfxFamily::MEDIA_VFE_STATE);
}
if (!this->isPreambleSent) {
size += PreambleHelper<GfxFamily>::getAdditionalCommandsSize(*memoryManager->device);
}
@ -218,17 +221,6 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
csrSizeRequestFlags.preemptionRequestChanged = this->lastPreemptionMode != dispatchFlags.preemptionMode;
csrSizeRequestFlags.mediaSamplerConfigChanged = this->lastMediaSamplerConfig != static_cast<int8_t>(dispatchFlags.mediaSamplerRequired);
auto &commandStreamCSR = this->getCS(getRequiredCmdStreamSizeAligned(dispatchFlags));
auto commandStreamStartCSR = commandStreamCSR.getUsed();
initPageTableManagerRegisters(commandStreamCSR);
programPreemption(commandStreamCSR, dispatchFlags);
programCoherency(commandStreamCSR, dispatchFlags);
programL3(commandStreamCSR, dispatchFlags, newL3Config);
programPipelineSelect(commandStreamCSR, dispatchFlags);
programPreamble(commandStreamCSR, dispatchFlags, newL3Config);
programMediaSampler(commandStreamCSR, dispatchFlags);
size_t requiredScratchSizeInBytes = requiredScratchSize * (hwInfo.pSysInfo->MaxSubSlicesSupported * hwInfo.pSysInfo->MaxEuPerSubSlice * hwInfo.pSysInfo->ThreadCount / hwInfo.pSysInfo->EUCount);
auto force32BitAllocations = getMemoryManager()->peekForce32BitAllocations();
@ -247,6 +239,17 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
}
}
auto &commandStreamCSR = this->getCS(getRequiredCmdStreamSizeAligned(dispatchFlags));
auto commandStreamStartCSR = commandStreamCSR.getUsed();
initPageTableManagerRegisters(commandStreamCSR);
programPreemption(commandStreamCSR, dispatchFlags);
programCoherency(commandStreamCSR, dispatchFlags);
programL3(commandStreamCSR, dispatchFlags, newL3Config);
programPipelineSelect(commandStreamCSR, dispatchFlags);
programPreamble(commandStreamCSR, dispatchFlags, newL3Config);
programMediaSampler(commandStreamCSR, dispatchFlags);
if (this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
PreambleHelper<GfxFamily>::programThreadArbitration(&commandStreamCSR, this->requiredThreadArbitrationPolicy);
this->lastSentThreadArbitrationPolicy = this->requiredThreadArbitrationPolicy;

View File

@ -98,6 +98,23 @@ HWTEST_F(UltCommandStreamReceiverTest, givenPreambleSentWhenEstimatingPreambleCm
EXPECT_EQ(expectedDifference, actualDifference);
}
HWTEST_F(UltCommandStreamReceiverTest, givenMediaVfeStateDirtyEstimatingPreambleCmdSizeThenResultDependsVfeStateProgrammingCmdSize) {
typedef typename FamilyType::MEDIA_VFE_STATE MEDIA_VFE_STATE;
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
commandStreamReceiver.overrideMediaVFEStateDirty(false);
auto notDirty = commandStreamReceiver.getRequiredCmdSizeForPreamble();
commandStreamReceiver.overrideMediaVFEStateDirty(true);
auto dirty = commandStreamReceiver.getRequiredCmdSizeForPreamble();
auto actualDifference = dirty - notDirty;
auto expectedDifference = sizeof(PIPE_CONTROL) + sizeof(MEDIA_VFE_STATE);
EXPECT_EQ(expectedDifference, actualDifference);
}
HWTEST_F(UltCommandStreamReceiverTest, givenCommandStreamReceiverInInitialStateWhenHeapsAreAskedForDirtyStatusThenTrueIsReturned) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();