diff --git a/core/rend/vulkan/commandpool.h b/core/rend/vulkan/commandpool.h index 6e183dd0b..8a25638dd 100644 --- a/core/rend/vulkan/commandpool.h +++ b/core/rend/vulkan/commandpool.h @@ -26,26 +26,24 @@ class CommandPool public: void Init() { - size_t size = VulkanContext::Instance()->GetSwapChainSize(); - - if (commandPools.size() > size) + if (commandPools.size() > chainSize) { - commandPools.resize(size); - fences.resize(size); + commandPools.resize(chainSize); + fences.resize(chainSize); } else { - while (commandPools.size() < size) + while (commandPools.size() < chainSize) { commandPools.push_back(VulkanContext::Instance()->GetDevice().createCommandPoolUnique( vk::CommandPoolCreateInfo(vk::CommandPoolCreateFlagBits::eTransient, VulkanContext::Instance()->GetGraphicsQueueFamilyIndex()))); fences.push_back(VulkanContext::Instance()->GetDevice().createFenceUnique(vk::FenceCreateInfo(vk::FenceCreateFlagBits::eSignaled))); } } - if (freeBuffers.size() != size) - freeBuffers.resize(size); - if (inFlightBuffers.size() != size) - inFlightBuffers.resize(size); + if (freeBuffers.size() != chainSize) + freeBuffers.resize(chainSize); + if (inFlightBuffers.size() != chainSize) + inFlightBuffers.resize(chainSize); } void Term() @@ -64,7 +62,7 @@ public: void BeginFrame() { - index = (index + 1) % VulkanContext::Instance()->GetSwapChainSize(); + index = (index + 1) % chainSize; VulkanContext::Instance()->GetDevice().waitForFences(1, &fences[index].get(), true, UINT64_MAX); VulkanContext::Instance()->GetDevice().resetFences(1, &fences[index].get()); std::vector& inFlight = inFlightBuffers[index]; @@ -106,4 +104,6 @@ private: std::vector> inFlightBuffers; std::vector commandPools; std::vector fences; + // size should be the same as used by client: 2 for renderer (texCommandPool) + static constexpr size_t chainSize = 2; }; diff --git a/core/rend/vulkan/overlay.cpp b/core/rend/vulkan/overlay.cpp index 44c724c20..79e0b00c1 100644 --- a/core/rend/vulkan/overlay.cpp +++ b/core/rend/vulkan/overlay.cpp @@ -197,7 +197,7 @@ void VulkanOverlay::Draw(vk::CommandBuffer commandBuffer, vk::Extent2D viewport, ((color >> 16) & 0xff) / 255.f, ((color >> 24) & 0xff) / 255.f }; - xhairDrawer->Draw(commandBuffer, xhairTexture->GetImageView(), vtx, true, xhairColor); + xhairDrawer->Draw(commandBuffer, i == 0 ? xhairTexture->GetImageView() : vk::ImageView(), vtx, true, xhairColor); } } } diff --git a/core/rend/vulkan/quad.cpp b/core/rend/vulkan/quad.cpp index 481aa87f2..f474d9379 100644 --- a/core/rend/vulkan/quad.cpp +++ b/core/rend/vulkan/quad.cpp @@ -197,10 +197,13 @@ void QuadDrawer::Draw(vk::CommandBuffer commandBuffer, vk::ImageView imageView, descSet = std::move(context->GetDevice().allocateDescriptorSetsUnique( vk::DescriptorSetAllocateInfo(context->GetDescriptorPool(), 1, &layout)).front()); } - vk::DescriptorImageInfo imageInfo(nearestFilter ? pipeline->GetNearestSampler() : pipeline->GetLinearSampler(), imageView, vk::ImageLayout::eShaderReadOnlyOptimal); - std::vector writeDescriptorSets; - writeDescriptorSets.emplace_back(*descSet, 0, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr); - context->GetDevice().updateDescriptorSets(writeDescriptorSets, nullptr); + if (imageView) + { + vk::DescriptorImageInfo imageInfo(nearestFilter ? pipeline->GetNearestSampler() : pipeline->GetLinearSampler(), imageView, vk::ImageLayout::eShaderReadOnlyOptimal); + std::vector writeDescriptorSets; + writeDescriptorSets.emplace_back(*descSet, 0, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr); + context->GetDevice().updateDescriptorSets(writeDescriptorSets, nullptr); + } commandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, pipeline->GetPipelineLayout(), 0, 1, &descSet.get(), 0, nullptr); buffer->Update(vertices);