Fix shared buffer object size
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
parent
049166688c
commit
8fa97ed4a8
|
@ -13,7 +13,7 @@ using namespace NEO;
|
||||||
|
|
||||||
void MemoryAllocatorMultiDeviceSystemSpecificFixture::SetUp(ExecutionEnvironment &executionEnvironment) {
|
void MemoryAllocatorMultiDeviceSystemSpecificFixture::SetUp(ExecutionEnvironment &executionEnvironment) {
|
||||||
auto memoryManager = static_cast<TestedDrmMemoryManager *>(executionEnvironment.memoryManager.get());
|
auto memoryManager = static_cast<TestedDrmMemoryManager *>(executionEnvironment.memoryManager.get());
|
||||||
auto bufferObject = memoryManager->createSharedBufferObject(0u, 10, true, 0u);
|
auto bufferObject = new (std::nothrow) BufferObject(&memoryManager->getDrm(0u), 0, 10, MemoryManager::maxOsContextCount);
|
||||||
memoryManager->pushSharedBufferObject(bufferObject);
|
memoryManager->pushSharedBufferObject(bufferObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2003,7 +2003,8 @@ TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenDrmMemoryManagerWithLocalMemory
|
||||||
ASSERT_NE(nullptr, graphicsAllocation);
|
ASSERT_NE(nullptr, graphicsAllocation);
|
||||||
|
|
||||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||||
EXPECT_EQ(alignUp(size, 2 * MemoryConstants::megaByte), graphicsAllocation->getUnderlyingBufferSize());
|
EXPECT_EQ(size, graphicsAllocation->getUnderlyingBufferSize());
|
||||||
|
EXPECT_EQ(alignUp(size, 2 * MemoryConstants::megaByte), graphicsAllocation->getReservedAddressSize());
|
||||||
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, graphicsAllocation->getMemoryPool());
|
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, graphicsAllocation->getMemoryPool());
|
||||||
EXPECT_EQ(this->mock->inputFd, static_cast<int32_t>(handle));
|
EXPECT_EQ(this->mock->inputFd, static_cast<int32_t>(handle));
|
||||||
|
|
||||||
|
@ -2015,7 +2016,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenDrmMemoryManagerWithLocalMemory
|
||||||
auto bo = drmAllocation->getBO();
|
auto bo = drmAllocation->getBO();
|
||||||
EXPECT_EQ(this->mock->outputHandle, static_cast<uint32_t>(bo->peekHandle()));
|
EXPECT_EQ(this->mock->outputHandle, static_cast<uint32_t>(bo->peekHandle()));
|
||||||
EXPECT_EQ(gpuAddress, bo->peekAddress());
|
EXPECT_EQ(gpuAddress, bo->peekAddress());
|
||||||
EXPECT_EQ(alignUp(size, 2 * MemoryConstants::megaByte), bo->peekSize());
|
EXPECT_EQ(size, bo->peekSize());
|
||||||
|
|
||||||
EXPECT_EQ(handle, graphicsAllocation->peekSharedHandle());
|
EXPECT_EQ(handle, graphicsAllocation->peekSharedHandle());
|
||||||
|
|
||||||
|
|
|
@ -567,21 +567,6 @@ BufferObject *DrmMemoryManager::findAndReferenceSharedBufferObject(int boHandle)
|
||||||
return bo;
|
return bo;
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferObject *DrmMemoryManager::createSharedBufferObject(int boHandle, size_t size, bool requireSpecificBitness, uint32_t rootDeviceIndex) {
|
|
||||||
uint64_t gpuRange = 0llu;
|
|
||||||
|
|
||||||
gpuRange = acquireGpuRange(size, requireSpecificBitness, rootDeviceIndex, isLocalMemorySupported(rootDeviceIndex));
|
|
||||||
|
|
||||||
auto bo = new (std::nothrow) BufferObject(&getDrm(rootDeviceIndex), boHandle, size, maxOsContextCount);
|
|
||||||
if (!bo) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bo->gpuAddress = gpuRange;
|
|
||||||
bo->setUnmapSize(size);
|
|
||||||
return bo;
|
|
||||||
}
|
|
||||||
|
|
||||||
GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness) {
|
GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness) {
|
||||||
std::unique_lock<std::mutex> lock(mtx);
|
std::unique_lock<std::mutex> lock(mtx);
|
||||||
|
|
||||||
|
@ -601,14 +586,24 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||||
auto boHandle = openFd.handle;
|
auto boHandle = openFd.handle;
|
||||||
auto bo = findAndReferenceSharedBufferObject(boHandle);
|
auto bo = findAndReferenceSharedBufferObject(boHandle);
|
||||||
|
|
||||||
|
uint64_t gpuRange = 0llu;
|
||||||
|
size_t reservedRange = 0u;
|
||||||
|
|
||||||
if (bo == nullptr) {
|
if (bo == nullptr) {
|
||||||
size_t size = lseekFunction(handle, 0, SEEK_END);
|
size_t size = lseekFunction(handle, 0, SEEK_END);
|
||||||
bo = createSharedBufferObject(boHandle, size, requireSpecificBitness, properties.rootDeviceIndex);
|
|
||||||
|
bo = new (std::nothrow) BufferObject(&getDrm(properties.rootDeviceIndex), boHandle, size, maxOsContextCount);
|
||||||
|
|
||||||
if (!bo) {
|
if (!bo) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpuRange = acquireGpuRange(size, requireSpecificBitness, properties.rootDeviceIndex, isLocalMemorySupported(properties.rootDeviceIndex));
|
||||||
|
|
||||||
|
bo->setAddress(gpuRange);
|
||||||
|
bo->setUnmapSize(size);
|
||||||
|
reservedRange = size;
|
||||||
|
|
||||||
pushSharedBufferObject(bo);
|
pushSharedBufferObject(bo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,6 +611,9 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||||
|
|
||||||
auto drmAllocation = new DrmAllocation(properties.rootDeviceIndex, properties.allocationType, bo, reinterpret_cast<void *>(bo->gpuAddress), bo->size,
|
auto drmAllocation = new DrmAllocation(properties.rootDeviceIndex, properties.allocationType, bo, reinterpret_cast<void *>(bo->gpuAddress), bo->size,
|
||||||
handle, MemoryPool::SystemCpuInaccessible);
|
handle, MemoryPool::SystemCpuInaccessible);
|
||||||
|
if (reservedRange) {
|
||||||
|
drmAllocation->setReservedAddressRange(reinterpret_cast<void *>(gpuRange), reservedRange);
|
||||||
|
}
|
||||||
|
|
||||||
if (requireSpecificBitness && this->force32bitAllocations) {
|
if (requireSpecificBitness && this->force32bitAllocations) {
|
||||||
drmAllocation->set32BitAllocation(true);
|
drmAllocation->set32BitAllocation(true);
|
||||||
|
|
|
@ -73,7 +73,6 @@ class DrmMemoryManager : public MemoryManager {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BufferObject *findAndReferenceSharedBufferObject(int boHandle);
|
BufferObject *findAndReferenceSharedBufferObject(int boHandle);
|
||||||
BufferObject *createSharedBufferObject(int boHandle, size_t size, bool requireSpecificBitness, uint32_t rootDeviceIndex);
|
|
||||||
void eraseSharedBufferObject(BufferObject *bo);
|
void eraseSharedBufferObject(BufferObject *bo);
|
||||||
void pushSharedBufferObject(BufferObject *bo);
|
void pushSharedBufferObject(BufferObject *bo);
|
||||||
BufferObject *allocUserptr(uintptr_t address, size_t size, uint64_t flags, uint32_t rootDeviceIndex);
|
BufferObject *allocUserptr(uintptr_t address, size_t size, uint64_t flags, uint32_t rootDeviceIndex);
|
||||||
|
|
|
@ -72,7 +72,6 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
|
||||||
using DrmMemoryManager::createAllocWithAlignment;
|
using DrmMemoryManager::createAllocWithAlignment;
|
||||||
using DrmMemoryManager::createAllocWithAlignmentFromUserptr;
|
using DrmMemoryManager::createAllocWithAlignmentFromUserptr;
|
||||||
using DrmMemoryManager::createGraphicsAllocation;
|
using DrmMemoryManager::createGraphicsAllocation;
|
||||||
using DrmMemoryManager::createSharedBufferObject;
|
|
||||||
using DrmMemoryManager::eraseSharedBufferObject;
|
using DrmMemoryManager::eraseSharedBufferObject;
|
||||||
using DrmMemoryManager::getDefaultDrmContextId;
|
using DrmMemoryManager::getDefaultDrmContextId;
|
||||||
using DrmMemoryManager::getDrm;
|
using DrmMemoryManager::getDrm;
|
||||||
|
|
Loading…
Reference in New Issue