From 3957a19bd051232065c24e86c24ba5a363d3b64b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 19 Apr 2019 21:08:15 +0200 Subject: [PATCH] - flush the commands for every 1000th Apply call --- src/rendering/vulkan/renderer/vk_renderstate.cpp | 9 +++++++++ src/rendering/vulkan/renderer/vk_renderstate.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/rendering/vulkan/renderer/vk_renderstate.cpp b/src/rendering/vulkan/renderer/vk_renderstate.cpp index 781768743..1e6dad299 100644 --- a/src/rendering/vulkan/renderer/vk_renderstate.cpp +++ b/src/rendering/vulkan/renderer/vk_renderstate.cpp @@ -160,6 +160,14 @@ void VkRenderState::EnableLineSmooth(bool on) void VkRenderState::Apply(int dt) { + mApplyCount++; + if (mApplyCount == 1000) + { + EndRenderPass(); + GetVulkanFrameBuffer()->FlushCommands(); + mApplyCount = 0; + } + ApplyRenderPass(dt); ApplyScissor(); ApplyViewport(); @@ -548,6 +556,7 @@ void VkRenderState::Bind(int bindingpoint, uint32_t offset) void VkRenderState::BeginFrame() { mMaterial.Reset(); + mApplyCount = 0; } void VkRenderState::EndRenderPass() diff --git a/src/rendering/vulkan/renderer/vk_renderstate.h b/src/rendering/vulkan/renderer/vk_renderstate.h index 0158454ce..dc2c035d6 100644 --- a/src/rendering/vulkan/renderer/vk_renderstate.h +++ b/src/rendering/vulkan/renderer/vk_renderstate.h @@ -113,6 +113,8 @@ protected: bool mLastModelMatrixEnabled = true; bool mLastTextureMatrixEnabled = true; + int mApplyCount = 0; + struct RenderTarget { VulkanImageView *View = nullptr;