Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a few errors in VKCommandBuffer.cpp #16731

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions native/cocos/renderer/gfx-vulkan/VKCommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ void CCVKCommandBuffer::pipelineBarrier(const GeneralBarrier *barrier, const Buf
bool fullBarrier = ccBarrier->getInfo().type == BarrierType::FULL;
bool missed = _barrierEvents.find(ccTexture) == _barrierEvents.end();
if (!fullBarrier && !missed) {
//CC_ASSERT(_barrierEvents.find(ccTexture) != _barrierEvents.end());
CC_ASSERT(_barrierEvents.find(ccTexture) != _barrierEvents.end());
VkEvent event = _barrierEvents.at(ccTexture);
scheduledEvents.push_back(event);

Expand All @@ -865,7 +865,7 @@ void CCVKCommandBuffer::pipelineBarrier(const GeneralBarrier *barrier, const Buf
} else {
gpuTexture->currentAccessTypes.assign(gpuBarrier->barrier.pNextAccesses, gpuBarrier->barrier.pNextAccesses + gpuBarrier->barrier.nextAccessCount);
fullImageBarriers.push_back(gpuBarrier->vkBarrier);
fullImageBarriers.back().srcAccessMask = missed ? VK_IMAGE_LAYOUT_UNDEFINED : fullImageBarriers.back().srcAccessMask;
fullImageBarriers.back().srcAccessMask = missed ? VK_ACCESS_NONE_KHR : fullImageBarriers.back().srcAccessMask;
fullImageBarriers.back().subresourceRange.aspectMask = gpuTexture->aspectMask;
if (gpuTexture->swapchain) {
fullImageBarriers.back().image = gpuTexture->swapchainVkImages[gpuTexture->swapchain->curImageIndex];
Expand All @@ -892,7 +892,7 @@ void CCVKCommandBuffer::pipelineBarrier(const GeneralBarrier *barrier, const Buf
bool fullBarrier = ccBarrier->getInfo().type == BarrierType::FULL;
bool missed = _barrierEvents.find(ccBuffer) != _barrierEvents.end();
if (!fullBarrier && !missed) {
CC_ASSERT(_barrierEvents.find(ccBuffer) != _barrierEvents.end());
// CC_ASSERT(_barrierEvents.find(ccBuffer) != _barrierEvents.end());
jcyuan marked this conversation as resolved.
Show resolved Hide resolved
VkEvent event = _barrierEvents.at(ccBuffer);
scheduledEvents.push_back(event);

Expand All @@ -904,7 +904,7 @@ void CCVKCommandBuffer::pipelineBarrier(const GeneralBarrier *barrier, const Buf
} else {
gpuBuffer->currentAccessTypes.assign(gpuBarrier->barrier.pNextAccesses, gpuBarrier->barrier.pNextAccesses + gpuBarrier->barrier.nextAccessCount);
fullBufferBarriers.push_back(gpuBarrier->vkBarrier);
fullBufferBarriers.back().srcAccessMask = missed ? VK_IMAGE_LAYOUT_UNDEFINED : fullBufferBarriers.back().srcAccessMask;
fullBufferBarriers.back().srcAccessMask = missed ? VK_ACCESS_NONE_KHR : fullBufferBarriers.back().srcAccessMask;
fullBufferBarriers.back().buffer = gpuBuffer->vkBuffer;
fullSrcStageMask |= gpuBarrier->srcStageMask;
fullDstStageMask |= gpuBarrier->dstStageMask;
Expand Down Expand Up @@ -965,8 +965,8 @@ void CCVKCommandBuffer::pipelineBarrier(const GeneralBarrier *barrier, const Buf
}

if (!fullBufferBarriers.empty() || !fullImageBarriers.empty()) {
vkCmdPipelineBarrier(_gpuCommandBuffer->vkCommandBuffer, fullSrcStageMask, fullDstStageMask, 0, 0, pMemoryBarrier,
fullBufferBarriers.size(), fullBufferBarriers.data(), fullImageBarriers.size(), fullImageBarriers.data());
vkCmdPipelineBarrier(_gpuCommandBuffer->vkCommandBuffer, fullSrcStageMask, fullDstStageMask, 0, pMemoryBarrier ? 1 : 0,
pMemoryBarrier, fullBufferBarriers.size(), fullBufferBarriers.data(), fullImageBarriers.size(), fullImageBarriers.data());
Comment on lines +968 to +969
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we change the if (!fullBufferBarriers.empty() || !fullImageBarriers.empty()) to if (!fullBufferBarriers.empty() || !fullImageBarriers.empty() || pMemoryBarrier) ?

pMemoryBarrier might not be executed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally i think it's fine, because memoryBarrierCount arg for vkCmdPipelineBarrier decides it will be used or not.

}
}
}
Expand Down
Loading