VERY experimental Nintendo Switch 2 emulator
C++
gl_shader_gen: Add additional function documentation.
bunnei06d9c2795cef
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cppindex 4854c347ea..5093710d40 100644--- a/src/video_core/renderer_opengl/gl_shader_gen.cpp+++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp@@ -11,6 +11,7 @@ using TevStageConfig = Regs::TevStageConfig;namespace GLShader {+/// Detects if a TEV stage is configured to be skipped (to avoid generating unnecessary code)static bool IsPassThroughTevStage(const TevStageConfig& stage) {return (stage.color_op == TevStageConfig::Operation::Replace &&stage.alpha_op == TevStageConfig::Operation::Replace &&@@ -22,6 +23,7 @@ static bool IsPassThroughTevStage(const TevStageConfig& stage) {stage.GetAlphaMultiplier() == 1);}+/// Writes the specified TEV stage source component(s)static void AppendSource(std::string& out, TevStageConfig::Source source,const std::string& index_name) {using Source = TevStageConfig::Source;@@ -62,6 +64,7 @@ static void AppendSource(std::string& out, TevStageConfig::Source source,}}+/// Writes the color components to use for the specified TEV stage color modifierstatic void AppendColorModifier(std::string& out, TevStageConfig::ColorModifier modifier,TevStageConfig::Source source, const std::string& index_name) {using ColorModifier = TevStageConfig::ColorModifier;@@ -118,6 +121,7 @@ static void AppendColorModifier(std::string& out, TevStageConfig::ColorModifier}}+/// Writes the alpha component to use for the specified TEV stage alpha modifierstatic void AppendAlphaModifier(std::string& out, TevStageConfig::AlphaModifier modifier,TevStageConfig::Source source, const std::string& index_name) {using AlphaModifier = TevStageConfig::AlphaModifier;@@ -165,6 +169,7 @@ static void AppendAlphaModifier(std::string& out, TevStageConfig::AlphaModifier}}+/// Writes the combiner function for the color components for the specified TEV stage operationstatic void AppendColorCombiner(std::string& out, TevStageConfig::Operation operation,const std::string& variable_name) {using Operation = TevStageConfig::Operation;@@ -201,6 +206,7 @@ static void AppendColorCombiner(std::string& out, TevStageConfig::Operation oper}}+/// Writes the combiner function for the alpha component for the specified TEV stage operationstatic void AppendAlphaCombiner(std::string& out, TevStageConfig::Operation operation,const std::string& variable_name) {using Operation = TevStageConfig::Operation;@@ -236,6 +242,7 @@ static void AppendAlphaCombiner(std::string& out, TevStageConfig::Operation oper}}+/// Writes the if-statement condition used to evaluate alpha testingstatic void AppendAlphaTestCondition(std::string& out, Regs::CompareFunc func) {using CompareFunc = Regs::CompareFunc;switch (func) {@@ -270,6 +277,7 @@ static void AppendAlphaTestCondition(std::string& out, Regs::CompareFunc func) {}}+/// Writes the code to emulate the specified TEV stagestatic void WriteTevStage(std::string& out, const ShaderCacheKey& config, unsigned index) {auto& stage = config.tev_stages[index];if (!IsPassThroughTevStage(stage)) {diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.hindex 7fd18de6d1..c8295e9e0f 100644--- a/src/video_core/renderer_opengl/gl_shader_gen.h+++ b/src/video_core/renderer_opengl/gl_shader_gen.h@@ -10,8 +10,18 @@namespace GLShader {+/**+ * Generates the GLSL vertex shader program source code for the current Pica state+ * @returns String of the shader source code+ */std::string GenerateVertexShader();+/**+ * Generates the GLSL fragment shader program source code for the current Pica state+ * @param config ShaderCacheKey object generated for the current Pica state, used for the shader+ * configuration (NOTE: Use state in this struct only, not the Pica registers!)+ * @returns String of the shader source code+ */std::string GenerateFragmentShader(const ShaderCacheKey& config);} // namespace GLShader