[Mesa-dev] [PATCH 3/4] glsl: Refactor generate_ARB_draw_buffers_variables to use add_builtin_constant
Kenneth Graunke
kenneth at whitecape.org
Tue Nov 1 00:24:49 PDT 2011
On 10/31/2011 06:07 PM, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/glsl/ir_variable.cpp | 11 ++++-------
> 1 files changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
> index 1ee84d2..bea0b2b 100644
> --- a/src/glsl/ir_variable.cpp
> +++ b/src/glsl/ir_variable.cpp
> @@ -400,7 +400,7 @@ add_builtin_variable(exec_list *instructions, glsl_symbol_table *symtab,
> }
> }
>
> -static void
> +static ir_variable *
> add_builtin_constant(exec_list *instructions, glsl_symbol_table *symtab,
> const char *name, int value)
> {
> @@ -408,6 +408,7 @@ add_builtin_constant(exec_list *instructions, glsl_symbol_table *symtab,
> name, glsl_type::int_type,
> ir_var_auto, -1);
> var->constant_value = new(var) ir_constant(value);
> + return var;
> }
>
> /* Several constants in GLSL ES have different names than normal desktop GLSL.
> @@ -749,16 +750,12 @@ generate_ARB_draw_buffers_variables(exec_list *instructions,
> /* gl_MaxDrawBuffers is available in all shader stages.
> */
> ir_variable *const mdb =
> - add_variable(instructions, state->symbols,
> - "gl_MaxDrawBuffers", glsl_type::int_type, ir_var_auto, -1);
> + add_builtin_constant(instructions, state->symbols, "gl_MaxDrawBuffers",
> + int(state->Const.MaxDrawBuffers));
I like this. You can actually drop the int() cast, though: the fourth
parameter of add_builtin_constant is an int type, so it'll already
convert from uint to int and create the right kind of ir_constant.
Either way, this mini-series is:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
> if (warn)
> mdb->warn_extension = "GL_ARB_draw_buffers";
>
> - mdb->constant_value = new(mdb)
> - ir_constant(int(state->Const.MaxDrawBuffers));
> -
> -
> /* gl_FragData is only available in the fragment shader.
> */
> if (target == fragment_shader) {
More information about the mesa-dev
mailing list