mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
Drain deferred deletions when cannot allocate memory for tiled image
Change-Id: I68b15269da4b5a58e02571a9c594c52b9a95edeb
This commit is contained in:
committed by
sys_ocldev
parent
45990a8181
commit
f12b5861fd
@@ -515,11 +515,10 @@ bool Wddm::freeGpuVirtualAddres(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size) {
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool Wddm::createAllocation(WddmAllocation *alloc) {
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
NTSTATUS Wddm::createAllocation(WddmAllocation *alloc) {
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
D3DDDI_ALLOCATIONINFO AllocationInfo = {0};
|
||||
D3DKMT_CREATEALLOCATION CreateAllocation = {0};
|
||||
bool success = false;
|
||||
size_t size;
|
||||
|
||||
if (alloc == nullptr)
|
||||
@@ -547,7 +546,7 @@ bool Wddm::createAllocation(WddmAllocation *alloc) {
|
||||
CreateAllocation.pAllocationInfo = &AllocationInfo;
|
||||
CreateAllocation.hDevice = device;
|
||||
|
||||
while (!success) {
|
||||
while (status != STATUS_SUCCESS) {
|
||||
|
||||
status = gdi->createAllocation(&CreateAllocation);
|
||||
|
||||
@@ -557,16 +556,14 @@ bool Wddm::createAllocation(WddmAllocation *alloc) {
|
||||
}
|
||||
|
||||
alloc->handle = AllocationInfo.hAllocation;
|
||||
success = mapGpuVirtualAddress(alloc, alloc->getAlignedCpuPtr(), size, alloc->is32BitAllocation, false);
|
||||
status = mapGpuVirtualAddress(alloc, alloc->getAlignedCpuPtr(), size, alloc->is32BitAllocation, false) == true ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
|
||||
|
||||
if (!success) {
|
||||
if (status != STATUS_SUCCESS) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
break;
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
return success;
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Wddm::createAllocation64k(WddmAllocation *alloc) {
|
||||
|
||||
@@ -79,7 +79,7 @@ class Wddm {
|
||||
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData, bool allocation32bit, bool use64kbPages);
|
||||
MOCKABLE_VIRTUAL D3DKMT_HANDLE createContext();
|
||||
MOCKABLE_VIRTUAL bool freeGpuVirtualAddres(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size);
|
||||
MOCKABLE_VIRTUAL bool createAllocation(WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL NTSTATUS createAllocation(WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL bool createAllocation64k(WddmAllocation *alloc);
|
||||
bool createAllocationsAndMapGpuVa(OsHandleStorage &osHandles);
|
||||
MOCKABLE_VIRTUAL bool destroyAllocations(D3DKMT_HANDLE *handles, uint32_t allocationCount, uint64_t lastFenceValue, D3DKMT_HANDLE resourceHandle);
|
||||
|
||||
@@ -31,6 +31,11 @@
|
||||
#include "runtime/os_interface/windows/wddm_allocation.h"
|
||||
#include "runtime/os_interface/windows/wddm.h"
|
||||
#include <algorithm>
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4005)
|
||||
#include <ntstatus.h>
|
||||
#pragma warning(pop)
|
||||
|
||||
#undef max
|
||||
|
||||
namespace OCLRT {
|
||||
@@ -63,13 +68,15 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo
|
||||
delete gmm;
|
||||
return allocateGraphicsMemory(imgInfo.size, MemoryConstants::preferredAlignment);
|
||||
}
|
||||
|
||||
WddmAllocation allocation(nullptr, imgInfo.size);
|
||||
allocation.gmm = gmm;
|
||||
bool success = wddm->createAllocation(&allocation);
|
||||
auto status = wddm->createAllocation(&allocation);
|
||||
if (status == STATUS_GRAPHICS_NO_VIDEO_MEMORY && deferredDeleter) {
|
||||
deferredDeleter->drain(true);
|
||||
status = wddm->createAllocation(&allocation);
|
||||
}
|
||||
allocation.setGpuAddress(allocation.gpuPtr);
|
||||
|
||||
if (success) {
|
||||
if (status == STATUS_SUCCESS) {
|
||||
auto *wddmAllocation = new WddmAllocation(allocation);
|
||||
return wddmAllocation;
|
||||
}
|
||||
@@ -126,7 +133,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, size_
|
||||
|
||||
while (success) {
|
||||
allocation.gmm = gmm;
|
||||
success = wddm->createAllocation(&allocation);
|
||||
success = wddm->createAllocation(&allocation) == STATUS_SUCCESS;
|
||||
|
||||
if (!success)
|
||||
break;
|
||||
@@ -182,7 +189,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size,
|
||||
|
||||
while (success) {
|
||||
allocation.gmm = gmm;
|
||||
success = wddm->createAllocation(&allocation);
|
||||
success = wddm->createAllocation(&allocation) == STATUS_SUCCESS;
|
||||
|
||||
if (!success)
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user