mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-12 17:33:00 +08:00
Change memory interface makeResident call to accept multiple allocations
Change-Id: I5434e30b5200d89d9912aeb7a06b230220ec1de4 Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
eedf063d86
commit
5e4ade58f8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "runtime/os_interface/windows/wddm_memory_operations_handler.h"
|
||||
|
||||
#include "core/memory_manager/host_ptr_defines.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
#include "runtime/os_interface/windows/wddm_allocation.h"
|
||||
#include "runtime/os_interface/windows/wddm_residency_allocations_container.h"
|
||||
|
||||
@@ -16,19 +18,62 @@ WddmMemoryOperationsHandler::WddmMemoryOperationsHandler(Wddm *wddm) : wddm(wddm
|
||||
residentAllocations = std::make_unique<WddmResidentAllocationsContainer>(wddm);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus WddmMemoryOperationsHandler::makeResident(GraphicsAllocation &gfxAllocation) {
|
||||
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
|
||||
return residentAllocations->makeResidentResources(wddmAllocation.getHandles().data(), wddmAllocation.getNumHandles());
|
||||
MemoryOperationsStatus WddmMemoryOperationsHandler::makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) {
|
||||
uint32_t totalHandlesCount = 0;
|
||||
constexpr uint32_t stackAllocations = 64;
|
||||
constexpr uint32_t stackHandlesCount = NEO::maxFragmentsCount * EngineLimits::maxHandleCount * stackAllocations;
|
||||
StackVec<D3DKMT_HANDLE, stackHandlesCount> handlesForResidency;
|
||||
|
||||
for (const auto &allocation : gfxAllocations) {
|
||||
WddmAllocation *wddmAllocation = reinterpret_cast<WddmAllocation *>(allocation);
|
||||
|
||||
if (wddmAllocation->fragmentsStorage.fragmentCount > 0) {
|
||||
for (uint32_t allocationId = 0; allocationId < wddmAllocation->fragmentsStorage.fragmentCount; allocationId++) {
|
||||
handlesForResidency[totalHandlesCount++] = wddmAllocation->fragmentsStorage.fragmentStorageData[allocationId].osHandleStorage->handle;
|
||||
}
|
||||
} else {
|
||||
memcpy_s(&handlesForResidency[totalHandlesCount],
|
||||
wddmAllocation->getNumHandles() * sizeof(D3DKMT_HANDLE),
|
||||
wddmAllocation->getHandles().data(),
|
||||
wddmAllocation->getNumHandles() * sizeof(D3DKMT_HANDLE));
|
||||
totalHandlesCount += wddmAllocation->getNumHandles();
|
||||
}
|
||||
}
|
||||
return residentAllocations->makeResidentResources(handlesForResidency.begin(), totalHandlesCount);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus WddmMemoryOperationsHandler::evict(GraphicsAllocation &gfxAllocation) {
|
||||
constexpr uint32_t stackHandlesCount = NEO::maxFragmentsCount * EngineLimits::maxHandleCount;
|
||||
StackVec<D3DKMT_HANDLE, stackHandlesCount> handlesForEviction;
|
||||
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
|
||||
return residentAllocations->evictResources(wddmAllocation.getHandles().data(), wddmAllocation.getNumHandles());
|
||||
uint32_t totalHandleCount = 0;
|
||||
if (wddmAllocation.fragmentsStorage.fragmentCount > 0) {
|
||||
OsHandleStorage &fragmentStorage = wddmAllocation.fragmentsStorage;
|
||||
|
||||
for (uint32_t allocId = 0; allocId < fragmentStorage.fragmentCount; allocId++) {
|
||||
handlesForEviction.push_back(fragmentStorage.fragmentStorageData[allocId].osHandleStorage->handle);
|
||||
totalHandleCount++;
|
||||
}
|
||||
} else {
|
||||
const D3DKMT_HANDLE *handlePtr = wddmAllocation.getHandles().data();
|
||||
size_t handleCount = wddmAllocation.getNumHandles();
|
||||
for (uint32_t i = 0; i < handleCount; i++, totalHandleCount++) {
|
||||
handlesForEviction.push_back(*handlePtr);
|
||||
handlePtr++;
|
||||
}
|
||||
}
|
||||
return residentAllocations->evictResources(handlesForEviction.begin(), totalHandleCount);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus WddmMemoryOperationsHandler::isResident(GraphicsAllocation &gfxAllocation) {
|
||||
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
|
||||
return residentAllocations->isAllocationResident(wddmAllocation.getDefaultHandle());
|
||||
D3DKMT_HANDLE defaultHandle = 0u;
|
||||
if (wddmAllocation.fragmentsStorage.fragmentCount > 0) {
|
||||
defaultHandle = wddmAllocation.fragmentsStorage.fragmentStorageData[0].osHandleStorage->handle;
|
||||
} else {
|
||||
defaultHandle = wddmAllocation.getDefaultHandle();
|
||||
}
|
||||
return residentAllocations->isAllocationResident(defaultHandle);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -20,7 +20,7 @@ class WddmMemoryOperationsHandler : public MemoryOperationsHandler {
|
||||
WddmMemoryOperationsHandler(Wddm *wddm);
|
||||
~WddmMemoryOperationsHandler() override = default;
|
||||
|
||||
MemoryOperationsStatus makeResident(GraphicsAllocation &gfxAllocation) override;
|
||||
MemoryOperationsStatus makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
||||
MemoryOperationsStatus evict(GraphicsAllocation &gfxAllocation) override;
|
||||
MemoryOperationsStatus isResident(GraphicsAllocation &gfxAllocation) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user