From 694b643df14e7f9cee242528ad510a4d95ec89bf Mon Sep 17 00:00:00 2001 From: "Hoppe, Mateusz" Date: Fri, 28 Dec 2018 11:07:43 +0100 Subject: [PATCH] Add useLocalMemory flag to ImageInfo Change-Id: I664f9e17c0c480c2b7b2b34dcfaefa7929b9ddfe --- runtime/helpers/surface_formats.h | 1 + .../memory_manager/memory_manager_tests.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/runtime/helpers/surface_formats.h b/runtime/helpers/surface_formats.h index 4ea71db710..4a7b878865 100644 --- a/runtime/helpers/surface_formats.h +++ b/runtime/helpers/surface_formats.h @@ -220,6 +220,7 @@ struct ImageInfo { uint32_t baseMipLevel; uint32_t mipCount; bool preferRenderCompression; + bool useLocalMemory; }; struct McsSurfaceInfo { diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 3b9f113460..7852c5a8aa 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -563,6 +563,22 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemor memoryManager.freeGraphicsMemory(imageAllocation); } +TEST(OsAgnosticMemoryManager, givenEnabledLocalMemoryWhenAllocateGraphicsMemoryForImageIsCalledThenUseLocalMemoryIsNotSet) { + ExecutionEnvironment executionEnvironment; + MockMemoryManager memoryManager(false, true, executionEnvironment); + cl_image_desc imgDesc = {}; + imgDesc.image_width = 1; + imgDesc.image_height = 1; + imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; + auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); + + executionEnvironment.initGmm(*platformDevices); + auto imageAllocation = memoryManager.allocateGraphicsMemoryForImage(imgInfo, nullptr); + ASSERT_NE(nullptr, imageAllocation); + EXPECT_FALSE(imgInfo.useLocalMemory); + memoryManager.freeGraphicsMemory(imageAllocation); +} + TEST(OsAgnosticMemoryManager, givenHostPointerNotRequiringCopyWhenAllocateGraphicsMemoryForImageFromHostPtrIsCalledThenGraphicsAllocationIsReturned) { ExecutionEnvironment executionEnvironment; OsAgnosticMemoryManager memoryManager(false, false, executionEnvironment);