mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 22:09:19 -07:00
6fbbc2683e
Migrates most of VideoCommon over to using fmt, with the exception being the shader generator code. The shader generators are quite large and have more corner cases to deal with in terms of conversion (shaders have braces in them, so we need to make sure to escape them). Because of the large amount of code that would need to be converted, the conversion of VideoCommon will be in two parts: - This change (which converts over the general case string formatting), - A follow up change that will specifically deal with converting over the shader generators.
87 lines
3.1 KiB
C++
87 lines
3.1 KiB
C++
// Copyright 2017 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#include "VideoCommon/ShaderGenCommon.h"
|
|
|
|
#include <fmt/format.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.stereo_mode != StereoMode::Off;
|
|
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;
|
|
bits.backend_bitfield = g_ActiveConfig.backend_info.bSupportsBitfield;
|
|
bits.backend_dynamic_sampler_indexing =
|
|
g_ActiveConfig.backend_info.bSupportsDynamicSamplerIndexing;
|
|
bits.backend_shader_framebuffer_fetch = g_ActiveConfig.backend_info.bSupportsFramebufferFetch;
|
|
bits.backend_logic_op = g_ActiveConfig.backend_info.bSupportsLogicOp;
|
|
bits.backend_palette_conversion = g_ActiveConfig.backend_info.bSupportsPaletteConversion;
|
|
return bits;
|
|
}
|
|
|
|
std::string GetDiskShaderCacheFileName(APIType api_type, const char* type, bool include_gameid,
|
|
bool include_host_config, bool include_api)
|
|
{
|
|
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
|
|
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
|
|
|
std::string filename = File::GetUserPath(D_SHADERCACHE_IDX);
|
|
if (include_api)
|
|
{
|
|
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 21 bits, so 6 hex characters.
|
|
ShaderHostConfig host_config = ShaderHostConfig::GetCurrent();
|
|
filename += fmt::format("-{:06X}", host_config.bits);
|
|
}
|
|
|
|
filename += ".cache";
|
|
return filename;
|
|
}
|