2019-11-19 16:54:47 +01:00
|
|
|
/*
|
2021-03-19 23:14:09 +00:00
|
|
|
* Copyright (C) 2019-2021 Intel Corporation
|
2019-11-19 16:54:47 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/program/sync_buffer_handler.h"
|
2019-11-19 16:54:47 +01:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2019-11-19 16:54:47 +01:00
|
|
|
namespace NEO {
|
|
|
|
|
|
|
|
SyncBufferHandler::~SyncBufferHandler() {
|
|
|
|
memoryManager.checkGpuUsageAndDestroyGraphicsAllocations(graphicsAllocation);
|
|
|
|
};
|
|
|
|
SyncBufferHandler::SyncBufferHandler(Device &device)
|
|
|
|
: device(device), memoryManager(*device.getMemoryManager()) {
|
|
|
|
|
|
|
|
allocateNewBuffer();
|
|
|
|
}
|
|
|
|
|
2020-04-09 17:33:07 +02:00
|
|
|
void SyncBufferHandler::makeResident(CommandStreamReceiver &csr) {
|
|
|
|
csr.makeResident(*graphicsAllocation);
|
|
|
|
}
|
|
|
|
|
2019-11-19 16:54:47 +01:00
|
|
|
void SyncBufferHandler::allocateNewBuffer() {
|
|
|
|
AllocationProperties allocationProperties{device.getRootDeviceIndex(), true, bufferSize,
|
|
|
|
GraphicsAllocation::AllocationType::LINEAR_STREAM,
|
2019-12-10 12:16:07 +01:00
|
|
|
false, false, device.getDeviceBitfield()};
|
2019-11-19 16:54:47 +01:00
|
|
|
graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties(allocationProperties);
|
|
|
|
UNRECOVERABLE_IF(graphicsAllocation == nullptr);
|
|
|
|
|
|
|
|
auto cpuPointer = graphicsAllocation->getUnderlyingBuffer();
|
|
|
|
std::memset(cpuPointer, 0, bufferSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace NEO
|