ShaderGen: Pass host config to shader generation functions

Also moves the host config checks to common.
This commit is contained in:
Stenzek
2017-07-20 17:10:02 +10:00
parent d01b0bf60f
commit 3ea9d86faa
27 changed files with 231 additions and 219 deletions

View File

@ -217,12 +217,13 @@ SHADER* ProgramShaderCache::SetShader(u32 primitive_type)
last_entry = &newentry;
newentry.in_cache = 0;
ShaderCode vcode = GenerateVertexShaderCode(APIType::OpenGL, uid.vuid.GetUidData());
ShaderCode pcode = GeneratePixelShaderCode(APIType::OpenGL, uid.puid.GetUidData());
ShaderHostConfig host_config = ShaderHostConfig::GetCurrent();
ShaderCode vcode = GenerateVertexShaderCode(APIType::OpenGL, host_config, uid.vuid.GetUidData());
ShaderCode pcode = GeneratePixelShaderCode(APIType::OpenGL, host_config, uid.puid.GetUidData());
ShaderCode gcode;
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders &&
!uid.guid.GetUidData()->IsPassthrough())
gcode = GenerateGeometryShaderCode(APIType::OpenGL, uid.guid.GetUidData());
gcode = GenerateGeometryShaderCode(APIType::OpenGL, host_config, uid.guid.GetUidData());
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_ActiveConfig.iLog & CONF_SAVESHADERS)
@ -553,7 +554,7 @@ void ProgramShaderCache::LoadProgramBinaries()
else
{
std::string cache_filename =
g_ActiveConfig.GetDiskCacheFileName(APIType::OpenGL, "ProgramBinaries", true, true);
GetDiskShaderCacheFileName(APIType::OpenGL, "ProgramBinaries", true, true);
ProgramShaderCacheInserter inserter;
g_program_disk_cache.OpenAndRead(cache_filename, inserter);
}

View File

@ -43,6 +43,7 @@
#include "VideoCommon/PixelEngine.h"
#include "VideoCommon/PixelShaderManager.h"
#include "VideoCommon/RenderState.h"
#include "VideoCommon/ShaderGenCommon.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
@ -664,6 +665,9 @@ Renderer::Renderer()
g_Config.VerifyValidity();
UpdateActiveConfig();
// Since we modify the config here, we need to update the last host bits, it may have changed.
m_last_host_config_bits = ShaderHostConfig::GetCurrent().bits;
OSD::AddMessage(StringFromFormat("Video Info: %s, %s, %s", g_ogl_config.gl_vendor,
g_ogl_config.gl_renderer, g_ogl_config.gl_version),
5000);
@ -688,7 +692,6 @@ Renderer::Renderer()
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
m_last_host_config_bits = g_ActiveConfig.GetHostConfigBits();
// Handle VSync on/off
s_vsync = g_ActiveConfig.IsVSync();
@ -1471,13 +1474,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
g_texture_cache->OnConfigChanged(g_ActiveConfig);
// Invalidate shader cache when the host config changes.
u32 new_host_config_bits = g_ActiveConfig.GetHostConfigBits();
if (new_host_config_bits != m_last_host_config_bits)
{
OSD::AddMessage("Video config changed, reloading shaders.", OSD::Duration::NORMAL);
if (CheckForHostConfigChanges())
ProgramShaderCache::Reload();
m_last_host_config_bits = new_host_config_bits;
}
// For testing zbuffer targets.
// Renderer::SetZBufferRender();

View File

@ -148,8 +148,5 @@ private:
std::array<int, 2> m_last_frame_height = {};
bool m_last_frame_exported = false;
AVIDump::Frame m_last_frame_state;
// last host config state
u32 m_last_host_config_bits = 0;
};
}