Skip to content

Commit fe228ea

Browse files
committed
Use GPU address in calculateNewGSH()
Change-Id: I82add7aab4b26444f288a9c4dbce6328578a03d2 Signed-off-by: Pawel Wilma <pawel.wilma@intel.com>
1 parent 13f23df commit fe228ea

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

runtime/command_stream/scratch_space_controller_base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void ScratchSpaceControllerBase::createScratchSpaceAllocation() {
4949
uint64_t ScratchSpaceControllerBase::calculateNewGSH() {
5050
auto &hwHelper = HwHelper::get(hwInfo.pPlatform->eRenderCoreFamily);
5151
auto scratchSpaceOffsetFor64bit = hwHelper.getScratchSpaceOffsetFor64bit();
52-
return reinterpret_cast<uint64_t>(scratchAllocation->getUnderlyingBuffer()) - scratchSpaceOffsetFor64bit;
52+
return scratchAllocation->getGpuAddress() - scratchSpaceOffsetFor64bit;
5353
}
5454
uint64_t ScratchSpaceControllerBase::getScratchPatchAddress() {
5555
//for 32 bit scratch space pointer is being programmed in Media VFE State and is relative to 0 as General State Base Address

unit_tests/command_stream/command_stream_receiver_hw_tests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,19 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsNotRequiredThenScratchAl
219219
EXPECT_FALSE(stateBaseAddressDirty);
220220
EXPECT_EQ(nullptr, scratchController->getScratchSpaceAllocation());
221221
}
222+
223+
HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsRequiredThenCorrectAddressIsReturned) {
224+
auto commandStreamReceiver = std::make_unique<MockCsrHw<FamilyType>>(*platformDevices[0], *pDevice->executionEnvironment);
225+
auto scratchController = commandStreamReceiver->scratchSpaceController.get();
226+
227+
bool cfeStateDirty = false;
228+
bool stateBaseAddressDirty = false;
229+
230+
std::unique_ptr<void, std::function<decltype(alignedFree)>> surfaceHeap(alignedMalloc(0x1000, 0x1000), alignedFree);
231+
scratchController->setRequiredScratchSpace(surfaceHeap.get(), 0x1000u, 0u, 0u, stateBaseAddressDirty, cfeStateDirty);
232+
233+
uint64_t expectedScratchAddress = 0xAAABBBCCCDDD000ull;
234+
scratchController->getScratchSpaceAllocation()->setCpuPtrAndGpuAddress(scratchController->getScratchSpaceAllocation()->getUnderlyingBuffer(), expectedScratchAddress);
235+
236+
EXPECT_EQ(expectedScratchAddress - MemoryConstants::pageSize, scratchController->calculateNewGSH());
237+
}

0 commit comments

Comments
 (0)