diff options
| author | Stenzek <stenzek@gmail.com> | 2017-07-20 17:10:02 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2017-07-20 17:54:33 +1000 |
| commit | 3ea9d86faa2544b8c1c235db9456f271baf42fec (patch) | |
| tree | 87a16a5a23002309127209967011c4d75ad8d93e /Source/Core/VideoCommon/ShaderGenCommon.cpp | |
| parent | d01b0bf60fba2101e45cfac1e5747edcdbab5fc1 (diff) | |
ShaderGen: Pass host config to shader generation functions
Also moves the host config checks to common.
Diffstat (limited to 'Source/Core/VideoCommon/ShaderGenCommon.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/ShaderGenCommon.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/ShaderGenCommon.cpp b/Source/Core/VideoCommon/ShaderGenCommon.cpp new file mode 100644 index 0000000000..58085fdafa --- /dev/null +++ b/Source/Core/VideoCommon/ShaderGenCommon.cpp @@ -0,0 +1,75 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "VideoCommon/ShaderGenCommon.h" +#include "Common/CommonPaths.h" +#include "Common/FileUtil.h" +#include "Core/ConfigManager.h" + +ShaderHostConfig ShaderHostConfig::GetCurrent() +{ + ShaderHostConfig bits = {}; + bits.msaa = g_ActiveConfig.iMultisamples > 1; + bits.ssaa = g_ActiveConfig.iMultisamples > 1 && g_ActiveConfig.bSSAA && + g_ActiveConfig.backend_info.bSupportsSSAA; + bits.stereo = g_ActiveConfig.iStereoMode > 0; + bits.wireframe = g_ActiveConfig.bWireFrame; + bits.per_pixel_lighting = g_ActiveConfig.bEnablePixelLighting; + bits.vertex_rounding = g_ActiveConfig.UseVertexRounding(); + bits.fast_depth_calc = g_ActiveConfig.bFastDepthCalc; + bits.bounding_box = g_ActiveConfig.bBBoxEnable; + bits.backend_dual_source_blend = g_ActiveConfig.backend_info.bSupportsDualSourceBlend; + bits.backend_geometry_shaders = g_ActiveConfig.backend_info.bSupportsGeometryShaders; + bits.backend_early_z = g_ActiveConfig.backend_info.bSupportsEarlyZ; + bits.backend_bbox = g_ActiveConfig.backend_info.bSupportsBBox; + bits.backend_gs_instancing = g_ActiveConfig.backend_info.bSupportsGSInstancing; + bits.backend_clip_control = g_ActiveConfig.backend_info.bSupportsClipControl; + bits.backend_ssaa = g_ActiveConfig.backend_info.bSupportsSSAA; + bits.backend_atomics = g_ActiveConfig.backend_info.bSupportsFragmentStoresAndAtomics; + bits.backend_depth_clamp = g_ActiveConfig.backend_info.bSupportsDepthClamp; + bits.backend_reversed_depth_range = g_ActiveConfig.backend_info.bSupportsReversedDepthRange; + return bits; +} + +std::string GetDiskShaderCacheFileName(APIType api_type, const char* type, bool include_gameid, + bool include_host_config) +{ + if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX))) + File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX)); + + std::string filename = File::GetUserPath(D_SHADERCACHE_IDX); + switch (api_type) + { + case APIType::D3D: + filename += "D3D"; + break; + case APIType::OpenGL: + filename += "OpenGL"; + break; + case APIType::Vulkan: + filename += "Vulkan"; + break; + default: + break; + } + + filename += '-'; + filename += type; + + if (include_gameid) + { + filename += '-'; + filename += SConfig::GetInstance().GetGameID(); + } + + if (include_host_config) + { + // We're using 18 bits, so 5 hex characters. + ShaderHostConfig host_config = ShaderHostConfig::GetCurrent(); + filename += StringFromFormat("-%05X", host_config.bits); + } + + filename += ".cache"; + return filename; +} |
