2019-11-19 23:54:47 +08:00
|
|
|
/*
|
2023-02-17 00:51:55 +08:00
|
|
|
* Copyright (C) 2019-2023 Intel Corporation
|
2019-11-19 23:54:47 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/program/sync_buffer_handler.h"
|
2019-11-19 23:54:47 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
2022-12-29 20:27:52 +08:00
|
|
|
#include "shared/source/device/device.h"
|
2022-12-06 19:19:36 +08:00
|
|
|
#include "shared/source/memory_manager/allocation_properties.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2023-02-17 00:51:55 +08:00
|
|
|
#include <cstring>
|
|
|
|
|
2019-11-19 23:54:47 +08:00
|
|
|
namespace NEO {
|
|
|
|
|
|
|
|
SyncBufferHandler::~SyncBufferHandler() {
|
|
|
|
memoryManager.checkGpuUsageAndDestroyGraphicsAllocations(graphicsAllocation);
|
|
|
|
};
|
|
|
|
SyncBufferHandler::SyncBufferHandler(Device &device)
|
|
|
|
: device(device), memoryManager(*device.getMemoryManager()) {
|
|
|
|
|
|
|
|
allocateNewBuffer();
|
|
|
|
}
|
|
|
|
|
2020-04-09 23:33:07 +08:00
|
|
|
void SyncBufferHandler::makeResident(CommandStreamReceiver &csr) {
|
|
|
|
csr.makeResident(*graphicsAllocation);
|
|
|
|
}
|
|
|
|
|
2019-11-19 23:54:47 +08:00
|
|
|
void SyncBufferHandler::allocateNewBuffer() {
|
|
|
|
AllocationProperties allocationProperties{device.getRootDeviceIndex(), true, bufferSize,
|
2022-02-04 21:59:01 +08:00
|
|
|
AllocationType::LINEAR_STREAM,
|
2022-01-17 19:23:53 +08:00
|
|
|
(device.getNumGenericSubDevices() > 1u), /* multiOsContextCapable */
|
|
|
|
false, device.getDeviceBitfield()};
|
2019-11-19 23:54:47 +08:00
|
|
|
graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties(allocationProperties);
|
|
|
|
UNRECOVERABLE_IF(graphicsAllocation == nullptr);
|
|
|
|
|
|
|
|
auto cpuPointer = graphicsAllocation->getUnderlyingBuffer();
|
|
|
|
std::memset(cpuPointer, 0, bufferSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace NEO
|