mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Replace boost::optional with std::optional where possible
This commit is contained in:
		
							parent
							
								
									87e16c80ac
								
							
						
					
					
						commit
						d37a2270d6
					
				
					 30 changed files with 104 additions and 106 deletions
				
			
		|  | @ -8,10 +8,10 @@ | |||
| #include <cstring> | ||||
| #include <iterator> | ||||
| #include <memory> | ||||
| #include <optional> | ||||
| #include <unordered_set> | ||||
| #include <utility> | ||||
| #include <vector> | ||||
| #include <boost/optional.hpp> | ||||
| #include <boost/range/iterator_range.hpp> | ||||
| #include <glad/glad.h> | ||||
| #include "common/alignment.h" | ||||
|  | @ -881,7 +881,7 @@ constexpr MatchFlags operator|(MatchFlags lhs, MatchFlags rhs) { | |||
| template <MatchFlags find_flags> | ||||
| Surface FindMatch(const SurfaceCache& surface_cache, const SurfaceParams& params, | ||||
|                   ScaleMatch match_scale_type, | ||||
|                   boost::optional<SurfaceInterval> validate_interval = boost::none) { | ||||
|                   std::optional<SurfaceInterval> validate_interval = {}) { | ||||
|     Surface match_surface = nullptr; | ||||
|     bool match_valid = false; | ||||
|     u32 match_scale = 0; | ||||
|  |  | |||
|  | @ -910,11 +910,11 @@ bool exec_shader(); | |||
| )"; | ||||
| } | ||||
| 
 | ||||
| boost::optional<std::string> DecompileProgram(const ProgramCode& program_code, | ||||
|                                               const SwizzleData& swizzle_data, u32 main_offset, | ||||
|                                               const RegGetter& inputreg_getter, | ||||
|                                               const RegGetter& outputreg_getter, bool sanitize_mul, | ||||
|                                               bool is_gs) { | ||||
| std::optional<std::string> DecompileProgram(const ProgramCode& program_code, | ||||
|                                             const SwizzleData& swizzle_data, u32 main_offset, | ||||
|                                             const RegGetter& inputreg_getter, | ||||
|                                             const RegGetter& outputreg_getter, bool sanitize_mul, | ||||
|                                             bool is_gs) { | ||||
| 
 | ||||
|     try { | ||||
|         auto subroutines = ControlFlowAnalyzer(program_code, main_offset).MoveSubroutines(); | ||||
|  | @ -923,7 +923,7 @@ boost::optional<std::string> DecompileProgram(const ProgramCode& program_code, | |||
|         return generator.MoveShaderCode(); | ||||
|     } catch (const DecompileFail& exception) { | ||||
|         LOG_INFO(HW_GPU, "Shader decompilation failed: {}", exception.what()); | ||||
|         return boost::none; | ||||
|         return {}; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,8 +4,8 @@ | |||
| 
 | ||||
| #include <array> | ||||
| #include <functional> | ||||
| #include <optional> | ||||
| #include <string> | ||||
| #include <boost/optional.hpp> | ||||
| #include "common/common_types.h" | ||||
| #include "video_core/shader/shader.h" | ||||
| 
 | ||||
|  | @ -19,11 +19,11 @@ using RegGetter = std::function<std::string(u32)>; | |||
| 
 | ||||
| std::string GetCommonDeclarations(); | ||||
| 
 | ||||
| boost::optional<std::string> DecompileProgram(const ProgramCode& program_code, | ||||
|                                               const SwizzleData& swizzle_data, u32 main_offset, | ||||
|                                               const RegGetter& inputreg_getter, | ||||
|                                               const RegGetter& outputreg_getter, bool sanitize_mul, | ||||
|                                               bool is_gs); | ||||
| std::optional<std::string> DecompileProgram(const ProgramCode& program_code, | ||||
|                                             const SwizzleData& swizzle_data, u32 main_offset, | ||||
|                                             const RegGetter& inputreg_getter, | ||||
|                                             const RegGetter& outputreg_getter, bool sanitize_mul, | ||||
|                                             bool is_gs); | ||||
| 
 | ||||
| } // namespace Decompiler
 | ||||
| } // namespace Shader
 | ||||
|  |  | |||
|  | @ -1634,9 +1634,8 @@ void main() { | |||
|     return out; | ||||
| } | ||||
| 
 | ||||
| boost::optional<std::string> GenerateVertexShader(const Pica::Shader::ShaderSetup& setup, | ||||
|                                                   const PicaVSConfig& config, | ||||
|                                                   bool separable_shader) { | ||||
| std::optional<std::string> GenerateVertexShader(const Pica::Shader::ShaderSetup& setup, | ||||
|                                                 const PicaVSConfig& config, bool separable_shader) { | ||||
|     std::string out = "#version 330 core\n"; | ||||
|     if (separable_shader) { | ||||
|         out += "#extension GL_ARB_separate_shader_objects : enable\n"; | ||||
|  | @ -1664,9 +1663,9 @@ boost::optional<std::string> GenerateVertexShader(const Pica::Shader::ShaderSetu | |||
|         get_output_reg, config.state.sanitize_mul, false); | ||||
| 
 | ||||
|     if (!program_source_opt) | ||||
|         return boost::none; | ||||
|         return {}; | ||||
| 
 | ||||
|     std::string& program_source = program_source_opt.get(); | ||||
|     std::string& program_source = *program_source_opt; | ||||
| 
 | ||||
|     out += R"( | ||||
| #define uniforms vs_uniforms | ||||
|  | @ -1822,16 +1821,16 @@ void main() { | |||
|     return out; | ||||
| } | ||||
| 
 | ||||
| boost::optional<std::string> GenerateGeometryShader(const Pica::Shader::ShaderSetup& setup, | ||||
|                                                     const PicaGSConfig& config, | ||||
|                                                     bool separable_shader) { | ||||
| std::optional<std::string> GenerateGeometryShader(const Pica::Shader::ShaderSetup& setup, | ||||
|                                                   const PicaGSConfig& config, | ||||
|                                                   bool separable_shader) { | ||||
|     std::string out = "#version 330 core\n"; | ||||
|     if (separable_shader) { | ||||
|         out += "#extension GL_ARB_separate_shader_objects : enable\n"; | ||||
|     } | ||||
| 
 | ||||
|     if (config.state.num_inputs % config.state.attributes_per_vertex != 0) | ||||
|         return boost::none; | ||||
|         return {}; | ||||
| 
 | ||||
|     switch (config.state.num_inputs / config.state.attributes_per_vertex) { | ||||
|     case 1: | ||||
|  | @ -1850,7 +1849,7 @@ boost::optional<std::string> GenerateGeometryShader(const Pica::Shader::ShaderSe | |||
|         out += "layout(triangles_adjacency) in;\n"; | ||||
|         break; | ||||
|     default: | ||||
|         return boost::none; | ||||
|         return {}; | ||||
|     } | ||||
|     out += "layout(triangle_strip, max_vertices = 30) out;\n\n"; | ||||
| 
 | ||||
|  | @ -1879,9 +1878,9 @@ boost::optional<std::string> GenerateGeometryShader(const Pica::Shader::ShaderSe | |||
|         get_output_reg, config.state.sanitize_mul, true); | ||||
| 
 | ||||
|     if (!program_source_opt) | ||||
|         return boost::none; | ||||
|         return {}; | ||||
| 
 | ||||
|     std::string& program_source = program_source_opt.get(); | ||||
|     std::string& program_source = *program_source_opt; | ||||
| 
 | ||||
|     out += R"( | ||||
| Vertex output_buffer; | ||||
|  |  | |||
|  | @ -7,9 +7,9 @@ | |||
| #include <array> | ||||
| #include <cstring> | ||||
| #include <functional> | ||||
| #include <optional> | ||||
| #include <string> | ||||
| #include <type_traits> | ||||
| #include <boost/optional.hpp> | ||||
| #include "common/hash.h" | ||||
| #include "video_core/regs.h" | ||||
| #include "video_core/shader/shader.h" | ||||
|  | @ -228,9 +228,8 @@ std::string GenerateTrivialVertexShader(bool separable_shader); | |||
|  * Generates the GLSL vertex shader program source code for the given VS program | ||||
|  * @returns String of the shader source code; boost::none on failure | ||||
|  */ | ||||
| boost::optional<std::string> GenerateVertexShader(const Pica::Shader::ShaderSetup& setup, | ||||
|                                                   const PicaVSConfig& config, | ||||
|                                                   bool separable_shader); | ||||
| std::optional<std::string> GenerateVertexShader(const Pica::Shader::ShaderSetup& setup, | ||||
|                                                 const PicaVSConfig& config, bool separable_shader); | ||||
| 
 | ||||
| /*
 | ||||
|  * Generates the GLSL fixed geometry shader program source code for non-GS PICA pipeline | ||||
|  | @ -243,9 +242,9 @@ std::string GenerateFixedGeometryShader(const PicaFixedGSConfig& config, bool se | |||
|  * configuration | ||||
|  * @returns String of the shader source code; boost::none on failure | ||||
|  */ | ||||
| boost::optional<std::string> GenerateGeometryShader(const Pica::Shader::ShaderSetup& setup, | ||||
|                                                     const PicaGSConfig& config, | ||||
|                                                     bool separable_shader); | ||||
| std::optional<std::string> GenerateGeometryShader(const Pica::Shader::ShaderSetup& setup, | ||||
|                                                   const PicaGSConfig& config, | ||||
|                                                   bool separable_shader); | ||||
| 
 | ||||
| /**
 | ||||
|  * Generates the GLSL fragment shader program source code for the current Pica state | ||||
|  |  | |||
|  | @ -162,8 +162,8 @@ private: | |||
| // program buffer from the previous shader, which is hashed into the config, resulting several
 | ||||
| // different config values from the same shader program.
 | ||||
| template <typename KeyConfigType, | ||||
|           boost::optional<std::string> (*CodeGenerator)(const Pica::Shader::ShaderSetup&, | ||||
|                                                         const KeyConfigType&, bool), | ||||
|           std::optional<std::string> (*CodeGenerator)(const Pica::Shader::ShaderSetup&, | ||||
|                                                       const KeyConfigType&, bool), | ||||
|           GLenum ShaderType> | ||||
| class ShaderDoubleCache { | ||||
| public: | ||||
|  | @ -177,7 +177,7 @@ public: | |||
|                 return 0; | ||||
|             } | ||||
| 
 | ||||
|             std::string& program = program_opt.get(); | ||||
|             std::string& program = *program_opt; | ||||
|             auto [iter, new_shader] = shader_cache.emplace(program, OGLShaderStage{separable}); | ||||
|             OGLShaderStage& cached_shader = iter->second; | ||||
|             if (new_shader) { | ||||
|  |  | |||
|  | @ -754,7 +754,7 @@ void JitShader::Compile_LOOP(Instruction instr) { | |||
|     sub(LOOPCOUNT, 1);           // Increment loop count by 1
 | ||||
|     jnz(l_loop_start);           // Loop if not equal
 | ||||
|     L(*loop_break_label); | ||||
|     loop_break_label = boost::none; | ||||
|     loop_break_label.reset(); | ||||
| 
 | ||||
|     looping = false; | ||||
| } | ||||
|  |  | |||
|  | @ -6,9 +6,9 @@ | |||
| 
 | ||||
| #include <array> | ||||
| #include <cstddef> | ||||
| #include <optional> | ||||
| #include <utility> | ||||
| #include <vector> | ||||
| #include <boost/optional.hpp> | ||||
| #include <nihstro/shader_bytecode.h> | ||||
| #include <xbyak.h> | ||||
| #include "common/bit_set.h" | ||||
|  | @ -123,7 +123,7 @@ private: | |||
| 
 | ||||
|     /// Label pointing to the end of the current LOOP block. Used by the BREAKC instruction to break
 | ||||
|     /// out of the loop.
 | ||||
|     boost::optional<Xbyak::Label> loop_break_label; | ||||
|     std::optional<Xbyak::Label> loop_break_label; | ||||
| 
 | ||||
|     /// Offsets in code where a return needs to be inserted
 | ||||
|     std::vector<unsigned> return_offsets; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue