diff options
| author | 2015-10-06 18:21:28 -0400 | |
|---|---|---|
| committer | 2015-10-21 21:53:17 -0400 | |
| commit | 4b5141954ebb2416c9de1996f155641cea46f60a (patch) | |
| tree | 05cc284480f26b4b6dc9ce666f1f67927d3c2a53 /src | |
| parent | gl_shader_util: Cleanup header file + add docstring. (diff) | |
| download | yuzu-4b5141954ebb2416c9de1996f155641cea46f60a.tar.gz yuzu-4b5141954ebb2416c9de1996f155641cea46f60a.tar.xz yuzu-4b5141954ebb2416c9de1996f155641cea46f60a.zip | |
gl_shader_gen: Add additional function documentation.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.h | 10 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 4854c347e..5093710d4 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; | |||
| 11 | 11 | ||
| 12 | namespace GLShader { | 12 | namespace GLShader { |
| 13 | 13 | ||
| 14 | /// Detects if a TEV stage is configured to be skipped (to avoid generating unnecessary code) | ||
| 14 | static bool IsPassThroughTevStage(const TevStageConfig& stage) { | 15 | static bool IsPassThroughTevStage(const TevStageConfig& stage) { |
| 15 | return (stage.color_op == TevStageConfig::Operation::Replace && | 16 | return (stage.color_op == TevStageConfig::Operation::Replace && |
| 16 | stage.alpha_op == TevStageConfig::Operation::Replace && | 17 | stage.alpha_op == TevStageConfig::Operation::Replace && |
| @@ -22,6 +23,7 @@ static bool IsPassThroughTevStage(const TevStageConfig& stage) { | |||
| 22 | stage.GetAlphaMultiplier() == 1); | 23 | stage.GetAlphaMultiplier() == 1); |
| 23 | } | 24 | } |
| 24 | 25 | ||
| 26 | /// Writes the specified TEV stage source component(s) | ||
| 25 | static void AppendSource(std::string& out, TevStageConfig::Source source, | 27 | static void AppendSource(std::string& out, TevStageConfig::Source source, |
| 26 | const std::string& index_name) { | 28 | const std::string& index_name) { |
| 27 | using Source = TevStageConfig::Source; | 29 | using Source = TevStageConfig::Source; |
| @@ -62,6 +64,7 @@ static void AppendSource(std::string& out, TevStageConfig::Source source, | |||
| 62 | } | 64 | } |
| 63 | } | 65 | } |
| 64 | 66 | ||
| 67 | /// Writes the color components to use for the specified TEV stage color modifier | ||
| 65 | static void AppendColorModifier(std::string& out, TevStageConfig::ColorModifier modifier, | 68 | static void AppendColorModifier(std::string& out, TevStageConfig::ColorModifier modifier, |
| 66 | TevStageConfig::Source source, const std::string& index_name) { | 69 | TevStageConfig::Source source, const std::string& index_name) { |
| 67 | using ColorModifier = TevStageConfig::ColorModifier; | 70 | using ColorModifier = TevStageConfig::ColorModifier; |
| @@ -118,6 +121,7 @@ static void AppendColorModifier(std::string& out, TevStageConfig::ColorModifier | |||
| 118 | } | 121 | } |
| 119 | } | 122 | } |
| 120 | 123 | ||
| 124 | /// Writes the alpha component to use for the specified TEV stage alpha modifier | ||
| 121 | static void AppendAlphaModifier(std::string& out, TevStageConfig::AlphaModifier modifier, | 125 | static void AppendAlphaModifier(std::string& out, TevStageConfig::AlphaModifier modifier, |
| 122 | TevStageConfig::Source source, const std::string& index_name) { | 126 | TevStageConfig::Source source, const std::string& index_name) { |
| 123 | using AlphaModifier = TevStageConfig::AlphaModifier; | 127 | using AlphaModifier = TevStageConfig::AlphaModifier; |
| @@ -165,6 +169,7 @@ static void AppendAlphaModifier(std::string& out, TevStageConfig::AlphaModifier | |||
| 165 | } | 169 | } |
| 166 | } | 170 | } |
| 167 | 171 | ||
| 172 | /// Writes the combiner function for the color components for the specified TEV stage operation | ||
| 168 | static void AppendColorCombiner(std::string& out, TevStageConfig::Operation operation, | 173 | static void AppendColorCombiner(std::string& out, TevStageConfig::Operation operation, |
| 169 | const std::string& variable_name) { | 174 | const std::string& variable_name) { |
| 170 | using Operation = TevStageConfig::Operation; | 175 | using Operation = TevStageConfig::Operation; |
| @@ -201,6 +206,7 @@ static void AppendColorCombiner(std::string& out, TevStageConfig::Operation oper | |||
| 201 | } | 206 | } |
| 202 | } | 207 | } |
| 203 | 208 | ||
| 209 | /// Writes the combiner function for the alpha component for the specified TEV stage operation | ||
| 204 | static void AppendAlphaCombiner(std::string& out, TevStageConfig::Operation operation, | 210 | static void AppendAlphaCombiner(std::string& out, TevStageConfig::Operation operation, |
| 205 | const std::string& variable_name) { | 211 | const std::string& variable_name) { |
| 206 | using Operation = TevStageConfig::Operation; | 212 | using Operation = TevStageConfig::Operation; |
| @@ -236,6 +242,7 @@ static void AppendAlphaCombiner(std::string& out, TevStageConfig::Operation oper | |||
| 236 | } | 242 | } |
| 237 | } | 243 | } |
| 238 | 244 | ||
| 245 | /// Writes the if-statement condition used to evaluate alpha testing | ||
| 239 | static void AppendAlphaTestCondition(std::string& out, Regs::CompareFunc func) { | 246 | static void AppendAlphaTestCondition(std::string& out, Regs::CompareFunc func) { |
| 240 | using CompareFunc = Regs::CompareFunc; | 247 | using CompareFunc = Regs::CompareFunc; |
| 241 | switch (func) { | 248 | switch (func) { |
| @@ -270,6 +277,7 @@ static void AppendAlphaTestCondition(std::string& out, Regs::CompareFunc func) { | |||
| 270 | } | 277 | } |
| 271 | } | 278 | } |
| 272 | 279 | ||
| 280 | /// Writes the code to emulate the specified TEV stage | ||
| 273 | static void WriteTevStage(std::string& out, const ShaderCacheKey& config, unsigned index) { | 281 | static void WriteTevStage(std::string& out, const ShaderCacheKey& config, unsigned index) { |
| 274 | auto& stage = config.tev_stages[index]; | 282 | auto& stage = config.tev_stages[index]; |
| 275 | if (!IsPassThroughTevStage(stage)) { | 283 | if (!IsPassThroughTevStage(stage)) { |
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h index 7fd18de6d..c8295e9e0 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 @@ | |||
| 10 | 10 | ||
| 11 | namespace GLShader { | 11 | namespace GLShader { |
| 12 | 12 | ||
| 13 | /** | ||
| 14 | * Generates the GLSL vertex shader program source code for the current Pica state | ||
| 15 | * @returns String of the shader source code | ||
| 16 | */ | ||
| 13 | std::string GenerateVertexShader(); | 17 | std::string GenerateVertexShader(); |
| 14 | 18 | ||
| 19 | /** | ||
| 20 | * Generates the GLSL fragment shader program source code for the current Pica state | ||
| 21 | * @param config ShaderCacheKey object generated for the current Pica state, used for the shader | ||
| 22 | * configuration (NOTE: Use state in this struct only, not the Pica registers!) | ||
| 23 | * @returns String of the shader source code | ||
| 24 | */ | ||
| 15 | std::string GenerateFragmentShader(const ShaderCacheKey& config); | 25 | std::string GenerateFragmentShader(const ShaderCacheKey& config); |
| 16 | 26 | ||
| 17 | } // namespace GLShader | 27 | } // namespace GLShader |