From 6f3f76b8511dee30e835a998005adba57adebe17 Mon Sep 17 00:00:00 2001 From: quou Date: Mon, 30 Dec 2024 10:17:17 +1100 Subject: correct render pass ends --- video.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'video.cpp') diff --git a/video.cpp b/video.cpp index f95fcaa..09261b5 100644 --- a/video.cpp +++ b/video.cpp @@ -593,6 +593,7 @@ struct Context_Vk : public Context { const Render_Pass& rp ); void end_rp(Renderpass_Vk& rpo, Framebuffer_Vk& fbo); + void check_end_rp(); }; struct Texture_Vk : public Texture, public Late_Terminated { @@ -1942,8 +1943,7 @@ void Device::submit(Context& ctx_) { si.pSignalSemaphores = &ctx->semaphore;*/ si.commandBufferCount = 1; si.pCommandBuffers = &ctx->cb; - if (ctx->last_rpo) - vkCmdEndRenderPass(ctx->cb); + ctx->check_end_rp(); vkEndCommandBuffer(ctx->cb); vkQueueSubmit(dev->queue, 1, &si, ctx->fence); ctx->wait(); @@ -1957,8 +1957,7 @@ void Device::present() { VkSubmitInfo si{}; VkPipelineStageFlags stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - if (ctx->last_rpo) - vkCmdEndRenderPass(ctx->cb); + ctx->check_end_rp(); ctx->transition( dev->get_backbuffer(), Resource_State::presentable @@ -2171,6 +2170,7 @@ void Context::copy(Buffer_Id dst, Buffer_Id src) { region.srcOffset = 0; region.dstOffset = 0; region.size = b.size; + ctx->check_end_rp(); vkCmdCopyBuffer( ctx->cb, b.buf, @@ -2191,6 +2191,7 @@ void Context::copy(Texture_Id dst, Buffer_Id src) { c.imageExtent.width = a.w; c.imageExtent.height = a.h; c.imageExtent.depth = 1; + ctx->check_end_rp(); vkCmdCopyBufferToImage( ctx->cb, b.buf, @@ -2347,8 +2348,7 @@ std::pair Context_Vk::begin_rp( bool has_depth = rp.depth.id; if (last_rpo == rpo.rpo && last_fbo == fbo.fbo) return { rpo, fbo }; - if (last_rpo) - vkCmdEndRenderPass(cb); + check_end_rp(); last_rpo = rpo.rpo; last_fbo = fbo.fbo; for (i = 0; i < c; i++) { @@ -2389,6 +2389,13 @@ void Context_Vk::end_rp(Renderpass_Vk& rpo, Framebuffer_Vk& fbo) { fbo.on_submit(); } +void Context_Vk::check_end_rp() { + if (last_rpo) { + vkCmdEndRenderPass(cb); + last_rpo = 0; + } +} + void Context::submit(const Render_Pass& rp) { Context_Vk* ctx = (Context_Vk*)this; auto [rpo, fbo] = ctx->begin_rp(rp); -- cgit v1.2.3-54-g00ecf