diff --git a/src/rendering/vulkan/renderer/vk_renderpass.h b/src/rendering/vulkan/renderer/vk_renderpass.h index 429231bc8b..f385dda3ba 100644 --- a/src/rendering/vulkan/renderer/vk_renderpass.h +++ b/src/rendering/vulkan/renderer/vk_renderpass.h @@ -20,10 +20,9 @@ public: int VertexFormat; int DrawType; - bool operator<(const VkRenderPassKey &other) const - { - return memcmp(this, &other, sizeof(VkRenderPassKey)) < 0; - } + bool operator<(const VkRenderPassKey &other) const { return memcmp(this, &other, sizeof(VkRenderPassKey)) < 0; } + bool operator==(const VkRenderPassKey &other) const { return memcmp(this, &other, sizeof(VkRenderPassKey)) == 0; } + bool operator!=(const VkRenderPassKey &other) const { return memcmp(this, &other, sizeof(VkRenderPassKey)) != 0; } }; class VkRenderPassSetup diff --git a/src/rendering/vulkan/renderer/vk_renderstate.cpp b/src/rendering/vulkan/renderer/vk_renderstate.cpp index be89d7f71c..a94ca75adc 100644 --- a/src/rendering/vulkan/renderer/vk_renderstate.cpp +++ b/src/rendering/vulkan/renderer/vk_renderstate.cpp @@ -231,10 +231,9 @@ void VkRenderState::ApplyRenderPass(int dt) passKey.EffectState = mTextureEnabled ? effectState : SHADER_NoTexture; passKey.AlphaTest = mAlphaThreshold >= 0.f; } - VkRenderPassSetup *passSetup = passManager->GetRenderPass(passKey); // Is this the one we already have or do we need to change render pass? - bool changingRenderPass = (passSetup != mRenderPassSetup); + bool changingRenderPass = (passKey != mRenderPassKey); if (!mCommandBuffer) { @@ -250,13 +249,16 @@ void VkRenderState::ApplyRenderPass(int dt) if (changingRenderPass) { + VkRenderPassSetup *passSetup = passManager->GetRenderPass(passKey); + RenderPassBegin beginInfo; beginInfo.setRenderPass(passSetup->RenderPass.get()); beginInfo.setRenderArea(0, 0, SCREENWIDTH, SCREENHEIGHT); beginInfo.setFramebuffer(passSetup->Framebuffer.get()); mCommandBuffer->beginRenderPass(beginInfo); mCommandBuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, passSetup->Pipeline.get()); - mRenderPassSetup = passSetup; + + mRenderPassKey = passKey; } } @@ -551,7 +553,7 @@ void VkRenderState::EndRenderPass() { mCommandBuffer->endRenderPass(); mCommandBuffer = nullptr; - mRenderPassSetup = nullptr; + mRenderPassKey = {}; // To do: move this elsewhere or rename this function to make it clear this can only happen at the end of a frame mMatricesOffset = 0; diff --git a/src/rendering/vulkan/renderer/vk_renderstate.h b/src/rendering/vulkan/renderer/vk_renderstate.h index 63dd69171f..8eeed7cab3 100644 --- a/src/rendering/vulkan/renderer/vk_renderstate.h +++ b/src/rendering/vulkan/renderer/vk_renderstate.h @@ -3,6 +3,7 @@ #include "vulkan/system/vk_buffers.h" #include "vulkan/shaders/vk_shader.h" +#include "vulkan/renderer/vk_renderpass.h" #include "name.h" @@ -57,7 +58,7 @@ private: bool mLastDepthClamp = true; VulkanCommandBuffer *mCommandBuffer = nullptr; - VkRenderPassSetup *mRenderPassSetup = nullptr; + VkRenderPassKey mRenderPassKey = {}; bool mDynamicSetChanged = true; int mScissorX = 0, mScissorY = 0, mScissorWidth = -1, mScissorHeight = -1;