From 0dd0a92b243487e83d8d96532873f319719248e5 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Mon, 2 Aug 2021 11:45:19 -0700 Subject: [PATCH] u_driconf: Use a macro to avoid repeating option names Suggested-by: Emil Velikov Reviewed-by: Charmaine Lee Reviewed-by: Neha Bhende Part-of: --- src/gallium/auxiliary/util/u_driconf.c | 91 ++++++++++++++-------------------- 1 file changed, 36 insertions(+), 55 deletions(-) diff --git a/src/gallium/auxiliary/util/u_driconf.c b/src/gallium/auxiliary/util/u_driconf.c index 8aa5db8..0cd84e9 100644 --- a/src/gallium/auxiliary/util/u_driconf.c +++ b/src/gallium/auxiliary/util/u_driconf.c @@ -27,62 +27,43 @@ void u_driconf_fill_st_options(struct st_config_options *options, const struct driOptionCache *optionCache) { - options->disable_blend_func_extended = - driQueryOptionb(optionCache, "disable_blend_func_extended"); - options->disable_arb_gpu_shader5 = - driQueryOptionb(optionCache, "disable_arb_gpu_shader5"); - options->disable_glsl_line_continuations = - driQueryOptionb(optionCache, "disable_glsl_line_continuations"); - options->force_glsl_extensions_warn = - driQueryOptionb(optionCache, "force_glsl_extensions_warn"); - options->force_glsl_version = - driQueryOptioni(optionCache, "force_glsl_version"); - options->allow_extra_pp_tokens = - driQueryOptionb(optionCache, "allow_extra_pp_tokens"); - options->allow_glsl_extension_directive_midshader = - driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader"); - options->allow_glsl_120_subset_in_110 = - driQueryOptionb(optionCache, "allow_glsl_120_subset_in_110"); - options->allow_glsl_builtin_const_expression = - driQueryOptionb(optionCache, "allow_glsl_builtin_const_expression"); - options->allow_glsl_relaxed_es = - driQueryOptionb(optionCache, "allow_glsl_relaxed_es"); - options->allow_glsl_builtin_variable_redeclaration = - driQueryOptionb(optionCache, "allow_glsl_builtin_variable_redeclaration"); - options->allow_higher_compat_version = - driQueryOptionb(optionCache, "allow_higher_compat_version"); - options->glsl_ignore_write_to_readonly_var = - driQueryOptionb(optionCache, "glsl_ignore_write_to_readonly_var"); - options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init"); - options->force_integer_tex_nearest = - driQueryOptionb(optionCache, "force_integer_tex_nearest"); - options->vs_position_always_invariant = - driQueryOptionb(optionCache, "vs_position_always_invariant"); - options->force_glsl_abs_sqrt = - driQueryOptionb(optionCache, "force_glsl_abs_sqrt"); - options->allow_glsl_cross_stage_interpolation_mismatch = - driQueryOptionb(optionCache, "allow_glsl_cross_stage_interpolation_mismatch"); - options->allow_draw_out_of_order = - driQueryOptionb(optionCache, "allow_draw_out_of_order"); - options->allow_incorrect_primitive_id = - driQueryOptionb(optionCache, "allow_incorrect_primitive_id"); - options->ignore_map_unsynchronized = - driQueryOptionb(optionCache, "ignore_map_unsynchronized"); - options->force_gl_names_reuse = - driQueryOptionb(optionCache, "force_gl_names_reuse"); - options->transcode_etc = - driQueryOptionb(optionCache, "transcode_etc"); - options->transcode_astc = - driQueryOptionb(optionCache, "transcode_astc"); +#define query_option_impl(option, type) \ + options->option = driQueryOption##type(optionCache, #option) +#define query_bool_option(option) query_option_impl(option, b) +#define query_int_option(option) query_option_impl(option, i) +#define query_string_option(option) \ + do { \ + char *option = driQueryOptionstr(optionCache, #option); \ + if (*option) \ + options->option = strdup(option); \ + } while (0) - char *vendor_str = driQueryOptionstr(optionCache, "force_gl_vendor"); - /* not an empty string */ - if (*vendor_str) - options->force_gl_vendor = strdup(vendor_str); - - char *renderer_str = driQueryOptionstr(optionCache, "force_gl_renderer"); - if (*renderer_str) - options->force_gl_renderer = strdup(renderer_str); + query_bool_option(disable_blend_func_extended); + query_bool_option(disable_arb_gpu_shader5); + query_bool_option(disable_glsl_line_continuations); + query_bool_option(force_glsl_extensions_warn); + query_int_option(force_glsl_version); + query_bool_option(allow_extra_pp_tokens); + query_bool_option(allow_glsl_extension_directive_midshader); + query_bool_option(allow_glsl_120_subset_in_110); + query_bool_option(allow_glsl_builtin_const_expression); + query_bool_option(allow_glsl_relaxed_es); + query_bool_option(allow_glsl_builtin_variable_redeclaration); + query_bool_option(allow_higher_compat_version); + query_bool_option(glsl_ignore_write_to_readonly_var); + query_bool_option(glsl_zero_init); + query_bool_option(force_integer_tex_nearest); + query_bool_option(vs_position_always_invariant); + query_bool_option(force_glsl_abs_sqrt); + query_bool_option(allow_glsl_cross_stage_interpolation_mismatch); + query_bool_option(allow_draw_out_of_order); + query_bool_option(allow_incorrect_primitive_id); + query_bool_option(ignore_map_unsynchronized); + query_bool_option(force_gl_names_reuse); + query_bool_option(transcode_etc); + query_bool_option(transcode_astc); + query_string_option(force_gl_vendor); + query_string_option(force_gl_renderer); driComputeOptionsSha1(optionCache, options->config_options_sha1); } -- 2.7.4