From eb81968fe63d5df0f9b0efd1533567096c2bb59b Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 28 Jul 2021 21:11:15 -0700 Subject: [PATCH] Convert ShaderHostConfig to BitField --- Source/Core/VideoCommon/ShaderCache.cpp | 2 +- Source/Core/VideoCommon/ShaderCache.h | 2 +- Source/Core/VideoCommon/ShaderGenCommon.h | 51 +++++++++++------------ 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index 40defb9fdc..655a5b6bb1 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -35,7 +35,7 @@ ShaderCache::~ShaderCache() bool ShaderCache::Initialize() { m_api_type = g_ActiveConfig.backend_info.api_type; - m_host_config = ShaderHostConfig::GetCurrent(); + m_host_config.bits = ShaderHostConfig::GetCurrent().bits; if (!CompileSharedPipelines()) return false; diff --git a/Source/Core/VideoCommon/ShaderCache.h b/Source/Core/VideoCommon/ShaderCache.h index 8feff52c15..b083927de4 100644 --- a/Source/Core/VideoCommon/ShaderCache.h +++ b/Source/Core/VideoCommon/ShaderCache.h @@ -53,7 +53,7 @@ public: void InitializeShaderCache(); // Changes the shader host config. Shaders should be reloaded afterwards. - void SetHostConfig(const ShaderHostConfig& host_config) { m_host_config = host_config; } + void SetHostConfig(const ShaderHostConfig& host_config) { m_host_config.bits = host_config.bits; } // Reloads/recreates all shaders and pipelines. void Reload(); diff --git a/Source/Core/VideoCommon/ShaderGenCommon.h b/Source/Core/VideoCommon/ShaderGenCommon.h index b4f0f2f179..67ad59d40e 100644 --- a/Source/Core/VideoCommon/ShaderGenCommon.h +++ b/Source/Core/VideoCommon/ShaderGenCommon.h @@ -11,6 +11,7 @@ #include +#include "Common/BitField.h" #include "Common/CommonTypes.h" #include "Common/StringUtil.h" @@ -143,33 +144,29 @@ union ShaderHostConfig { u32 bits; - struct - { - u32 msaa : 1; - u32 ssaa : 1; - u32 stereo : 1; - u32 wireframe : 1; - u32 per_pixel_lighting : 1; - u32 vertex_rounding : 1; - u32 fast_depth_calc : 1; - u32 bounding_box : 1; - u32 backend_dual_source_blend : 1; - u32 backend_geometry_shaders : 1; - u32 backend_early_z : 1; - u32 backend_bbox : 1; - u32 backend_gs_instancing : 1; - u32 backend_clip_control : 1; - u32 backend_ssaa : 1; - u32 backend_atomics : 1; - u32 backend_depth_clamp : 1; - u32 backend_reversed_depth_range : 1; - u32 backend_bitfield : 1; - u32 backend_dynamic_sampler_indexing : 1; - u32 backend_shader_framebuffer_fetch : 1; - u32 backend_logic_op : 1; - u32 backend_palette_conversion : 1; - u32 pad : 9; - }; + BitField<0, 1, bool, u32> msaa; + BitField<1, 1, bool, u32> ssaa; + BitField<2, 1, bool, u32> stereo; + BitField<3, 1, bool, u32> wireframe; + BitField<4, 1, bool, u32> per_pixel_lighting; + BitField<5, 1, bool, u32> vertex_rounding; + BitField<6, 1, bool, u32> fast_depth_calc; + BitField<7, 1, bool, u32> bounding_box; + BitField<8, 1, bool, u32> backend_dual_source_blend; + BitField<9, 1, bool, u32> backend_geometry_shaders; + BitField<10, 1, bool, u32> backend_early_z; + BitField<11, 1, bool, u32> backend_bbox; + BitField<12, 1, bool, u32> backend_gs_instancing; + BitField<13, 1, bool, u32> backend_clip_control; + BitField<14, 1, bool, u32> backend_ssaa; + BitField<15, 1, bool, u32> backend_atomics; + BitField<16, 1, bool, u32> backend_depth_clamp; + BitField<17, 1, bool, u32> backend_reversed_depth_range; + BitField<18, 1, bool, u32> backend_bitfield; + BitField<19, 1, bool, u32> backend_dynamic_sampler_indexing; + BitField<20, 1, bool, u32> backend_shader_framebuffer_fetch; + BitField<21, 1, bool, u32> backend_logic_op; + BitField<22, 1, bool, u32> backend_palette_conversion; static ShaderHostConfig GetCurrent(); };