OGL: Support returning pipeline cache data

This commit is contained in:
Stenzek
2019-04-15 23:38:10 +10:00
parent 5cef09e383
commit 616ad378b7
6 changed files with 138 additions and 56 deletions

View File

@ -350,6 +350,7 @@ Renderer::Renderer(std::unique_ptr<GLContext> main_gl_context, float backbuffer_
}
bool bSuccess = true;
bool supports_glsl_cache = false;
g_ogl_config.gl_vendor = (const char*)glGetString(GL_VENDOR);
g_ogl_config.gl_renderer = (const char*)glGetString(GL_RENDERER);
@ -466,7 +467,7 @@ Renderer::Renderer(std::unique_ptr<GLContext> main_gl_context, float backbuffer_
GLExtensions::Supports("GL_ARB_gpu_shader5");
g_ogl_config.bIsES = m_main_gl_context->IsGLES();
g_ogl_config.bSupportsGLSLCache = GLExtensions::Supports("GL_ARB_get_program_binary");
supports_glsl_cache = GLExtensions::Supports("GL_ARB_get_program_binary");
g_ogl_config.bSupportsGLPinnedMemory = GLExtensions::Supports("GL_AMD_pinned_memory");
g_ogl_config.bSupportsGLSync = GLExtensions::Supports("GL_ARB_sync");
g_ogl_config.bSupportsGLBaseVertex = GLExtensions::Supports("GL_ARB_draw_elements_base_vertex") ||
@ -507,7 +508,7 @@ Renderer::Renderer(std::unique_ptr<GLContext> main_gl_context, float backbuffer_
EsTexbufType::TexbufExt :
EsTexbufType::TexbufNone;
g_ogl_config.bSupportsGLSLCache = true;
supports_glsl_cache = true;
g_ogl_config.bSupportsGLSync = true;
// TODO: Implement support for GL_EXT_clip_cull_distance when there is an extension for
@ -675,6 +676,16 @@ Renderer::Renderer(std::unique_ptr<GLContext> main_gl_context, float backbuffer_
g_Config.backend_info.bSupportsBackgroundCompiling =
!DriverDetails::HasBug(DriverDetails::BUG_SHARED_CONTEXT_SHADER_COMPILATION);
// Program binaries are supported on GL4.1+, ARB_get_program_binary, or ES3.
if (supports_glsl_cache)
{
// We need to check the number of formats supported. If zero, don't bother getting the binaries.
GLint num_formats = 0;
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &num_formats);
supports_glsl_cache = num_formats > 0;
}
g_Config.backend_info.bSupportsPipelineCacheData = supports_glsl_cache;
if (g_ogl_config.bSupportsDebug)
{
if (GLExtensions::Supports("GL_KHR_debug"))
@ -739,7 +750,7 @@ Renderer::Renderer(std::unique_ptr<GLContext> main_gl_context, float backbuffer_
g_ActiveConfig.backend_info.bSupportsPrimitiveRestart ? "" : "PrimitiveRestart ",
g_ActiveConfig.backend_info.bSupportsEarlyZ ? "" : "EarlyZ ",
g_ogl_config.bSupportsGLPinnedMemory ? "" : "PinnedMemory ",
g_ogl_config.bSupportsGLSLCache ? "" : "ShaderCache ",
supports_glsl_cache ? "" : "ShaderCache ",
g_ogl_config.bSupportsGLBaseVertex ? "" : "BaseVertex ",
g_ogl_config.bSupportsGLBufferStorage ? "" : "BufferStorage ",
g_ogl_config.bSupportsGLSync ? "" : "Sync ", g_ogl_config.bSupportsMSAA ? "" : "MSAA ",
@ -832,7 +843,7 @@ std::unique_ptr<AbstractPipeline> Renderer::CreatePipeline(const AbstractPipelin
const void* cache_data,
size_t cache_data_length)
{
return OGLPipeline::Create(config);
return OGLPipeline::Create(config, cache_data, cache_data_length);
}
void Renderer::SetScissorRect(const MathUtil::Rectangle<int>& rc)