mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-28 00:03:14 +08:00
Reuse command buffers in L0 command queue
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
dd3c59f46d
commit
b2f286fc4a
@@ -178,8 +178,18 @@ ze_result_t CommandQueueImp::CommandBufferManager::initialize(Device *device, si
|
||||
false,
|
||||
device->getNEODevice()->getDeviceBitfield()};
|
||||
|
||||
buffers[BUFFER_ALLOCATION::FIRST] = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
buffers[BUFFER_ALLOCATION::SECOND] = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
auto firstBuffer = device->obtainReusableAllocation(alignedSize, NEO::GraphicsAllocation::AllocationType::COMMAND_BUFFER);
|
||||
if (!firstBuffer) {
|
||||
firstBuffer = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
}
|
||||
|
||||
auto secondBuffer = device->obtainReusableAllocation(alignedSize, NEO::GraphicsAllocation::AllocationType::COMMAND_BUFFER);
|
||||
if (!secondBuffer) {
|
||||
secondBuffer = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
}
|
||||
|
||||
buffers[BUFFER_ALLOCATION::FIRST] = firstBuffer;
|
||||
buffers[BUFFER_ALLOCATION::SECOND] = secondBuffer;
|
||||
|
||||
if (!buffers[BUFFER_ALLOCATION::FIRST] || !buffers[BUFFER_ALLOCATION::SECOND]) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
@@ -192,13 +202,13 @@ ze_result_t CommandQueueImp::CommandBufferManager::initialize(Device *device, si
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void CommandQueueImp::CommandBufferManager::destroy(NEO::MemoryManager *memoryManager) {
|
||||
void CommandQueueImp::CommandBufferManager::destroy(Device *device) {
|
||||
if (buffers[BUFFER_ALLOCATION::FIRST]) {
|
||||
memoryManager->freeGraphicsMemory(buffers[BUFFER_ALLOCATION::FIRST]);
|
||||
device->storeReusableAllocation(*buffers[BUFFER_ALLOCATION::FIRST]);
|
||||
buffers[BUFFER_ALLOCATION::FIRST] = nullptr;
|
||||
}
|
||||
if (buffers[BUFFER_ALLOCATION::SECOND]) {
|
||||
memoryManager->freeGraphicsMemory(buffers[BUFFER_ALLOCATION::SECOND]);
|
||||
device->storeReusableAllocation(*buffers[BUFFER_ALLOCATION::SECOND]);
|
||||
buffers[BUFFER_ALLOCATION::SECOND] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::destroy() {
|
||||
delete commandStream;
|
||||
commandStream = nullptr;
|
||||
}
|
||||
buffers.destroy(this->getDevice()->getNEODevice()->getMemoryManager());
|
||||
buffers.destroy(this->getDevice());
|
||||
delete this;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ struct CommandQueueImp : public CommandQueue {
|
||||
};
|
||||
|
||||
ze_result_t initialize(Device *device, size_t sizeRequested);
|
||||
void destroy(NEO::MemoryManager *memoryManager);
|
||||
void destroy(Device *device);
|
||||
void switchBuffers(NEO::CommandStreamReceiver *csr);
|
||||
|
||||
NEO::GraphicsAllocation *getCurrentBufferAllocation() {
|
||||
|
||||
Reference in New Issue
Block a user