Skip to content

Commit 9af7793

Browse files
committed
GPU Vulkan Display: Simplify: number of command buffers can equal number of images
1 parent f20b672 commit 9af7793

3 files changed

Lines changed: 58 additions & 72 deletions

File tree

‎GPU/GPUTracking/Definitions/GPUSettingsList.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ EndConfig()
514514

515515
// Vulkan Display Settings
516516
BeginSubConfig(GPUSettingsDisplayVulkan, vulkan, configStandalone.display, "GLV", 0, "Vulkan display settings", display_vulkan)
517-
AddOption(nFramesInFlight, int32_t, 0, "", 0, "Max number of render frames in flight (0 = as many as swapchain images)")
517+
AddOption(nFramesInFlight, uint32_t, 3, "", 0, "Max number of render frames in flight")
518518
AddOption(uniformBuffersInDeviceMemory, bool, 1, "", 0, "Have uniform buffers in host-accessible device memory")
519519
AddOption(forceDevice, int32_t, -1, "", 0, "Force Vulkan device number to use")
520520
AddHelp("help", 'h')

‎GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.cxx‎

Lines changed: 57 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ void GPUDisplayBackendVulkan::createCommandBuffers()
532532
vk::CommandBufferAllocateInfo allocInfo{};
533533
allocInfo.commandPool = mCommandPool;
534534
allocInfo.level = vk::CommandBufferLevel::ePrimary;
535-
allocInfo.commandBufferCount = mFramesInFlight;
536-
mCommandBufferUpToDate.resize(mFramesInFlight, false);
535+
allocInfo.commandBufferCount = mImageCount;
536+
mCommandBufferUpToDate.resize(mImageCount, false);
537537
mCommandBuffers = mDevice.allocateCommandBuffers(allocInfo);
538538
mCommandBuffersText = mDevice.allocateCommandBuffers(allocInfo);
539539
mCommandBuffersTexture = mDevice.allocateCommandBuffers(allocInfo);
@@ -591,23 +591,23 @@ void GPUDisplayBackendVulkan::clearSemaphoresAndFences()
591591
void GPUDisplayBackendVulkan::createUniformLayoutsAndBuffers()
592592
{
593593
for (int32_t j = 0; j < 3; j++) {
594-
mUniformBuffersMat[j].resize(mFramesInFlight);
595-
mUniformBuffersCol[j].resize(mFramesInFlight);
596-
for (uint32_t i = 0; i < mFramesInFlight; i++) {
594+
mUniformBuffersMat[j].resize(mImageCount);
595+
mUniformBuffersCol[j].resize(mImageCount);
596+
for (uint32_t i = 0; i < mImageCount; i++) {
597597
mUniformBuffersMat[j][i] = createBuffer(sizeof(hmm_mat4), nullptr, vk::BufferUsageFlagBits::eUniformBuffer, mDisplay->cfg().vulkan.uniformBuffersInDeviceMemory ? 2 : 0);
598598
mUniformBuffersCol[j][i] = createBuffer(sizeof(float) * 4, nullptr, vk::BufferUsageFlagBits::eUniformBuffer, mDisplay->cfg().vulkan.uniformBuffersInDeviceMemory ? 2 : 0);
599599
}
600600
}
601601

602602
std::array<vk::DescriptorPoolSize, 2> poolSizes{};
603603
poolSizes[0].type = vk::DescriptorType::eUniformBuffer;
604-
poolSizes[0].descriptorCount = (uint32_t)mFramesInFlight * (2 * 3);
604+
poolSizes[0].descriptorCount = (uint32_t)mImageCount * (2 * 3);
605605
poolSizes[1].type = vk::DescriptorType::eCombinedImageSampler;
606-
poolSizes[1].descriptorCount = (uint32_t)mFramesInFlight * 2;
606+
poolSizes[1].descriptorCount = (uint32_t)mImageCount * 2;
607607
vk::DescriptorPoolCreateInfo poolInfo{};
608608
poolInfo.poolSizeCount = poolSizes.size();
609609
poolInfo.pPoolSizes = poolSizes.data();
610-
poolInfo.maxSets = (uint32_t)mFramesInFlight * 3;
610+
poolInfo.maxSets = (uint32_t)mImageCount * 3;
611611
mDescriptorPool = mDevice.createDescriptorPool(poolInfo, nullptr);
612612

613613
vk::DescriptorSetLayoutBinding uboLayoutBindingMat{};
@@ -634,15 +634,15 @@ void GPUDisplayBackendVulkan::createUniformLayoutsAndBuffers()
634634

635635
vk::DescriptorSetAllocateInfo allocInfo{};
636636
allocInfo.descriptorPool = mDescriptorPool;
637-
allocInfo.descriptorSetCount = (uint32_t)mFramesInFlight;
637+
allocInfo.descriptorSetCount = (uint32_t)mImageCount;
638638
for (int32_t j = 0; j < 3; j++) { // 0 = Render, 1 = Text, 2 = Texture
639-
std::vector<vk::DescriptorSetLayout> layouts(mFramesInFlight, j ? mUniformDescriptorTexture : mUniformDescriptor);
639+
std::vector<vk::DescriptorSetLayout> layouts(mImageCount, j ? mUniformDescriptorTexture : mUniformDescriptor);
640640
allocInfo.pSetLayouts = layouts.data();
641641
mDescriptorSets[j] = mDevice.allocateDescriptorSets(allocInfo);
642642

643643
for (int32_t k = 0; k < 2; k++) {
644644
auto& mUniformBuffers = k ? mUniformBuffersCol[j] : mUniformBuffersMat[j];
645-
for (uint32_t i = 0; i < mFramesInFlight; i++) {
645+
for (uint32_t i = 0; i < mImageCount; i++) {
646646
vk::DescriptorBufferInfo bufferInfo{};
647647
bufferInfo.buffer = mUniformBuffers[i].buffer;
648648
bufferInfo.offset = 0;
@@ -733,7 +733,7 @@ void GPUDisplayBackendVulkan::createSwapChain(bool forScreenshot, bool forMixing
733733
mPresentMode = chooseSwapPresentMode(mSwapChainDetails.presentModes, mDisplay->cfgR().drawQualityVSync ? vk::PresentModeKHR::eMailbox : vk::PresentModeKHR::eImmediate);
734734
vk::Extent2D extent = chooseSwapExtent(mSwapChainDetails.capabilities);
735735

736-
uint32_t imageCount = mSwapChainDetails.capabilities.minImageCount + 1;
736+
uint32_t imageCount = std::max<uint32_t>(mSwapChainDetails.capabilities.minImageCount + 1, mDisplay->cfg().vulkan.nFramesInFlight + 1);
737737
if (mSwapChainDetails.capabilities.maxImageCount > 0 && imageCount > mSwapChainDetails.capabilities.maxImageCount) {
738738
imageCount = mSwapChainDetails.capabilities.maxImageCount;
739739
}
@@ -769,13 +769,12 @@ void GPUDisplayBackendVulkan::createSwapChain(bool forScreenshot, bool forMixing
769769

770770
mSwapChainImages = mDevice.getSwapchainImagesKHR(mSwapChain);
771771
uint32_t oldFramesInFlight = mFramesInFlight;
772+
mFramesInFlight = mDisplay->cfg().vulkan.nFramesInFlight;
772773
mImageCount = mSwapChainImages.size();
773-
mFramesInFlight = mDisplay->cfg().vulkan.nFramesInFlight == 0 ? mImageCount : mDisplay->cfg().vulkan.nFramesInFlight;
774-
mCommandBufferPerImage = mFramesInFlight == mImageCount;
775774

776775
if (mFramesInFlight > oldFramesInFlight || !mCommandInfrastructureCreated) {
777776
if (mCommandInfrastructureCreated) {
778-
clearUniformLayoutsAndBuffers();
777+
clearUniformLayoutsAndBuffers(); // TODO: Check what must actually be cleaned up if frames in flight changes
779778
clearCommandBuffers();
780779
clearSemaphoresAndFences();
781780
}
@@ -1016,14 +1015,12 @@ void GPUDisplayBackendVulkan::createOffscreenBuffers(bool forScreenshot, bool fo
10161015
{(float)mRenderWidth, (float)mRenderHeight, 1.0f, 1.0f}};
10171016
mMixingTextureVertexArray = createBuffer(sizeof(vertices), &vertices[0][0], vk::BufferUsageFlagBits::eVertexBuffer, 1);
10181017

1019-
if (mCommandBufferPerImage) {
1020-
for (uint32_t i = 0; i < mFramesInFlight; i++) {
1021-
setMixDescriptor(i, i);
1022-
}
1018+
for (uint32_t i = 0; i < mImageCount; i++) {
1019+
setMixDescriptor(i, i);
10231020
}
10241021
}
10251022

1026-
mFontVertexBuffer.resize(mFramesInFlight);
1023+
mFontVertexBuffer.resize(mImageCount);
10271024
}
10281025

10291026
void GPUDisplayBackendVulkan::clearOffscreenBuffers()
@@ -1253,7 +1250,7 @@ void GPUDisplayBackendVulkan::startFillCommandBuffer(vk::CommandBuffer& commandB
12531250

12541251
vk::DeviceSize offsets[] = {0};
12551252
commandBuffer.bindVertexBuffers(0, 1, &mVBO.buffer, offsets);
1256-
commandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, mPipelineLayout, 0, 1, &mDescriptorSets[0][mCurrentBufferSet], 0, nullptr);
1253+
commandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, mPipelineLayout, 0, 1, &mDescriptorSets[0][mCurrentImageIndex], 0, nullptr);
12571254
}
12581255

12591256
void GPUDisplayBackendVulkan::endFillCommandBuffer(vk::CommandBuffer& commandBuffer)
@@ -1428,7 +1425,7 @@ void GPUDisplayBackendVulkan::clearImage(VulkanImage& image)
14281425
int32_t GPUDisplayBackendVulkan::InitBackendA()
14291426
{
14301427
mEnableValidationLayers = (mDisplay->param() && mDisplay->GetProcessingSettings().debugLevel >= 2) || (getenv("GPUCA_VULKAN_VALIDATION") && atoi(getenv("GPUCA_VULKAN_VALIDATION")));
1431-
mFramesInFlight = 2;
1428+
mFramesInFlight = mDisplay->cfg().vulkan.nFramesInFlight;
14321429

14331430
createDevice();
14341431
createShaders();
@@ -1496,7 +1493,7 @@ uint32_t GPUDisplayBackendVulkan::drawVertices(const vboList& v, const drawType
14961493
if (count == 0) {
14971494
return 0;
14981495
}
1499-
if (mCommandBufferUpToDate[mCurrentBufferSet]) {
1496+
if (mCommandBufferUpToDate[mCurrentImageIndex]) {
15001497
return count;
15011498
}
15021499

@@ -1527,12 +1524,9 @@ void GPUDisplayBackendVulkan::prepareDraw(const hmm_mat4& proj, const hmm_mat4&
15271524
auto getImage = [&]() {
15281525
vk::Fence fen = VkFence(VK_NULL_HANDLE);
15291526
vk::Semaphore sem = VkSemaphore(VK_NULL_HANDLE);
1530-
if (mCommandBufferPerImage) {
1531-
fen = mInFlightFence[mCurrentFrame];
1532-
CHKERR(mDevice.resetFences(1, &fen));
1533-
} else {
1534-
sem = mImageAvailableSemaphore[mCurrentFrame];
1535-
}
1527+
fen = mInFlightFence[mCurrentFrame];
1528+
CHKERR(mDevice.resetFences(1, &fen));
1529+
// sem = mImageAvailableSemaphore[mCurrentFrame]; // TODO: Why not !
15361530
return mDevice.acquireNextImageKHR(mSwapChain, UINT64_MAX, sem, fen, &mCurrentImageIndex);
15371531
};
15381532

@@ -1551,31 +1545,28 @@ void GPUDisplayBackendVulkan::prepareDraw(const hmm_mat4& proj, const hmm_mat4&
15511545
retVal = getImage();
15521546
}
15531547
CHKERR(retVal);
1554-
if (mCommandBufferPerImage) {
1555-
CHKERR(mDevice.waitForFences(1, &mInFlightFence[mCurrentFrame], true, UINT64_MAX));
1556-
}
1548+
CHKERR(mDevice.waitForFences(1, &mInFlightFence[mCurrentFrame], true, UINT64_MAX));
15571549
CHKERR(mDevice.resetFences(1, &mInFlightFence[mCurrentFrame]));
15581550
mMustUpdateSwapChain = false;
15591551
mHasDrawnText = false;
1560-
mCurrentBufferSet = mCommandBufferPerImage ? mCurrentImageIndex : mCurrentFrame;
15611552

15621553
const hmm_mat4 modelViewProj = proj * view;
1563-
writeToBuffer(mUniformBuffersMat[0][mCurrentBufferSet], sizeof(modelViewProj), &modelViewProj);
1554+
writeToBuffer(mUniformBuffersMat[0][mCurrentImageIndex], sizeof(modelViewProj), &modelViewProj);
15641555
}
15651556

1566-
mCurrentCommandBuffer = toMixBuffer ? mCommandBuffersMix[mCurrentBufferSet] : mCommandBuffers[mCurrentBufferSet];
1557+
mCurrentCommandBuffer = toMixBuffer ? mCommandBuffersMix[mCurrentImageIndex] : mCommandBuffers[mCurrentImageIndex];
15671558
mCurrentCommandBufferLastPipeline = -1;
1568-
if (!mCommandBufferUpToDate[mCurrentBufferSet]) {
1559+
if (!mCommandBufferUpToDate[mCurrentImageIndex]) {
15691560
startFillCommandBuffer(mCurrentCommandBuffer, mCurrentImageIndex, toMixBuffer);
15701561
}
15711562
}
15721563

15731564
void GPUDisplayBackendVulkan::finishDraw(bool doScreenshot, bool toMixBuffer, float includeMixImage)
15741565
{
1575-
if (!mCommandBufferUpToDate[mCurrentBufferSet]) {
1566+
if (!mCommandBufferUpToDate[mCurrentImageIndex]) {
15761567
endFillCommandBuffer(mCurrentCommandBuffer);
1577-
if (!toMixBuffer && includeMixImage == 0.f && mCommandBufferPerImage) {
1578-
mCommandBufferUpToDate[mCurrentBufferSet] = true;
1568+
if (!toMixBuffer && includeMixImage == 0.f) {
1569+
mCommandBufferUpToDate[mCurrentImageIndex] = true;
15791570
}
15801571
}
15811572
}
@@ -1587,7 +1578,7 @@ void GPUDisplayBackendVulkan::finishFrame(bool doScreenshot, bool toMixBuffer, f
15871578

15881579
vk::SubmitInfo submitInfo{};
15891580
vk::PipelineStageFlags waitStages[] = {vk::PipelineStageFlagBits::eColorAttachmentOutput};
1590-
submitInfo.pWaitSemaphores = includeMixImage > 0.f ? &mRenderFinishedSemaphore[mCurrentFrame] : (!mCommandBufferPerImage ? &mImageAvailableSemaphore[mCurrentFrame] : nullptr);
1581+
submitInfo.pWaitSemaphores = includeMixImage > 0.f ? &mRenderFinishedSemaphore[mCurrentFrame] : nullptr;
15911582
submitInfo.waitSemaphoreCount = submitInfo.pWaitSemaphores != nullptr ? 1 : 0;
15921583
submitInfo.pWaitDstStageMask = waitStages;
15931584
submitInfo.commandBufferCount = 1;
@@ -1597,19 +1588,19 @@ void GPUDisplayBackendVulkan::finishFrame(bool doScreenshot, bool toMixBuffer, f
15971588
CHKERR(mGraphicsQueue.submit(1, &submitInfo, includeMixImage > 0 || toMixBuffer || mHasDrawnText || mDownsampleFSAA ? noFence : mInFlightFence[mCurrentFrame]));
15981589
if (!toMixBuffer) {
15991590
if (includeMixImage > 0.f) {
1600-
mixImages(mCommandBuffersTexture[mCurrentBufferSet], includeMixImage);
1591+
mixImages(mCommandBuffersTexture[mCurrentImageIndex], includeMixImage);
16011592
submitInfo.pWaitSemaphores = stageFinishedSemaphore;
16021593
waitStages[0] = {vk::PipelineStageFlagBits::eColorAttachmentOutput};
16031594
submitInfo.waitSemaphoreCount = 1;
1604-
submitInfo.pCommandBuffers = &mCommandBuffersTexture[mCurrentBufferSet];
1595+
submitInfo.pCommandBuffers = &mCommandBuffersTexture[mCurrentImageIndex];
16051596
stageFinishedSemaphore = &mMixFinishedSemaphore[mCurrentFrame];
16061597
submitInfo.pSignalSemaphores = stageFinishedSemaphore;
16071598
CHKERR(mGraphicsQueue.submit(1, &submitInfo, mHasDrawnText || mDownsampleFSAA ? noFence : mInFlightFence[mCurrentFrame]));
16081599
}
16091600

16101601
if (mDownsampleFSAA) {
1611-
downsampleToFramebuffer(mCommandBuffersDownsample[mCurrentBufferSet]);
1612-
submitInfo.pCommandBuffers = &mCommandBuffersDownsample[mCurrentBufferSet];
1602+
downsampleToFramebuffer(mCommandBuffersDownsample[mCurrentImageIndex]);
1603+
submitInfo.pCommandBuffers = &mCommandBuffersDownsample[mCurrentImageIndex];
16131604
submitInfo.pWaitSemaphores = stageFinishedSemaphore;
16141605
waitStages[0] = {vk::PipelineStageFlagBits::eTransfer};
16151606
submitInfo.waitSemaphoreCount = 1;
@@ -1631,7 +1622,7 @@ void GPUDisplayBackendVulkan::finishFrame(bool doScreenshot, bool toMixBuffer, f
16311622
submitInfo.pWaitSemaphores = stageFinishedSemaphore;
16321623
waitStages[0] = {vk::PipelineStageFlagBits::eColorAttachmentOutput};
16331624
submitInfo.waitSemaphoreCount = 1;
1634-
submitInfo.pCommandBuffers = &mCommandBuffersText[mCurrentBufferSet];
1625+
submitInfo.pCommandBuffers = &mCommandBuffersText[mCurrentImageIndex];
16351626
stageFinishedSemaphore = &mTextFinishedSemaphore[mCurrentFrame];
16361627
submitInfo.pSignalSemaphores = stageFinishedSemaphore;
16371628
CHKERR(mGraphicsQueue.submit(1, &submitInfo, mInFlightFence[mCurrentFrame]));
@@ -1690,7 +1681,7 @@ void GPUDisplayBackendVulkan::downsampleToFramebuffer(vk::CommandBuffer& command
16901681
void GPUDisplayBackendVulkan::prepareText()
16911682
{
16921683
hmm_mat4 proj = HMM_Orthographic(0.f, mScreenWidth, 0.f, mScreenHeight, -1, 1);
1693-
writeToBuffer(mUniformBuffersMat[1][mCurrentBufferSet], sizeof(proj), &proj);
1684+
writeToBuffer(mUniformBuffersMat[1][mCurrentImageIndex], sizeof(proj), &proj);
16941685

16951686
mFontVertexBufferHost.clear();
16961687
mTextDrawCommands.clear();
@@ -1702,45 +1693,45 @@ void GPUDisplayBackendVulkan::finishText()
17021693
return;
17031694
}
17041695

1705-
mCommandBuffersText[mCurrentBufferSet].reset({});
1696+
mCommandBuffersText[mCurrentImageIndex].reset({});
17061697

17071698
vk::CommandBufferBeginInfo beginInfo{};
17081699
beginInfo.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
1709-
mCommandBuffersText[mCurrentBufferSet].begin(beginInfo);
1700+
mCommandBuffersText[mCurrentImageIndex].begin(beginInfo);
17101701

17111702
vk::RenderPassBeginInfo renderPassInfo{};
17121703
renderPassInfo.renderPass = mRenderPassText;
17131704
renderPassInfo.framebuffer = mFramebuffersText.size() ? mFramebuffersText[mCurrentImageIndex] : mFramebuffers[mCurrentImageIndex];
17141705
renderPassInfo.renderArea.offset = vk::Offset2D{0, 0};
17151706
renderPassInfo.renderArea.extent = vk::Extent2D{mScreenWidth, mScreenHeight};
17161707
renderPassInfo.clearValueCount = 0;
1717-
mCommandBuffersText[mCurrentBufferSet].beginRenderPass(renderPassInfo, vk::SubpassContents::eInline);
1708+
mCommandBuffersText[mCurrentImageIndex].beginRenderPass(renderPassInfo, vk::SubpassContents::eInline);
17181709

1719-
if (mFontVertexBuffer[mCurrentBufferSet].size) {
1720-
clearBuffer(mFontVertexBuffer[mCurrentBufferSet]);
1710+
if (mFontVertexBuffer[mCurrentImageIndex].size) {
1711+
clearBuffer(mFontVertexBuffer[mCurrentImageIndex]);
17211712
}
1722-
mFontVertexBuffer[mCurrentBufferSet] = createBuffer(mFontVertexBufferHost.size() * sizeof(float), mFontVertexBufferHost.data(), vk::BufferUsageFlagBits::eVertexBuffer, 0);
1713+
mFontVertexBuffer[mCurrentImageIndex] = createBuffer(mFontVertexBufferHost.size() * sizeof(float), mFontVertexBufferHost.data(), vk::BufferUsageFlagBits::eVertexBuffer, 0);
17231714

1724-
mCommandBuffersText[mCurrentBufferSet].bindPipeline(vk::PipelineBindPoint::eGraphics, mPipelines[3]);
1725-
mCommandBuffersText[mCurrentBufferSet].bindDescriptorSets(vk::PipelineBindPoint::eGraphics, mPipelineLayoutTexture, 0, 1, &mDescriptorSets[1][mCurrentBufferSet], 0, nullptr);
1715+
mCommandBuffersText[mCurrentImageIndex].bindPipeline(vk::PipelineBindPoint::eGraphics, mPipelines[3]);
1716+
mCommandBuffersText[mCurrentImageIndex].bindDescriptorSets(vk::PipelineBindPoint::eGraphics, mPipelineLayoutTexture, 0, 1, &mDescriptorSets[1][mCurrentImageIndex], 0, nullptr);
17261717
vk::DeviceSize offsets[] = {0};
1727-
mCommandBuffersText[mCurrentBufferSet].bindVertexBuffers(0, 1, &mFontVertexBuffer[mCurrentBufferSet].buffer, offsets);
1718+
mCommandBuffersText[mCurrentImageIndex].bindVertexBuffers(0, 1, &mFontVertexBuffer[mCurrentImageIndex].buffer, offsets);
17281719

17291720
for (const auto& cmd : mTextDrawCommands) {
1730-
mCommandBuffersText[mCurrentBufferSet].pushConstants(mPipelineLayoutTexture, vk::ShaderStageFlagBits::eFragment, 0, sizeof(cmd.color), cmd.color);
1731-
mCommandBuffersText[mCurrentBufferSet].draw(cmd.nVertices, 1, cmd.firstVertex, 0);
1721+
mCommandBuffersText[mCurrentImageIndex].pushConstants(mPipelineLayoutTexture, vk::ShaderStageFlagBits::eFragment, 0, sizeof(cmd.color), cmd.color);
1722+
mCommandBuffersText[mCurrentImageIndex].draw(cmd.nVertices, 1, cmd.firstVertex, 0);
17321723
}
17331724

17341725
mFontVertexBufferHost.clear();
17351726

1736-
mCommandBuffersText[mCurrentBufferSet].endRenderPass();
1737-
mCommandBuffersText[mCurrentBufferSet].end();
1727+
mCommandBuffersText[mCurrentImageIndex].endRenderPass();
1728+
mCommandBuffersText[mCurrentImageIndex].end();
17381729
}
17391730

17401731
void GPUDisplayBackendVulkan::mixImages(vk::CommandBuffer commandBuffer, float mixSlaveImage)
17411732
{
17421733
hmm_mat4 proj = HMM_Orthographic(0.f, mRenderWidth, 0.f, mRenderHeight, -1, 1);
1743-
writeToBuffer(mUniformBuffersMat[2][mCurrentBufferSet], sizeof(proj), &proj);
1734+
writeToBuffer(mUniformBuffersMat[2][mCurrentImageIndex], sizeof(proj), &proj);
17441735

17451736
commandBuffer.reset({});
17461737
vk::CommandBufferBeginInfo beginInfo{};
@@ -1760,10 +1751,7 @@ void GPUDisplayBackendVulkan::mixImages(vk::CommandBuffer commandBuffer, float m
17601751
commandBuffer.beginRenderPass(renderPassInfo, vk::SubpassContents::eInline);
17611752

17621753
commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, mPipelines[4]);
1763-
if (!mCommandBufferPerImage) {
1764-
setMixDescriptor(mCurrentBufferSet, mCurrentImageIndex);
1765-
}
1766-
commandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, mPipelineLayoutTexture, 0, 1, &mDescriptorSets[2][mCurrentBufferSet], 0, nullptr);
1754+
commandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, mPipelineLayoutTexture, 0, 1, &mDescriptorSets[2][mCurrentImageIndex], 0, nullptr);
17671755
vk::DeviceSize offsets[] = {0};
17681756
commandBuffer.bindVertexBuffers(0, 1, &mMixingTextureVertexArray.buffer, offsets);
17691757

@@ -1776,15 +1764,15 @@ void GPUDisplayBackendVulkan::mixImages(vk::CommandBuffer commandBuffer, float m
17761764

17771765
void GPUDisplayBackendVulkan::ActivateColor(std::array<float, 4>& color)
17781766
{
1779-
if (mCommandBufferUpToDate[mCurrentBufferSet]) {
1767+
if (mCommandBufferUpToDate[mCurrentImageIndex]) {
17801768
return;
17811769
}
17821770
mCurrentCommandBuffer.pushConstants(mPipelineLayout, vk::ShaderStageFlagBits::eFragment, 0, sizeof(color), color.data());
17831771
}
17841772

17851773
void GPUDisplayBackendVulkan::pointSizeFactor(float factor)
17861774
{
1787-
if (mCommandBufferUpToDate[mCurrentBufferSet]) {
1775+
if (mCommandBufferUpToDate[mCurrentImageIndex]) {
17881776
return;
17891777
}
17901778
float size = mDisplay->cfgL().pointSize * mDownsampleFactor * factor;
@@ -1793,7 +1781,7 @@ void GPUDisplayBackendVulkan::pointSizeFactor(float factor)
17931781

17941782
void GPUDisplayBackendVulkan::lineWidthFactor(float factor)
17951783
{
1796-
if (mCommandBufferUpToDate[mCurrentBufferSet]) {
1784+
if (mCommandBufferUpToDate[mCurrentImageIndex]) {
17971785
return;
17981786
}
17991787
mCurrentCommandBuffer.setLineWidth(mDisplay->cfgL().lineWidth * mDownsampleFactor * factor);
@@ -1893,7 +1881,7 @@ void GPUDisplayBackendVulkan::updateFontTextureDescriptor()
18931881
imageInfo.imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal;
18941882
imageInfo.imageView = mFontImage.view;
18951883
imageInfo.sampler = mTextureSampler;
1896-
for (uint32_t i = 0; i < mFramesInFlight; i++) {
1884+
for (uint32_t i = 0; i < mImageCount; i++) {
18971885
vk::WriteDescriptorSet descriptorWrite{};
18981886
descriptorWrite.dstSet = mDescriptorSets[1][i];
18991887
descriptorWrite.dstBinding = 2;
@@ -2024,5 +2012,5 @@ uint32_t GPUDisplayBackendVulkan::DepthBits()
20242012

20252013
bool GPUDisplayBackendVulkan::backendNeedRedraw()
20262014
{
2027-
return !mCommandBufferUpToDate[mCurrentBufferSet];
2015+
return !mCommandBufferUpToDate[mCurrentImageIndex];
20282016
}

‎GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,11 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend
162162
std::vector<vk::Framebuffer> mFramebuffersTexture;
163163
vk::CommandPool mCommandPool;
164164

165-
bool mCommandBufferPerImage = false;
166165
bool mCommandInfrastructureCreated = false;
167166
uint32_t mImageCount = 0;
168167
uint32_t mFramesInFlight = 0;
169168
int32_t mCurrentFrame = 0;
170169
uint32_t mCurrentImageIndex = 0;
171-
int32_t mCurrentBufferSet = 0;
172170
vk::CommandBuffer mCurrentCommandBuffer;
173171
int32_t mCurrentCommandBufferLastPipeline = -1;
174172

0 commit comments

Comments
 (0)