summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2015-10-06 18:21:28 -0400
committerGravatar bunnei2015-10-21 21:53:17 -0400
commit4b5141954ebb2416c9de1996f155641cea46f60a (patch)
tree05cc284480f26b4b6dc9ce666f1f67927d3c2a53 /src
parentgl_shader_util: Cleanup header file + add docstring. (diff)
downloadyuzu-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.cpp8
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.h10
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
12namespace GLShader { 12namespace GLShader {
13 13
14/// Detects if a TEV stage is configured to be skipped (to avoid generating unnecessary code)
14static bool IsPassThroughTevStage(const TevStageConfig& stage) { 15static 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)
25static void AppendSource(std::string& out, TevStageConfig::Source source, 27static 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
65static void AppendColorModifier(std::string& out, TevStageConfig::ColorModifier modifier, 68static 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
121static void AppendAlphaModifier(std::string& out, TevStageConfig::AlphaModifier modifier, 125static 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
168static void AppendColorCombiner(std::string& out, TevStageConfig::Operation operation, 173static 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
204static void AppendAlphaCombiner(std::string& out, TevStageConfig::Operation operation, 210static 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
239static void AppendAlphaTestCondition(std::string& out, Regs::CompareFunc func) { 246static 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
273static void WriteTevStage(std::string& out, const ShaderCacheKey& config, unsigned index) { 281static 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
11namespace GLShader { 11namespace 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 */
13std::string GenerateVertexShader(); 17std::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 */
15std::string GenerateFragmentShader(const ShaderCacheKey& config); 25std::string GenerateFragmentShader(const ShaderCacheKey& config);
16 26
17} // namespace GLShader 27} // namespace GLShader