summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2018-02-25 17:56:09 +1000
committerStenzek <stenzek@gmail.com>2018-03-10 15:56:34 +1000
commitf9c829c7f711efadea1db7aabb51c703380fa03a (patch)
treecc645756b893e4c994360ec362977aaa9e5ad51f /Source/Core/VideoCommon
parentdec0c3bce85ceda89ea05f00b94aad00e675598d (diff)
OGL: Re-implement async shader compiling
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/DriverDetails.cpp2
-rw-r--r--Source/Core/VideoCommon/DriverDetails.h6
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp5
-rw-r--r--Source/Core/VideoCommon/RenderBase.h3
-rw-r--r--Source/Core/VideoCommon/ShaderCache.cpp2
-rw-r--r--Source/Core/VideoCommon/VideoConfig.cpp6
-rw-r--r--Source/Core/VideoCommon/VideoConfig.h1
7 files changed, 16 insertions, 9 deletions
diff --git a/Source/Core/VideoCommon/DriverDetails.cpp b/Source/Core/VideoCommon/DriverDetails.cpp
index d280a6a9b4..8fd990395d 100644
--- a/Source/Core/VideoCommon/DriverDetails.cpp
+++ b/Source/Core/VideoCommon/DriverDetails.cpp
@@ -102,8 +102,6 @@ static BugInfo m_known_bugs[] = {
true},
{API_OPENGL, OS_LINUX, VENDOR_MESA, DRIVER_I965, Family::UNKNOWN,
BUG_SHARED_CONTEXT_SHADER_COMPILATION, -1.0, -1.0, true},
- {API_OPENGL, OS_LINUX, VENDOR_MESA, DRIVER_NOUVEAU, Family::UNKNOWN,
- BUG_SHARED_CONTEXT_SHADER_COMPILATION, -1.0, -1.0, true},
{API_VULKAN, OS_ALL, VENDOR_NVIDIA, DRIVER_NVIDIA, Family::UNKNOWN, BUG_BROKEN_MSAA_CLEAR, -1.0,
-1.0, true},
{API_VULKAN, OS_ALL, VENDOR_IMGTEC, DRIVER_IMGTEC, Family::UNKNOWN,
diff --git a/Source/Core/VideoCommon/DriverDetails.h b/Source/Core/VideoCommon/DriverDetails.h
index df06a77d92..bc96ee2aab 100644
--- a/Source/Core/VideoCommon/DriverDetails.h
+++ b/Source/Core/VideoCommon/DriverDetails.h
@@ -252,8 +252,10 @@ enum Bug
// the negated value to a temporary variable then using that in the bitwise op.
BUG_BROKEN_BITWISE_OP_NEGATION,
- // Bug: Shaders are recompiled on the main thread after being previously compiled on
- // a worker thread on Mesa i965.
+ // BUG: The GPU shader code appears to be context-specific on Mesa/i965.
+ // This means that if we compiled the ubershaders asynchronously, they will be recompiled
+ // on the main thread the first time they are used, causing stutter. For now, disable
+ // asynchronous compilation on Mesa i965.
// Started version: -1
// Ended Version: -1
BUG_SHARED_CONTEXT_SHADER_COMPILATION,
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index 4c03168d20..a5e5272651 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -1027,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>();
+}
diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h
index da8e0b819f..b906cd2558 100644
--- a/Source/Core/VideoCommon/RenderBase.h
+++ b/Source/Core/VideoCommon/RenderBase.h
@@ -28,6 +28,7 @@
#include "Common/Flag.h"
#include "Common/MathUtil.h"
#include "VideoCommon/AVIDump.h"
+#include "VideoCommon/AsyncShaderCompiler.h"
#include "VideoCommon/BPMemory.h"
#include "VideoCommon/FPSCounter.h"
#include "VideoCommon/RenderState.h"
@@ -189,6 +190,8 @@ public:
void ResizeSurface(int new_width, int new_height);
bool UseVertexDepthRange() const;
+ virtual std::unique_ptr<VideoCommon::AsyncShaderCompiler> CreateAsyncShaderCompiler();
+
virtual void Shutdown();
// Drawing utility shaders.
diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp
index 05624e9fe4..1e4a0ef741 100644
--- a/Source/Core/VideoCommon/ShaderCache.cpp
+++ b/Source/Core/VideoCommon/ShaderCache.cpp
@@ -27,7 +27,7 @@ bool ShaderCache::Initialize()
m_efb_multisamples = g_ActiveConfig.iMultisamples;
// Create the async compiler, and start the worker threads.
- m_async_shader_compiler = std::make_unique<VideoCommon::AsyncShaderCompiler>();
+ m_async_shader_compiler = g_renderer->CreateAsyncShaderCompiler();
m_async_shader_compiler->ResizeWorkerThreads(g_ActiveConfig.GetShaderPrecompilerThreads());
// Load shader and UID caches.
diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp
index 771adf60bf..d8c0dfaa6c 100644
--- a/Source/Core/VideoCommon/VideoConfig.cpp
+++ b/Source/Core/VideoCommon/VideoConfig.cpp
@@ -187,8 +187,7 @@ static u32 GetNumAutoShaderCompilerThreads()
u32 VideoConfig::GetShaderCompilerThreads() const
{
- // videocommon shader cache is currently broken on OGL, needs multiple contexts.
- if (backend_info.api_type == APIType::OpenGL)
+ if (!backend_info.bSupportsBackgroundCompiling)
return 0;
if (iShaderCompilerThreads >= 0)
@@ -199,8 +198,7 @@ u32 VideoConfig::GetShaderCompilerThreads() const
u32 VideoConfig::GetShaderPrecompilerThreads() const
{
- // videocommon shader cache is currently broken on OGL, needs multiple contexts.
- if (backend_info.api_type == APIType::OpenGL)
+ if (!backend_info.bSupportsBackgroundCompiling)
return 0;
if (iShaderPrecompilerThreads >= 0)
diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h
index fb05408303..7839cb0e8f 100644
--- a/Source/Core/VideoCommon/VideoConfig.h
+++ b/Source/Core/VideoCommon/VideoConfig.h
@@ -227,6 +227,7 @@ struct VideoConfig final
bool bSupportsDynamicSamplerIndexing; // Needed by UberShaders, so must stay in VideoCommon
bool bSupportsBPTCTextures;
bool bSupportsFramebufferFetch; // Used as an alternative to dual-source blend on GLES
+ bool bSupportsBackgroundCompiling;
} backend_info;
// Utility