Permalink
Browse files

Dirty-track the current pipeline to avoid many vkBindPipeline calls.

  • Loading branch information...
hrydgard committed Aug 14, 2017
1 parent 5a65334 commit a1fd2d1ed199fe005b13a459b826fb7b71197c21
Showing with 13 additions and 1 deletion.
  1. +10 −1 GPU/Vulkan/DrawEngineVulkan.cpp
  2. +3 −0 GPU/Vulkan/DrawEngineVulkan.h
@@ -569,6 +569,12 @@ void DrawEngineVulkan::DoFlush() {
gpuStats.numFlushes++;
VkCommandBuffer cmd = (VkCommandBuffer)draw_->GetNativeObject(Draw::NativeObject::RENDERPASS_COMMANDBUFFER);
if (cmd != lastCmd_) {
lastPipeline_ = nullptr;
lastCmd_ = cmd;
gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE);
}
VkRenderPass rp = (VkRenderPass)draw_->GetNativeObject(Draw::NativeObject::CURRENT_RENDERPASS);
if (!rp)
Crash();
@@ -660,7 +666,10 @@ void DrawEngineVulkan::DoFlush() {
// Already logged, let's bail out.
return;
}
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->pipeline); // TODO: Avoid if same as last draw.
if (pipeline != lastPipeline_) {
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->pipeline); // TODO: Avoid if same as last draw.
lastPipeline_ = pipeline;
}
UpdateUBOs(frame);
@@ -60,6 +60,7 @@ typedef u32 ReliableHashType;
class VulkanContext;
class VulkanPushBuffer;
struct VulkanPipeline;
struct DrawEngineVulkanStats {
int pushUBOSpaceUsed;
@@ -146,6 +147,8 @@ class DrawEngineVulkan : public DrawEngineCommon {
// We use a single descriptor set layout for all PSP draws.
VkDescriptorSetLayout descriptorSetLayout_;
VkPipelineLayout pipelineLayout_;
VkCommandBuffer lastCmd_ = VK_NULL_HANDLE;
VulkanPipeline *lastPipeline_;
struct DescriptorSetKey {
VkImageView imageView_;

0 comments on commit a1fd2d1

Please sign in to comment.