Skip to content

Commit 60c5a38

Browse files
test: remove magic number from kernel test
Related-To: NEO-14216 Signed-off-by: Katarzyna Cencelewska <[email protected]>
1 parent aa0075a commit 60c5a38

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ void ImmediateCmdListSharedHeapsFixture::setUp() {
303303
mockKernelImmData->kernelInfo->kernelDescriptor.payloadMappings.samplerTable.tableOffset = 16;
304304
mockKernelImmData->kernelInfo->kernelDescriptor.payloadMappings.samplerTable.borderColor = 0;
305305

306-
kernel->dynamicStateHeapDataSize = static_cast<uint32_t>(16 * 2 + mockKernelImmData->kernelInfo->kernelDescriptor.payloadMappings.samplerTable.tableOffset);
306+
auto surfaceStateSize = device->getNEODevice()->getGfxCoreHelper().getSamplerStateSize();
307+
308+
kernel->dynamicStateHeapDataSize = static_cast<uint32_t>(surfaceStateSize * 2 + mockKernelImmData->kernelInfo->kernelDescriptor.payloadMappings.samplerTable.tableOffset);
307309
kernel->dynamicStateHeapData.reset(new uint8_t[kernel->dynamicStateHeapDataSize]);
308310

309311
mockKernelImmData->mockKernelDescriptor->payloadMappings.samplerTable = mockKernelImmData->kernelInfo->kernelDescriptor.payloadMappings.samplerTable;

level_zero/core/test/unit_tests/sources/kernel/test_kernel_2.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2022-2024 Intel Corporation
2+
* Copyright (C) 2022-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -485,6 +485,7 @@ HWTEST_F(KernelImpSuggestMaxCooperativeGroupCountTests, GivenUsedSlmSizeWhenCalc
485485

486486
using KernelTest = Test<DeviceFixture>;
487487
HWTEST2_F(KernelTest, GivenInlineSamplersWhenSettingInlineSamplerThenDshIsPatched, SupportsSampler) {
488+
using SamplerState = typename FamilyType::SAMPLER_STATE;
488489
WhiteBox<::L0::KernelImmutableData> kernelImmData = {};
489490
NEO::KernelDescriptor descriptor;
490491
kernelImmData.kernelDescriptor = &descriptor;
@@ -498,12 +499,11 @@ HWTEST2_F(KernelTest, GivenInlineSamplersWhenSettingInlineSamplerThenDshIsPatche
498499
Mock<KernelImp> kernel;
499500
kernel.module = &module;
500501
kernel.kernelImmData = &kernelImmData;
501-
kernel.dynamicStateHeapData.reset(new uint8_t[64 + 16]);
502-
kernel.dynamicStateHeapDataSize = 64 + 16;
502+
kernel.dynamicStateHeapData.reset(new uint8_t[64 + sizeof(SamplerState)]);
503+
kernel.dynamicStateHeapDataSize = 64 + sizeof(SamplerState);
503504

504505
kernel.setInlineSamplers();
505506

506-
using SamplerState = typename FamilyType::SAMPLER_STATE;
507507
auto samplerState = reinterpret_cast<const SamplerState *>(kernel.dynamicStateHeapData.get() + 64U);
508508
EXPECT_TRUE(samplerState->getNonNormalizedCoordinateEnable());
509509
EXPECT_EQ(SamplerState::TEXTURE_COORDINATE_MODE_WRAP, samplerState->getTcxAddressControlMode());

0 commit comments

Comments
 (0)