From 43dd16e1b824aa12adadb0233ead6642318ef71d Mon Sep 17 00:00:00 2001 From: Gibala Date: Thu, 28 Nov 2019 17:48:44 +0100 Subject: [PATCH] Add unit tests to check value shift Related-To: NEO-3962 Change-Id: Ia3ba560201dd495a22742ef9fef767d6aa4c35f9 Signed-off-by: Gibala --- unit_tests/gen11/image_tests_gen11.cpp | 13 +++++++++++++ unit_tests/gen12lp/image_tests_gen12lp.inl | 13 +++++++++++++ unit_tests/gen9/image_tests_gen9.cpp | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/unit_tests/gen11/image_tests_gen11.cpp b/unit_tests/gen11/image_tests_gen11.cpp index 22f2ed05642eb..6821cd0878666 100644 --- a/unit_tests/gen11/image_tests_gen11.cpp +++ b/unit_tests/gen11/image_tests_gen11.cpp @@ -88,3 +88,16 @@ GEN11TEST_F(gen11ImageTests, givenImageForGen11WhenClearColorParametersAreSetThe EXPECT_EQ(0, memcmp(&surfaceStateBefore, &surfaceStateAfter, sizeof(RENDER_SURFACE_STATE))); } + +using Gen11RenderSurfaceStateDataTests = ::testing::Test; + +GEN11TEST_F(Gen11RenderSurfaceStateDataTests, WhenMemoryObjectControlStateIndexToMocsTablesIsSetThenValueIsShift) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + auto surfaceState = FamilyType::cmdInitRenderSurfaceState; + + uint32_t value = 4; + surfaceState.setMemoryObjectControlStateIndexToMocsTables(value); + + EXPECT_EQ(surfaceState.TheStructure.Common.MemoryObjectControlState_IndexToMocsTables, value >> 1); + EXPECT_EQ(surfaceState.getMemoryObjectControlStateIndexToMocsTables(), value); +} diff --git a/unit_tests/gen12lp/image_tests_gen12lp.inl b/unit_tests/gen12lp/image_tests_gen12lp.inl index d5c7049600317..2ccfa38ed2713 100644 --- a/unit_tests/gen12lp/image_tests_gen12lp.inl +++ b/unit_tests/gen12lp/image_tests_gen12lp.inl @@ -159,3 +159,16 @@ GEN12LPTEST_F(gen12LpImageTests, givenCompressionEnabledWhenAppendingSurfaceStat image->appendSurfaceStateParams(&rss); EXPECT_EQ(expectedCompressionFormat, rss.getCompressionFormat()); } + +using Gen12lpRenderSurfaceStateDataTests = ::testing::Test; + +GEN12LPTEST_F(Gen12lpRenderSurfaceStateDataTests, WhenMemoryObjectControlStateIndexToMocsTablesIsSetThenValueIsShift) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + auto surfaceState = FamilyType::cmdInitRenderSurfaceState; + + uint32_t value = 4; + surfaceState.setMemoryObjectControlStateIndexToMocsTables(value); + + EXPECT_EQ(surfaceState.TheStructure.Common.MemoryObjectControlStateIndexToMocsTables, value >> 1); + EXPECT_EQ(surfaceState.getMemoryObjectControlStateIndexToMocsTables(), value); +} diff --git a/unit_tests/gen9/image_tests_gen9.cpp b/unit_tests/gen9/image_tests_gen9.cpp index ea2b428574477..4ec13f2e12fe9 100644 --- a/unit_tests/gen9/image_tests_gen9.cpp +++ b/unit_tests/gen9/image_tests_gen9.cpp @@ -27,3 +27,16 @@ GEN9TEST_F(gen9ImageTests, appendSurfaceStateParamsDoesNothing) { EXPECT_EQ(0, memcmp(&surfaceStateBefore, &surfaceStateAfter, sizeof(RENDER_SURFACE_STATE))); } + +using Gen9RenderSurfaceStateDataTests = ::testing::Test; + +GEN9TEST_F(Gen9RenderSurfaceStateDataTests, WhenMemoryObjectControlStateIndexToMocsTablesIsSetThenValueIsShift) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + auto surfaceState = FamilyType::cmdInitRenderSurfaceState; + + uint32_t value = 4; + surfaceState.setMemoryObjectControlStateIndexToMocsTables(value); + + EXPECT_EQ(surfaceState.TheStructure.Common.MemoryObjectControlState_IndexToMocsTables, value >> 1); + EXPECT_EQ(surfaceState.getMemoryObjectControlStateIndexToMocsTables(), value); +}