1 /*
2 * Copyright (C) 2021 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "shared/source/gen9/hw_cmds_base.h"
9 #include "shared/test/common/test_macros/test.h"
10
11 using namespace NEO;
12
13 using Gen9HwCmdTest = ::testing::Test;
14
GEN9TEST_F(Gen9HwCmdTest,givenRenderSurfaceStateWhenProgrammingMocsThenMocsIndexIsSetProperly)15 GEN9TEST_F(Gen9HwCmdTest, givenRenderSurfaceStateWhenProgrammingMocsThenMocsIndexIsSetProperly) {
16 auto renderSurfaceState = FamilyType::cmdInitRenderSurfaceState;
17 uint32_t mocs = 4u;
18 uint32_t expectedMocsIndex = (mocs >> 1);
19 renderSurfaceState.setMemoryObjectControlState(mocs);
20 EXPECT_EQ(expectedMocsIndex, renderSurfaceState.TheStructure.Common.MemoryObjectControlState_IndexToMocsTables);
21 }
22
GEN9TEST_F(Gen9HwCmdTest,givenStateBaseAddressWhenProgrammingMocsThenMocsIndexIsSetProperly)23 GEN9TEST_F(Gen9HwCmdTest, givenStateBaseAddressWhenProgrammingMocsThenMocsIndexIsSetProperly) {
24 auto stateBaseAddress = FamilyType::cmdInitStateBaseAddress;
25 uint32_t mocs = 4u;
26 uint32_t expectedMocsIndex = (mocs >> 1);
27 stateBaseAddress.setGeneralStateMemoryObjectControlState(mocs);
28 EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.GeneralStateMemoryObjectControlState_IndexToMocsTables);
29
30 stateBaseAddress.setStatelessDataPortAccessMemoryObjectControlState(mocs);
31 EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.StatelessDataPortAccessMemoryObjectControlState_IndexToMocsTables);
32
33 stateBaseAddress.setSurfaceStateMemoryObjectControlState(mocs);
34 EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.SurfaceStateMemoryObjectControlState_IndexToMocsTables);
35
36 stateBaseAddress.setDynamicStateMemoryObjectControlState(mocs);
37 EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.DynamicStateMemoryObjectControlState_IndexToMocsTables);
38
39 stateBaseAddress.setIndirectObjectMemoryObjectControlState(mocs);
40 EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.IndirectObjectMemoryObjectControlState_IndexToMocsTables);
41
42 stateBaseAddress.setInstructionMemoryObjectControlState(mocs);
43 EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.InstructionMemoryObjectControlState_IndexToMocsTables);
44
45 stateBaseAddress.setBindlessSurfaceStateMemoryObjectControlState(mocs);
46 EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.BindlessSurfaceStateMemoryObjectControlState_IndexToMocsTables);
47 }
48
GEN9TEST_F(Gen9HwCmdTest,givenMediaSurfaceStateWhenProgrammingMocsThenMocsIndexIsSetProperly)49 GEN9TEST_F(Gen9HwCmdTest, givenMediaSurfaceStateWhenProgrammingMocsThenMocsIndexIsSetProperly) {
50 auto mediaSurfaceState = FamilyType::cmdInitMediaSurfaceState;
51 uint32_t mocs = 4u;
52 uint32_t expectedMocsIndex = (mocs >> 1);
53 mediaSurfaceState.setSurfaceMemoryObjectControlState(mocs);
54 EXPECT_EQ(expectedMocsIndex, mediaSurfaceState.TheStructure.Common.SurfaceMemoryObjectControlState_IndexToMocsTables);
55 }