Skip to content

Commit 52dc359

Browse files
Return zero as scratch required GSBA when no scratch allocation present
Change-Id: Idc59b6d0193b7310d9330432df8ccf300a93a912 Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent b64210d commit 52dc359

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

runtime/command_stream/scratch_space_controller_base.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ void ScratchSpaceControllerBase::createScratchSpaceAllocation() {
4949
}
5050

5151
uint64_t ScratchSpaceControllerBase::calculateNewGSH() {
52-
auto &hwHelper = HwHelper::get(executionEnvironment.getHardwareInfo()->platform.eRenderCoreFamily);
53-
auto scratchSpaceOffsetFor64bit = hwHelper.getScratchSpaceOffsetFor64bit();
54-
return scratchAllocation->getGpuAddress() - scratchSpaceOffsetFor64bit;
52+
uint64_t gsh = 0;
53+
if (scratchAllocation) {
54+
auto &hwHelper = HwHelper::get(executionEnvironment.getHardwareInfo()->platform.eRenderCoreFamily);
55+
auto scratchSpaceOffsetFor64bit = hwHelper.getScratchSpaceOffsetFor64bit();
56+
gsh = scratchAllocation->getGpuAddress() - scratchSpaceOffsetFor64bit;
57+
}
58+
return gsh;
5559
}
5660
uint64_t ScratchSpaceControllerBase::getScratchPatchAddress() {
5761
//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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,14 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsRequiredThenCorrectAddre
256256
EXPECT_TRUE(UnitTestHelper<FamilyType>::evaluateGshAddressForScratchSpace((expectedScratchAddress - MemoryConstants::pageSize), scratchController->calculateNewGSH()));
257257
}
258258

259+
HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsNotRequiredThenGshAddressZeroIsReturned) {
260+
auto commandStreamReceiver = std::make_unique<MockCsrHw<FamilyType>>(*pDevice->executionEnvironment);
261+
auto scratchController = commandStreamReceiver->getScratchSpaceController();
262+
263+
EXPECT_EQ(nullptr, scratchController->getScratchSpaceAllocation());
264+
EXPECT_EQ(0u, scratchController->calculateNewGSH());
265+
}
266+
259267
struct BcsTests : public CommandStreamReceiverHwTest {
260268
void SetUp() override {
261269
CommandStreamReceiverHwTest::SetUp();

0 commit comments

Comments
 (0)