Windows: use HEAP_INTERNAL in 32bit scenarios
Change-Id: I652727303eec45cd3547bd98bec42f276000d9b4 Signed-off-by: Jablonski, Mateusz <mateusz.jablonski@intel.com>
This commit is contained in:
parent
4943c102cd
commit
e095ac834d
|
@ -999,7 +999,7 @@ std::unique_lock<SpinLock> Wddm::acquireLock(SpinLock &lock) {
|
|||
HeapIndex Wddm::selectHeap(const WddmAllocation *allocation, const void *ptr) const {
|
||||
if (allocation) {
|
||||
if (allocation->origin == AllocationOrigin::INTERNAL_ALLOCATION) {
|
||||
return HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY;
|
||||
return internalHeapIndex;
|
||||
} else if (allocation->is32BitAllocation) {
|
||||
return HeapIndex::HEAP_EXTERNAL;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "runtime/os_interface/os_context.h"
|
||||
#include "runtime/helpers/debug_helpers.h"
|
||||
#include "runtime/gmm_helper/gmm_lib.h"
|
||||
#include "runtime/memory_manager/memory_constants.h"
|
||||
#include "runtime/utilities/spinlock.h"
|
||||
#include "sku_info.h"
|
||||
#include <memory>
|
||||
|
@ -52,6 +53,8 @@ enum class HeapIndex : uint32_t {
|
|||
HEAP_LIMITED
|
||||
};
|
||||
|
||||
constexpr auto internalHeapIndex = is32bit ? HeapIndex::HEAP_INTERNAL : HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY;
|
||||
|
||||
class Wddm {
|
||||
public:
|
||||
typedef HRESULT(WINAPI *CreateDXGIFactoryFcn)(REFIID riid, void **ppFactory);
|
||||
|
|
|
@ -450,7 +450,7 @@ uint64_t WddmMemoryManager::getMaxApplicationAddress() {
|
|||
}
|
||||
|
||||
uint64_t WddmMemoryManager::getInternalHeapBaseAddress() {
|
||||
return this->wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Base;
|
||||
return this->wddm->getGfxPartition().Heap32[static_cast<uint32_t>(internalHeapIndex)].Base;
|
||||
}
|
||||
|
||||
bool WddmMemoryManager::mapAuxGpuVA(GraphicsAllocation *graphicsAllocation) {
|
||||
|
|
|
@ -267,7 +267,7 @@ TEST_F(Wddm20Tests, createAllocation32bit) {
|
|||
delete gmm;
|
||||
}
|
||||
|
||||
TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddressWithingHeap0Limits) {
|
||||
TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddressWithingHeapInternalLimits) {
|
||||
void *alignedPtr = (void *)0x12000;
|
||||
size_t alignedSize = 0x2000;
|
||||
WddmAllocation allocation(alignedPtr, alignedSize, nullptr, MemoryPool::MemoryNull, 1u, false);
|
||||
|
@ -275,13 +275,12 @@ TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddr
|
|||
allocation.handle = ALLOCATION_HANDLE;
|
||||
allocation.gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
|
||||
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, wddm->selectHeap(&allocation, allocation.getAlignedCpuPtr()));
|
||||
EXPECT_EQ(internalHeapIndex, wddm->selectHeap(&allocation, allocation.getAlignedCpuPtr()));
|
||||
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
uint32_t heapIndex = static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY);
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[heapIndex].Base);
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[heapIndex].Limit);
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[static_cast<uint32_t>(internalHeapIndex)].Base);
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[static_cast<uint32_t>(internalHeapIndex)].Limit);
|
||||
|
||||
EXPECT_GE(allocation.gpuPtr, cannonizedHeapBase);
|
||||
EXPECT_LE(allocation.gpuPtr, cannonizedHeapEnd);
|
||||
|
@ -1001,17 +1000,17 @@ TEST_F(Wddm20Tests, whenEvictingTemporaryResourceThenOtherResourcesRemainOnTheLi
|
|||
|
||||
using WddmHeapSelectorTest = Wddm20Tests;
|
||||
|
||||
TEST_F(WddmHeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalDeviceMemoryHeapIsUsed) {
|
||||
TEST_F(WddmHeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
|
||||
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
|
||||
allocation.is32BitAllocation = true;
|
||||
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, wddm->selectHeap(&allocation, nullptr));
|
||||
EXPECT_EQ(internalHeapIndex, wddm->selectHeap(&allocation, nullptr));
|
||||
}
|
||||
TEST_F(WddmHeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalDeviceMemoryHeapIsUsed) {
|
||||
TEST_F(WddmHeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
|
||||
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
|
||||
allocation.is32BitAllocation = false;
|
||||
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, wddm->selectHeap(&allocation, nullptr));
|
||||
EXPECT_EQ(internalHeapIndex, wddm->selectHeap(&allocation, nullptr));
|
||||
}
|
||||
TEST_F(WddmHeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternalHeapIsUsed) {
|
||||
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
|
||||
|
|
|
@ -865,7 +865,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAnd
|
|||
EXPECT_FALSE(ret);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocationWhenCallIsMadeThenAllocationIsCreatedIn32BitHeap1) {
|
||||
TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocationWhenCallIsMadeThenAllocationIsCreatedIn32BitHeapInternal) {
|
||||
auto wddmAllocation = static_cast<WddmAllocation *>(memoryManager->allocate32BitGraphicsMemory(MemoryConstants::pageSize, nullptr, AllocationOrigin::INTERNAL_ALLOCATION));
|
||||
ASSERT_NE(nullptr, wddmAllocation);
|
||||
EXPECT_EQ(wddmAllocation->gpuBaseAddress, GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress()));
|
||||
|
@ -873,7 +873,7 @@ TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocatio
|
|||
EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress());
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress());
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Limit);
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[static_cast<uint32_t>(internalHeapIndex)].Limit);
|
||||
|
||||
EXPECT_GE(wddmAllocation->getGpuAddress(), cannonizedHeapBase);
|
||||
EXPECT_LE(wddmAllocation->getGpuAddress(), cannonizedHeapEnd);
|
||||
|
@ -892,7 +892,7 @@ TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhe
|
|||
EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress());
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress());
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Limit);
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(wddm->getGfxPartition().Heap32[static_cast<uint32_t>(internalHeapIndex)].Limit);
|
||||
|
||||
EXPECT_GE(wddmAllocation->getGpuAddress(), cannonizedHeapBase);
|
||||
EXPECT_LE(wddmAllocation->getGpuAddress(), cannonizedHeapEnd);
|
||||
|
@ -1152,12 +1152,12 @@ TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithoutAsyncDele
|
|||
EXPECT_EQ(1u, wddm->createAllocationResult.called);
|
||||
}
|
||||
|
||||
TEST(WddmMemoryManagerDefaults, givenDefaultWddmMemoryManagerWhenItIsQueriedForInternalHeapBaseThenHeapInternalDeviceMemoryBaseIsReturned) {
|
||||
TEST(WddmMemoryManagerDefaults, givenDefaultWddmMemoryManagerWhenItIsQueriedForInternalHeapBaseThenHeapInternalBaseIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
auto wddm = std::make_unique<WddmMock>();
|
||||
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
|
||||
MockWddmMemoryManager memoryManager(wddm.get(), executionEnvironment);
|
||||
auto heapBase = wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Base;
|
||||
auto heapBase = wddm->getGfxPartition().Heap32[static_cast<uint32_t>(internalHeapIndex)].Base;
|
||||
EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue