mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Keep cmdBuffer list in CommandContainer
- add function to allocate new cmd buffer Change-Id: Iab54aaff6185060f8a87b0544381981a49259b07 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
8fcff2241f
commit
763b08c9a5
@@ -27,7 +27,9 @@ CommandContainer::~CommandContainer() {
|
||||
|
||||
auto memoryManager = device->getMemoryManager();
|
||||
|
||||
memoryManager->freeGraphicsMemory(cmdBufferAllocation);
|
||||
for (auto *alloc : cmdBufferAllocations) {
|
||||
memoryManager->freeGraphicsMemory(alloc);
|
||||
}
|
||||
|
||||
for (auto allocationIndirectHeap : allocationIndirectHeaps) {
|
||||
heapHelper->storeHeapAllocation(allocationIndirectHeap);
|
||||
@@ -55,10 +57,11 @@ bool CommandContainer::initialize(Device *device) {
|
||||
false,
|
||||
{}};
|
||||
|
||||
cmdBufferAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
auto cmdBufferAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
UNRECOVERABLE_IF(!cmdBufferAllocation);
|
||||
|
||||
cmdBufferAllocations.push_back(cmdBufferAllocation);
|
||||
|
||||
commandStream = std::unique_ptr<LinearStream>(new LinearStream(cmdBufferAllocation->getUnderlyingBuffer(),
|
||||
defaultListCmdBufferSize));
|
||||
commandStream->replaceGraphicsAllocation(cmdBufferAllocation);
|
||||
@@ -99,7 +102,12 @@ void CommandContainer::reset() {
|
||||
getResidencyContainer().clear();
|
||||
getDeallocationContainer().clear();
|
||||
|
||||
commandStream->replaceBuffer(this->getCommandStream()->getCpuBase(),
|
||||
for (size_t i = 1; i < cmdBufferAllocations.size(); i++) {
|
||||
device->getMemoryManager()->freeGraphicsMemory(cmdBufferAllocations[i]);
|
||||
}
|
||||
cmdBufferAllocations.erase(cmdBufferAllocations.begin() + 1, cmdBufferAllocations.end());
|
||||
|
||||
commandStream->replaceBuffer(cmdBufferAllocations[0]->getUnderlyingBuffer(),
|
||||
defaultListCmdBufferSize);
|
||||
addToResidencyContainer(commandStream->getGraphicsAllocation());
|
||||
|
||||
@@ -141,4 +149,25 @@ IndirectHeap *CommandContainer::getHeapWithRequiredSizeAndAlignment(NEO::HeapTyp
|
||||
return indirectHeap;
|
||||
}
|
||||
|
||||
void CommandContainer::allocateNextCommandBuffer() {
|
||||
size_t alignedSize = alignUp<size_t>(totalCmdBufferSize, MemoryConstants::pageSize64k);
|
||||
NEO::AllocationProperties properties{0u,
|
||||
true /* allocateMemory*/,
|
||||
alignedSize,
|
||||
GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
(device->getNumAvailableDevices() > 1u) /* multiOsContextCapable */,
|
||||
false,
|
||||
{}};
|
||||
|
||||
auto cmdBufferAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
UNRECOVERABLE_IF(!cmdBufferAllocation);
|
||||
|
||||
cmdBufferAllocations.push_back(cmdBufferAllocation);
|
||||
|
||||
commandStream->replaceBuffer(cmdBufferAllocation->getUnderlyingBuffer(), defaultListCmdBufferSize);
|
||||
commandStream->replaceGraphicsAllocation(cmdBufferAllocation);
|
||||
|
||||
addToResidencyContainer(cmdBufferAllocation);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -21,6 +21,7 @@ class Device;
|
||||
class GraphicsAllocation;
|
||||
class LinearStream;
|
||||
using ResidencyContainer = std::vector<GraphicsAllocation *>;
|
||||
using CmdBufferContainer = std::vector<GraphicsAllocation *>;
|
||||
using HeapType = IndirectHeap::Type;
|
||||
|
||||
class CommandContainer : public NonCopyableOrMovableClass {
|
||||
@@ -33,7 +34,7 @@ class CommandContainer : public NonCopyableOrMovableClass {
|
||||
|
||||
CommandContainer() = default;
|
||||
|
||||
GraphicsAllocation *getCmdBufferAllocation() { return cmdBufferAllocation; }
|
||||
CmdBufferContainer &getCmdBufferAllocations() { return cmdBufferAllocations; }
|
||||
|
||||
ResidencyContainer &getResidencyContainer() { return residencyContainer; }
|
||||
|
||||
@@ -51,8 +52,6 @@ class CommandContainer : public NonCopyableOrMovableClass {
|
||||
|
||||
void setIndirectHeapAllocation(HeapType heapType, GraphicsAllocation *allocation) { allocationIndirectHeaps[heapType] = allocation; }
|
||||
|
||||
void setCmdBufferAllocation(GraphicsAllocation *allocation) { cmdBufferAllocation = allocation; }
|
||||
|
||||
uint64_t getInstructionHeapBaseAddress() const { return instructionHeapBaseAddress; }
|
||||
|
||||
bool initialize(Device *device);
|
||||
@@ -64,6 +63,7 @@ class CommandContainer : public NonCopyableOrMovableClass {
|
||||
Device *getDevice() const { return device; }
|
||||
|
||||
IndirectHeap *getHeapWithRequiredSizeAndAlignment(NEO::HeapType heapType, size_t sizeRequired, size_t alignment);
|
||||
void allocateNextCommandBuffer();
|
||||
|
||||
void reset();
|
||||
|
||||
@@ -76,7 +76,7 @@ class CommandContainer : public NonCopyableOrMovableClass {
|
||||
Device *device = nullptr;
|
||||
std::unique_ptr<HeapHelper> heapHelper;
|
||||
|
||||
GraphicsAllocation *cmdBufferAllocation = nullptr;
|
||||
CmdBufferContainer cmdBufferAllocations;
|
||||
GraphicsAllocation *allocationIndirectHeaps[HeapType::NUM_TYPES] = {};
|
||||
|
||||
uint64_t instructionHeapBaseAddress = 0u;
|
||||
|
||||
Reference in New Issue
Block a user