2020-01-17 08:56:05 +01:00
|
|
|
/*
|
2022-03-24 17:19:42 +00:00
|
|
|
* Copyright (C) 2020-2022 Intel Corporation
|
2020-01-17 08:56:05 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/command_container/cmdcontainer.h"
|
|
|
|
|
#include "shared/source/command_container/command_encoder.h"
|
2022-06-29 19:17:47 +00:00
|
|
|
#include "shared/source/gen9/hw_cmds.h"
|
2021-01-21 13:10:13 +01:00
|
|
|
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
|
|
|
|
#include "shared/test/common/fixtures/device_fixture.h"
|
2022-06-29 19:17:47 +00:00
|
|
|
#include "shared/test/common/test_macros/header/per_product_test_definitions.h"
|
|
|
|
|
#include "shared/test/common/test_macros/test.h"
|
2020-01-17 08:56:05 +01:00
|
|
|
|
|
|
|
|
#include "reg_configs_common.h"
|
|
|
|
|
|
|
|
|
|
using namespace NEO;
|
|
|
|
|
|
2022-08-11 14:01:11 +00:00
|
|
|
using CommandEncoderTest = Test<DeviceFixture>;
|
2020-01-17 08:56:05 +01:00
|
|
|
|
2021-05-25 19:57:58 +00:00
|
|
|
GEN9TEST_F(CommandEncoderTest, WhenProgrammingThenLoadRegisterImmIsUsed) {
|
2020-01-17 08:56:05 +01:00
|
|
|
CommandContainer cmdContainer;
|
2022-03-24 17:19:42 +00:00
|
|
|
cmdContainer.initialize(pDevice, nullptr, true);
|
2020-01-17 08:56:05 +01:00
|
|
|
EncodeL3State<FamilyType>::encode(cmdContainer, false);
|
|
|
|
|
|
|
|
|
|
GenCmdList commands;
|
|
|
|
|
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
|
|
|
|
|
|
|
|
|
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
|
|
|
|
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(commands.begin(), commands.end());
|
|
|
|
|
ASSERT_NE(itorLRI, commands.end());
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-25 19:57:58 +00:00
|
|
|
GEN9TEST_F(CommandEncoderTest, givenNoSlmThenCorrectMmioIsSet) {
|
2020-01-17 08:56:05 +01:00
|
|
|
CommandContainer cmdContainer;
|
2022-03-24 17:19:42 +00:00
|
|
|
cmdContainer.initialize(pDevice, nullptr, true);
|
2020-01-17 08:56:05 +01:00
|
|
|
EncodeL3State<FamilyType>::encode(cmdContainer, false);
|
|
|
|
|
|
|
|
|
|
GenCmdList commands;
|
|
|
|
|
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
|
|
|
|
|
|
|
|
|
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
|
|
|
|
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(commands.begin(), commands.end());
|
|
|
|
|
ASSERT_NE(itorLRI, commands.end());
|
|
|
|
|
auto cmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
|
|
|
|
|
auto expectedData = PreambleHelper<FamilyType>::isL3Configurable(cmdContainer.getDevice()->getHardwareInfo()) ? 0x80000340u : 0x60000321u;
|
|
|
|
|
EXPECT_EQ(cmd->getRegisterOffset(), 0x7034u);
|
|
|
|
|
EXPECT_EQ(cmd->getDataDword(), expectedData);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-25 19:57:58 +00:00
|
|
|
GEN9TEST_F(CommandEncoderTest, givenSlmThenCorrectMmioIsSet) {
|
2020-01-17 08:56:05 +01:00
|
|
|
CommandContainer cmdContainer;
|
2022-03-24 17:19:42 +00:00
|
|
|
cmdContainer.initialize(pDevice, nullptr, true);
|
2020-01-17 08:56:05 +01:00
|
|
|
EncodeL3State<FamilyType>::encode(cmdContainer, true);
|
|
|
|
|
|
|
|
|
|
GenCmdList commands;
|
|
|
|
|
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
|
|
|
|
|
|
|
|
|
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
|
|
|
|
auto itorLRI = find<MI_LOAD_REGISTER_IMM *>(commands.begin(), commands.end());
|
|
|
|
|
ASSERT_NE(itorLRI, commands.end());
|
|
|
|
|
auto cmd = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itorLRI);
|
|
|
|
|
EXPECT_EQ(cmd->getRegisterOffset(), 0x7034u);
|
|
|
|
|
EXPECT_EQ(cmd->getDataDword(), 0x60000321u);
|
|
|
|
|
}
|
2020-11-16 17:12:08 +00:00
|
|
|
|
|
|
|
|
using Gen9CommandEncodeTest = testing::Test;
|
|
|
|
|
|
|
|
|
|
GEN9TEST_F(Gen9CommandEncodeTest, givenBcsCommandsHelperWhenMiArbCheckWaRequiredThenReturnTrue) {
|
|
|
|
|
EXPECT_FALSE(BlitCommandsHelper<FamilyType>::miArbCheckWaRequired());
|
|
|
|
|
}
|