|
10 | 10 | #include "shared/source/indirect_heap/heap_size.h"
|
11 | 11 | #include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
12 | 12 | #include "shared/test/common/fixtures/device_fixture.h"
|
| 13 | +#include "shared/test/common/helpers/gtest_helpers.h" |
13 | 14 | #include "shared/test/common/mocks/mock_device.h"
|
14 | 15 | #include "shared/test/common/test_macros/hw_test.h"
|
15 | 16 | #include "shared/test/unit_test/mocks/mock_dispatch_kernel_encoder_interface.h"
|
@@ -489,6 +490,64 @@ HWTEST_F(CommandEncoderMathTest, givenPayloadArgumentStoredInInlineDataWhenEncod
|
489 | 490 | }
|
490 | 491 | }
|
491 | 492 |
|
| 493 | +HWTEST_F(CommandEncoderMathTest, givenPayloadArgumentStoredInInlineDataWhenEncodeIndirectParamsThenPreparserMitigationIsProgrammed) { |
| 494 | + using MI_ARB_CHECK = typename FamilyType::MI_ARB_CHECK; |
| 495 | + using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START; |
| 496 | + CommandContainer cmdContainer0; |
| 497 | + cmdContainer0.initialize(pDevice, nullptr, HeapSize::defaultHeapSize, true, false); |
| 498 | + |
| 499 | + CommandContainer cmdContainer1; |
| 500 | + cmdContainer1.initialize(pDevice, nullptr, HeapSize::defaultHeapSize, true, false); |
| 501 | + |
| 502 | + uint64_t crossThreadGpuVa = 0xBADF000; |
| 503 | + |
| 504 | + IndirectParamsInInlineDataArgs args{}; |
| 505 | + |
| 506 | + MockDispatchKernelEncoder dispatchInterface; |
| 507 | + |
| 508 | + auto &kernelDescriptor = dispatchInterface.kernelDescriptor; |
| 509 | + uint32_t groupSizes[3] = {1, 2, 3}; |
| 510 | + dispatchInterface.getGroupSizeResult = groupSizes; |
| 511 | + |
| 512 | + kernelDescriptor.kernelAttributes.inlineDataPayloadSize = 0x100; |
| 513 | + kernelDescriptor.payloadMappings.dispatchTraits.numWorkGroups[0] = 0x100; |
| 514 | + kernelDescriptor.payloadMappings.dispatchTraits.numWorkGroups[1] = 0x110; |
| 515 | + kernelDescriptor.payloadMappings.dispatchTraits.numWorkGroups[2] = undefined<CrossThreadDataOffset>; |
| 516 | + |
| 517 | + kernelDescriptor.payloadMappings.dispatchTraits.globalWorkSize[0] = undefined<CrossThreadDataOffset>; |
| 518 | + kernelDescriptor.payloadMappings.dispatchTraits.globalWorkSize[1] = 0x120; |
| 519 | + kernelDescriptor.payloadMappings.dispatchTraits.globalWorkSize[2] = 0x130; |
| 520 | + |
| 521 | + kernelDescriptor.payloadMappings.dispatchTraits.workDim = 0x140; |
| 522 | + |
| 523 | + EncodeIndirectParams<FamilyType>::encode(cmdContainer0, crossThreadGpuVa, &dispatchInterface, 0u, &args); |
| 524 | + |
| 525 | + kernelDescriptor.payloadMappings.dispatchTraits.workDim = 0x60; |
| 526 | + |
| 527 | + EncodeIndirectParams<FamilyType>::encode(cmdContainer1, crossThreadGpuVa, &dispatchInterface, 0u, &args); |
| 528 | + |
| 529 | + auto used0 = cmdContainer0.getCommandStream()->getUsed(); |
| 530 | + auto used1 = cmdContainer1.getCommandStream()->getUsed(); |
| 531 | + |
| 532 | + auto expectedDiff = sizeof(MI_ARB_CHECK) * 2 + sizeof(MI_BATCH_BUFFER_START); |
| 533 | + EXPECT_EQ(expectedDiff, used1 - used0); |
| 534 | + |
| 535 | + GenCmdList commands; |
| 536 | + CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer1.getCommandStream()->getCpuBase(), used0), used1 - used0); |
| 537 | + auto itor = commands.begin(); |
| 538 | + itor = find<MI_ARB_CHECK *>(itor, commands.end()); |
| 539 | + ASSERT_NE(itor, commands.end()); |
| 540 | + itor = find<MI_BATCH_BUFFER_START *>(++itor, commands.end()); |
| 541 | + |
| 542 | + ASSERT_NE(itor, commands.end()); |
| 543 | + itor = find<MI_ARB_CHECK *>(++itor, commands.end()); |
| 544 | + |
| 545 | + ASSERT_NE(itor, commands.end()); |
| 546 | + itor = find<MI_ARB_CHECK *>(++itor, commands.end()); |
| 547 | + |
| 548 | + EXPECT_EQ(itor, commands.end()); |
| 549 | +} |
| 550 | + |
492 | 551 | using CommandEncodeAluTests = ::testing::Test;
|
493 | 552 |
|
494 | 553 | HWTEST_F(CommandEncodeAluTests, whenAskingForIncrementOrDecrementCmdsSizeThenReturnCorrectValue) {
|
|
0 commit comments