summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/RenderBase.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2018-03-10 08:22:28 +0100
committerGitHub <noreply@github.com>2018-03-10 08:22:28 +0100
commita4ef133456a18178f345d3c25195bf74c0e83750 (patch)
tree1564aa8e85c3800882466b953984a57be0bf0b0c /Source/Core/VideoCommon/RenderBase.cpp
parent63838c013bde06ed13bfc1b5e24c53594934f641 (diff)
parent93ab50c55584c416d32b5bbdf39f37e9c67f4105 (diff)
Merge pull request #6399 from stenzek/videocommon-shader-cache
VideoCommon Shader (Pipeline) Cache
Diffstat (limited to 'Source/Core/VideoCommon/RenderBase.cpp')
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index 8aea2f098d..a5e5272651 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -56,6 +56,7 @@
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/PixelShaderManager.h"
#include "VideoCommon/PostProcessing.h"
+#include "VideoCommon/ShaderCache.h"
#include "VideoCommon/ShaderGenCommon.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/TextureCacheBase.h"
@@ -92,6 +93,7 @@ Renderer::Renderer(int backbuffer_width, int backbuffer_height)
m_surface_handle = Host_GetRenderHandle();
m_last_host_config_bits = ShaderHostConfig::GetCurrent().bits;
+ m_last_efb_multisamples = g_ActiveConfig.iMultisamples;
}
Renderer::~Renderer() = default;
@@ -234,11 +236,20 @@ void Renderer::SaveScreenshot(const std::string& filename, bool wait_for_complet
bool Renderer::CheckForHostConfigChanges()
{
ShaderHostConfig new_host_config = ShaderHostConfig::GetCurrent();
- if (new_host_config.bits == m_last_host_config_bits)
+ if (new_host_config.bits == m_last_host_config_bits &&
+ m_last_efb_multisamples == g_ActiveConfig.iMultisamples)
+ {
return false;
+ }
- OSD::AddMessage("Video config changed, reloading shaders.", OSD::Duration::NORMAL);
m_last_host_config_bits = new_host_config.bits;
+ m_last_efb_multisamples = g_ActiveConfig.iMultisamples;
+
+ // Reload shaders.
+ OSD::AddMessage("Video config changed, reloading shaders.", OSD::Duration::NORMAL);
+ SetPipeline(nullptr);
+ g_vertex_manager->InvalidatePipelineObject();
+ g_shader_cache->SetHostConfig(new_host_config, g_ActiveConfig.iMultisamples);
return true;
}
@@ -688,6 +699,13 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const
// Set default viewport and scissor, for the clear to work correctly
// New frame
stats.ResetFrame();
+ g_shader_cache->RetrieveAsyncShaders();
+
+ // We invalidate the pipeline object at the start of the frame.
+ // This is for the rare case where only a single pipeline configuration is used,
+ // and hybrid ubershaders have compiled the specialized shader, but without any
+ // state changes the specialized shader will not take over.
+ g_vertex_manager->InvalidatePipelineObject();
Core::Callback_VideoCopiedToXFB(true);
}
@@ -1009,3 +1027,8 @@ bool Renderer::UseVertexDepthRange() const
// in the vertex shader.
return fabs(xfmem.viewport.zRange) > 16777215.0f || fabs(xfmem.viewport.farZ) > 16777215.0f;
}
+
+std::unique_ptr<VideoCommon::AsyncShaderCompiler> Renderer::CreateAsyncShaderCompiler()
+{
+ return std::make_unique<VideoCommon::AsyncShaderCompiler>();
+}