@@ -21,6 +21,8 @@ namespace NEO {
2121GraphicsAllocation *allocateGlobalsSurface (NEO::SVMAllocsManager *const svmAllocManager, NEO::Device &device, size_t size, bool constant,
2222 LinkerInput *const linkerInput, const void *initData) {
2323 bool globalsAreExported = false ;
24+ GraphicsAllocation *gpuAllocation = nullptr ;
25+
2426 if (linkerInput != nullptr ) {
2527 globalsAreExported = constant ? linkerInput->getTraits ().exportsGlobalConstants : linkerInput->getTraits ().exportsGlobalVariables ;
2628 }
@@ -37,30 +39,33 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
3739 }
3840 auto svmAlloc = svmAllocManager->getSVMAlloc (ptr);
3941 UNRECOVERABLE_IF (svmAlloc == nullptr );
40- auto gpuAlloc = svmAlloc->gpuAllocations .getGraphicsAllocation (device.getRootDeviceIndex ());
41- UNRECOVERABLE_IF (gpuAlloc == nullptr );
42- device.getMemoryManager ()->copyMemoryToAllocation (gpuAlloc, initData, static_cast <uint32_t >(size));
43- return gpuAlloc;
42+ gpuAllocation = svmAlloc->gpuAllocations .getGraphicsAllocation (device.getRootDeviceIndex ());
4443 } else {
4544 auto allocationType = constant ? GraphicsAllocation::AllocationType::CONSTANT_SURFACE : GraphicsAllocation::AllocationType::GLOBAL_SURFACE;
46- auto gpuAlloc = device.getMemoryManager ()->allocateGraphicsMemoryWithProperties ({device.getRootDeviceIndex (),
45+ gpuAllocation = device.getMemoryManager ()->allocateGraphicsMemoryWithProperties ({device.getRootDeviceIndex (),
4746 true , // allocateMemory
4847 size, allocationType,
4948 false , // isMultiStorageAllocation
5049 device.getDeviceBitfield ()});
51- DEBUG_BREAK_IF (gpuAlloc == nullptr );
52- if (gpuAlloc == nullptr ) {
53- return nullptr ;
54- }
55- auto &hwInfo = device.getHardwareInfo ();
56- auto &helper = HwHelper::get (hwInfo.platform .eRenderCoreFamily );
57- if (gpuAlloc->isAllocatedInLocalMemoryPool () && helper.isBlitCopyRequiredForLocalMemory (hwInfo)) {
58- BlitHelperFunctions::blitMemoryToAllocation (device, gpuAlloc, 0 , initData, {size, 1 , 1 });
59- } else {
60- memcpy_s (gpuAlloc->getUnderlyingBuffer (), gpuAlloc->getUnderlyingBufferSize (), initData, size);
61- }
62- return gpuAlloc;
6350 }
51+
52+ if (!gpuAllocation) {
53+ return nullptr ;
54+ }
55+
56+ auto &hwInfo = device.getHardwareInfo ();
57+ auto &helper = HwHelper::get (hwInfo.platform .eRenderCoreFamily );
58+
59+ bool success = false ;
60+ if (gpuAllocation->isAllocatedInLocalMemoryPool () && helper.isBlitCopyRequiredForLocalMemory (hwInfo)) {
61+ success = (BlitHelperFunctions::blitMemoryToAllocation (device, gpuAllocation, 0 , initData, {size, 1 , 1 }) == BlitOperationResult::Success);
62+ } else {
63+ success = device.getMemoryManager ()->copyMemoryToAllocation (gpuAllocation, initData, static_cast <uint32_t >(size));
64+ }
65+
66+ UNRECOVERABLE_IF (!success);
67+
68+ return gpuAllocation;
6469}
6570
6671} // namespace NEO
0 commit comments