Skip to content

Commit c83f4f4

Browse files
author
devsh
committed
pipeline barrier lambda, and fix the extraSignal semaphores (dual fix - that fix is somwhere else too)
1 parent 0add2e3 commit c83f4f4

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/nbl/video/utilities/CAssetConverter.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,6 +3024,21 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
30243024
};
30253025
using ownership_op_t = IGPUCommandBuffer::SOwnershipTransferBarrier::OWNERSHIP_OP;
30263026

3027+
// unify logging
3028+
auto pipelineBarrier = [logger]/*<typename... Args>*/(
3029+
const IQueue::SSubmitInfo::SCommandBufferInfo* const cmdbufInfo,
3030+
const IGPUCommandBuffer::SPipelineBarrierDependencyInfo & info,
3031+
const char* failMessage/*, Args&&... args*/
3032+
)->bool
3033+
{
3034+
if (!cmdbufInfo->cmdbuf->pipelineBarrier(E_DEPENDENCY_FLAGS::EDF_NONE,info))
3035+
{
3036+
logger.log(failMessage,system::ILogger::ELL_ERROR/*,std::forward<Args>(args)...*/);
3037+
return false;
3038+
}
3039+
return true;
3040+
};
3041+
30273042
// upload Buffers
30283043
auto& buffersToUpload = std::get<SReserveResult::conversion_requests_t<ICPUBuffer>>(reservations.m_conversionRequests);
30293044
{
@@ -3070,8 +3085,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
30703085
buffersToUpload.clear();
30713086
// release ownership
30723087
if (!ownershipTransfers.empty())
3073-
if (!params.transfer->getCommandBufferForRecording()->cmdbuf->pipelineBarrier(E_DEPENDENCY_FLAGS::EDF_NONE,{.memBarriers={},.bufBarriers=ownershipTransfers}))
3074-
logger.log("Ownership Releases of Buffers Failed",system::ILogger::ELL_ERROR);
3088+
pipelineBarrier(params.transfer->getCommandBufferForRecording(),{.memBarriers={},.bufBarriers=ownershipTransfers},"Ownership Releases of Buffers Failed");
30753089
}
30763090

30773091
// some state so we don't need to look later
@@ -3349,7 +3363,8 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
33493363
// should have already been in GENERAL by now
33503364
source.oldLayout = layout_t::GENERAL;
33513365
}
3352-
computeCmdBuf->cmdbuf->pipelineBarrier(E_DEPENDENCY_FLAGS::EDF_NONE,{.memBarriers={},.bufBarriers={},.imgBarriers=preComputeBarriers});
3366+
if (!pipelineBarrier(computeCmdBuf,{.memBarriers={},.bufBarriers={},.imgBarriers=preComputeBarriers},"Failed to record pre-mipmapping-dispatch pipeline barrier!"))
3367+
break;
33533368
submitsNeeded |= IQueue::FAMILY_FLAGS::COMPUTE_BIT;
33543369
}
33553370
//
@@ -3483,11 +3498,8 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
34833498
// keep in general layout to avoid a transfer->general transition
34843499
tmp.newLayout = sourceForNextMipCompute ? layout_t::GENERAL : layout_t::TRANSFER_DST_OPTIMAL;
34853500
// fire off the pipeline barrier so we can start uploading right away
3486-
if (!xferCmdBuf->cmdbuf->pipelineBarrier(E_DEPENDENCY_FLAGS::EDF_NONE, { .memBarriers = {},.bufBarriers = {},.imgBarriers = {&tmp,1} }))
3487-
{
3488-
logger.log("Initial Pre-Image-Region-Upload Layout Transition failed!", system::ILogger::ELL_ERROR);
3501+
if (!pipelineBarrier(xferCmdBuf,{.memBarriers={},.bufBarriers={},.imgBarriers={&tmp,1}},"Initial Pre-Image-Region-Upload Layout Transition failed!"))
34893502
break;
3490-
}
34913503
// first use owns
34923504
submitsNeeded |= IQueue::FAMILY_FLAGS::TRANSFER_BIT;
34933505
// start recording uploads
@@ -3557,9 +3569,8 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
35573569
// here we only record barriers that do final layout transitions and release ownership to final queue family
35583570
if (!transferBarriers.empty())
35593571
{
3560-
if (!xferCmdBuf->cmdbuf->pipelineBarrier(E_DEPENDENCY_FLAGS::EDF_NONE, { .memBarriers = {},.bufBarriers = {},.imgBarriers = transferBarriers }))
3572+
if (!pipelineBarrier(xferCmdBuf,{.memBarriers={},.bufBarriers={},.imgBarriers=transferBarriers},"Final Pipeline Barrier recording to Transfer Command Buffer failed"))
35613573
{
3562-
logger.log("Final Pipeline Barrier recording to Transfer Command Buffer failed", system::ILogger::ELL_ERROR);
35633574
markFailureInStaging(image, pFoundHash);
35643575
continue;
35653576
}
@@ -3568,9 +3579,8 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
35683579
if (!computeBarriers.empty())
35693580
{
35703581
dsAlloc->multi_deallocate(SrcMipBinding,1,&srcIx,params.compute->getFutureScratchSemaphore());
3571-
if (!computeCmdBuf->cmdbuf->pipelineBarrier(E_DEPENDENCY_FLAGS::EDF_NONE, { .memBarriers = {},.bufBarriers = {},.imgBarriers = computeBarriers }))
3582+
if (!pipelineBarrier(computeCmdBuf,{.memBarriers={},.bufBarriers={},.imgBarriers=computeBarriers},"Final Pipeline Barrier recording to Compute Command Buffer failed"))
35723583
{
3573-
logger.log("Final Pipeline Barrier recording to Compute Command Buffer failed", system::ILogger::ELL_ERROR);
35743584
markFailureInStaging(image,pFoundHash);
35753585
continue;
35763586
}
@@ -3589,7 +3599,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
35893599
{
35903600
// if there's still a compute submit to perform, then we will signal the extra semaphores from there
35913601
constexpr auto emptySignalSpan = std::span<const IQueue::SSubmitInfo::SSemaphoreInfo>{};
3592-
if (params.transfer->submit(xferCmdBuf,computeSubmitIsNeeded ? params.extraSignalSemaphores:emptySignalSpan)!=IQueue::RESULT::SUCCESS)
3602+
if (params.transfer->submit(xferCmdBuf,computeSubmitIsNeeded ? emptySignalSpan:params.extraSignalSemaphores)!=IQueue::RESULT::SUCCESS)
35933603
return retval;
35943604
// leave open for next user
35953605
params.transfer->beginNextCommandBuffer(xferCmdBuf);

0 commit comments

Comments
 (0)