diff --git a/runtime/gmm_helper/gmm.cpp b/runtime/gmm_helper/gmm.cpp index 33a4b76d65..d8567b24f2 100644 --- a/runtime/gmm_helper/gmm.cpp +++ b/runtime/gmm_helper/gmm.cpp @@ -25,12 +25,14 @@ #include "runtime/gmm_helper/resource_info.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/debug_helpers.h" +#include "runtime/helpers/hw_info.h" #include "runtime/helpers/ptr_math.h" #include "runtime/helpers/surface_formats.h" -#include "runtime/helpers/hw_info.h" namespace OCLRT { -Gmm::Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable) { +Gmm::Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable) : Gmm(alignedPtr, alignedSize, uncacheable, false) {} + +Gmm::Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable, bool preferRenderCompressed) { resourceParams.Type = RESOURCE_BUFFER; resourceParams.Format = GMM_FORMAT_GENERIC_8BIT; resourceParams.BaseWidth = static_cast(alignedSize); @@ -55,7 +57,7 @@ Gmm::Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable) { resourceParams.Flags.Gpu.NoRestriction = 1; } - applyAuxFlagsForBuffer(false); + applyAuxFlagsForBuffer(preferRenderCompressed); gmmResourceInfo.reset(GmmResourceInfo::create(&resourceParams)); } diff --git a/runtime/gmm_helper/gmm.h b/runtime/gmm_helper/gmm.h index 4917cebe20..a5004377bf 100644 --- a/runtime/gmm_helper/gmm.h +++ b/runtime/gmm_helper/gmm.h @@ -21,11 +21,11 @@ */ #pragma once +#include "runtime/api/cl_types.h" +#include "runtime/gmm_helper/gmm_lib.h" #include #include #include -#include "runtime/gmm_helper/gmm_lib.h" -#include "runtime/api/cl_types.h" namespace OCLRT { enum class OCLPlane; @@ -39,6 +39,7 @@ class Gmm { Gmm() = delete; Gmm(ImageInfo &inputOutputImgInfo); Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable); + Gmm(const void *alignedPtr, size_t alignedSize, bool uncacheable, bool preferRenderCompressed); Gmm(GMM_RESOURCE_INFO *inputGmm); void queryImageParams(ImageInfo &inputOutputImgInfo); diff --git a/runtime/gmm_helper/gmm_utils.cpp b/runtime/gmm_helper/gmm_utils.cpp index 72f5accf7f..404ba2bc03 100644 --- a/runtime/gmm_helper/gmm_utils.cpp +++ b/runtime/gmm_helper/gmm_utils.cpp @@ -21,6 +21,7 @@ */ #include "runtime/gmm_helper/gmm.h" +#include "runtime/gmm_helper/resource_info.h" #include "runtime/helpers/hw_info.h" #include "runtime/helpers/surface_formats.h" diff --git a/runtime/memory_manager/graphics_allocation.h b/runtime/memory_manager/graphics_allocation.h index 7dd7c1baf8..113200754d 100644 --- a/runtime/memory_manager/graphics_allocation.h +++ b/runtime/memory_manager/graphics_allocation.h @@ -68,6 +68,7 @@ class GraphicsAllocation : public IDNode { enum class AllocationType { UNKNOWN = 0, + BUFFER_COMPRESSED, BUFFER, IMAGE, TAG_BUFFER, diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index a2f96572d9..8eaa00dff1 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -20,19 +20,19 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/memory_manager/memory_manager.h" +#include "runtime/command_stream/command_stream_receiver.h" +#include "runtime/event/event.h" +#include "runtime/event/hw_timestamps.h" +#include "runtime/event/perf_counter.h" #include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/resource_info.h" -#include "runtime/memory_manager/deferred_deleter.h" -#include "runtime/memory_manager/memory_manager.h" -#include "runtime/event/event.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/basic_math.h" #include "runtime/helpers/options.h" -#include "runtime/command_stream/command_stream_receiver.h" +#include "runtime/memory_manager/deferred_deleter.h" #include "runtime/utilities/stackvec.h" #include "runtime/utilities/tag_allocator.h" -#include "runtime/event/hw_timestamps.h" -#include "runtime/event/perf_counter.h" #include @@ -114,7 +114,7 @@ void *MemoryManager::allocateSystemMemory(size_t size, size_t alignment) { GraphicsAllocation *MemoryManager::allocateGraphicsMemoryForSVM(size_t size, bool coherent) { GraphicsAllocation *graphicsAllocation = nullptr; if (peek64kbPagesEnabled()) { - graphicsAllocation = allocateGraphicsMemory64kb(size, MemoryConstants::pageSize64k, false); + graphicsAllocation = allocateGraphicsMemory64kb(size, MemoryConstants::pageSize64k, false, false); } else { graphicsAllocation = allocateGraphicsMemory(size); } @@ -375,6 +375,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, bool mustB switch (type) { case GraphicsAllocation::AllocationType::BUFFER: + case GraphicsAllocation::AllocationType::BUFFER_COMPRESSED: case GraphicsAllocation::AllocationType::PIPE: case GraphicsAllocation::AllocationType::SCRATCH_SURFACE: case GraphicsAllocation::AllocationType::PRIVATE_SURFACE: @@ -432,7 +433,8 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData & return allocateGraphicsMemory(allocationData.size, allocationData.hostPtr, allocationData.flags.forcePin); } if (peek64kbPagesEnabled() && allocationData.flags.allow64kbPages) { - return allocateGraphicsMemory64kb(allocationData.size, MemoryConstants::pageSize64k, allocationData.flags.forcePin); + bool preferRenderCompressed = (allocationData.type == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); + return allocateGraphicsMemory64kb(allocationData.size, MemoryConstants::pageSize64k, allocationData.flags.forcePin, preferRenderCompressed); } return allocateGraphicsMemory(allocationData.size, MemoryConstants::pageSize, allocationData.flags.forcePin, allocationData.flags.uncacheable); } diff --git a/runtime/memory_manager/memory_manager.h b/runtime/memory_manager/memory_manager.h index 0876dfacd9..832c9776eb 100644 --- a/runtime/memory_manager/memory_manager.h +++ b/runtime/memory_manager/memory_manager.h @@ -21,15 +21,15 @@ */ #pragma once +#include "runtime/helpers/aligned_memory.h" +#include "runtime/memory_manager/graphics_allocation.h" #include "runtime/memory_manager/host_ptr_defines.h" #include "runtime/memory_manager/host_ptr_manager.h" -#include "runtime/memory_manager/graphics_allocation.h" #include "runtime/os_interface/32bit_memory.h" -#include "runtime/helpers/aligned_memory.h" #include -#include #include +#include namespace OCLRT { class Device; @@ -121,7 +121,7 @@ class MemoryManager { virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) = 0; - virtual GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) = 0; + virtual GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) = 0; virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr) { return MemoryManager::allocateGraphicsMemory(size, ptr, false); diff --git a/runtime/memory_manager/os_agnostic_memory_manager.cpp b/runtime/memory_manager/os_agnostic_memory_manager.cpp index 406465b238..873850167c 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager.cpp +++ b/runtime/memory_manager/os_agnostic_memory_manager.cpp @@ -20,11 +20,11 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include "runtime/helpers/basic_math.h" -#include "runtime/helpers/aligned_memory.h" +#include "runtime/memory_manager/os_agnostic_memory_manager.h" #include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" -#include "runtime/memory_manager/os_agnostic_memory_manager.h" +#include "runtime/helpers/aligned_memory.h" +#include "runtime/helpers/basic_math.h" #include "runtime/helpers/options.h" #include "runtime/helpers/ptr_math.h" #include "runtime/helpers/surface_formats.h" @@ -63,7 +63,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size, return memoryAllocation; } -GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) { +GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) { auto memoryAllocation = allocateGraphicsMemory(alignUp(size, MemoryConstants::pageSize64k), MemoryConstants::pageSize64k, forcePin, false); if (memoryAllocation) { reinterpret_cast(memoryAllocation)->overrideMemoryPool(MemoryPool::System64KBPages); diff --git a/runtime/memory_manager/os_agnostic_memory_manager.h b/runtime/memory_manager/os_agnostic_memory_manager.h index 91745eaf09..70e4408e62 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager.h +++ b/runtime/memory_manager/os_agnostic_memory_manager.h @@ -21,8 +21,8 @@ */ #pragma once -#include "runtime/memory_manager/memory_manager.h" #include "runtime/helpers/basic_math.h" +#include "runtime/memory_manager/memory_manager.h" #include namespace OCLRT { @@ -63,7 +63,7 @@ class OsAgnosticMemoryManager : public MemoryManager { }; ~OsAgnosticMemoryManager() override; GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override; - GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override; + GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) override; GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) override; GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness, bool reuseBO) override; GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle) override { return nullptr; } diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index 11deff0c25..3979443277 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -204,7 +204,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemory(size_t size, const void return res; } -DrmAllocation *DrmMemoryManager::allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) { +DrmAllocation *DrmMemoryManager::allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) { return nullptr; } diff --git a/runtime/os_interface/linux/drm_memory_manager.h b/runtime/os_interface/linux/drm_memory_manager.h index 476546a9fc..0204ff0745 100644 --- a/runtime/os_interface/linux/drm_memory_manager.h +++ b/runtime/os_interface/linux/drm_memory_manager.h @@ -45,7 +45,7 @@ class DrmMemoryManager : public MemoryManager { void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override; void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override; DrmAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override; - DrmAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override; + DrmAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) override; DrmAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override { return allocateGraphicsMemory(size, ptr, false); } diff --git a/runtime/os_interface/windows/wddm_memory_manager.cpp b/runtime/os_interface/windows/wddm_memory_manager.cpp index 85315189f3..71184df750 100644 --- a/runtime/os_interface/windows/wddm_memory_manager.cpp +++ b/runtime/os_interface/windows/wddm_memory_manager.cpp @@ -75,13 +75,13 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo return allocation; } -GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) { +GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) { size_t sizeAligned = alignUp(size, MemoryConstants::pageSize64k); Gmm *gmm = nullptr; auto wddmAllocation = new WddmAllocation(nullptr, sizeAligned, nullptr, sizeAligned, nullptr, MemoryPool::System64KBPages); - gmm = new Gmm(nullptr, sizeAligned, false); + gmm = new Gmm(nullptr, sizeAligned, false, preferRenderCompressed); wddmAllocation->gmm = gmm; if (!wddm->createAllocation64k(wddmAllocation)) { diff --git a/runtime/os_interface/windows/wddm_memory_manager.h b/runtime/os_interface/windows/wddm_memory_manager.h index 91d266fc3c..87d94cf95c 100644 --- a/runtime/os_interface/windows/wddm_memory_manager.h +++ b/runtime/os_interface/windows/wddm_memory_manager.h @@ -46,7 +46,7 @@ class WddmMemoryManager : public MemoryManager { WddmMemoryManager &operator=(const WddmMemoryManager &) = delete; void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override; - GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override; + GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) override; GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override; GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override; GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) override; diff --git a/unit_tests/mem_obj/buffer_pin_tests.cpp b/unit_tests/mem_obj/buffer_pin_tests.cpp index 18ed3d810c..398987275e 100644 --- a/unit_tests/mem_obj/buffer_pin_tests.cpp +++ b/unit_tests/mem_obj/buffer_pin_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -20,16 +20,16 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/helpers/options.h" #include "runtime/mem_obj/buffer.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h" +#include "test.h" #include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/fixtures/memory_management_fixture.h" +#include "unit_tests/fixtures/platform_fixture.h" #include "unit_tests/helpers/memory_management.h" #include "unit_tests/mocks/mock_context.h" -#include "unit_tests/fixtures/platform_fixture.h" -#include "runtime/helpers/options.h" #include "gtest/gtest.h" -#include "test.h" using namespace OCLRT; @@ -43,7 +43,7 @@ class TestedMemoryManager : public OsAgnosticMemoryManager { } return OsAgnosticMemoryManager::allocateGraphicsMemory(size, alignment, forcePin, uncacheable); }; - GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override { + GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) override { return nullptr; }; GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr, bool forcePin) override { diff --git a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp index 7309891c88..6eb0546470 100644 --- a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp @@ -22,8 +22,8 @@ #include "runtime/memory_manager/os_agnostic_memory_manager.h" -#include "gtest/gtest.h" #include "test.h" +#include "gtest/gtest.h" using namespace OCLRT; class MemoryManagerGetAlloctionDataTest : public testing::TestWithParam { @@ -42,9 +42,10 @@ class MockOsAgnosticMemoryManager : public OsAgnosticMemoryManager { allocationCreated = true; return OsAgnosticMemoryManager::allocateGraphicsMemory(size, alignment, forcePin, uncacheable); } - GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override { + GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) override { allocation64kbPageCreated = true; - return OsAgnosticMemoryManager::allocateGraphicsMemory64kb(size, alignment, forcePin); + preferRenderCompressedFlagPassed = preferRenderCompressed; + return OsAgnosticMemoryManager::allocateGraphicsMemory64kb(size, alignment, forcePin, preferRenderCompressed); } GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override { @@ -68,6 +69,7 @@ class MockOsAgnosticMemoryManager : public OsAgnosticMemoryManager { bool allocationInDevicePoolCreated = false; bool failInDevicePool = false; bool failInDevicePoolWithError = false; + bool preferRenderCompressedFlagPassed = false; }; TEST(MemoryManagerGetAlloctionDataTest, givenMustBeZeroCopyAndAllocateMemoryFlagsAndNullptrWhenAllocationDataIsQueriedThenCorrectFlagsAndSizeAreSet) { @@ -128,6 +130,22 @@ TEST_P(MemoryManagerGetAlloctionData32BitAnd64kbPagesAllowedTest, givenAllocatio EXPECT_EQ(allocType, allocData.type); } +TEST_P(MemoryManagerGetAlloctionData32BitAnd64kbPagesAllowedTest, given64kbAllowedAllocationTypeWhenAllocatingThenPreferRenderCompressionOnlyForSpecificTypes) { + auto allocType = GetParam(); + AllocationData allocData; + MockOsAgnosticMemoryManager::getAllocationData(allocData, false, true, false, false, nullptr, 10, allocType); + bool bufferCompressedType = (allocType == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); + EXPECT_TRUE(allocData.flags.allow64kbPages); + + MockOsAgnosticMemoryManager mockMemoryManager(true); + auto allocation = mockMemoryManager.allocateGraphicsMemory(allocData); + + EXPECT_TRUE(mockMemoryManager.allocation64kbPageCreated); + EXPECT_EQ(mockMemoryManager.preferRenderCompressedFlagPassed, bufferCompressedType); + + mockMemoryManager.freeGraphicsMemory(allocation); +} + typedef MemoryManagerGetAlloctionDataTest MemoryManagerGetAlloctionData32BitAnd64kbPagesNotAllowedTest; TEST_P(MemoryManagerGetAlloctionData32BitAnd64kbPagesNotAllowedTest, givenAllocationTypesWith32BitAnd64kbPagesDisallowedWhenAllocationDataIsQueriedThenFlagsAreNotSet) { @@ -142,6 +160,7 @@ TEST_P(MemoryManagerGetAlloctionData32BitAnd64kbPagesNotAllowedTest, givenAlloca } static const GraphicsAllocation::AllocationType allocationTypesWith32BitAnd64KbPagesAllowed[] = {GraphicsAllocation::AllocationType::BUFFER, + GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, GraphicsAllocation::AllocationType::PIPE, GraphicsAllocation::AllocationType::SCRATCH_SURFACE, GraphicsAllocation::AllocationType::PRIVATE_SURFACE, diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 22d5c19cb2..cf28aeb1f0 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -856,7 +856,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocate OsAgnosticMemoryManager memoryManager(true); auto size = 4096u; - auto allocation = memoryManager.allocateGraphicsMemory64kb(size, MemoryConstants::preferredAlignment, false); + auto allocation = memoryManager.allocateGraphicsMemory64kb(size, MemoryConstants::preferredAlignment, false, false); EXPECT_NE(nullptr, allocation); EXPECT_EQ(MemoryPool::System64KBPages, allocation->getMemoryPool()); memoryManager.freeGraphicsMemory(allocation); @@ -874,7 +874,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocate MockOsAgnosticManagerWithFailingAllocate memoryManager(true); auto size = 4096u; - auto allocation = memoryManager.allocateGraphicsMemory64kb(size, MemoryConstants::preferredAlignment, false); + auto allocation = memoryManager.allocateGraphicsMemory64kb(size, MemoryConstants::preferredAlignment, false, false); EXPECT_EQ(nullptr, allocation); memoryManager.freeGraphicsMemory(allocation); } diff --git a/unit_tests/memory_manager/svm_memory_manager.cpp b/unit_tests/memory_manager/svm_memory_manager.cpp index 28cc8fd0bf..4c41c580e5 100644 --- a/unit_tests/memory_manager/svm_memory_manager.cpp +++ b/unit_tests/memory_manager/svm_memory_manager.cpp @@ -20,15 +20,15 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include "gtest/gtest.h" -#include "test.h" -#include "runtime/event/event.h" #include "runtime/memory_manager/svm_memory_manager.h" +#include "runtime/event/event.h" #include "runtime/utilities/tag_allocator.h" -#include "unit_tests/helpers/memory_management.h" -#include "unit_tests/utilities/containers_tests_helpers.h" +#include "test.h" #include "unit_tests/fixtures/memory_allocator_fixture.h" +#include "unit_tests/helpers/memory_management.h" #include "unit_tests/mocks/mock_context.h" +#include "unit_tests/utilities/containers_tests_helpers.h" +#include "gtest/gtest.h" #include @@ -145,3 +145,19 @@ TEST_F(SVMMemoryAllocatorTest, WhenCouldNotAllocateInMemoryManagerThenReturnsNul EXPECT_EQ(0U, svmM.GetSVMAllocs().getNumAllocs()); } } + +TEST_F(SVMMemoryAllocatorTest, given64kbAllowedwhenAllocatingSvmMemoryThenDontPreferRenderCompression) { + class MyMemoryManager : public OsAgnosticMemoryManager { + public: + MyMemoryManager() { enable64kbpages = true; } + GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) override { + preferRenderCompressedFlag = preferRenderCompressed; + return nullptr; + } + bool preferRenderCompressedFlag = true; + }; + + MyMemoryManager myMemoryManager; + myMemoryManager.allocateGraphicsMemoryForSVM(1, false); + EXPECT_FALSE(myMemoryManager.preferRenderCompressedFlag); +} diff --git a/unit_tests/mocks/mock_device.h b/unit_tests/mocks/mock_device.h index c445fbefaa..259008b0c3 100644 --- a/unit_tests/mocks/mock_device.h +++ b/unit_tests/mocks/mock_device.h @@ -161,7 +161,7 @@ class FailMemoryManager : public MockMemoryManager { allocations.push_back(alloc); return alloc; }; - GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override { + GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) override { return nullptr; }; GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override { diff --git a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp index c1cd7bef87..6f2db02e1e 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -732,7 +732,7 @@ TEST_F(DrmMemoryManagerTest, GivenPointerAndSizeWhenAskedToCreateGrahicsAllocati } TEST_F(DrmMemoryManagerTest, GivenPointerAndSizeWhenAskedToCreateGrahicsAllocation64kThenNullPtr) { - auto allocation = memoryManager->allocateGraphicsMemory64kb(65536, 65536, false); + auto allocation = memoryManager->allocateGraphicsMemory64kb(65536, 65536, false, false); EXPECT_EQ(nullptr, allocation); } @@ -2466,7 +2466,7 @@ TEST(DrmMemoryManager, givenMemoryManagerWhenCreateAllocationFromHandleIsCalledT TEST(DrmMemoryManager, DISABLED_givenMemoryManagerWith64KBPagesEnabledWhenAllocateGraphicsMemory64kbIsCalledThenMemoryPoolIsSystem64KBPages) { std::unique_ptr memoryManager(new (std::nothrow) TestedDrmMemoryManager(Drm::get(0), false, true)); auto size = 4096u; - auto allocation = memoryManager->allocateGraphicsMemory64kb(size, MemoryConstants::preferredAlignment, false); + auto allocation = memoryManager->allocateGraphicsMemory64kb(size, MemoryConstants::preferredAlignment, false, false); ASSERT_NE(nullptr, allocation); EXPECT_EQ(MemoryPool::System64KBPages, allocation->getMemoryPool()); memoryManager->freeGraphicsMemory(allocation); diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp index 006cad69fe..ded09e4fc4 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -99,7 +99,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocateGraphicsMemory TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesEnabledWhenAllocateGraphicsMemory64kbIsCalledThenMemoryPoolIsSystem64KBPages) { memoryManager.reset(new MockWddmMemoryManager(false, wddm)); auto size = 4096u; - auto allocation = memoryManager->allocateGraphicsMemory64kb(size, MemoryConstants::preferredAlignment, false); + auto allocation = memoryManager->allocateGraphicsMemory64kb(size, MemoryConstants::preferredAlignment, false, false); EXPECT_NE(nullptr, allocation); EXPECT_EQ(MemoryPool::System64KBPages, allocation->getMemoryPool()); memoryManager->freeGraphicsMemory(allocation); @@ -2020,7 +2020,7 @@ HWTEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocati EXPECT_TRUE(wddm->init()); DebugManager.flags.Enable64kbpages.set(true); WddmMemoryManager memoryManager(true, wddm); - auto graphicsAllocation = memoryManager.allocateGraphicsMemory64kb(1, MemoryConstants::pageSize64k, false); + auto graphicsAllocation = memoryManager.allocateGraphicsMemory64kb(1, MemoryConstants::pageSize64k, false, false); EXPECT_NE(nullptr, graphicsAllocation); EXPECT_EQ(MemoryConstants::pageSize64k, graphicsAllocation->getUnderlyingBufferSize()); @@ -2041,7 +2041,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenWddmWhenallocateGraphicsMemory64kbThenL MockWddmMemoryManager memoryManager64k(wddm); uint32_t lockCount = wddm->lockResult.called; uint32_t mapGpuVirtualAddressResult = wddm->mapGpuVirtualAddressResult.called; - GraphicsAllocation *galloc = memoryManager64k.allocateGraphicsMemory64kb(65536, 65536, true); + GraphicsAllocation *galloc = memoryManager64k.allocateGraphicsMemory64kb(65536, 65536, true, false); EXPECT_EQ(lockCount + 1, wddm->lockResult.called); EXPECT_EQ(mapGpuVirtualAddressResult + 1, wddm->mapGpuVirtualAddressResult.called); EXPECT_NE(wddm->mapGpuVirtualAddressResult.cpuPtrPassed, nullptr);