mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Move neo_shared_tests sources from /common to /unit_test
Resolves: NEO-6524 Signed-off-by: Warchulski, Jaroslaw <jaroslaw.warchulski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
e135c0ba82
commit
1388818a0e
@@ -4,66 +4,8 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(NEO_CORE_HELPERS_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}hw_helper_extended_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aligned_memory_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bindless_heaps_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests_gen12lp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_manager_state_restore.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dispatch_flags_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/engine_descriptor_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/file_io_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hash_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/includes${BRANCH_DIR_SUFFIX}test_traits_common.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/includes${BRANCH_DIR_SUFFIX}test_traits_platforms_common.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_binary_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_filename_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_leak_listener.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_management.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/string_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/string_to_hash_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_traits.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_traits_platforms.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ult_hw_config.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ult_hw_config.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ult_hw_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/variable_backup.h
|
||||
)
|
||||
|
||||
if(TESTS_XEHP_AND_LATER)
|
||||
list(APPEND NEO_CORE_HELPERS_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_blit_commands_helper_xehp_and_later.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(TESTS_DG2_AND_LATER)
|
||||
list(APPEND NEO_CORE_HELPERS_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_dg2_and_later.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(TESTS_PVC_AND_LATER)
|
||||
list(APPEND NEO_CORE_HELPERS_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests_pvc_and_later.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_blit_commands_helper_pvc_and_later.cpp
|
||||
)
|
||||
target_sources(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests_pvc_and_later.inl)
|
||||
endif()
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/state_base_address_tests.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/state_base_address_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/heap_assigner_shared_tests.cpp
|
||||
${NEO_CORE_HELPERS_TESTS}
|
||||
)
|
||||
|
||||
@@ -1,281 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
TEST(AlignedFree, GivenNullPtrWhenFreeingAlignedThenNoCrash) {
|
||||
alignedFree(nullptr);
|
||||
}
|
||||
void *ptrAlignedToPage = (void *)0x1000;
|
||||
void *ptrNotAlignedToPage = (void *)0x1001;
|
||||
|
||||
struct AlignedMalloc : public ::testing::TestWithParam<size_t> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
ptr = nullptr;
|
||||
alignAlloc = GetParam();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
alignedFree(ptr);
|
||||
}
|
||||
|
||||
void *ptr;
|
||||
size_t alignAlloc;
|
||||
};
|
||||
|
||||
TEST_P(AlignedMalloc, GivenSizeZeroWhenAllocatingAlignedThenAlignedPointerIsReturned) {
|
||||
size_t sizeAlloc = 0;
|
||||
ptr = alignedMalloc(sizeAlloc, alignAlloc);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
EXPECT_EQ(0u, (uintptr_t)ptr % alignAlloc);
|
||||
}
|
||||
|
||||
TEST_P(AlignedMalloc, GivenSize4096WhenAllocatingAlignedThenAlignedPointerIsReturned) {
|
||||
size_t sizeAlloc = 4096;
|
||||
ptr = alignedMalloc(sizeAlloc, alignAlloc);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
EXPECT_EQ(0u, (uintptr_t)ptr % alignAlloc);
|
||||
}
|
||||
|
||||
TEST(AlignedMallocTests, GivenSizeZeroAndAlign4096WhenAllocatingAlignedThenAlignedPointerIsReturned) {
|
||||
size_t sizeAlloc = 0;
|
||||
auto ptr = alignedMalloc(sizeAlloc, 4096);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
EXPECT_EQ(0u, (uintptr_t)ptr % 4096);
|
||||
alignedFree(ptr);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
AlignedMallocParameterized,
|
||||
AlignedMalloc,
|
||||
testing::Values(
|
||||
1,
|
||||
4,
|
||||
8,
|
||||
64,
|
||||
4096));
|
||||
|
||||
struct AlignUp : public ::testing::TestWithParam<size_t> {
|
||||
};
|
||||
|
||||
TEST_P(AlignUp, GivenPointerBelowAlignmentWhenAligningUpThenReturnAlignedPointer) {
|
||||
uintptr_t addrBefore = 0x1fffffff;
|
||||
auto ptrBefore = (uint32_t *)addrBefore;
|
||||
|
||||
auto alignment = GetParam();
|
||||
auto ptrAfter = alignUp(ptrBefore, alignment);
|
||||
auto addrAfter = (uintptr_t)ptrAfter;
|
||||
|
||||
EXPECT_EQ(0u, addrAfter % alignment);
|
||||
}
|
||||
|
||||
TEST_P(AlignUp, GivenPointerAtAlignmentWhenAligningUpThenReturnAlignedPointer) {
|
||||
uintptr_t addrBefore = 0x20000000;
|
||||
auto ptrBefore = (uint32_t *)addrBefore;
|
||||
|
||||
auto alignment = GetParam();
|
||||
auto ptrAfter = alignUp(ptrBefore, alignment);
|
||||
auto addrAfter = (uintptr_t)ptrAfter;
|
||||
|
||||
EXPECT_EQ(0u, addrAfter % alignment);
|
||||
}
|
||||
|
||||
TEST_P(AlignUp, GivenPointerAboveAlignmentWhenAligningUpThenReturnAlignedPointer) {
|
||||
uintptr_t addrBefore = 0x20000001;
|
||||
auto ptrBefore = (uint32_t *)addrBefore;
|
||||
|
||||
auto alignment = GetParam();
|
||||
auto ptrAfter = alignUp(ptrBefore, alignment);
|
||||
auto addrAfter = (uintptr_t)ptrAfter;
|
||||
|
||||
EXPECT_EQ(0u, addrAfter % alignment);
|
||||
}
|
||||
|
||||
TEST_P(AlignUp, WhenAligningUpThen64BitIsPreserved) {
|
||||
uint64_t aligned = 1ULL << 48;
|
||||
auto alignment = GetParam();
|
||||
auto result = alignUp(aligned, alignment);
|
||||
EXPECT_EQ(aligned, result);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
AlignUpParameterized,
|
||||
AlignUp,
|
||||
testing::Values(
|
||||
1,
|
||||
4,
|
||||
8,
|
||||
32,
|
||||
64,
|
||||
256,
|
||||
4096));
|
||||
|
||||
TEST(AlignWholeSize, GivenSizeLessThanPageSizeWhenAligningWholeSizeToPageThenAlignedSizeIsPageSize) {
|
||||
int size = 1;
|
||||
auto retSize = alignSizeWholePage(ptrAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeGreaterThanPageSizeWhenAligningWholeSizeToPageThenAlignedSizeIsMultipleOfPageSize) {
|
||||
|
||||
int size = 4097;
|
||||
auto retSize = alignSizeWholePage(ptrAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 2);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeGreaterThanPageSizeAndUnalignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsMultipleOfPageSize) {
|
||||
|
||||
int size = 4097;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 2);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeOneAndUnalignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsPageSize) {
|
||||
|
||||
int size = 1;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeOneLessThanPageSizeAndUnalignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsPageSize) {
|
||||
|
||||
int size = 4095;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeOneLessThanTwoPageSizeAndUnalignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsTwoPageSize) {
|
||||
|
||||
int size = 4095 + 4096;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 2);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenNonAlignedPointerThenAllocationOverlapsToAnotherPage) {
|
||||
|
||||
int size = 4096;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 2);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeofTwoPagesAndUnalignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsThreePageSize) {
|
||||
|
||||
int size = 4096 * 2;
|
||||
auto retSize = alignSizeWholePage(ptrNotAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 3);
|
||||
}
|
||||
TEST(AlignWholeSize, GivenSizeofTwoPagesAndAlignedPointerWhenAligningWholeSizeToPageThenAlignedSizeIsTwoPageSize) {
|
||||
|
||||
int size = 4096 * 2;
|
||||
auto retSize = alignSizeWholePage(ptrAlignedToPage, size);
|
||||
EXPECT_EQ(retSize, 4096u * 2);
|
||||
}
|
||||
|
||||
TEST(AlignDown, GivenPtrAlignedToPageWhenAligningDownToPageSizeThenReturnTheSamePointer) {
|
||||
void *ptr = (void *)0x1000;
|
||||
|
||||
auto alignedDownPtr = alignDown(ptr, MemoryConstants::pageSize);
|
||||
EXPECT_EQ(ptr, alignedDownPtr);
|
||||
}
|
||||
TEST(AlignDown, GivenPtrNotAlignedToPageWhenAligningDownToPageSizeThenPageAlignedPointerIsReturned) {
|
||||
void *ptr = (void *)0x1001;
|
||||
void *expectedPtr = (void *)0x1000;
|
||||
auto alignedDownPtr = alignDown(ptr, MemoryConstants::pageSize);
|
||||
EXPECT_EQ(expectedPtr, alignedDownPtr);
|
||||
}
|
||||
|
||||
TEST(AlignDown, GivenPtrNotAlignedToTwoPageWhenAligningDownToPageSizeThenReturnAlignedPointerToPreviousPage) {
|
||||
void *ptr = (void *)0x1241;
|
||||
void *expectedPtr = (void *)0x1000;
|
||||
auto alignedDownPtr = alignDown(ptr, MemoryConstants::pageSize);
|
||||
EXPECT_EQ(expectedPtr, alignedDownPtr);
|
||||
}
|
||||
|
||||
TEST(AlignDown, GivenPtrNotAlignedToThreePageWhenAligningDownToPageSizeThenReturnAlignedPointerToPreviousPage) {
|
||||
void *ptr = (void *)0x3241;
|
||||
void *expectedPtr = (void *)0x3000;
|
||||
auto alignedDownPtr = alignDown(ptr, MemoryConstants::pageSize);
|
||||
EXPECT_EQ(expectedPtr, alignedDownPtr);
|
||||
}
|
||||
|
||||
TEST(AlignDown, GivenPtrNotAlignedToDwordWhenAligningDownToDwordThenDwordAlignedPointerIsReturned) {
|
||||
void *ptr = (void *)0x3241;
|
||||
void *expectedPtr = (void *)0x3240;
|
||||
auto alignedDownPtr = alignDown(ptr, 4);
|
||||
EXPECT_EQ(expectedPtr, alignedDownPtr);
|
||||
}
|
||||
|
||||
TEST(AlignDown, WhenAligningDownThen64BitIsPreserved) {
|
||||
uint64_t aligned = 1ULL << 48;
|
||||
auto result = alignDown(aligned, MemoryConstants::pageSize);
|
||||
EXPECT_EQ(aligned, result);
|
||||
}
|
||||
|
||||
TEST(DLLbitness, Given32or64BitLibraryWhenAskedIfItIs32BitThenProperValueIsReturned) {
|
||||
auto pointerSize = sizeof(void *);
|
||||
if (pointerSize == 8) {
|
||||
EXPECT_FALSE(is32bit);
|
||||
EXPECT_TRUE(is64bit);
|
||||
} else if (pointerSize == 4) {
|
||||
EXPECT_TRUE(is32bit);
|
||||
EXPECT_FALSE(is64bit);
|
||||
} else {
|
||||
FAIL() << "unrecognized bitness";
|
||||
}
|
||||
auto pointerSizeFromSizeT = sizeof(size_t);
|
||||
if (pointerSizeFromSizeT == 8) {
|
||||
EXPECT_FALSE(is32bit);
|
||||
EXPECT_TRUE(is64bit);
|
||||
} else if (pointerSizeFromSizeT == 4) {
|
||||
EXPECT_TRUE(is32bit);
|
||||
EXPECT_FALSE(is64bit);
|
||||
} else {
|
||||
FAIL() << "unrecognized bitness";
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class IsAlignedTests : public ::testing::Test {
|
||||
};
|
||||
|
||||
typedef ::testing::Types<int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, float, double> IsAlignedTypes;
|
||||
|
||||
TYPED_TEST_CASE(IsAlignedTests, IsAlignedTypes);
|
||||
TYPED_TEST(IsAlignedTests, WhenCheckingForAlignmentThenReturnCorrectValue) {
|
||||
TypeParam *ptr = reinterpret_cast<TypeParam *>(static_cast<uintptr_t>(0xdeadbeefu));
|
||||
// one byte alignment should always return true
|
||||
if (alignof(TypeParam) == 1)
|
||||
EXPECT_TRUE(isAligned(ptr));
|
||||
else
|
||||
EXPECT_FALSE(isAligned(ptr));
|
||||
|
||||
auto ptr1 = reinterpret_cast<TypeParam *>(reinterpret_cast<uintptr_t>(ptr) & ~(alignof(TypeParam) - 1));
|
||||
EXPECT_TRUE(isAligned(ptr1));
|
||||
|
||||
auto ptr2 = reinterpret_cast<TypeParam *>(reinterpret_cast<uintptr_t>(ptr) & ~((alignof(TypeParam) << 1) - 1));
|
||||
EXPECT_TRUE(isAligned(ptr2));
|
||||
|
||||
// this is hard to align in the middle of byte aligned types
|
||||
if (alignof(TypeParam) == 1)
|
||||
return;
|
||||
|
||||
auto ptr3 = reinterpret_cast<TypeParam *>(reinterpret_cast<uintptr_t>(ptr) & ~((alignof(TypeParam) >> 1) - 1));
|
||||
EXPECT_FALSE(isAligned(ptr3));
|
||||
}
|
||||
|
||||
TEST(IsAligned, GivenNonPointerTypeWhenCheckingForAlignmentThenReturnIsCorrect) {
|
||||
EXPECT_TRUE(isAligned<3>(0));
|
||||
EXPECT_FALSE(isAligned<3>(1));
|
||||
EXPECT_FALSE(isAligned<3>(2));
|
||||
EXPECT_TRUE(isAligned<3>(3));
|
||||
EXPECT_FALSE(isAligned<3>(4));
|
||||
EXPECT_FALSE(isAligned<3>(5));
|
||||
EXPECT_TRUE(isAligned<3>(6));
|
||||
}
|
||||
|
||||
TEST(IsAligned, WhenUsingConstexprEvaluationThenResultIsCorrect) {
|
||||
static_assert(false == isAligned<3>(2), "");
|
||||
static_assert(true == isAligned<3>(3), "");
|
||||
}
|
||||
@@ -1,200 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/bindless_heaps_helper.h"
|
||||
#include "shared/test/common/fixtures/front_window_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_bindless_heaps_helper.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(BindlessHeapsHelper, givenBindlessModeFlagEnabledWhenCreatingRootDevicesThenBindlesHeapHelperCreated) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
||||
EXPECT_NE(deviceFactory->rootDevices[0]->getBindlessHeapsHelper(), nullptr);
|
||||
}
|
||||
|
||||
TEST(BindlessHeapsHelper, givenBindlessModeFlagDisabledWhenCreatingRootDevicesThenBindlesHeapHelperCreated) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.UseBindlessMode.set(0);
|
||||
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
||||
EXPECT_EQ(deviceFactory->rootDevices[0]->getBindlessHeapsHelper(), nullptr);
|
||||
}
|
||||
|
||||
using BindlessHeapsHelperTests = Test<MemManagerFixture>;
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenItsCreatedThenSpecialSshAllocatedAtHeapBegining) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
auto specialSshAllocation = bindlessHeapHelper->specialSsh->getGraphicsAllocation();
|
||||
EXPECT_EQ(specialSshAllocation->getGpuAddress(), specialSshAllocation->getGpuBaseAddress());
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThenHeapUsedSpaceGrow) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
auto usedBefore = bindlessHeapHelper->globalSsh->getUsed();
|
||||
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
auto usedAfter = bindlessHeapHelper->globalSsh->getUsed();
|
||||
EXPECT_GT(usedAfter, usedBefore);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThenMemoryAtReturnedOffsetIsCorrect) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
|
||||
auto allocInHeapPtr = bindlessHeapHelper->globalSsh->getGraphicsAllocation()->getUnderlyingBuffer();
|
||||
EXPECT_EQ(ssInHeapInfo.ssPtr, allocInHeapPtr);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwiceForTheSameAllocationThenTheSameOffsetReturned) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo1 = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
auto ssInHeapInfo2 = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
|
||||
EXPECT_EQ(ssInHeapInfo1.surfaceStateOffset, ssInHeapInfo2.surfaceStateOffset);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwiceForDifferentAllocationThenDifferentOffsetsReturned) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
|
||||
MockGraphicsAllocation alloc1;
|
||||
MockGraphicsAllocation alloc2;
|
||||
size_t size = 0x40;
|
||||
auto ss = std::make_unique<uint8_t[]>(size);
|
||||
memset(ss.get(), 35, size);
|
||||
auto ssInHeapInfo1 = bindlessHeapHelper->allocateSSInHeap(size, &alloc1, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
auto ssInHeapInfo2 = bindlessHeapHelper->allocateSSInHeap(size, &alloc2, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
|
||||
EXPECT_NE(ssInHeapInfo1.surfaceStateOffset, ssInHeapInfo2.surfaceStateOffset);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocatingMoreSsThenNewHeapAllocationCreated) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
size_t ssSize = 0x40;
|
||||
auto ssCount = bindlessHeapHelper->globalSsh->getAvailableSpace() / ssSize;
|
||||
auto graphicsAllocations = std::make_unique<MockGraphicsAllocation[]>(ssCount);
|
||||
auto ssAllocationBefore = bindlessHeapHelper->globalSsh->getGraphicsAllocation();
|
||||
for (uint32_t i = 0; i < ssCount; i++) {
|
||||
bindlessHeapHelper->allocateSSInHeap(ssSize, &graphicsAllocations[i], BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
}
|
||||
MockGraphicsAllocation alloc;
|
||||
bindlessHeapHelper->allocateSSInHeap(ssSize, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
|
||||
auto ssAllocationAfter = bindlessHeapHelper->globalSsh->getGraphicsAllocation();
|
||||
|
||||
EXPECT_NE(ssAllocationBefore, ssAllocationAfter);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenCreatedThenAllocationsHaveTheSameBaseAddress) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
for (auto allocation : bindlessHeapHelper->ssHeapsAllocations) {
|
||||
EXPECT_EQ(allocation->getGpuBaseAddress(), bindlessHeapHelper->getGlobalHeapsBase());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenGetDefaultBorderColorOffsetCalledThenCorrectOffsetReturned) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
auto expectedOffset = bindlessHeapHelper->borderColorStates->getGpuAddress() - bindlessHeapHelper->borderColorStates->getGpuBaseAddress();
|
||||
EXPECT_EQ(bindlessHeapHelper->getDefaultBorderColorOffset(), expectedOffset);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenGetAlphaBorderColorOffsetCalledThenCorrectOffsetReturned) {
|
||||
auto borderColorSize = 0x40;
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
auto expectedOffset = bindlessHeapHelper->borderColorStates->getGpuAddress() - bindlessHeapHelper->borderColorStates->getGpuBaseAddress() + borderColorSize;
|
||||
EXPECT_EQ(bindlessHeapHelper->getAlphaBorderColorOffset(), expectedOffset);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInSpecialHeapThenOffsetLessThanFrontWindowSize) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::SPECIAL_SSH);
|
||||
auto frontWindowSize = GfxPartition::externalFrontWindowPoolSize;
|
||||
EXPECT_LT(ssInHeapInfo.surfaceStateOffset, frontWindowSize);
|
||||
}
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalHeapThenOffsetLessThanFrontWindowSize) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
auto frontWindowSize = GfxPartition::externalFrontWindowPoolSize;
|
||||
EXPECT_LT(ssInHeapInfo.surfaceStateOffset, frontWindowSize);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInScratchHeapThenOffsetLessThanFrontWindowSize) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::SCRATCH_SSH);
|
||||
auto frontWindowSize = GfxPartition::externalFrontWindowPoolSize;
|
||||
EXPECT_LT(ssInHeapInfo.surfaceStateOffset, frontWindowSize);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalDshThenOffsetGreaterOrEqualFrontWindowSize) {
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
MockGraphicsAllocation alloc;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH);
|
||||
auto frontWindowSize = GfxPartition::externalFrontWindowPoolSize;
|
||||
EXPECT_GE(ssInHeapInfo.surfaceStateOffset, frontWindowSize);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenFreeGraphicsMemoryIsCalledThenSSinHeapInfoShouldBePlacedInReuseVector) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
MockBindlesHeapsHelper *bindlessHeapHelperPtr = bindlessHeapHelper.get();
|
||||
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapHelper.release());
|
||||
MockGraphicsAllocation *alloc = new MockGraphicsAllocation;
|
||||
size_t size = 0x40;
|
||||
auto ssinHeapInfo = bindlessHeapHelperPtr->allocateSSInHeap(size, alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
memManager->freeGraphicsMemory(alloc);
|
||||
EXPECT_EQ(bindlessHeapHelperPtr->surfaceStateInHeapVectorReuse.size(), 1u);
|
||||
auto ssInHeapInfoFromReuseVector = bindlessHeapHelperPtr->surfaceStateInHeapVectorReuse.front().get();
|
||||
EXPECT_EQ(ssInHeapInfoFromReuseVector->surfaceStateOffset, ssinHeapInfo.surfaceStateOffset);
|
||||
EXPECT_EQ(ssInHeapInfoFromReuseVector->ssPtr, ssinHeapInfo.ssPtr);
|
||||
}
|
||||
|
||||
TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperPreviousAllocationThenItShouldBeReused) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
MockBindlesHeapsHelper *bindlessHeapHelperPtr = bindlessHeapHelper.get();
|
||||
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapHelper.release());
|
||||
MockGraphicsAllocation *alloc = new MockGraphicsAllocation;
|
||||
size_t size = 0x40;
|
||||
auto ssInHeapInfo = bindlessHeapHelperPtr->allocateSSInHeap(size, alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
memManager->freeGraphicsMemory(alloc);
|
||||
EXPECT_EQ(bindlessHeapHelperPtr->surfaceStateInHeapVectorReuse.size(), 1u);
|
||||
MockGraphicsAllocation *alloc2 = new MockGraphicsAllocation;
|
||||
auto reusedSSinHeapInfo = bindlessHeapHelperPtr->allocateSSInHeap(size, alloc2, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH);
|
||||
EXPECT_EQ(bindlessHeapHelperPtr->surfaceStateInHeapVectorReuse.size(), 0u);
|
||||
EXPECT_EQ(ssInHeapInfo.surfaceStateOffset, reusedSSinHeapInfo.surfaceStateOffset);
|
||||
EXPECT_EQ(ssInHeapInfo.ssPtr, reusedSSinHeapInfo.ssPtr);
|
||||
memManager->freeGraphicsMemory(alloc2);
|
||||
}
|
||||
TEST_F(BindlessHeapsHelperTests, givenDeviceWhenBindlessHeapHelperInitializedThenCorrectDeviceBitFieldIsUsed) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
DeviceBitfield devBitfield = 7;
|
||||
auto bindlessHeapHelper = std::make_unique<MockBindlesHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), devBitfield);
|
||||
EXPECT_EQ(reinterpret_cast<MockMemoryManager *>(pDevice->getMemoryManager())->recentlyPassedDeviceBitfield, devBitfield);
|
||||
}
|
||||
@@ -1,665 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/blit_commands_helper_tests.inl"
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/helpers/blit_commands_helper.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/common/test_macros/test_checks_shared.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(BlitCommandsHelperTest, GivenBufferParamsWhenConstructingPropertiesForReadWriteThenPropertiesCreatedCorrectly) {
|
||||
uint32_t src[] = {1, 2, 3, 4};
|
||||
uint32_t dst[] = {4, 3, 2, 1};
|
||||
uint64_t srcGpuAddr = 0x12345;
|
||||
std::unique_ptr<MockGraphicsAllocation> srcAlloc(new MockGraphicsAllocation(src, srcGpuAddr, sizeof(src)));
|
||||
|
||||
Vec3<size_t> srcOffsets{1, 2, 3};
|
||||
Vec3<size_t> dstOffsets{3, 2, 1};
|
||||
Vec3<size_t> copySize{2, 2, 2};
|
||||
|
||||
size_t srcRowPitch = 2;
|
||||
size_t srcSlicePitch = 3;
|
||||
|
||||
size_t dstRowPitch = 2;
|
||||
size_t dstSlicePitch = 3;
|
||||
|
||||
UltDeviceFactory deviceFactory{1, 0};
|
||||
|
||||
auto csr = deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver;
|
||||
|
||||
auto blitProperties = NEO::BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::BufferToHostPtr,
|
||||
*csr, srcAlloc.get(), nullptr,
|
||||
dst,
|
||||
srcGpuAddr,
|
||||
0, dstOffsets, srcOffsets, copySize, dstRowPitch, dstSlicePitch, srcRowPitch, srcSlicePitch);
|
||||
|
||||
EXPECT_EQ(blitProperties.blitDirection, BlitterConstants::BlitDirection::BufferToHostPtr);
|
||||
EXPECT_NE(blitProperties.dstAllocation, nullptr);
|
||||
EXPECT_EQ(blitProperties.dstAllocation->getUnderlyingBufferSize(), copySize.x * copySize.y * copySize.z);
|
||||
EXPECT_EQ(blitProperties.srcAllocation, srcAlloc.get());
|
||||
EXPECT_EQ(blitProperties.clearColorAllocation, csr->getClearColorAllocation());
|
||||
EXPECT_EQ(blitProperties.dstGpuAddress, blitProperties.dstAllocation->getGpuAddress());
|
||||
EXPECT_EQ(blitProperties.srcGpuAddress, srcGpuAddr);
|
||||
EXPECT_EQ(blitProperties.copySize, copySize);
|
||||
EXPECT_EQ(blitProperties.dstOffset, dstOffsets);
|
||||
EXPECT_EQ(blitProperties.srcOffset, srcOffsets);
|
||||
EXPECT_EQ(blitProperties.dstRowPitch, dstRowPitch);
|
||||
EXPECT_EQ(blitProperties.dstSlicePitch, dstSlicePitch);
|
||||
EXPECT_EQ(blitProperties.srcRowPitch, srcRowPitch);
|
||||
EXPECT_EQ(blitProperties.srcSlicePitch, srcSlicePitch);
|
||||
}
|
||||
|
||||
TEST(BlitCommandsHelperTest, GivenBufferParamsWhenConstructingPropertiesForBufferRegionsThenPropertiesCreatedCorrectly) {
|
||||
uint32_t src[] = {1, 2, 3, 4};
|
||||
uint32_t dst[] = {4, 3, 2, 1};
|
||||
uint32_t clear[] = {5, 6, 7, 8};
|
||||
uint64_t srcGpuAddr = 0x12345;
|
||||
uint64_t dstGpuAddr = 0x54321;
|
||||
uint64_t clearGpuAddr = 0x5678;
|
||||
std::unique_ptr<MockGraphicsAllocation> srcAlloc(new MockGraphicsAllocation(src, srcGpuAddr, sizeof(src)));
|
||||
std::unique_ptr<MockGraphicsAllocation> dstAlloc(new MockGraphicsAllocation(dst, dstGpuAddr, sizeof(dst)));
|
||||
std::unique_ptr<GraphicsAllocation> clearColorAllocation(new MockGraphicsAllocation(clear, clearGpuAddr, sizeof(clear)));
|
||||
|
||||
Vec3<size_t> srcOffsets{1, 2, 3};
|
||||
Vec3<size_t> dstOffsets{3, 2, 1};
|
||||
Vec3<size_t> copySize{2, 2, 2};
|
||||
|
||||
size_t srcRowPitch = 2;
|
||||
size_t srcSlicePitch = 3;
|
||||
|
||||
size_t dstRowPitch = 2;
|
||||
size_t dstSlicePitch = 3;
|
||||
|
||||
auto blitProperties = NEO::BlitProperties::constructPropertiesForCopy(dstAlloc.get(), srcAlloc.get(),
|
||||
dstOffsets, srcOffsets, copySize, srcRowPitch, srcSlicePitch,
|
||||
dstRowPitch, dstSlicePitch, clearColorAllocation.get());
|
||||
|
||||
EXPECT_EQ(blitProperties.blitDirection, BlitterConstants::BlitDirection::BufferToBuffer);
|
||||
EXPECT_EQ(blitProperties.dstAllocation, dstAlloc.get());
|
||||
EXPECT_EQ(blitProperties.srcAllocation, srcAlloc.get());
|
||||
EXPECT_EQ(blitProperties.clearColorAllocation, clearColorAllocation.get());
|
||||
EXPECT_EQ(blitProperties.dstGpuAddress, dstGpuAddr);
|
||||
EXPECT_EQ(blitProperties.srcGpuAddress, srcGpuAddr);
|
||||
EXPECT_EQ(blitProperties.copySize, copySize);
|
||||
EXPECT_EQ(blitProperties.dstOffset, dstOffsets);
|
||||
EXPECT_EQ(blitProperties.srcOffset, srcOffsets);
|
||||
EXPECT_EQ(blitProperties.dstRowPitch, dstRowPitch);
|
||||
EXPECT_EQ(blitProperties.dstSlicePitch, dstSlicePitch);
|
||||
EXPECT_EQ(blitProperties.srcRowPitch, srcRowPitch);
|
||||
EXPECT_EQ(blitProperties.srcSlicePitch, srcSlicePitch);
|
||||
}
|
||||
|
||||
TEST(BlitCommandsHelperTest, GivenCopySizeYAndZEqual0WhenConstructingPropertiesForBufferRegionsThenCopyZAndZEqual1) {
|
||||
uint32_t src[] = {1, 2, 3, 4};
|
||||
uint32_t dst[] = {4, 3, 2, 1};
|
||||
uint32_t clear[] = {5, 6, 7, 8};
|
||||
uint64_t srcGpuAddr = 0x12345;
|
||||
uint64_t dstGpuAddr = 0x54321;
|
||||
uint64_t clearGpuAddr = 0x5678;
|
||||
std::unique_ptr<MockGraphicsAllocation> srcAlloc(new MockGraphicsAllocation(src, srcGpuAddr, sizeof(src)));
|
||||
std::unique_ptr<MockGraphicsAllocation> dstAlloc(new MockGraphicsAllocation(dst, dstGpuAddr, sizeof(dst)));
|
||||
std::unique_ptr<GraphicsAllocation> clearColorAllocation(new MockGraphicsAllocation(clear, clearGpuAddr, sizeof(clear)));
|
||||
Vec3<size_t> srcOffsets{1, 2, 3};
|
||||
Vec3<size_t> dstOffsets{3, 2, 1};
|
||||
Vec3<size_t> copySize{2, 0, 0};
|
||||
|
||||
size_t srcRowPitch = 2;
|
||||
size_t srcSlicePitch = 3;
|
||||
|
||||
size_t dstRowPitch = 2;
|
||||
size_t dstSlicePitch = 3;
|
||||
|
||||
auto blitProperties = NEO::BlitProperties::constructPropertiesForCopy(dstAlloc.get(), srcAlloc.get(),
|
||||
dstOffsets, srcOffsets, copySize, srcRowPitch, srcSlicePitch,
|
||||
dstRowPitch, dstSlicePitch, clearColorAllocation.get());
|
||||
Vec3<size_t> expectedSize{copySize.x, 1, 1};
|
||||
EXPECT_EQ(blitProperties.copySize, expectedSize);
|
||||
}
|
||||
|
||||
using BlitTests = Test<DeviceFixture>;
|
||||
|
||||
HWTEST_F(BlitTests, givenDebugVariablesWhenGettingMaxBlitSizeThenHonorUseProvidedValues) {
|
||||
DebugManagerStateRestore restore{};
|
||||
|
||||
ASSERT_EQ(BlitterConstants::maxBlitWidth, BlitCommandsHelper<FamilyType>::getMaxBlitWidth(pDevice->getRootDeviceEnvironment()));
|
||||
ASSERT_EQ(BlitterConstants::maxBlitHeight, BlitCommandsHelper<FamilyType>::getMaxBlitHeight(pDevice->getRootDeviceEnvironment()));
|
||||
|
||||
DebugManager.flags.LimitBlitterMaxWidth.set(50);
|
||||
EXPECT_EQ(50u, BlitCommandsHelper<FamilyType>::getMaxBlitWidth(pDevice->getRootDeviceEnvironment()));
|
||||
|
||||
DebugManager.flags.LimitBlitterMaxHeight.set(60);
|
||||
EXPECT_EQ(60u, BlitCommandsHelper<FamilyType>::getMaxBlitHeight(pDevice->getRootDeviceEnvironment()));
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenDebugVariableWhenEstimatingPostBlitsCommandSizeThenReturnCorrectResult) {
|
||||
const size_t arbCheckSize = sizeof(typename FamilyType::MI_ARB_CHECK);
|
||||
|
||||
DebugManagerStateRestore restore{};
|
||||
|
||||
size_t expectedDefaultSize = arbCheckSize;
|
||||
|
||||
if (BlitCommandsHelper<FamilyType>::miArbCheckWaRequired()) {
|
||||
expectedDefaultSize += EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite();
|
||||
}
|
||||
|
||||
EXPECT_EQ(expectedDefaultSize, BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize());
|
||||
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiArbCheck);
|
||||
EXPECT_EQ(arbCheckSize, BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize());
|
||||
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiFlush);
|
||||
EXPECT_EQ(EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite(), BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize());
|
||||
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::None);
|
||||
EXPECT_EQ(0u, BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize());
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenDebugVariableWhenDispatchingPostBlitsCommandThenUseCorrectCommands) {
|
||||
using MI_ARB_CHECK = typename FamilyType::MI_ARB_CHECK;
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
DebugManagerStateRestore restore{};
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream linearStream{streamBuffer, sizeof(streamBuffer)};
|
||||
GenCmdList commands{};
|
||||
|
||||
size_t expectedDefaultSize = sizeof(MI_ARB_CHECK);
|
||||
|
||||
if (BlitCommandsHelper<FamilyType>::miArbCheckWaRequired()) {
|
||||
expectedDefaultSize += EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite();
|
||||
}
|
||||
|
||||
// -1: default
|
||||
BlitCommandsHelper<FamilyType>::dispatchPostBlitCommand(linearStream, *defaultHwInfo);
|
||||
EXPECT_EQ(expectedDefaultSize, linearStream.getUsed());
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, linearStream.getCpuBase(), linearStream.getUsed());
|
||||
|
||||
auto iterator = commands.begin();
|
||||
if (BlitCommandsHelper<FamilyType>::miArbCheckWaRequired()) {
|
||||
iterator = find<MI_FLUSH_DW *>(commands.begin(), commands.end());
|
||||
EXPECT_NE(commands.end(), iterator);
|
||||
if (EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite() == 2 * sizeof(MI_FLUSH_DW)) {
|
||||
iterator = find<MI_FLUSH_DW *>(++iterator, commands.end());
|
||||
EXPECT_NE(commands.end(), iterator);
|
||||
}
|
||||
}
|
||||
|
||||
auto arbCheck = find<MI_ARB_CHECK *>(iterator, commands.end());
|
||||
EXPECT_NE(commands.end(), arbCheck);
|
||||
|
||||
// 0: MI_ARB_CHECK
|
||||
memset(streamBuffer, 0, sizeof(streamBuffer));
|
||||
linearStream.replaceBuffer(streamBuffer, sizeof(streamBuffer));
|
||||
commands.clear();
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiArbCheck);
|
||||
BlitCommandsHelper<FamilyType>::dispatchPostBlitCommand(linearStream, *defaultHwInfo);
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, linearStream.getCpuBase(), linearStream.getUsed());
|
||||
arbCheck = find<MI_ARB_CHECK *>(commands.begin(), commands.end());
|
||||
EXPECT_NE(commands.end(), arbCheck);
|
||||
|
||||
// 1: MI_FLUSH_DW
|
||||
memset(streamBuffer, 0, sizeof(streamBuffer));
|
||||
linearStream.replaceBuffer(streamBuffer, sizeof(streamBuffer));
|
||||
commands.clear();
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::MiFlush);
|
||||
BlitCommandsHelper<FamilyType>::dispatchPostBlitCommand(linearStream, *defaultHwInfo);
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, linearStream.getCpuBase(), linearStream.getUsed());
|
||||
auto miFlush = find<MI_FLUSH_DW *>(commands.begin(), commands.end());
|
||||
EXPECT_NE(commands.end(), miFlush);
|
||||
|
||||
// 2: Nothing
|
||||
memset(streamBuffer, 0, sizeof(streamBuffer));
|
||||
linearStream.replaceBuffer(streamBuffer, sizeof(streamBuffer));
|
||||
commands.clear();
|
||||
DebugManager.flags.PostBlitCommand.set(BlitterConstants::PostBlitMode::None);
|
||||
BlitCommandsHelper<FamilyType>::dispatchPostBlitCommand(linearStream, *defaultHwInfo);
|
||||
EXPECT_EQ(0u, linearStream.getUsed());
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenMemoryWhenFillPatternWithBlitThenCommandIsProgrammed) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
uint32_t pattern[4] = {1, 0, 0, 0};
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenMemorySizeBiggerThanMaxWidthButLessThanTwiceMaxWidthWhenFillPatternWithBlitThenHeightIsOne) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
uint32_t pattern[4] = {1, 0, 0, 0};
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, (2 * BlitterConstants::maxBlitWidth) - 1,
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<XY_COLOR_BLT *>(*itor);
|
||||
EXPECT_EQ(cmd->getDestinationY2CoordinateBottom(), 1u);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenMemoryPointerOffsetVerifyCorrectDestinationBaseAddress) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
uint32_t pattern[4] = {5, 0, 0, 0};
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0x234, pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<XY_COLOR_BLT *>(*itor);
|
||||
EXPECT_EQ(cmd->getDestinationBaseAddress(), static_cast<uint64_t>(0x1234));
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenMemorySizeTwiceBiggerThanMaxWidthWhenFillPatternWithBlitThenHeightIsTwo) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
|
||||
HardwareInfo *hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = true;
|
||||
|
||||
REQUIRE_BLITTER_OR_SKIP(hwInfo);
|
||||
|
||||
uint32_t pattern[4] = {1, 0, 0, 0};
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, (2 * BlitterConstants::maxBlitWidth * sizeof(uint32_t)),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<XY_COLOR_BLT *>(*itor);
|
||||
EXPECT_EQ(cmd->getDestinationY2CoordinateBottom(), 2u);
|
||||
EXPECT_EQ(cmd->getDestinationPitch(), BlitterConstants::maxBlitWidth * sizeof(uint32_t));
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenMemorySizeIsLessThanTwicenMaxWidthWhenFillPatternWithBlitThenHeightIsOne) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
|
||||
HardwareInfo *hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = true;
|
||||
|
||||
REQUIRE_BLITTER_OR_SKIP(hwInfo);
|
||||
|
||||
uint32_t pattern[4] = {1, 0, 0, 0};
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, ((BlitterConstants::maxBlitWidth + 1) * sizeof(uint32_t)),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<XY_COLOR_BLT *>(*itor);
|
||||
EXPECT_EQ(cmd->getDestinationY2CoordinateBottom(), 1u);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenXyCopyBltCommandWhenAppendBlitCommandsMemCopyIsCalledThenNothingChanged) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
auto bltCmdBefore = bltCmd;
|
||||
BlitProperties properties = {};
|
||||
NEO::BlitCommandsHelper<FamilyType>::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment());
|
||||
EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_COPY_BLT)), 0);
|
||||
}
|
||||
|
||||
HWTEST_F(BlitTests, givenXyBlockCopyBltCommandAndSliceIndex0WhenAppendBaseAddressOffsetIsCalledThenNothingChanged) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
auto bltCmdBefore = bltCmd;
|
||||
BlitProperties properties{};
|
||||
uint32_t sliceIndex = 0;
|
||||
NEO::BlitCommandsHelper<FamilyType>::appendBaseAddressOffset(properties, bltCmd, sliceIndex, false);
|
||||
EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_BLOCK_COPY_BLT)), 0);
|
||||
}
|
||||
|
||||
using BlitColor = IsWithinProducts<IGFX_SKYLAKE, IGFX_ICELAKE_LP>;
|
||||
|
||||
HWTEST2_F(BlitTests, givenMemoryWhenFillPatternSizeIs4BytesThen32BitMaskISSetCorrectly, BlitColor) {
|
||||
using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT;
|
||||
using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH;
|
||||
uint32_t pattern = 1;
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<XY_COLOR_BLT *>(*itor);
|
||||
EXPECT_EQ(XY_COLOR_BLT::_32BPP_BYTE_MASK::_32BPP_BYTE_MASK_WRITE_RGBA_CHANNEL, cmd->get32BppByteMask());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH getColorDepth(size_t patternSize) {
|
||||
using COLOR_DEPTH = typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH;
|
||||
COLOR_DEPTH depth = {};
|
||||
switch (patternSize) {
|
||||
case 1:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR;
|
||||
break;
|
||||
case 2:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR1555;
|
||||
break;
|
||||
case 4:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR;
|
||||
break;
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitColorTests, givenCommandStreamAndPaternSizeEqualOneWhenCallToDispatchMemoryFillThenColorDepthAreProgrammedCorrectly, BlitColor) {
|
||||
size_t patternSize = 1;
|
||||
auto expecttedDepth = getColorDepth<FamilyType>(patternSize);
|
||||
GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed<FamilyType> test(pDevice);
|
||||
test.TestBodyImpl(patternSize, expecttedDepth);
|
||||
}
|
||||
HWTEST2_F(BlitColorTests, givenCommandStreamAndPaternSizeEqualTwoWhenCallToDispatchMemoryFillThenColorDepthAreProgrammedCorrectly, BlitColor) {
|
||||
size_t patternSize = 2;
|
||||
auto expecttedDepth = getColorDepth<FamilyType>(patternSize);
|
||||
GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed<FamilyType> test(pDevice);
|
||||
test.TestBodyImpl(patternSize, expecttedDepth);
|
||||
}
|
||||
HWTEST2_F(BlitColorTests, givenCommandStreamAndPaternSizeEqualFourWhenCallToDispatchMemoryFillThenColorDepthAreProgrammedCorrectly, BlitColor) {
|
||||
size_t patternSize = 4;
|
||||
auto expecttedDepth = getColorDepth<FamilyType>(patternSize);
|
||||
GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed<FamilyType> test(pDevice);
|
||||
test.TestBodyImpl(patternSize, expecttedDepth);
|
||||
}
|
||||
|
||||
using BlitPlatforms = IsWithinProducts<IGFX_SKYLAKE, IGFX_TIGERLAKE_LP>;
|
||||
template <typename FamilyType>
|
||||
typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH getFastColorDepth(size_t patternSize) {
|
||||
using COLOR_DEPTH = typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH;
|
||||
COLOR_DEPTH depth = {};
|
||||
switch (patternSize) {
|
||||
case 1:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR;
|
||||
break;
|
||||
case 2:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR;
|
||||
break;
|
||||
case 4:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR;
|
||||
break;
|
||||
case 8:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR;
|
||||
break;
|
||||
case 16:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR;
|
||||
break;
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
|
||||
using BlitFastColorTest = BlitColorTests;
|
||||
|
||||
HWTEST2_P(BlitFastColorTest, givenCommandStreamWhenCallToDispatchMemoryFillThenColorDepthAreProgrammedCorrectly, IsGen12LP) {
|
||||
auto patternSize = GetParam();
|
||||
auto expecttedDepth = getFastColorDepth<FamilyType>(patternSize);
|
||||
GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed<FamilyType> test(pDevice);
|
||||
test.TestBodyImpl(patternSize, expecttedDepth);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(size_t,
|
||||
BlitFastColorTest,
|
||||
testing::Values(1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
16));
|
||||
|
||||
HWTEST2_F(BlitTests, givenMemoryAndImageWhenDispatchCopyImageCallThenCommandAddedToStream, BlitPlatforms) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
MockGraphicsAllocation srcAlloc;
|
||||
MockGraphicsAllocation dstAlloc;
|
||||
MockGraphicsAllocation clearColorAllocation;
|
||||
|
||||
Vec3<size_t> dstOffsets = {0, 0, 0};
|
||||
Vec3<size_t> srcOffsets = {0, 0, 0};
|
||||
|
||||
Vec3<size_t> copySize = {0x100, 0x40, 0x1};
|
||||
Vec3<size_t> srcSize = {0x100, 0x40, 0x1};
|
||||
Vec3<size_t> dstSize = {0x100, 0x40, 0x1};
|
||||
|
||||
size_t srcRowPitch = srcSize.x;
|
||||
size_t srcSlicePitch = srcSize.y;
|
||||
size_t dstRowPitch = dstSize.x;
|
||||
size_t dstSlicePitch = dstSize.y;
|
||||
|
||||
auto blitProperties = NEO::BlitProperties::constructPropertiesForCopy(&dstAlloc, &srcAlloc,
|
||||
dstOffsets, srcOffsets, copySize, srcRowPitch, srcSlicePitch,
|
||||
dstRowPitch, dstSlicePitch, &clearColorAllocation);
|
||||
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
blitProperties.bytesPerPixel = 4;
|
||||
blitProperties.srcSize = srcSize;
|
||||
blitProperties.dstSize = dstSize;
|
||||
NEO::BlitCommandsHelper<FamilyType>::dispatchBlitCommandsForImageRegion(blitProperties, stream, *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_BLOCK_COPY_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, whenPrintImageBlitBlockCopyCommandIsCalledThenCmdDetailsAreNotPrintedToStdOutput, BlitPlatforms) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
NEO::BlitCommandsHelper<FamilyType>::printImageBlitBlockCopyCommand(bltCmd, 0);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput("");
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenGen9AndGetBlitAllocationPropertiesThenCorrectValuesAreReturned, IsGen9) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
|
||||
MockGraphicsAllocation alloc;
|
||||
uint32_t pitch = 0x10;
|
||||
uint32_t qPitch = 0x20;
|
||||
GMM_TILE_TYPE tileType = GMM_NOT_TILED;
|
||||
uint32_t mipTailLod = 0;
|
||||
|
||||
auto expectedPitch = pitch;
|
||||
auto expectedQPitch = qPitch;
|
||||
auto expectedtileType = tileType;
|
||||
auto expectedMipTailLod = mipTailLod;
|
||||
auto compressionDetails = 0u;
|
||||
auto compressionType = 0u;
|
||||
|
||||
NEO::BlitCommandsHelper<FamilyType>::getBlitAllocationProperties(alloc, pitch, qPitch, tileType, mipTailLod, compressionDetails,
|
||||
compressionType, pDevice->getRootDeviceEnvironment(),
|
||||
GMM_YUV_PLANE_ENUM::GMM_NO_PLANE);
|
||||
|
||||
EXPECT_EQ(expectedPitch, pitch);
|
||||
EXPECT_EQ(expectedQPitch, qPitch);
|
||||
EXPECT_EQ(expectedtileType, tileType);
|
||||
EXPECT_EQ(expectedMipTailLod, mipTailLod);
|
||||
}
|
||||
|
||||
using BlitTestsParams = BlitColorTests;
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenCopySizeAlignedWithin1and16BytesWhenGettingBytesPerPixelThenCorrectPixelSizeIsReturned, BlitPlatforms) {
|
||||
size_t copySize = 33;
|
||||
auto alignment = GetParam();
|
||||
copySize = alignUp(copySize, alignment);
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
srcOrigin = dstOrigin = 0;
|
||||
srcSize = dstSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, alignment);
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenSrcSizeAlignedWithin1and16BytesWhenGettingBytesPerPixelThenCorrectPixelSizeIsReturned, BlitPlatforms) {
|
||||
size_t copySize = BlitterConstants::maxBytesPerPixel;
|
||||
auto alignment = GetParam();
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
srcSize = 33;
|
||||
srcSize = alignUp(srcSize, alignment);
|
||||
srcOrigin = dstOrigin = dstSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, alignment);
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenSrcSizeNotAlignedWithin1and16BytesWhenGettingBytesPerPixelThen1BytePixelSizeIsReturned, BlitPlatforms) {
|
||||
size_t copySize = BlitterConstants::maxBytesPerPixel;
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
srcSize = 33;
|
||||
srcOrigin = dstOrigin = dstSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, 1u);
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenDstSizeAlignedWithin1and16BytesWhenGettingBytesPerPixelThenCorrectPixelSizeIsReturned, BlitPlatforms) {
|
||||
size_t copySize = BlitterConstants::maxBytesPerPixel;
|
||||
auto alignment = GetParam();
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
dstSize = 33;
|
||||
dstSize = alignUp(dstSize, alignment);
|
||||
srcOrigin = dstOrigin = srcSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, alignment);
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenDstSizeNotAlignedWithin1and16BytesWhenGettingBytesPerPixelThen1BytePixelSizeIsReturned, BlitPlatforms) {
|
||||
size_t copySize = BlitterConstants::maxBytesPerPixel;
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
dstSize = 33;
|
||||
srcOrigin = dstOrigin = srcSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, 1u);
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenSrcOriginAlignedWithin1and16BytesWhenGettingBytesPerPixelThenCorrectPixelSizeIsReturned, BlitPlatforms) {
|
||||
size_t copySize = BlitterConstants::maxBytesPerPixel;
|
||||
auto alignment = GetParam();
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
srcOrigin = 33;
|
||||
srcOrigin = alignUp(srcOrigin, alignment);
|
||||
dstSize = dstOrigin = srcSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, alignment);
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenDstOriginAlignedWithin1and16BytesWhenGettingBytesPerPixelThenCorrectPixelSizeIsReturned, BlitPlatforms) {
|
||||
size_t copySize = BlitterConstants::maxBytesPerPixel;
|
||||
auto alignment = GetParam();
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
dstOrigin = 33;
|
||||
dstOrigin = alignUp(dstOrigin, alignment);
|
||||
dstSize = srcOrigin = srcSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, alignment);
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsParams, givenDstOriginNotAlignedWithin1and16BytesWhenGettingBytesPerPixelThen1BytePixelSizeIsReturned, BlitPlatforms) {
|
||||
size_t copySize = BlitterConstants::maxBytesPerPixel;
|
||||
uint32_t srcOrigin, dstOrigin, srcSize, dstSize;
|
||||
dstOrigin = 33;
|
||||
dstSize = srcOrigin = srcSize = static_cast<uint32_t>(BlitterConstants::maxBytesPerPixel);
|
||||
uint32_t bytesPerPixel = NEO::BlitCommandsHelper<FamilyType>::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize);
|
||||
|
||||
EXPECT_EQ(bytesPerPixel, 1u);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(size_t,
|
||||
BlitTestsParams,
|
||||
testing::Values(1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
16));
|
||||
|
||||
using WithoutGen12Lp = IsNotGfxCore<IGFX_GEN12LP_CORE>;
|
||||
|
||||
HWTEST2_F(BlitTests, givenPlatformWhenCallingPreBlitCommandWARequiredThenReturnsFalse, WithoutGen12Lp) {
|
||||
EXPECT_FALSE(BlitCommandsHelper<FamilyType>::preBlitCommandWARequired());
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenPlatformWhenCallingEstimatePreBlitCommandSizeThenZeroIsReturned, WithoutGen12Lp) {
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
EXPECT_EQ(0u, BlitCommandsHelper<FamilyType>::estimatePreBlitCommandSize());
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenPlatformWhenCallingDispatchPreBlitCommandThenNoneMiFlushDwIsProgramed, WithoutGen12Lp) {
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
auto miFlushBuffer = std::make_unique<MI_FLUSH_DW>();
|
||||
LinearStream linearStream(miFlushBuffer.get(), EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite());
|
||||
|
||||
BlitCommandsHelper<FamilyType>::dispatchPreBlitCommand(linearStream, *defaultHwInfo);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(linearStream);
|
||||
auto cmdIterator = find<typename FamilyType::MI_FLUSH_DW *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
|
||||
ASSERT_EQ(hwParser.cmdList.end(), cmdIterator);
|
||||
}
|
||||
@@ -1,265 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/helpers/blit_commands_helper.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/helpers/blit_commands_helper_tests.inl"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_gmm.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using BlitTests = Test<DeviceFixture>;
|
||||
|
||||
HWTEST2_F(BlitTests, givenOneBytePerPixelWhenAppendColorDepthThenCorrectDepthIsSet, IsGen12LP) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 1;
|
||||
BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getColorDepth(), XY_BLOCK_COPY_BLT::COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenTwoBytePerPixelWhenAppendColorDepthThenCorrectDepthIsSet, IsGen12LP) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 2;
|
||||
BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getColorDepth(), XY_BLOCK_COPY_BLT::COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenFourBytePerPixelWhenAppendColorDepthThenCorrectDepthIsSet, IsGen12LP) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 4;
|
||||
BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getColorDepth(), XY_BLOCK_COPY_BLT::COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenEightBytePerPixelWhenAppendColorDepthThenCorrectDepthIsSet, IsGen12LP) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 8;
|
||||
BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getColorDepth(), XY_BLOCK_COPY_BLT::COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenSixteenBytePerPixelWhenAppendColorDepthThenCorrectDepthIsSet, IsGen12LP) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 16;
|
||||
BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getColorDepth(), XY_BLOCK_COPY_BLT::COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenIncorrectBytePerPixelWhenAppendColorDepthThenAbortIsThrown, IsGen12LP) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.bytesPerPixel = 48;
|
||||
EXPECT_THROW(BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd), std::exception);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenSrcAndDestinationImagesWhenAppendSliceOffsetsThenAdressAreCorectOffseted, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
|
||||
MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
mockAllocationSrc.setGmm(gmm.get(), 0);
|
||||
mockAllocationDst.setGmm(gmm.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
properties.srcGpuAddress = mockAllocationSrc.getGpuAddress();
|
||||
properties.dstGpuAddress = mockAllocationDst.getGpuAddress();
|
||||
|
||||
properties.srcSize.y = 0x10;
|
||||
properties.srcRowPitch = 0x10;
|
||||
auto srcSlicePitch = static_cast<uint32_t>(properties.srcSize.y * properties.srcRowPitch);
|
||||
|
||||
properties.dstSize.y = 0x20;
|
||||
properties.dstRowPitch = 0x20;
|
||||
auto dstSlicePitch = static_cast<uint32_t>(properties.dstSize.y * properties.dstRowPitch);
|
||||
|
||||
properties.srcOffset = {0x10, 0x10, 0x10};
|
||||
properties.dstOffset = {0x20, 0x20, 0x20};
|
||||
uint32_t index = 7;
|
||||
|
||||
BlitCommandsHelper<FamilyType>::appendSliceOffsets(properties, bltCmd, index, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
auto expectesSrcOffset = (index + properties.srcOffset.z) * srcSlicePitch;
|
||||
auto expectesDstOffset = (index + properties.dstOffset.z) * dstSlicePitch;
|
||||
|
||||
EXPECT_EQ(bltCmd.getSourceBaseAddress(), ptrOffset(mockAllocationSrc.getGpuAddress(), expectesSrcOffset));
|
||||
EXPECT_EQ(bltCmd.getDestinationBaseAddress(), ptrOffset(mockAllocationDst.getGpuAddress(), expectesDstOffset));
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenInputAndDefaultSlicePitchWhenAppendBlitCommandsForImagesThenSlicePitchesAreCorrect, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
|
||||
MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
properties.srcSize = {10, 10, 1};
|
||||
properties.dstSize = {8, 12, 1};
|
||||
properties.srcRowPitch = 0x10;
|
||||
properties.dstRowPitch = 0x40;
|
||||
|
||||
{
|
||||
uint32_t inputSlicePitch = 0;
|
||||
auto srcSlicePitch = inputSlicePitch;
|
||||
auto dstSlicePitch = inputSlicePitch;
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
|
||||
EXPECT_EQ(srcSlicePitch, static_cast<uint32_t>(properties.srcRowPitch * properties.srcSize.y));
|
||||
EXPECT_EQ(dstSlicePitch, static_cast<uint32_t>(properties.dstRowPitch * properties.dstSize.y));
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t inputSlicePitch = 0x40000;
|
||||
auto srcSlicePitch = inputSlicePitch;
|
||||
auto dstSlicePitch = inputSlicePitch;
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
|
||||
EXPECT_EQ(srcSlicePitch, inputSlicePitch);
|
||||
EXPECT_EQ(dstSlicePitch, inputSlicePitch);
|
||||
}
|
||||
}
|
||||
struct MyMockResourecInfo : public GmmResourceInfo {
|
||||
using GmmResourceInfo::resourceInfo;
|
||||
|
||||
MyMockResourecInfo(GmmClientContext *clientContext, GMM_RESCREATE_PARAMS *inputParams) : GmmResourceInfo(clientContext, inputParams){};
|
||||
MyMockResourecInfo(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmmResourceInfo) : GmmResourceInfo(clientContext, inputGmmResourceInfo){};
|
||||
size_t getRenderPitch() override {
|
||||
return pitch;
|
||||
}
|
||||
uint32_t getQPitch() override {
|
||||
return 0;
|
||||
}
|
||||
GMM_RESOURCE_FLAG *getResourceFlags() override {
|
||||
return &flags;
|
||||
}
|
||||
uint32_t getMipTailStartLodSurfaceState() override {
|
||||
return 0;
|
||||
}
|
||||
size_t pitch = 0;
|
||||
GMM_RESOURCE_FLAG flags = {};
|
||||
};
|
||||
|
||||
HWTEST2_F(BlitTests, givenTiledSrcAndDestinationImagesWhenAppendImageCommandsThenPitchIsValueFromGmm, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
|
||||
GMM_RESCREATE_PARAMS gmmParams = {};
|
||||
auto myResourecInfo = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
|
||||
myResourecInfo->pitch = 0x100;
|
||||
myResourecInfo->flags.Info.TiledY = 1;
|
||||
gmm->gmmResourceInfo.reset(myResourecInfo.release());
|
||||
MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
mockAllocationSrc.setGmm(gmm.get(), 0);
|
||||
mockAllocationDst.setGmm(gmm.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
properties.srcRowPitch = 0x1000;
|
||||
properties.dstRowPitch = 0x4000;
|
||||
auto srcSlicePitch = static_cast<uint32_t>(properties.srcSlicePitch);
|
||||
auto dstSlicePitch = static_cast<uint32_t>(properties.dstSlicePitch);
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
EXPECT_EQ(bltCmd.getDestinationPitch(), gmm->gmmResourceInfo->getRenderPitch());
|
||||
EXPECT_EQ(bltCmd.getSourcePitch(), gmm->gmmResourceInfo->getRenderPitch());
|
||||
EXPECT_NE(bltCmd.getDestinationPitch(), static_cast<uint32_t>(properties.dstRowPitch));
|
||||
EXPECT_NE(bltCmd.getSourcePitch(), static_cast<uint32_t>(properties.srcRowPitch));
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenLinearSrcAndDestinationImagesWhenAppendImageCommandsThenPitchIsValueFromProperties, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
|
||||
GMM_RESCREATE_PARAMS gmmParams = {};
|
||||
auto myResourecInfo = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
|
||||
myResourecInfo->pitch = 0x100;
|
||||
myResourecInfo->flags.Info.Linear = 1;
|
||||
gmm->gmmResourceInfo.reset(myResourecInfo.release());
|
||||
MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
mockAllocationSrc.setGmm(gmm.get(), 0);
|
||||
mockAllocationDst.setGmm(gmm.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
properties.srcRowPitch = 0x1000;
|
||||
properties.dstRowPitch = 0x4000;
|
||||
auto srcSlicePitch = static_cast<uint32_t>(properties.srcSlicePitch);
|
||||
auto dstSlicePitch = static_cast<uint32_t>(properties.dstSlicePitch);
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
EXPECT_NE(bltCmd.getDestinationPitch(), gmm->gmmResourceInfo->getRenderPitch());
|
||||
EXPECT_NE(bltCmd.getSourcePitch(), gmm->gmmResourceInfo->getRenderPitch());
|
||||
EXPECT_EQ(bltCmd.getDestinationPitch(), static_cast<uint32_t>(properties.dstRowPitch));
|
||||
EXPECT_EQ(bltCmd.getSourcePitch(), static_cast<uint32_t>(properties.srcRowPitch));
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenBlitCommandWhenAppendClearColorCalledThenNothingHappens, IsGen12LP) {
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
auto expectedBlitCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
BlitCommandsHelper<FamilyType>::appendClearColor(properties, bltCmd);
|
||||
EXPECT_EQ(0, std::memcmp(&expectedBlitCmd, &bltCmd, sizeof(bltCmd)));
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenGen12LpPlatformWhenPreBlitCommandWARequiredThenReturnsTrue, IsGen12LP) {
|
||||
EXPECT_TRUE(BlitCommandsHelper<FamilyType>::preBlitCommandWARequired());
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenGen12LpPlatformWhenEstimatePreBlitCommandSizeThenSizeOfFlushIsReturned, IsGen12LP) {
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
EXPECT_EQ(EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite(), BlitCommandsHelper<FamilyType>::estimatePreBlitCommandSize());
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenGen12LpPlatformWhenDispatchPreBlitCommandThenMiFlushDwIsProgramed, IsGen12LP) {
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
auto miFlushBuffer = std::make_unique<MI_FLUSH_DW>();
|
||||
LinearStream linearStream(miFlushBuffer.get(), EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite());
|
||||
|
||||
BlitCommandsHelper<FamilyType>::dispatchPreBlitCommand(linearStream, *defaultHwInfo);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(linearStream);
|
||||
auto cmdIterator = find<typename FamilyType::MI_FLUSH_DW *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
|
||||
ASSERT_NE(hwParser.cmdList.end(), cmdIterator);
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/helpers/engine_node_helper.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(EngineNodeHelperTest, givenValidEngineUsageWhenGettingStringRepresentationThenItIsCorrect) {
|
||||
EXPECT_EQ(std::string{"Regular"}, EngineHelpers::engineUsageToString(EngineUsage::Regular));
|
||||
EXPECT_EQ(std::string{"Internal"}, EngineHelpers::engineUsageToString(EngineUsage::Internal));
|
||||
EXPECT_EQ(std::string{"LowPriority"}, EngineHelpers::engineUsageToString(EngineUsage::LowPriority));
|
||||
EXPECT_EQ(std::string{"Cooperative"}, EngineHelpers::engineUsageToString(EngineUsage::Cooperative));
|
||||
}
|
||||
|
||||
TEST(EngineNodeHelperTest, givenInValidEngineUsageWhenGettingStringRepresentationThenReturnUnknown) {
|
||||
EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineUsageToString(EngineUsage::EngineUsageCount));
|
||||
EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineUsageToString(static_cast<EngineUsage>(0xcc)));
|
||||
}
|
||||
|
||||
TEST(EngineNodeHelperTest, givenValidEngineTypeWhenGettingStringRepresentationThenItIsCorrect) {
|
||||
#define CHECK_ENGINE(type) EXPECT_EQ(std::string{#type}, EngineHelpers::engineTypeToString(aub_stream::EngineType::ENGINE_##type))
|
||||
CHECK_ENGINE(RCS);
|
||||
CHECK_ENGINE(BCS);
|
||||
CHECK_ENGINE(VCS);
|
||||
CHECK_ENGINE(VECS);
|
||||
CHECK_ENGINE(CCS);
|
||||
CHECK_ENGINE(CCS1);
|
||||
CHECK_ENGINE(CCS2);
|
||||
CHECK_ENGINE(CCS3);
|
||||
CHECK_ENGINE(CCCS);
|
||||
CHECK_ENGINE(BCS1);
|
||||
CHECK_ENGINE(BCS2);
|
||||
CHECK_ENGINE(BCS3);
|
||||
CHECK_ENGINE(BCS4);
|
||||
CHECK_ENGINE(BCS5);
|
||||
CHECK_ENGINE(BCS6);
|
||||
CHECK_ENGINE(BCS7);
|
||||
CHECK_ENGINE(BCS8);
|
||||
#undef CHECK_ENGINE
|
||||
}
|
||||
|
||||
TEST(EngineNodeHelperTest, givenBcsWhenGettingBcsIndexThenReturnCorrectIndex) {
|
||||
EXPECT_EQ(0u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS));
|
||||
EXPECT_EQ(1u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS1));
|
||||
EXPECT_EQ(2u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS2));
|
||||
EXPECT_EQ(3u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS3));
|
||||
EXPECT_EQ(4u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS4));
|
||||
EXPECT_EQ(5u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS5));
|
||||
EXPECT_EQ(6u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS6));
|
||||
EXPECT_EQ(7u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS7));
|
||||
EXPECT_EQ(8u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS8));
|
||||
}
|
||||
|
||||
TEST(EngineNodeHelperTest, givenCcsEngineWhenHelperIsUsedThenReturnTrue) {
|
||||
EXPECT_TRUE(EngineHelpers::isCcs(aub_stream::EngineType::ENGINE_CCS));
|
||||
EXPECT_TRUE(EngineHelpers::isCcs(aub_stream::EngineType::ENGINE_CCS1));
|
||||
EXPECT_TRUE(EngineHelpers::isCcs(aub_stream::EngineType::ENGINE_CCS2));
|
||||
EXPECT_TRUE(EngineHelpers::isCcs(aub_stream::EngineType::ENGINE_CCS3));
|
||||
EXPECT_FALSE(EngineHelpers::isCcs(aub_stream::EngineType::ENGINE_RCS));
|
||||
EXPECT_FALSE(EngineHelpers::isCcs(aub_stream::EngineType::NUM_ENGINES));
|
||||
}
|
||||
|
||||
TEST(EngineNodeHelperTest, givenInvalidEngineTypeWhenGettingStringRepresentationThenItIsCorrect) {
|
||||
EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineTypeToString(aub_stream::EngineType::NUM_ENGINES));
|
||||
EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineTypeToString(static_cast<aub_stream::EngineType>(0xcc)));
|
||||
}
|
||||
|
||||
TEST(EngineNodeHelperTest, givenLinkCopyEnginesSupportedWhenGettingBcsEngineTypeThenFirstReturnMainCopyEngineAndThenRoundRobinBetweenLinkEngines) {
|
||||
SelectorCopyEngine selectorCopyEngine{};
|
||||
HardwareInfo hwInfo = *::defaultHwInfo;
|
||||
DeviceBitfield deviceBitfield = 0b11;
|
||||
hwInfo.featureTable.ftrBcsInfo = 0b111;
|
||||
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
}
|
||||
|
||||
TEST(EngineNodeHelperTest, givenMainBcsEngineIsReleasedWhenGettingBcsEngineTypeThenItCanBeReturnedAgain) {
|
||||
SelectorCopyEngine selectorCopyEngine{};
|
||||
HardwareInfo hwInfo = *::defaultHwInfo;
|
||||
DeviceBitfield deviceBitfield = 0b11;
|
||||
hwInfo.featureTable.ftrBcsInfo = 0b111;
|
||||
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
|
||||
EngineHelpers::releaseBcsEngineType(aub_stream::EngineType::ENGINE_BCS, selectorCopyEngine);
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
}
|
||||
|
||||
TEST(EngineNodeHelperTest, givenLinkBcsEngineIsReleasedWhenGettingBcsEngineTypeThenItDoesNotAffectFurtherSelections) {
|
||||
SelectorCopyEngine selectorCopyEngine{};
|
||||
HardwareInfo hwInfo = *::defaultHwInfo;
|
||||
DeviceBitfield deviceBitfield = 0b11;
|
||||
hwInfo.featureTable.ftrBcsInfo = 0b111;
|
||||
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
|
||||
EngineHelpers::releaseBcsEngineType(aub_stream::EngineType::ENGINE_BCS1, selectorCopyEngine);
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false));
|
||||
}
|
||||
|
||||
TEST(EngineNodeHelperTest, givenLinkCopyEnginesAndInternalUsageEnabledWhenGettingBcsEngineThenUseBcs2only) {
|
||||
SelectorCopyEngine selectorCopyEngine{};
|
||||
HardwareInfo hwInfo = *::defaultHwInfo;
|
||||
DeviceBitfield deviceBitfield = 0b11;
|
||||
hwInfo.featureTable.ftrBcsInfo = 0b111;
|
||||
auto isInternalUsage = true;
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, isInternalUsage));
|
||||
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, isInternalUsage));
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/helpers/stdio.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
TEST(FileIO, GivenNonEmptyFileWhenCheckingIfHasSizeThenReturnTrue) {
|
||||
std::string fileName("fileIO.bin");
|
||||
std::remove(fileName.c_str());
|
||||
ASSERT_FALSE(fileExists(fileName.c_str()));
|
||||
|
||||
FILE *fp = nullptr;
|
||||
fopen_s(&fp, fileName.c_str(), "wb");
|
||||
ASSERT_NE(nullptr, fp);
|
||||
fprintf(fp, "TEST");
|
||||
fclose(fp);
|
||||
|
||||
EXPECT_TRUE(fileExists(fileName.c_str()));
|
||||
EXPECT_TRUE(fileExistsHasSize(fileName.c_str()));
|
||||
}
|
||||
|
||||
TEST(FileIO, GivenEmptyFileWhenCheckingIfHasSizeThenReturnFalse) {
|
||||
std::string fileName("fileIO.bin");
|
||||
std::remove(fileName.c_str());
|
||||
ASSERT_FALSE(fileExists(fileName.c_str()));
|
||||
|
||||
FILE *fp = nullptr;
|
||||
fopen_s(&fp, fileName.c_str(), "wb");
|
||||
ASSERT_NE(nullptr, fp);
|
||||
fclose(fp);
|
||||
|
||||
EXPECT_TRUE(fileExists(fileName.c_str()));
|
||||
EXPECT_FALSE(fileExistsHasSize(fileName.c_str()));
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hash.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(HashTests, givenSamePointersWhenHashIsCalculatedThenSame32BitValuesAreGenerated) {
|
||||
uintptr_t ptr1UI = 1;
|
||||
uintptr_t ptr2UI = 1;
|
||||
void *ptr1 = reinterpret_cast<void *>(ptr1UI);
|
||||
void *ptr2 = reinterpret_cast<void *>(ptr2UI);
|
||||
|
||||
uint32_t hash1 = hashPtrToU32(ptr1);
|
||||
uint32_t hash2 = hashPtrToU32(ptr2);
|
||||
|
||||
EXPECT_EQ(hash1, hash2);
|
||||
}
|
||||
|
||||
TEST(HashTests, givenDifferentPointersWhenHashIsCalculatedThenUnique32BitValuesAreGenerated) {
|
||||
uintptr_t ptr1UI = 1;
|
||||
uintptr_t ptr2UI = ptr1UI | (ptr1UI << ((sizeof(uintptr_t) / 2) * 8));
|
||||
void *ptr1 = reinterpret_cast<void *>(ptr1UI);
|
||||
void *ptr2 = reinterpret_cast<void *>(ptr2UI);
|
||||
|
||||
uint32_t hash1 = hashPtrToU32(ptr1);
|
||||
uint32_t hash2 = hashPtrToU32(ptr2);
|
||||
|
||||
EXPECT_NE(hash1, hash2);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/heap_assigner.h"
|
||||
#include "shared/source/memory_manager/gfx_partition.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(HeapAssigner, givenInternalHeapIndexWhenMappingToInternalFrontWindowThenInternalFrontWindowReturned) {
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW, HeapAssigner::mapInternalWindowIndex(HeapIndex::HEAP_INTERNAL));
|
||||
}
|
||||
|
||||
TEST(HeapAssigner, givenInternalDeviceHeapIndexWhenMappingToInternalFrontWindowThenInternalDeviceFrontWindowReturned) {
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW, HeapAssigner::mapInternalWindowIndex(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY));
|
||||
}
|
||||
|
||||
TEST(HeapAssigner, givenOtherThanInternalHeapIndexWhenMappingToInternalFrontWindowThenAbortIsThrown) {
|
||||
EXPECT_THROW(HeapAssigner::mapInternalWindowIndex(HeapIndex::HEAP_STANDARD), std::exception);
|
||||
}
|
||||
|
||||
TEST(HeapAssigner, givenInternalHeapIndexWhenCheckingIsInternalHeapThenTrueIsReturned) {
|
||||
EXPECT_TRUE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL));
|
||||
EXPECT_TRUE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY));
|
||||
}
|
||||
|
||||
TEST(HeapAssigner, givenNonInternalHeapIndexWhenCheckingIsInternalHeapThenFalseIsReturned) {
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL_FRONT_WINDOW));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTERNAL_DEVICE_FRONT_WINDOW));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL_FRONT_WINDOW));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_STANDARD));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_STANDARD64KB));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_SVM));
|
||||
EXPECT_FALSE(HeapAssigner::isInternalHeap(HeapIndex::HEAP_EXTENDED));
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
typedef Test<DeviceFixture> HwHelperTest;
|
||||
|
||||
HWTEST_F(HwHelperTest, GivenHwInfoWithEnabledBliterWhenCheckCopyEnginesCountThenReturnedOne) {
|
||||
HardwareInfo hwInfo{};
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = true;
|
||||
EXPECT_EQ(HwHelper::getCopyEnginesCount(hwInfo), 1u);
|
||||
}
|
||||
|
||||
HWTEST_F(HwHelperTest, GivenHwInfoWithDisabledBliterWhenCheckCopyEnginesCountThenReturnedZero) {
|
||||
HardwareInfo hwInfo{};
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = false;
|
||||
EXPECT_EQ(HwHelper::getCopyEnginesCount(hwInfo), 0u);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using HwHelperDg2AndLaterTest = Test<DeviceFixture>;
|
||||
|
||||
HWTEST2_F(HwHelperDg2AndLaterTest, GivenUseL1CacheAsTrueWhenCallSetL1CachePolicyThenL1CachePolicyL1CacheControlIsSetProperly, IsAtLeastXeHpgCore) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE;
|
||||
|
||||
auto &helper = reinterpret_cast<HwHelperHw<FamilyType> &>(HwHelperHw<FamilyType>::get());
|
||||
|
||||
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
|
||||
bool useL1Cache = true;
|
||||
helper.setL1CachePolicy(useL1Cache, &surfaceState, defaultHwInfo.get());
|
||||
EXPECT_EQ(RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB, surfaceState.getL1CachePolicyL1CacheControl());
|
||||
}
|
||||
|
||||
HWTEST2_F(HwHelperDg2AndLaterTest, GivenOverrideL1CacheControlInSurfaceStateForScratchSpaceWhenCallSetL1CachePolicyThenL1CachePolicyL1CacheControlIsSetProperly, IsAtLeastXeHpgCore) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.OverrideL1CacheControlInSurfaceStateForScratchSpace.set(1);
|
||||
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE;
|
||||
|
||||
auto &helper = reinterpret_cast<HwHelperHw<FamilyType> &>(HwHelperHw<FamilyType>::get());
|
||||
|
||||
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
|
||||
bool useL1Cache = true;
|
||||
helper.setL1CachePolicy(useL1Cache, &surfaceState, defaultHwInfo.get());
|
||||
EXPECT_EQ(RENDER_SURFACE_STATE::L1_CACHE_POLICY_UC, surfaceState.getL1CachePolicyL1CacheControl());
|
||||
}
|
||||
|
||||
HWTEST2_F(HwHelperDg2AndLaterTest, GivenUseL1CacheAsFalseWhenCallSetL1CachePolicyThenL1CachePolicyL1CacheControlIsNotSet, IsAtLeastXeHpgCore) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE;
|
||||
|
||||
auto &helper = reinterpret_cast<HwHelperHw<FamilyType> &>(HwHelperHw<FamilyType>::get());
|
||||
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
|
||||
bool useL1Cache = false;
|
||||
helper.setL1CachePolicy(useL1Cache, &surfaceState, defaultHwInfo.get());
|
||||
EXPECT_NE(RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB, surfaceState.getL1CachePolicyL1CacheControl());
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/helpers/kernel_helpers.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
struct KernelHelperMaxWorkGroupsTests : ::testing::Test {
|
||||
uint32_t simd = 8;
|
||||
uint32_t threadCount = 8 * 1024;
|
||||
uint32_t dssCount = 16;
|
||||
uint32_t availableSlm = 64 * KB;
|
||||
uint32_t usedSlm = 0;
|
||||
uint32_t maxBarrierCount = 32;
|
||||
uint32_t numberOfBarriers = 0;
|
||||
uint32_t workDim = 3;
|
||||
size_t lws[3] = {10, 10, 10};
|
||||
|
||||
uint32_t getMaxWorkGroupCount() {
|
||||
return KernelHelper::getMaxWorkGroupCount(simd, threadCount, dssCount, availableSlm, usedSlm,
|
||||
maxBarrierCount, numberOfBarriers, workDim, lws);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(KernelHelperMaxWorkGroupsTests, GivenNoBarriersOrSlmUsedWhenCalculatingMaxWorkGroupsCountThenResultIsCalculatedWithSimd) {
|
||||
auto workGroupSize = lws[0] * lws[1] * lws[2];
|
||||
auto expected = threadCount / Math::divideAndRoundUp(workGroupSize, simd);
|
||||
EXPECT_EQ(expected, getMaxWorkGroupCount());
|
||||
}
|
||||
|
||||
TEST_F(KernelHelperMaxWorkGroupsTests, GivenDebugFlagSetWhenGetMaxWorkGroupCountCalledThenReturnCorrectValue) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.OverrideMaxWorkGroupCount.set(123);
|
||||
|
||||
EXPECT_EQ(123u, getMaxWorkGroupCount());
|
||||
}
|
||||
|
||||
TEST_F(KernelHelperMaxWorkGroupsTests, GivenBarriersWhenCalculatingMaxWorkGroupsCountThenResultIsCalculatedWithRegardToBarriersCount) {
|
||||
numberOfBarriers = 16;
|
||||
|
||||
auto expected = dssCount * (maxBarrierCount / numberOfBarriers);
|
||||
EXPECT_EQ(expected, getMaxWorkGroupCount());
|
||||
}
|
||||
|
||||
TEST_F(KernelHelperMaxWorkGroupsTests, GivenUsedSlmSizeWhenCalculatingMaxWorkGroupsCountThenResultIsCalculatedWithRegardToUsedSlmSize) {
|
||||
usedSlm = 4 * KB;
|
||||
|
||||
auto expected = availableSlm / usedSlm;
|
||||
EXPECT_EQ(expected, getMaxWorkGroupCount());
|
||||
}
|
||||
|
||||
TEST_F(KernelHelperMaxWorkGroupsTests, GivenVariousValuesWhenCalculatingMaxWorkGroupsCountThenLowestResultIsAlwaysReturned) {
|
||||
usedSlm = 1 * KB;
|
||||
numberOfBarriers = 1;
|
||||
dssCount = 1;
|
||||
|
||||
workDim = 1;
|
||||
lws[0] = simd;
|
||||
threadCount = 1;
|
||||
EXPECT_EQ(1u, getMaxWorkGroupCount());
|
||||
|
||||
threadCount = 1024;
|
||||
EXPECT_NE(1u, getMaxWorkGroupCount());
|
||||
|
||||
numberOfBarriers = 32;
|
||||
EXPECT_EQ(1u, getMaxWorkGroupCount());
|
||||
|
||||
numberOfBarriers = 1;
|
||||
EXPECT_NE(1u, getMaxWorkGroupCount());
|
||||
|
||||
usedSlm = availableSlm;
|
||||
EXPECT_EQ(1u, getMaxWorkGroupCount());
|
||||
}
|
||||
@@ -1,323 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/state_base_address_tests.h"
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
using IsBetweenSklAndTgllp = IsWithinProducts<IGFX_SKYLAKE, IGFX_TIGERLAKE_LP>;
|
||||
|
||||
HWTEST2_F(SBATest, WhenAppendStateBaseAddressParametersIsCalledThenSBACmdHasBindingSurfaceStateProgrammed, IsBetweenSklAndTgllp) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
STATE_BASE_ADDRESS stateBaseAddress;
|
||||
stateBaseAddress.setBindlessSurfaceStateSize(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddress(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddressModifyEnable(false);
|
||||
|
||||
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(
|
||||
&stateBaseAddress,
|
||||
&ssh,
|
||||
false,
|
||||
0,
|
||||
nullptr,
|
||||
false,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
true,
|
||||
false,
|
||||
1u);
|
||||
|
||||
EXPECT_EQ(ssh.getMaxAvailableSpace() / 64 - 1, stateBaseAddress.getBindlessSurfaceStateSize());
|
||||
EXPECT_EQ(ssh.getHeapGpuBase(), stateBaseAddress.getBindlessSurfaceStateBaseAddress());
|
||||
EXPECT_TRUE(stateBaseAddress.getBindlessSurfaceStateBaseAddressModifyEnable());
|
||||
}
|
||||
|
||||
HWTEST2_F(SBATest, WhenProgramStateBaseAddressParametersIsCalledThenSBACmdHasBindingSurfaceStateProgrammed, IsAtLeastSkl) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
STATE_BASE_ADDRESS stateBaseAddress;
|
||||
stateBaseAddress.setBindlessSurfaceStateSize(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddress(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddressModifyEnable(false);
|
||||
|
||||
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(commandStream.getSpace(0));
|
||||
*cmd = stateBaseAddress;
|
||||
|
||||
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
|
||||
cmd,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&ssh,
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
pDevice->getGmmHelper(),
|
||||
true,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
1u,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(ssh.getMaxAvailableSpace() / 64 - 1, cmd->getBindlessSurfaceStateSize());
|
||||
EXPECT_EQ(ssh.getHeapGpuBase(), cmd->getBindlessSurfaceStateBaseAddress());
|
||||
EXPECT_TRUE(cmd->getBindlessSurfaceStateBaseAddressModifyEnable());
|
||||
}
|
||||
|
||||
using SbaForBindlessTests = Test<DeviceFixture>;
|
||||
|
||||
HWTEST2_F(SbaForBindlessTests, givenGlobalBindlessBaseAddressWhenProgramStateBaseAddressThenSbaProgrammedCorrectly, IsAtLeastSkl) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
uint64_t globalBindlessHeapsBaseAddress = 0x12340000;
|
||||
|
||||
StackVec<char, 4096> buffer(4096);
|
||||
NEO::LinearStream cmdStream(buffer.begin(), buffer.size());
|
||||
|
||||
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(cmdStream.getSpace(0));
|
||||
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
|
||||
cmd,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
globalBindlessHeapsBaseAddress,
|
||||
false,
|
||||
true,
|
||||
pDevice->getGmmHelper(),
|
||||
true,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
1u,
|
||||
nullptr);
|
||||
EXPECT_TRUE(cmd->getBindlessSurfaceStateBaseAddressModifyEnable());
|
||||
EXPECT_EQ(cmd->getBindlessSurfaceStateBaseAddress(), globalBindlessHeapsBaseAddress);
|
||||
|
||||
auto surfaceStateCount = StateBaseAddressHelper<FamilyType>::getMaxBindlessSurfaceStates();
|
||||
EXPECT_EQ(surfaceStateCount, cmd->getBindlessSurfaceStateSize());
|
||||
}
|
||||
|
||||
using IohSupported = IsWithinGfxCore<GFXCORE_FAMILY::IGFX_GEN9_CORE, GFXCORE_FAMILY::IGFX_GEN12LP_CORE>;
|
||||
|
||||
HWTEST2_F(SbaForBindlessTests, givenGlobalBindlessBaseAddressWhenPassingIndirectBaseAddressThenIndirectBaseAddressIsSet, IohSupported) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
uint64_t globalBindlessHeapsBaseAddress = 0x12340000;
|
||||
uint64_t indirectObjectBaseAddress = 0x12340000;
|
||||
|
||||
StackVec<char, 4096> buffer(4096);
|
||||
NEO::LinearStream cmdStream(buffer.begin(), buffer.size());
|
||||
|
||||
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(cmdStream.getSpace(0));
|
||||
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
|
||||
cmd,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
indirectObjectBaseAddress,
|
||||
0,
|
||||
globalBindlessHeapsBaseAddress,
|
||||
false,
|
||||
true,
|
||||
pDevice->getGmmHelper(),
|
||||
true,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
1u,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(cmd->getIndirectObjectBaseAddress(), indirectObjectBaseAddress);
|
||||
}
|
||||
|
||||
HWTEST2_F(SBATest, givenSbaWhenOverrideBindlessSurfaceBaseIsFalseThenBindlessSurfaceBaseIsNotSet, IsAtLeastSkl) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
STATE_BASE_ADDRESS stateBaseAddress;
|
||||
stateBaseAddress.setBindlessSurfaceStateSize(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddress(0);
|
||||
stateBaseAddress.setBindlessSurfaceStateBaseAddressModifyEnable(false);
|
||||
|
||||
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(
|
||||
&stateBaseAddress,
|
||||
&ssh,
|
||||
false,
|
||||
0,
|
||||
pDevice->getRootDeviceEnvironment().getGmmHelper(),
|
||||
false,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
false,
|
||||
1u);
|
||||
|
||||
EXPECT_EQ(0u, stateBaseAddress.getBindlessSurfaceStateBaseAddress());
|
||||
}
|
||||
|
||||
HWTEST2_F(SBATest, givenGlobalBindlessBaseAddressWhenSshIsPassedThenBindlessSurfaceBaseIsGlobalHeapBase, IsAtLeastSkl) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
uint64_t globalBindlessHeapsBaseAddress = 0x12340000;
|
||||
|
||||
StackVec<char, 4096> buffer(4096);
|
||||
NEO::LinearStream cmdStream(buffer.begin(), buffer.size());
|
||||
|
||||
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(cmdStream.getSpace(0));
|
||||
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
|
||||
cmd,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&ssh,
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
globalBindlessHeapsBaseAddress,
|
||||
false,
|
||||
true,
|
||||
pDevice->getGmmHelper(),
|
||||
true,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
1u,
|
||||
nullptr);
|
||||
EXPECT_EQ(cmd->getBindlessSurfaceStateBaseAddress(), globalBindlessHeapsBaseAddress);
|
||||
}
|
||||
HWTEST2_F(SBATest, givenSurfaceStateHeapWhenNotUsingGlobalHeapBaseThenBindlessSurfaceBaseIsSshBase, IsAtLeastSkl) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
|
||||
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
|
||||
|
||||
uint64_t globalBindlessHeapsBaseAddress = 0x12340000;
|
||||
|
||||
StackVec<char, 4096> buffer(4096);
|
||||
NEO::LinearStream cmdStream(buffer.begin(), buffer.size());
|
||||
|
||||
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(cmdStream.getSpace(0));
|
||||
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
|
||||
cmd,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&ssh,
|
||||
0,
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
globalBindlessHeapsBaseAddress,
|
||||
false,
|
||||
false,
|
||||
pDevice->getGmmHelper(),
|
||||
true,
|
||||
MemoryCompressionState::NotApplicable,
|
||||
false,
|
||||
1u,
|
||||
nullptr);
|
||||
EXPECT_EQ(ssh.getHeapGpuBase(), cmd->getBindlessSurfaceStateBaseAddress());
|
||||
}
|
||||
|
||||
HWTEST2_F(SBATest, givenStateBaseAddressAndDebugFlagSetWhenAppendExtraCacheSettingsThenNothingChanged, IsAtMostXeHpCore) {
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
auto stateBaseAddress = FamilyType::cmdInitStateBaseAddress;
|
||||
auto expectedStateBaseAddress = FamilyType::cmdInitStateBaseAddress;
|
||||
|
||||
StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo);
|
||||
EXPECT_EQ(0, memcmp(&stateBaseAddress, &expectedStateBaseAddress, sizeof(STATE_BASE_ADDRESS)));
|
||||
|
||||
DebugManager.flags.ForceStatelessL1CachingPolicy.set(2);
|
||||
StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo);
|
||||
EXPECT_EQ(0, memcmp(&stateBaseAddress, &expectedStateBaseAddress, sizeof(STATE_BASE_ADDRESS)));
|
||||
}
|
||||
|
||||
HWTEST2_F(SBATest, givenDebugFlagSetWhenAppendingSbaThenProgramCorrectL1CachePolicy, IsAtLeastXeHpgCore) {
|
||||
auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get();
|
||||
AllocationProperties properties(pDevice->getRootDeviceIndex(), 1, AllocationType::BUFFER, pDevice->getDeviceBitfield());
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
IndirectHeap indirectHeap(allocation, 1);
|
||||
auto sbaCmd = FamilyType::cmdInitStateBaseAddress;
|
||||
|
||||
struct {
|
||||
uint32_t option;
|
||||
typename FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY cachePolicy;
|
||||
} testInputs[] = {
|
||||
{0, FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP},
|
||||
{2, FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB},
|
||||
{3, FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WT},
|
||||
{4, FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WS}};
|
||||
|
||||
for (const auto &input : testInputs) {
|
||||
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(input.option);
|
||||
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(&sbaCmd, &indirectHeap, true, 0,
|
||||
pDevice->getRootDeviceEnvironment().getGmmHelper(), false,
|
||||
MemoryCompressionState::NotApplicable, true, false, 1u);
|
||||
|
||||
EXPECT_EQ(input.cachePolicy, sbaCmd.getL1CachePolicyL1CacheControl());
|
||||
}
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
HWTEST2_F(SBATest, givenDebugFlagSetWhenAppendingRssThenProgramCorrectL1CachePolicy, IsAtLeastXeHpgCore) {
|
||||
auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get();
|
||||
size_t allocationSize = MemoryConstants::pageSize;
|
||||
AllocationProperties properties(pDevice->getRootDeviceIndex(), allocationSize, AllocationType::BUFFER, pDevice->getDeviceBitfield());
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
auto rssCmd = FamilyType::cmdInitRenderSurfaceState;
|
||||
|
||||
auto multiGraphicsAllocation = MultiGraphicsAllocation(pDevice->getRootDeviceIndex());
|
||||
multiGraphicsAllocation.addAllocation(allocation);
|
||||
|
||||
EncodeSurfaceStateArgs args;
|
||||
args.outMemory = &rssCmd;
|
||||
args.graphicsAddress = allocation->getGpuAddress();
|
||||
args.size = allocation->getUnderlyingBufferSize();
|
||||
args.mocs = 0;
|
||||
args.numAvailableDevices = pDevice->getNumGenericSubDevices();
|
||||
args.allocation = allocation;
|
||||
args.gmmHelper = pDevice->getGmmHelper();
|
||||
args.areMultipleSubDevicesInContext = true;
|
||||
|
||||
struct {
|
||||
uint32_t option;
|
||||
typename FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY cachePolicy;
|
||||
} testInputs[] = {
|
||||
{0, FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WBP},
|
||||
{2, FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB},
|
||||
{3, FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WT},
|
||||
{4, FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WS}};
|
||||
|
||||
for (const auto &input : testInputs) {
|
||||
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(input.option);
|
||||
EncodeSurfaceState<FamilyType>::encodeBuffer(args);
|
||||
EXPECT_EQ(input.cachePolicy, rssCmd.getL1CachePolicyL1CacheControl());
|
||||
}
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hash.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
|
||||
TEST(StringHelpers, GivenParamsWhenUsingStrncpyThenReturnIsCorrect) {
|
||||
char dst[1024] = "";
|
||||
char src[1024] = "HelloWorld";
|
||||
|
||||
//preconditions
|
||||
ASSERT_EQ(sizeof(dst), sizeof(src));
|
||||
//String must be smaller than array capacity
|
||||
ASSERT_LT(strlen(src), sizeof(src));
|
||||
|
||||
auto ret = strncpy_s(nullptr, 1024, src, 1024);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strncpy_s(dst, 1024, nullptr, 1024);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strncpy_s(dst, 512, src, 1024);
|
||||
EXPECT_EQ(ret, -ERANGE);
|
||||
|
||||
memset(dst, 0, sizeof(dst));
|
||||
ret = strncpy_s(dst, 1024, src, strlen(src) / 2);
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(0, memcmp(dst, src, strlen(src) / 2));
|
||||
for (size_t i = strlen(src) / 2; i < sizeof(dst); i++)
|
||||
EXPECT_EQ(0, dst[i]);
|
||||
|
||||
memset(dst, 0, sizeof(dst));
|
||||
ret = strncpy_s(dst, strlen(src) / 2, src, strlen(src) / 2);
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(0, memcmp(dst, src, strlen(src) / 2));
|
||||
for (size_t i = strlen(src) / 2; i < sizeof(dst); i++)
|
||||
EXPECT_EQ(0, dst[i]);
|
||||
|
||||
strncpy_s(dst, 1024, src, 1024);
|
||||
EXPECT_EQ(0, memcmp(dst, src, strlen(src)));
|
||||
for (size_t i = strlen(src); i < sizeof(dst); i++)
|
||||
EXPECT_EQ(0, dst[i]);
|
||||
}
|
||||
|
||||
TEST(StringHelpers, GivenParamsWhenUsingMemmoveThenReturnIsCorrect) {
|
||||
char dst[1024] = "";
|
||||
char src[1024] = "HelloWorld";
|
||||
|
||||
ASSERT_EQ(sizeof(dst), sizeof(src));
|
||||
|
||||
auto ret = memmove_s(nullptr, sizeof(dst), src, sizeof(src));
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = memmove_s(dst, sizeof(dst), nullptr, sizeof(src));
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = memmove_s(dst, sizeof(src) / 2, src, sizeof(src));
|
||||
EXPECT_EQ(ret, -ERANGE);
|
||||
|
||||
memset(dst, 0, sizeof(dst));
|
||||
ret = memmove_s(dst, sizeof(dst), src, sizeof(src));
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(0, memcmp(dst, src, sizeof(dst)));
|
||||
}
|
||||
|
||||
TEST(StringHelpers, GivenParamsWhenUsingStrcpyThenReturnIsCorrect) {
|
||||
char dst[1024] = "";
|
||||
char src[1024] = "HelloWorld";
|
||||
|
||||
ASSERT_EQ(sizeof(dst), sizeof(src));
|
||||
|
||||
auto ret = strcpy_s(nullptr, 0, src);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strcpy_s(nullptr, sizeof(dst), src);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strcpy_s(nullptr, 0, nullptr);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strcpy_s(nullptr, sizeof(dst), nullptr);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strcpy_s(dst, 0, nullptr);
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = strcpy_s(dst, strlen(src) / 2, src);
|
||||
EXPECT_EQ(ret, -ERANGE);
|
||||
|
||||
ret = strcpy_s(dst, strlen(src), src);
|
||||
EXPECT_EQ(ret, -ERANGE);
|
||||
|
||||
char pattern = 0x5a;
|
||||
memset(dst, pattern, sizeof(dst));
|
||||
ret = strcpy_s(dst, sizeof(dst), src);
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(0, memcmp(dst, src, strlen(src)));
|
||||
EXPECT_EQ(0, dst[strlen(src)]);
|
||||
for (size_t i = strlen(src) + 1; i < sizeof(dst); i++)
|
||||
EXPECT_EQ(pattern, dst[i]);
|
||||
}
|
||||
|
||||
TEST(StringHelpers, GivenParamsWhenUsingStrnlenThenReturnIsCorrect) {
|
||||
char src[1024] = "HelloWorld";
|
||||
|
||||
auto ret = strnlen_s(nullptr, sizeof(src));
|
||||
EXPECT_EQ(ret, 0u);
|
||||
|
||||
ret = strnlen_s(src, 0);
|
||||
EXPECT_EQ(ret, 0u);
|
||||
|
||||
ret = strnlen_s(src, sizeof(src));
|
||||
EXPECT_EQ(ret, strlen(src));
|
||||
}
|
||||
|
||||
TEST(StringHelpers, GivenParamsWhenUsingMemcpyThenReturnIsCorrect) {
|
||||
char dst[1024] = "";
|
||||
char src[1024] = "HelloWorld";
|
||||
|
||||
//preconditions
|
||||
ASSERT_EQ(sizeof(dst), sizeof(src));
|
||||
//String must be smaller than array capacity
|
||||
ASSERT_LT(strlen(src), sizeof(src));
|
||||
|
||||
auto ret = memcpy_s(nullptr, sizeof(dst), src, sizeof(src));
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = memcpy_s(dst, sizeof(dst), nullptr, sizeof(src));
|
||||
EXPECT_EQ(ret, -EINVAL);
|
||||
|
||||
ret = memcpy_s(dst, sizeof(dst) / 2, src, sizeof(src));
|
||||
EXPECT_EQ(ret, -ERANGE);
|
||||
|
||||
memset(dst, 0, sizeof(dst));
|
||||
ret = memcpy_s(dst, sizeof(dst), src, strlen(src) / 2);
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(0, memcmp(dst, src, strlen(src) / 2));
|
||||
for (size_t i = strlen(src) / 2; i < sizeof(dst); i++)
|
||||
EXPECT_EQ(0, dst[i]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
TEST(StringHelpers, GivenParamsWhenUsingSnprintfsThenReturnIsCorrect) {
|
||||
char buffer[15] = "";
|
||||
const char *fmtStr = "World!";
|
||||
|
||||
int retVal1 = snprintf_s(buffer, sizeof(buffer), sizeof(buffer), "Hello %s", fmtStr);
|
||||
ASSERT_EQ(12, retVal1);
|
||||
ASSERT_EQ(0, std::strcmp("Hello World!", buffer));
|
||||
|
||||
int retVal2 = snprintf_s(nullptr, sizeof(buffer), sizeof(buffer), "Hello %s", fmtStr);
|
||||
ASSERT_EQ(-EINVAL, retVal2);
|
||||
|
||||
int retVal3 = snprintf_s(buffer, sizeof(buffer), sizeof(buffer), nullptr, fmtStr);
|
||||
ASSERT_EQ(-EINVAL, retVal3);
|
||||
|
||||
int retVal4 = snprintf_s(nullptr, sizeof(buffer), sizeof(buffer), nullptr, fmtStr);
|
||||
ASSERT_EQ(-EINVAL, retVal4);
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hash.h"
|
||||
#include "shared/source/helpers/string_helpers.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using NEO::Hash;
|
||||
|
||||
TEST(CreateCombinedStrings, GivenSingleStringWhenCreatingCombinedStringThenDstStringMatchesSrcString) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char srcString[] = "HelloWorld";
|
||||
const char *pSrcString = srcString;
|
||||
auto srcStrings = &pSrcString;
|
||||
size_t lengths = strlen(srcString);
|
||||
|
||||
auto retVal = StringHelpers::createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
1,
|
||||
srcStrings,
|
||||
&lengths);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(lengths + 1, dstStringSizeInBytes);
|
||||
|
||||
EXPECT_EQ(0, strcmp(srcString, dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenNullLengthWhenCreatingCombinedStringThenDstStringIsCreatedCorrectly) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char srcString[] = "HelloWorld";
|
||||
const char *pSrcString = srcString;
|
||||
auto srcStrings = &pSrcString;
|
||||
|
||||
auto retVal = StringHelpers::createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
1,
|
||||
srcStrings,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(srcString, dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenZeroLengthWhenCreatingCombinedStringThenDstStringIsCreatedCorrectly) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char srcString[] = "HelloWorld";
|
||||
const char *pSrcString = srcString;
|
||||
auto srcStrings = &pSrcString;
|
||||
size_t lengths = 0;
|
||||
|
||||
auto retVal = StringHelpers::createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
1,
|
||||
srcStrings,
|
||||
&lengths);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(srcString, dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenMultiStringWhenCreatingCombinedStringThenDstStringIsConcatenationOfSrcStrings) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *srcString[] = {"HelloWorld", "dlroWolleH"};
|
||||
std::string combined(srcString[0]);
|
||||
combined += srcString[1];
|
||||
|
||||
auto srcStrings = &srcString[0];
|
||||
size_t lengths[2] = {strlen(srcString[0]), strlen(srcString[1])};
|
||||
|
||||
auto retVal = StringHelpers::createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
2,
|
||||
srcStrings,
|
||||
lengths);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(combined.c_str(), dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenMultiStringAndNullLengthWhenCreatingCombinedStringThenDstStringIsConcatenationOfSrcStrings) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *srcString[] = {"HelloWorld", "dlroWolleH"};
|
||||
std::string combined(srcString[0]);
|
||||
combined += srcString[1];
|
||||
auto srcStrings = &srcString[0];
|
||||
|
||||
auto retVal = StringHelpers::createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
2,
|
||||
srcStrings,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(combined.c_str(), dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenMultiStringAndZeroLengthWhenCreatingCombinedStringThenDstStringIsConcatenationOfSrcStrings) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *srcString[] = {"HelloWorld", "dlroWolleH"};
|
||||
std::string combined(srcString[0]);
|
||||
combined += srcString[1];
|
||||
auto srcStrings = &srcString[0];
|
||||
size_t lengths[2] = {0, strlen(srcString[1])};
|
||||
|
||||
auto retVal = StringHelpers::createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
2,
|
||||
srcStrings,
|
||||
lengths);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(combined.c_str(), dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenMultipleStringsIncludingOneWithErrorWhenCreatingCombinedStringThenErrorIsOmittedInDstString) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *srcString[] = {"HelloWorld", "dlroWolleHBABA"};
|
||||
const char *expString[] = {"HelloWorld", "dlroWolleH"};
|
||||
size_t lengths[2] = {0, strlen(expString[1])};
|
||||
std::string combined(expString[0]);
|
||||
combined += expString[1];
|
||||
|
||||
auto retVal = StringHelpers::createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
2,
|
||||
srcString,
|
||||
lengths);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(combined.c_str(), dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenInvalidInputWhenCreatingCombinedStringThenInvalidValueErrorIsReturned) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *srcString[] = {"HelloWorld", "dlroWolleH"};
|
||||
std::string combined(srcString[0]);
|
||||
combined += srcString[1];
|
||||
const char *srcStrings[2] = {srcString[0], srcString[1]};
|
||||
size_t lengths[2] = {0, strlen(srcString[1])};
|
||||
|
||||
auto retVal = StringHelpers::createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
0,
|
||||
srcStrings,
|
||||
lengths);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
|
||||
retVal = StringHelpers::createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
1,
|
||||
nullptr,
|
||||
lengths);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
|
||||
srcStrings[0] = nullptr;
|
||||
retVal = StringHelpers::createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
2,
|
||||
srcStrings,
|
||||
lengths);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
}
|
||||
|
||||
TEST(CreateCombinedStrings, GivenMultipleStringThatCountIsHigherThanMaximalStackSizeSizesWhenCreatingCombinedStringThenCorrectStringIsReturned) {
|
||||
std::string dstString;
|
||||
size_t dstStringSizeInBytes = 0;
|
||||
const char *defaultString = "hello";
|
||||
const char *srcString[StringHelpers::maximalStackSizeSizes + 2];
|
||||
std::string combinedString;
|
||||
for (int i = 0; i < StringHelpers::maximalStackSizeSizes + 2; i++) {
|
||||
srcString[i] = defaultString;
|
||||
combinedString += defaultString;
|
||||
}
|
||||
|
||||
auto retVal = StringHelpers::createCombinedString(
|
||||
dstString,
|
||||
dstStringSizeInBytes,
|
||||
StringHelpers::maximalStackSizeSizes + 2,
|
||||
srcString,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(combinedString.c_str(), dstString.c_str()));
|
||||
}
|
||||
|
||||
TEST(CreateHash, WhenGettingHashesThenHashesAreDeterministicAndDoNotCollide) {
|
||||
char pBuffer[128];
|
||||
memset(pBuffer, 0x23, sizeof(pBuffer));
|
||||
|
||||
// make sure we can get a hash and make sure we can get the same hash
|
||||
auto hash1 = Hash::hash(pBuffer, sizeof(pBuffer));
|
||||
auto hash2 = Hash::hash(pBuffer, sizeof(pBuffer));
|
||||
EXPECT_NE(0u, hash1);
|
||||
EXPECT_NE(0u, hash2);
|
||||
EXPECT_EQ(hash1, hash2);
|
||||
|
||||
// make sure that we get a different hash for different length/data
|
||||
auto hash3 = Hash::hash(pBuffer, sizeof(pBuffer) - 1);
|
||||
EXPECT_NE(0u, hash3);
|
||||
EXPECT_NE(hash2, hash3);
|
||||
}
|
||||
|
||||
TEST(CreateHash, WhenGettingHashThenChangesPastLengthDoNotAffectOutput) {
|
||||
char pBuffer[] = {
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55};
|
||||
|
||||
// Use unaligned lengths. Wiggle the byte after the length
|
||||
// Shouldn't affect hash.
|
||||
for (auto length = 1u; length < sizeof(pBuffer); length++) {
|
||||
auto hash1 = Hash::hash(pBuffer, length);
|
||||
pBuffer[length]++;
|
||||
EXPECT_EQ(hash1, Hash::hash(pBuffer, length));
|
||||
}
|
||||
}
|
||||
@@ -1,342 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
|
||||
#include "shared/test/common/helpers/blit_commands_helper_tests.inl"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_gmm.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using BlitTests = Test<DeviceFixture>;
|
||||
|
||||
HWTEST2_F(BlitTests, givenOneBytePatternWhenFillPatternWithBlitThenCommandIsProgrammed, IsPVC) {
|
||||
using MEM_SET = typename FamilyType::MEM_SET;
|
||||
uint32_t pattern = 1;
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<MEM_SET *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenDeviceWithoutDefaultGmmWhenAppendBlitCommandsForVillBufferThenDstCompressionDisabled, IsPVC) {
|
||||
using MEM_SET = typename FamilyType::MEM_SET;
|
||||
uint32_t pattern = 1;
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<MEM_SET *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto blitCmd = genCmdCast<MEM_SET *>(*itor);
|
||||
EXPECT_EQ(blitCmd->getDestinationCompressible(), MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_NOT_COMPRESSIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenGmmWithDisabledCompresionWhenAppendBlitCommandsForVillBufferThenDstCompressionDisabled, IsPVC) {
|
||||
using MEM_SET = typename FamilyType::MEM_SET;
|
||||
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
|
||||
gmm->isCompressionEnabled = false;
|
||||
|
||||
uint32_t pattern = 1;
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
mockAllocation.setGmm(gmm.get(), 0u);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<MEM_SET *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto blitCmd = genCmdCast<MEM_SET *>(*itor);
|
||||
EXPECT_EQ(blitCmd->getDestinationCompressible(), MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_NOT_COMPRESSIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenGmmWithEnabledCompresionWhenAppendBlitCommandsForVillBufferThenDstCompressionEnabled, IsPVC) {
|
||||
using MEM_SET = typename FamilyType::MEM_SET;
|
||||
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
|
||||
gmm->isCompressionEnabled = true;
|
||||
|
||||
uint32_t pattern = 1;
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
mockAllocation.setGmm(gmm.get(), 0u);
|
||||
const auto &rootDeviceEnvironment = pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()];
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), *rootDeviceEnvironment);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<MEM_SET *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto blitCmd = genCmdCast<MEM_SET *>(*itor);
|
||||
EXPECT_EQ(blitCmd->getDestinationCompressible(), MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_COMPRESSIBLE);
|
||||
|
||||
auto resourceFormat = gmm->gmmResourceInfo->getResourceFormat();
|
||||
auto compressionFormat = rootDeviceEnvironment->getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat);
|
||||
EXPECT_EQ(compressionFormat, blitCmd->getCompressionFormat40());
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenOverridedMocksValueWhenAppendBlitCommandsForVillBufferThenDebugMocksValueIsSet, IsPVC) {
|
||||
using MEM_SET = typename FamilyType::MEM_SET;
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
uint32_t mockValue = 5;
|
||||
DebugManager.flags.OverrideBlitterMocs.set(mockValue);
|
||||
|
||||
uint32_t pattern = 1;
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<MEM_SET *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto blitCmd = genCmdCast<MEM_SET *>(*itor);
|
||||
EXPECT_EQ(blitCmd->getDestinationMOCS(), mockValue);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenEnableStatelessCompressionWithUnifiedMemoryAndSystemMemWhenAppendBlitCommandsForVillBufferThenCompresionDisabled, IsPVC) {
|
||||
using MEM_SET = typename FamilyType::MEM_SET;
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(true);
|
||||
|
||||
uint32_t pattern = 1;
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<MEM_SET *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto blitCmd = genCmdCast<MEM_SET *>(*itor);
|
||||
EXPECT_EQ(blitCmd->getDestinationCompressible(), MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_NOT_COMPRESSIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenEnableStatelessCompressionWithUnifiedMemoryAndLocalMemWhenAppendBlitCommandsForVillBufferThenCompresionEnabled, IsPVC) {
|
||||
using MEM_SET = typename FamilyType::MEM_SET;
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(true);
|
||||
|
||||
uint32_t pattern = 1;
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::LocalMemory, MemoryManager::maxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<MEM_SET *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto blitCmd = genCmdCast<MEM_SET *>(*itor);
|
||||
EXPECT_EQ(blitCmd->getDestinationCompressible(), MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_COMPRESSIBLE);
|
||||
EXPECT_EQ(static_cast<uint32_t>(DebugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()), blitCmd->getCompressionFormat40());
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenMemorySizeBiggerThanMaxWidthButLessThanTwiceMaxWidthWhenFillPatternWithBlitThenHeightIsOne, IsPVC) {
|
||||
using MEM_SET = typename FamilyType::MEM_SET;
|
||||
uint32_t pattern = 1;
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, (2 * BlitterConstants::maxBlitSetWidth) - 1,
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<MEM_SET *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<MEM_SET *>(*itor);
|
||||
EXPECT_EQ(cmd->getFillHeight(), 1u);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenMemorySizeTwiceBiggerThanMaxWidthWhenFillPatternWithBlitThenHeightIsTwo, IsPVC) {
|
||||
using MEM_SET = typename FamilyType::MEM_SET;
|
||||
uint32_t pattern = 1;
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, (2 * BlitterConstants::maxBlitSetWidth),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<MEM_SET *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
{
|
||||
auto cmd = genCmdCast<MEM_SET *>(*itor);
|
||||
EXPECT_EQ(cmd->getFillHeight(), 2u);
|
||||
}
|
||||
}
|
||||
|
||||
struct BlitTestsTestXeHpc : BlitColorTests {};
|
||||
|
||||
template <typename FamilyType>
|
||||
class GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammedPVC : public GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed<FamilyType> {
|
||||
public:
|
||||
GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammedPVC(Device *device) : GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed<FamilyType>(device) {}
|
||||
};
|
||||
|
||||
template <typename FamilyType>
|
||||
typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH getColorDepth(size_t patternSize) {
|
||||
using COLOR_DEPTH = typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH;
|
||||
COLOR_DEPTH depth = {};
|
||||
switch (patternSize) {
|
||||
case 1:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR;
|
||||
break;
|
||||
case 2:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR;
|
||||
break;
|
||||
case 4:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR;
|
||||
break;
|
||||
case 8:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR;
|
||||
break;
|
||||
case 16:
|
||||
depth = COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR;
|
||||
break;
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
|
||||
HWTEST2_P(BlitTestsTestXeHpc, givenCommandStreamWhenCallToDispatchMemoryFillThenColorDepthAreProgrammedCorrectly, IsXeHpcCore) {
|
||||
auto patternSize = GetParam();
|
||||
auto expecttedDepth = getColorDepth<FamilyType>(patternSize);
|
||||
GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammedPVC<FamilyType> test(pDevice);
|
||||
test.TestBodyImpl(patternSize, expecttedDepth);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(size_t,
|
||||
BlitTestsTestXeHpc,
|
||||
testing::Values(2,
|
||||
4,
|
||||
8,
|
||||
16));
|
||||
|
||||
HWTEST2_F(BlitTests, givenMemoryAndImageWhenDispatchCopyImageCallThenCommandAddedToStream, IsPVC) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
MockGraphicsAllocation srcAlloc;
|
||||
MockGraphicsAllocation dstAlloc;
|
||||
MockGraphicsAllocation clearColorAlloc;
|
||||
|
||||
Vec3<size_t> dstOffsets = {0, 0, 0};
|
||||
Vec3<size_t> srcOffsets = {0, 0, 0};
|
||||
|
||||
Vec3<size_t> copySize = {0x100, 0x40, 0x1};
|
||||
Vec3<size_t> srcSize = {0x100, 0x40, 0x1};
|
||||
Vec3<size_t> dstSize = {0x100, 0x40, 0x1};
|
||||
|
||||
size_t srcRowPitch = srcSize.x;
|
||||
size_t srcSlicePitch = srcSize.y;
|
||||
size_t dstRowPitch = dstSize.x;
|
||||
size_t dstSlicePitch = dstSize.y;
|
||||
|
||||
auto blitProperties = BlitProperties::constructPropertiesForCopy(&dstAlloc, &srcAlloc,
|
||||
dstOffsets, srcOffsets, copySize, srcRowPitch, srcSlicePitch,
|
||||
dstRowPitch, dstSlicePitch, &clearColorAlloc);
|
||||
|
||||
uint32_t streamBuffer[100] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
blitProperties.bytesPerPixel = 4;
|
||||
blitProperties.srcSize = srcSize;
|
||||
blitProperties.dstSize = dstSize;
|
||||
NEO::BlitCommandsHelper<FamilyType>::dispatchBlitCommandsForImageRegion(blitProperties, stream, *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed()));
|
||||
auto itor = find<XY_BLOCK_COPY_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenBlockCopyCommandWhenAppendBlitCommandsForImagesThenNothingChanged, IsPVC) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
auto bltCmdBefore = bltCmd;
|
||||
BlitProperties properties = {};
|
||||
auto srcSlicePitch = static_cast<uint32_t>(properties.srcSlicePitch);
|
||||
auto dstSlicePitch = static_cast<uint32_t>(properties.dstSlicePitch);
|
||||
NEO::BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_BLOCK_COPY_BLT)), 0);
|
||||
}
|
||||
HWTEST2_F(BlitTests, givenBlockCopyCommandWhenAppendColorDepthThenNothingChanged, IsPVC) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
auto bltCmdBefore = bltCmd;
|
||||
BlitProperties properties = {};
|
||||
NEO::BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd);
|
||||
EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_BLOCK_COPY_BLT)), 0);
|
||||
}
|
||||
HWTEST2_F(BlitTests, givenBlockCopyCommandWhenAppendSliceOffsetThenNothingChanged, IsPVC) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
auto bltCmdBefore = bltCmd;
|
||||
BlitProperties properties = {};
|
||||
auto srcSlicePitch = 0u;
|
||||
auto dstSlicePitch = 0u;
|
||||
|
||||
NEO::BlitCommandsHelper<FamilyType>::appendSliceOffsets(properties, bltCmd, 0, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_BLOCK_COPY_BLT)), 0);
|
||||
}
|
||||
HWTEST2_F(BlitTests, givenBlockCopyCommandWhenAppendSurfaceTypeThenNothingChanged, IsPVC) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
auto bltCmdBefore = bltCmd;
|
||||
BlitProperties properties = {};
|
||||
NEO::BlitCommandsHelper<FamilyType>::appendSurfaceType(properties, bltCmd);
|
||||
EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_BLOCK_COPY_BLT)), 0);
|
||||
}
|
||||
HWTEST2_F(BlitTests, givenBlockCopyCommandWhenAppendTilingTypeThenNothingChanged, IsPVC) {
|
||||
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;
|
||||
auto bltCmdBefore = bltCmd;
|
||||
BlitProperties properties = {};
|
||||
NEO::BlitCommandsHelper<FamilyType>::appendTilingType(GMM_NOT_TILED, GMM_NOT_TILED, bltCmd);
|
||||
EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_BLOCK_COPY_BLT)), 0);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user