Permalink
Browse files

Avoid re-binding pipelines.

  • Loading branch information...
hrydgard committed Aug 28, 2017
1 parent 72a41cd commit c403edfa890238afd225abf34e767bcebda1907e
Showing with 16 additions and 9 deletions.
  1. +6 −7 GPU/Software/SoftGpu.cpp
  2. +10 −2 ext/native/thin3d/VulkanRenderManager.cpp
View
@@ -146,13 +146,6 @@ void SoftGPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat for
void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
if (!draw_)
return;
float dstwidth = (float)PSP_CoreParameter().pixelWidth;
float dstheight = (float)PSP_CoreParameter().pixelHeight;
Draw::Viewport viewport = {0.0f, 0.0f, dstwidth, dstheight, 0.0f, 1.0f};
draw_->SetViewports(1, &viewport);
draw_->SetScissorRect(0, 0, dstwidth, dstheight);
float u0 = 0.0f;
float u1;
@@ -216,6 +209,9 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
fbTex = draw_->CreateTexture(desc);
float dstwidth = (float)PSP_CoreParameter().pixelWidth;
float dstheight = (float)PSP_CoreParameter().pixelHeight;
float x, y, w, h;
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, dstwidth, dstheight, ROTATION_LOCKED_HORIZONTAL);
@@ -242,6 +238,9 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
std::swap(v0, v1);
}
draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE });
Draw::Viewport viewport = { 0.0f, 0.0f, dstwidth, dstheight, 0.0f, 1.0f };
draw_->SetViewports(1, &viewport);
draw_->SetScissorRect(0, 0, dstwidth, dstheight);
Draw::SamplerState *sampler;
if (g_Config.iBufFilter == SCALE_NEAREST) {
@@ -771,6 +771,8 @@ void VulkanRenderManager::PerformRenderPass(const VKRStep &step, VkCommandBuffer
VKRFramebuffer *fb = step.render.framebuffer;
VkPipeline lastPipeline = VK_NULL_HANDLE;
auto &commands = step.commands;
// TODO: Dynamic state commands (SetViewport, SetScissor, SetBlendConstants, SetStencil*) are only
@@ -798,15 +800,21 @@ void VulkanRenderManager::PerformRenderPass(const VKRStep &step, VkCommandBuffer
break;
case VKRRenderCommand::DRAW_INDEXED:
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, c.drawIndexed.pipeline);
if (c.drawIndexed.pipeline != lastPipeline) {
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, c.drawIndexed.pipeline);
lastPipeline = c.drawIndexed.pipeline;
}
vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, c.drawIndexed.pipelineLayout, 0, 1, &c.drawIndexed.ds, c.drawIndexed.numUboOffsets, c.drawIndexed.uboOffsets);
vkCmdBindIndexBuffer(cmd, c.drawIndexed.ibuffer, c.drawIndexed.ioffset, VK_INDEX_TYPE_UINT16);
vkCmdBindVertexBuffers(cmd, 0, 1, &c.drawIndexed.vbuffer, &c.drawIndexed.voffset);
vkCmdDrawIndexed(cmd, c.drawIndexed.count, c.drawIndexed.instances, 0, 0, 0);
break;
case VKRRenderCommand::DRAW:
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, c.draw.pipeline);
if (c.draw.pipeline != lastPipeline) {
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, c.draw.pipeline);
lastPipeline = c.draw.pipeline;
}
vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, c.draw.pipelineLayout, 0, 1, &c.draw.ds, c.draw.numUboOffsets, c.draw.uboOffsets);
vkCmdBindVertexBuffers(cmd, 0, 1, &c.draw.vbuffer, &c.draw.voffset);
vkCmdDraw(cmd, c.draw.count, 1, 0, 0);

0 comments on commit c403edf

Please sign in to comment.