vk_present_window: Match guest swapchain size to vulkan image count
* Less latency and fixes crashes that were caused by images being deleted before free
This commit is contained in:
@@ -109,7 +109,9 @@ PresentWindow::PresentWindow(Frontend::EmuWindow& emu_window_, const Instance& i
|
||||
use_present_thread{Settings::values.async_presentation.GetValue()},
|
||||
last_render_surface{emu_window.GetWindowInfo().render_surface} {
|
||||
|
||||
const u32 num_images = swapchain.GetImageCount();
|
||||
const vk::Device device = instance.GetDevice();
|
||||
|
||||
const vk::CommandPoolCreateInfo pool_info = {
|
||||
.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer |
|
||||
vk::CommandPoolCreateFlagBits::eTransient,
|
||||
@@ -120,11 +122,12 @@ PresentWindow::PresentWindow(Frontend::EmuWindow& emu_window_, const Instance& i
|
||||
const vk::CommandBufferAllocateInfo alloc_info = {
|
||||
.commandPool = command_pool,
|
||||
.level = vk::CommandBufferLevel::ePrimary,
|
||||
.commandBufferCount = SWAP_CHAIN_SIZE,
|
||||
.commandBufferCount = num_images,
|
||||
};
|
||||
const std::vector command_buffers = device.allocateCommandBuffers(alloc_info);
|
||||
|
||||
for (u32 i = 0; i < SWAP_CHAIN_SIZE; i++) {
|
||||
swap_chain.resize(num_images);
|
||||
for (u32 i = 0; i < num_images; i++) {
|
||||
Frame& frame = swap_chain[i];
|
||||
frame.cmdbuf = command_buffers[i];
|
||||
frame.render_ready = device.createSemaphore({});
|
||||
|
@@ -35,8 +35,6 @@ struct Frame {
|
||||
};
|
||||
|
||||
class PresentWindow final {
|
||||
static constexpr std::size_t SWAP_CHAIN_SIZE = 6;
|
||||
|
||||
public:
|
||||
explicit PresentWindow(Frontend::EmuWindow& emu_window, const Instance& instance,
|
||||
Scheduler& scheduler);
|
||||
@@ -81,7 +79,7 @@ private:
|
||||
vk::CommandPool command_pool;
|
||||
vk::Queue graphics_queue;
|
||||
vk::RenderPass present_renderpass;
|
||||
std::array<Frame, SWAP_CHAIN_SIZE> swap_chain{};
|
||||
std::vector<Frame> swap_chain;
|
||||
std::queue<Frame*> free_queue;
|
||||
std::queue<Frame*> present_queue;
|
||||
std::condition_variable free_cv;
|
||||
|
@@ -44,8 +44,7 @@ void Scheduler::CommandChunk::ExecuteAll(vk::CommandBuffer cmdbuf) {
|
||||
|
||||
Scheduler::Scheduler(const Instance& instance, RenderpassCache& renderpass_cache)
|
||||
: renderpass_cache{renderpass_cache}, master_semaphore{MakeMasterSemaphore(instance)},
|
||||
command_pool{instance, master_semaphore.get()}, use_worker_thread{
|
||||
!Settings::values.renderer_debug} {
|
||||
command_pool{instance, master_semaphore.get()}, use_worker_thread{true} {
|
||||
AllocateWorkerCommandBuffers();
|
||||
if (use_worker_thread) {
|
||||
AcquireNewChunk();
|
||||
|
@@ -275,7 +275,7 @@ VideoCore::StagingData TextureRuntime::FindStaging(u32 size, bool upload) {
|
||||
}
|
||||
|
||||
u32 TextureRuntime::RemoveThreshold() {
|
||||
return num_swapchain_images + 2;
|
||||
return num_swapchain_images;
|
||||
}
|
||||
|
||||
void TextureRuntime::Finish() {
|
||||
|
Reference in New Issue
Block a user