mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Tracking the internal allocation when creating a buffer
This fix prevents the creation of a buffer from the pointer obtained from clEnqueueMapBuffer Change-Id: I203f2d5263eeb02fe0d73bc9db159438af3cf1fc
This commit is contained in:
committed by
sys_ocldev
parent
c46f716d6c
commit
fe56c57318
@@ -412,6 +412,28 @@ GraphicsAllocation *DrmMemoryManager::createPaddedAllocation(GraphicsAllocation
|
||||
return new DrmAllocation(bo, (void *)srcPtr, (uint64_t)ptrOffset(gpuRange, offset), sizeWithPadding);
|
||||
}
|
||||
|
||||
void DrmMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) {
|
||||
DrmAllocation *drmMemory = static_cast<DrmAllocation *>(gfxAllocation);
|
||||
FragmentStorage fragment = {};
|
||||
fragment.driverAllocation = true;
|
||||
fragment.fragmentCpuPointer = gfxAllocation->getUnderlyingBuffer();
|
||||
fragment.fragmentSize = alignUp(gfxAllocation->getUnderlyingBufferSize(), MemoryConstants::pageSize);
|
||||
fragment.osInternalStorage = new OsHandle();
|
||||
fragment.osInternalStorage->bo = drmMemory->getBO();
|
||||
hostPtrManager.storeFragment(fragment);
|
||||
}
|
||||
|
||||
void DrmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) {
|
||||
auto buffer = gfxAllocation->getUnderlyingBuffer();
|
||||
auto fragment = hostPtrManager.getFragment(buffer);
|
||||
if (fragment && fragment->driverAllocation) {
|
||||
OsHandle *osStorageToRelease = fragment->osInternalStorage;
|
||||
if (hostPtrManager.releaseHostPtr(buffer)) {
|
||||
delete osStorageToRelease;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
|
||||
DrmAllocation *input;
|
||||
input = static_cast<DrmAllocation *>(gfxAllocation);
|
||||
|
||||
@@ -40,7 +40,8 @@ class DrmMemoryManager : public MemoryManager {
|
||||
~DrmMemoryManager() override;
|
||||
|
||||
BufferObject *getPinBB() const;
|
||||
|
||||
void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||
void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
|
||||
DrmAllocation *allocateGraphicsMemory(size_t size, size_t alignment) override {
|
||||
return allocateGraphicsMemory(size, alignment, false, false);
|
||||
|
||||
Reference in New Issue
Block a user