@@ -3596,11 +3596,27 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
3596
3596
return const_cast <core::blake3_hash_t *>(&found->second .value );
3597
3597
};
3598
3598
// wipe gpu item in staging cache (this may drop it as well if it was made for only a root asset == no users)
3599
- auto markFailureInStaging = [logger](const char * message, auto * gpuObj, core::blake3_hash_t * hash)->void
3599
+ core::unordered_map<const IBackendObject*,uint32_t > outputReverseMap;
3600
+ core::for_each_in_tuple (reservations.m_gpuObjects ,[&outputReverseMap](const auto & gpuObjects)->void
3601
+ {
3602
+ uint32_t i = 0 ;
3603
+ for (const auto & gpuObj : gpuObjects)
3604
+ outputReverseMap[gpuObj.value .get ()] = i++;
3605
+ }
3606
+ );
3607
+ auto markFailureInStaging = [&reservations,&outputReverseMap,logger]<Asset AssetType>(const char * message, const asset_traits<AssetType>::video_t * gpuObj, core::blake3_hash_t * hash)->void
3600
3608
{
3601
3609
logger.log (" %s failed for \" %s\" " ,system::ILogger::ELL_ERROR,message,gpuObj->getObjectDebugName ());
3602
3610
// change the content hash on the reverse map to a NoContentHash
3603
3611
*hash = CHashCache::NoContentHash;
3612
+ // also drop the smart pointer from the output array so failures release memory quickly
3613
+ const auto foundIx = outputReverseMap.find (gpuObj);
3614
+ if (foundIx!=outputReverseMap.end ())
3615
+ {
3616
+ auto & resultOutput = std::get<SReserveResult::vector_t <AssetType>>(reservations.m_gpuObjects );
3617
+ resultOutput[foundIx->second ].value = nullptr ;
3618
+ outputReverseMap.erase (foundIx);
3619
+ }
3604
3620
};
3605
3621
3606
3622
//
@@ -3683,7 +3699,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
3683
3699
item.canonical = nullptr ;
3684
3700
if (!success)
3685
3701
{
3686
- markFailureInStaging (" Data Upload" ,buffer,pFoundHash);
3702
+ markFailureInStaging. operator ()<ICPUBuffer> (" Data Upload" ,buffer,pFoundHash);
3687
3703
continue ;
3688
3704
}
3689
3705
submitsNeeded |= IQueue::FAMILY_FLAGS::TRANSFER_BIT;
@@ -3883,7 +3899,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
3883
3899
}
3884
3900
if (!quickWriteDescriptor (SrcMipBinding,srcIx,std::move (srcView)))
3885
3901
{
3886
- markFailureInStaging (" Source Mip Level Descriptor Write" ,image,pFoundHash);
3902
+ markFailureInStaging. operator ()<ICPUImage> (" Source Mip Level Descriptor Write" ,image,pFoundHash);
3887
3903
continue ;
3888
3904
}
3889
3905
}
@@ -4191,7 +4207,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4191
4207
// failed in the for-loop
4192
4208
if (lvl != creationParams.mipLevels )
4193
4209
{
4194
- markFailureInStaging (" Compute Mip Mapping" ,image,pFoundHash);
4210
+ markFailureInStaging. operator ()<ICPUImage> (" Compute Mip Mapping" ,image,pFoundHash);
4195
4211
continue ;
4196
4212
}
4197
4213
}
@@ -4200,7 +4216,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4200
4216
{
4201
4217
if (!pipelineBarrier (xferCmdBuf,{.memBarriers ={},.bufBarriers ={},.imgBarriers =transferBarriers}," Final Pipeline Barrier recording to Transfer Command Buffer failed" ))
4202
4218
{
4203
- markFailureInStaging (" Image Data Upload Pipeline Barrier" ,image,pFoundHash);
4219
+ markFailureInStaging. operator ()<ICPUImage> (" Image Data Upload Pipeline Barrier" ,image,pFoundHash);
4204
4220
continue ;
4205
4221
}
4206
4222
submitsNeeded |= IQueue::FAMILY_FLAGS::TRANSFER_BIT;
@@ -4210,7 +4226,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4210
4226
dsAlloc->multi_deallocate (SrcMipBinding,1 ,&srcIx,params.compute ->getFutureScratchSemaphore ());
4211
4227
if (!pipelineBarrier (computeCmdBuf,{.memBarriers ={},.bufBarriers ={},.imgBarriers =computeBarriers}," Final Pipeline Barrier recording to Compute Command Buffer failed" ))
4212
4228
{
4213
- markFailureInStaging (" Compute Mip Mapping Pipeline Barrier" ,image,pFoundHash);
4229
+ markFailureInStaging. operator ()<ICPUImage> (" Compute Mip Mapping Pipeline Barrier" ,image,pFoundHash);
4214
4230
continue ;
4215
4231
}
4216
4232
}
@@ -4287,7 +4303,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4287
4303
//
4288
4304
if (!device->buildAccelerationStructure (dOp.get (),info,range))
4289
4305
{
4290
- markFailureInStaging (" BLAS Build Command Recording" ,gpuObj,pFoundHash);
4306
+ markFailureInStaging. operator ()<ICPUBottomLevelAccelerationStructure> (" BLAS Build Command Recording" ,gpuObj,pFoundHash);
4291
4307
continue ;
4292
4308
}
4293
4309
}
@@ -4353,7 +4369,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4353
4369
for (const auto & info : buildInfos)
4354
4370
{
4355
4371
const auto pFoundHash = findInStaging.operator ()<ICPUTopLevelAccelerationStructure>(info.dstAS );
4356
- markFailureInStaging (" TLAS Build Command Recording" ,info.dstAS ,pFoundHash); // TODO: make messages configurable message
4372
+ markFailureInStaging. operator ()<ICPUTopLevelAccelerationStructure> (" TLAS Build Command Recording" ,info.dstAS ,pFoundHash); // TODO: make messages configurable message
4357
4373
}
4358
4374
buildInfos.clear ();
4359
4375
rangeInfos.clear ();
@@ -4383,7 +4399,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4383
4399
// problem with finding the dependents (BLASes)
4384
4400
if (instanceDataSize==0 )
4385
4401
{
4386
- markFailureInStaging (" Finding Dependant GPU BLASes for TLAS build" ,as,pFoundHash);
4402
+ markFailureInStaging. operator ()<ICPUTopLevelAccelerationStructure> (" Finding Dependant GPU BLASes for TLAS build" ,as,pFoundHash);
4387
4403
continue ;
4388
4404
}
4389
4405
// allocate scratch and build inputs
@@ -4485,7 +4501,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4485
4501
xferCmdBuf = params.transfer ->getCommandBufferForRecording ();
4486
4502
if (!success)
4487
4503
{
4488
- markFailureInStaging (" Uploading Instance Data for TLAS build failed" ,as,pFoundHash);
4504
+ markFailureInStaging. operator ()<ICPUTopLevelAccelerationStructure> (" Uploading Instance Data for TLAS build failed" ,as,pFoundHash);
4489
4505
continue ;
4490
4506
}
4491
4507
}
0 commit comments