Add command encoder for store data command

Related-To: NEO-6262

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2021-12-02 14:17:45 +00:00
committed by Compute-Runtime-Automation
parent 7764924387
commit 47dbe359bf
17 changed files with 284 additions and 109 deletions

View File

@@ -6,6 +6,7 @@
*/
#include "shared/source/command_container/command_encoder.h"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/mocks/mock_device.h"
@@ -49,3 +50,49 @@ HWTEST2_F(XeHPAndLaterCommandEncoderTest, givenCommandContainerWithDirtyHeapWhen
size_t size = EncodeStateBaseAddress<FamilyType>::getRequiredSizeForStateBaseAddress(*pDevice, container);
EXPECT_EQ(size, 104ul);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterHardwareCommandsTest, givenPartitionArgumentFalseWhenAddingStoreDataImmThenExpectCommandFlagFalse) {
using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM;
uint64_t gpuAddress = 0xFF0000;
uint32_t dword0 = 0x123;
uint32_t dword1 = 0x456;
constexpr size_t bufferSize = 64;
uint8_t buffer[bufferSize];
LinearStream cmdStream(buffer, bufferSize);
EncodeStoreMemory<FamilyType>::programStoreDataImm(cmdStream,
gpuAddress,
dword0,
dword1,
false,
false);
auto storeDataImm = genCmdCast<MI_STORE_DATA_IMM *>(buffer);
ASSERT_NE(nullptr, storeDataImm);
EXPECT_FALSE(storeDataImm->getWorkloadPartitionIdOffsetEnable());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterHardwareCommandsTest, givenPartitionArgumentTrueWhenAddingStoreDataImmThenExpectCommandFlagTrue) {
using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM;
uint64_t gpuAddress = 0xFF0000;
uint32_t dword0 = 0x123;
uint32_t dword1 = 0x456;
constexpr size_t bufferSize = 64;
uint8_t buffer[bufferSize];
LinearStream cmdStream(buffer, bufferSize);
EncodeStoreMemory<FamilyType>::programStoreDataImm(cmdStream,
gpuAddress,
dword0,
dword1,
false,
true);
auto storeDataImm = genCmdCast<MI_STORE_DATA_IMM *>(buffer);
ASSERT_NE(nullptr, storeDataImm);
EXPECT_TRUE(storeDataImm->getWorkloadPartitionIdOffsetEnable());
}

View File

@@ -6,6 +6,7 @@
*/
#include "shared/source/command_container/cmdcontainer.h"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "test.h"
@@ -62,3 +63,65 @@ HWTEST2_F(CommandEncoderTest, givenICLLPWhenGettingRequiredSizeForStateBaseAddre
size_t size = EncodeStateBaseAddress<FamilyType>::getRequiredSizeForStateBaseAddress(*pDevice, container);
EXPECT_EQ(size, 88ul);
}
HWTEST_F(CommandEncoderTest, GivenDwordStoreWhenAddingStoreDataImmThenExpectDwordProgramming) {
using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM;
size_t size = EncodeStoreMemory<FamilyType>::getStoreDataImmSize();
EXPECT_EQ(sizeof(MI_STORE_DATA_IMM), size);
uint64_t gpuAddress = 0xFF0000;
uint32_t dword0 = 0x123;
uint32_t dword1 = 0x456;
constexpr size_t bufferSize = 64;
uint8_t buffer[bufferSize];
LinearStream cmdStream(buffer, bufferSize);
EncodeStoreMemory<FamilyType>::programStoreDataImm(cmdStream,
gpuAddress,
dword0,
dword1,
false,
false);
size_t usedAfter = cmdStream.getUsed();
EXPECT_EQ(size, usedAfter);
auto storeDataImm = genCmdCast<MI_STORE_DATA_IMM *>(buffer);
ASSERT_NE(nullptr, storeDataImm);
EXPECT_EQ(gpuAddress, storeDataImm->getAddress());
EXPECT_EQ(dword0, storeDataImm->getDataDword0());
EXPECT_EQ(0u, storeDataImm->getDataDword1());
EXPECT_FALSE(storeDataImm->getStoreQword());
EXPECT_EQ(MI_STORE_DATA_IMM::DWORD_LENGTH::DWORD_LENGTH_STORE_DWORD, storeDataImm->getDwordLength());
}
HWTEST_F(CommandEncoderTest, GivenQwordStoreWhenAddingStoreDataImmThenExpectQwordProgramming) {
using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM;
size_t size = EncodeStoreMemory<FamilyType>::getStoreDataImmSize();
EXPECT_EQ(sizeof(MI_STORE_DATA_IMM), size);
uint64_t gpuAddress = 0xFF0000;
uint32_t dword0 = 0x123;
uint32_t dword1 = 0x456;
constexpr size_t bufferSize = 64;
uint8_t buffer[bufferSize];
LinearStream cmdStream(buffer, bufferSize);
EncodeStoreMemory<FamilyType>::programStoreDataImm(cmdStream,
gpuAddress,
dword0,
dword1,
true,
false);
size_t usedAfter = cmdStream.getUsed();
EXPECT_EQ(size, usedAfter);
auto storeDataImm = genCmdCast<MI_STORE_DATA_IMM *>(buffer);
ASSERT_NE(nullptr, storeDataImm);
EXPECT_EQ(gpuAddress, storeDataImm->getAddress());
EXPECT_EQ(dword0, storeDataImm->getDataDword0());
EXPECT_EQ(dword1, storeDataImm->getDataDword1());
EXPECT_TRUE(storeDataImm->getStoreQword());
EXPECT_EQ(MI_STORE_DATA_IMM::DWORD_LENGTH::DWORD_LENGTH_STORE_QWORD, storeDataImm->getDwordLength());
}