2019-11-19 16:54:47 +01:00
|
|
|
/*
|
2023-02-16 16:51:55 +00:00
|
|
|
* Copyright (C) 2019-2023 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"
|
2022-12-29 12:27:52 +00:00
|
|
|
#include "shared/source/device/device.h"
|
2022-12-06 11:19:36 +00:00
|
|
|
#include "shared/source/memory_manager/allocation_properties.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
|
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2023-02-16 16:51:55 +00:00
|
|
|
#include <cstring>
|
|
|
|
|
|
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,
|
2022-02-04 13:59:01 +00:00
|
|
|
AllocationType::LINEAR_STREAM,
|
2022-01-17 11:23:53 +00:00
|
|
|
(device.getNumGenericSubDevices() > 1u), /* multiOsContextCapable */
|
|
|
|
|
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
|