diff options
author | Ian Romanick <[email protected]> | 2013-09-25 11:44:41 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2013-10-30 13:49:30 -0700 |
commit | f8c579dc0fc0ffed41a86daecbcfe6c3b9843e61 (patch) | |
tree | 1fc49c33a09dacca38a525ae0515a193797ba23b /src/glsl/ir.cpp | |
parent | 2cb760d9945b30bed027a14c2a9ac20d07d7c5ba (diff) |
glsl: Make mode_string function globally available
I made this a function (instead of a method of ir_variable) because it
made the change set smaller, and I expect that there will be an overload
that takes an ir_var_mode enum. Having both functions used the same way
seemed better.
v2: Add missing case for ir_var_system_value.
v3: Change the ir_var_mode_count case to just break. Move the assertion
and the return outside the switch-statment. In the unlikely event that
var->mode is an invalid value other than ir_var_mode_count, the
assertion will still fire, and in release builds we won't wind up
returning a garbage pointer. Suggested by Paul.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Paul Berry <[email protected]>
Diffstat (limited to 'src/glsl/ir.cpp')
-rw-r--r-- | src/glsl/ir.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 768c4dcc707..1b4973612e0 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1891,3 +1891,46 @@ vertices_per_prim(GLenum prim) return 3; } } + +/** + * Generate a string describing the mode of a variable + */ +const char * +mode_string(const ir_variable *var) +{ + switch (var->mode) { + case ir_var_auto: + return (var->read_only) ? "global constant" : "global variable"; + + case ir_var_uniform: + return "uniform"; + + case ir_var_shader_in: + return "shader input"; + + case ir_var_shader_out: + return "shader output"; + + case ir_var_function_in: + case ir_var_const_in: + return "function input"; + + case ir_var_function_out: + return "function output"; + + case ir_var_function_inout: + return "function inout"; + + case ir_var_system_value: + return "shader input"; + + case ir_var_temporary: + return "compiler temporary"; + + case ir_var_mode_count: + break; + } + + assert(!"Should not get here."); + return "invalid variable"; +} |