2017-07-20 01:10:02 -06:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "VideoCommon/ShaderGenCommon.h"
|
2019-11-22 15:10:41 -07:00
|
|
|
|
|
|
|
#include <fmt/format.h>
|
|
|
|
|
2017-07-20 01:10:02 -06:00
|
|
|
#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;
|
2017-11-10 20:55:00 -07:00
|
|
|
bits.stereo = g_ActiveConfig.stereo_mode != StereoMode::Off;
|
2017-07-20 01:10:02 -06:00
|
|
|
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;
|
2017-07-19 23:25:24 -06:00
|
|
|
bits.backend_bitfield = g_ActiveConfig.backend_info.bSupportsBitfield;
|
|
|
|
bits.backend_dynamic_sampler_indexing =
|
|
|
|
g_ActiveConfig.backend_info.bSupportsDynamicSamplerIndexing;
|
2017-10-25 23:44:39 -06:00
|
|
|
bits.backend_shader_framebuffer_fetch = g_ActiveConfig.backend_info.bSupportsFramebufferFetch;
|
2018-05-25 08:04:18 -06:00
|
|
|
bits.backend_logic_op = g_ActiveConfig.backend_info.bSupportsLogicOp;
|
2019-02-14 18:59:50 -07:00
|
|
|
bits.backend_palette_conversion = g_ActiveConfig.backend_info.bSupportsPaletteConversion;
|
2017-07-20 01:10:02 -06:00
|
|
|
return bits;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string GetDiskShaderCacheFileName(APIType api_type, const char* type, bool include_gameid,
|
2018-02-24 08:15:35 -07:00
|
|
|
bool include_host_config, bool include_api)
|
2017-07-20 01:10:02 -06:00
|
|
|
{
|
|
|
|
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
|
|
|
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
|
|
|
|
|
|
|
std::string filename = File::GetUserPath(D_SHADERCACHE_IDX);
|
2018-02-24 08:15:35 -07:00
|
|
|
if (include_api)
|
2017-07-20 01:10:02 -06:00
|
|
|
{
|
2018-02-24 08:15:35 -07:00
|
|
|
switch (api_type)
|
|
|
|
{
|
|
|
|
case APIType::D3D:
|
|
|
|
filename += "D3D";
|
|
|
|
break;
|
|
|
|
case APIType::OpenGL:
|
|
|
|
filename += "OpenGL";
|
|
|
|
break;
|
|
|
|
case APIType::Vulkan:
|
|
|
|
filename += "Vulkan";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
filename += '-';
|
2017-07-20 01:10:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
filename += type;
|
|
|
|
|
|
|
|
if (include_gameid)
|
|
|
|
{
|
|
|
|
filename += '-';
|
|
|
|
filename += SConfig::GetInstance().GetGameID();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (include_host_config)
|
|
|
|
{
|
2017-10-25 23:44:39 -06:00
|
|
|
// We're using 21 bits, so 6 hex characters.
|
2017-07-20 01:10:02 -06:00
|
|
|
ShaderHostConfig host_config = ShaderHostConfig::GetCurrent();
|
2019-11-22 15:10:41 -07:00
|
|
|
filename += fmt::format("-{:06X}", host_config.bits);
|
2017-07-20 01:10:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
filename += ".cache";
|
|
|
|
return filename;
|
|
|
|
}
|