- don't search for a renderpass if the current one matches

This commit is contained in:
Magnus Norddahl 2019-03-03 00:16:00 +01:00
parent 1d003ca3fc
commit fd752dec54
3 changed files with 11 additions and 9 deletions

View file

@ -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

View file

@ -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;

View file

@ -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;