@@ -3692,9 +3692,13 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
3692
3692
auto pFoundHash = findInStaging.operator ()<ICPUBuffer>(buffer);
3693
3693
//
3694
3694
const auto ownerQueueFamily = checkOwnership (buffer,params.getFinalOwnerQueueFamily (buffer,*pFoundHash),transferFamily);
3695
- bool success = ownerQueueFamily!=QueueFamilyInvalid;
3695
+ if (ownerQueueFamily==QueueFamilyInvalid)
3696
+ {
3697
+ markFailureInStaging (" invalid Final Queue Family given by user callback" ,item.canonical ,buffer,pFoundHash);
3698
+ continue ;
3699
+ }
3696
3700
// do the upload
3697
- success = success && params.utilities ->updateBufferRangeViaStagingBuffer (*params.transfer ,range,item.canonical ->getPointer ());
3701
+ const bool success = params.utilities ->updateBufferRangeViaStagingBuffer (*params.transfer ,range,item.canonical ->getPointer ());
3698
3702
// current recording buffer may have changed
3699
3703
xferCmdBuf = params.transfer ->getCommandBufferForRecording ();
3700
3704
if (!success)
@@ -4274,6 +4278,9 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4274
4278
if (blasCount)
4275
4279
{
4276
4280
// build
4281
+ {
4282
+ computeCmdBuf->cmdbuf ->beginDebugMarker (" Asset Converter Build BLASes START" );
4283
+ computeCmdBuf->cmdbuf ->endDebugMarker ();
4277
4284
#ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION
4278
4285
constexpr auto GeometryIsAABBFlag = ICPUBottomLevelAccelerationStructure::BUILD_FLAGS::GEOMETRY_TYPE_IS_AABB_BIT;
4279
4286
@@ -4326,12 +4333,19 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4326
4333
}
4327
4334
}
4328
4335
#endif
4336
+ blasesToBuild.clear ();
4337
+ computeCmdBuf->cmdbuf ->beginDebugMarker (" Asset Converter Build BLASes END" );
4338
+ computeCmdBuf->cmdbuf ->endDebugMarker ();
4339
+ }
4329
4340
// compact
4341
+ computeCmdBuf->cmdbuf ->beginDebugMarker (" Asset Converter Compact BLASes START" );
4342
+ computeCmdBuf->cmdbuf ->endDebugMarker ();
4330
4343
{
4331
4344
// the already compacted BLASes need to be written into the TLASes using them, want to swap them out ASAP
4332
4345
// reservations.m_blasBuildMap[canonical].gpuBLAS = compacted;
4333
4346
}
4334
- blasesToBuild.clear ();
4347
+ computeCmdBuf->cmdbuf ->beginDebugMarker (" Asset Converter Compact BLASes END" );
4348
+ computeCmdBuf->cmdbuf ->endDebugMarker ();
4335
4349
}
4336
4350
4337
4351
// Device TLAS builds
@@ -4351,7 +4365,10 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4351
4365
if (blasCount==0 || pipelineBarrier (computeCmdBuf,{.memBarriers ={&readBLASInTLASBuildBarrier,1 }}," Failed to sync BLAS with TLAS build!" ))
4352
4366
{
4353
4367
core::vector<const IGPUAccelerationStructure*> compactions;
4368
+ // 0xffFFffFFu when not releasing ownership, otherwise index into `ownershipTransfers` where the ownership release for the old buffer was
4369
+ core::vector<uint32_t > compactedOwnershipReleaseIndices;
4354
4370
compactions.reserve (tlasCount);
4371
+ compactedOwnershipReleaseIndices.reserve (tlasCount);
4355
4372
// build
4356
4373
{
4357
4374
//
@@ -4395,6 +4412,13 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4395
4412
dedupBLASesUsed.clear ();
4396
4413
const auto as = tlasToBuild.gpuObj ;
4397
4414
const auto pFoundHash = findInStaging.operator ()<ICPUTopLevelAccelerationStructure>(as);
4415
+ const auto & backingRange = as->getCreationParams ().bufferRange ;
4416
+ const auto ownerQueueFamily = checkOwnership (backingRange.buffer .get (),params.getFinalOwnerQueueFamily (backingRange.buffer .get (),*pFoundHash),computeFamily);
4417
+ if (ownerQueueFamily==QueueFamilyInvalid)
4418
+ {
4419
+ markFailureInStaging (" invalid Final Queue Family given by user callback" ,tlasToBuild.canonical ,as,pFoundHash);
4420
+ continue ;
4421
+ }
4398
4422
const auto instances = tlasToBuild.canonical ->getInstances ();
4399
4423
const auto instanceCount = static_cast <uint32_t >(instances.size ());
4400
4424
size_t instanceDataSize = 0 ;
@@ -4545,12 +4569,31 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4545
4569
}
4546
4570
// no special extra byte offset into the instance buffer
4547
4571
rangeInfos.emplace_back (instanceCount,0u );
4572
+ //
4573
+ const bool willCompact = tlasToBuild.compact ();
4574
+ if (willCompact)
4575
+ compactions.push_back (as);
4576
+ // enqueue ownership release if necessary
4577
+ if (ownerQueueFamily!=IQueue::FamilyIgnored)
4578
+ ownershipTransfers.push_back ({
4579
+ .barrier = {
4580
+ .dep = {
4581
+ .srcStageMask = PIPELINE_STAGE_FLAGS::ACCELERATION_STRUCTURE_BUILD_BIT,
4582
+ .srcAccessMask = ACCESS_FLAGS::ACCELERATION_STRUCTURE_WRITE_BIT
4583
+ // leave rest empty, we can release whenever after the copies and before the semaphore signal
4584
+ },
4585
+ .ownershipOp = ownership_op_t ::RELEASE,
4586
+ .otherQueueFamilyIndex = ownerQueueFamily
4587
+ },
4588
+ .range = backingRange
4589
+ });
4548
4590
}
4549
4591
// finish the last batch
4550
4592
recordBuildCommands ();
4551
4593
computeCmdBuf->cmdbuf ->beginDebugMarker (" Asset Converter Compact TLASes END" );
4552
4594
computeCmdBuf->cmdbuf ->endDebugMarker ();
4553
4595
}
4596
+ tlasesToBuild.clear ();
4554
4597
// compact
4555
4598
computeCmdBuf->cmdbuf ->beginDebugMarker (" Asset Converter Compact TLASes START" );
4556
4599
computeCmdBuf->cmdbuf ->endDebugMarker ();
@@ -4639,6 +4682,9 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4639
4682
logFail (" record Acceleration Structure compaction" ,compactedAS.get ());
4640
4683
continue ;
4641
4684
}
4685
+ // modify the ownership release
4686
+ if (const auto ix=compactedOwnershipReleaseIndices[i]; ix<ownershipTransfers.size ())
4687
+ ownershipTransfers[ix].range = compactedAS->getCreationParams ().bufferRange ;
4642
4688
// insert into compaction map
4643
4689
compactedTLASMap[as] = std::move (compactedAS);
4644
4690
}
@@ -4647,7 +4693,6 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
4647
4693
}
4648
4694
computeCmdBuf->cmdbuf ->beginDebugMarker (" Asset Converter Compact TLASes END" );
4649
4695
computeCmdBuf->cmdbuf ->endDebugMarker ();
4650
- tlasesToBuild.clear ();
4651
4696
}
4652
4697
4653
4698
// release ownership
0 commit comments