[Mesa-dev] [PATCH] gallivm: Make it possible to disable some optimization shortcuts in release builds

Roland Scheidegger sroland at vmware.com
Wed Oct 3 20:47:26 UTC 2018


Is it worth it splitting out to another var?
We actually have code branches internally where we just define the 
gallivm_debug var always, and some of the debug flags outside the #ifdef 
debug (we'll actually need more than just these 3 accessible outside 
debug builds).
If you think this is cleaner though I suppose we can deal with it...

Roland



On 10/03/2018 09:52 AM, Gert Wollny wrote:
> From: Gert Wollny <gert.wollny at collabora.com>
> 
> For testing it is of interetest that all tests of dEQP pass, e.g. to test
> virglrenderer on a host only providing software rendering like in a CI.
> Hence make it possible to disable certain optimizations that make tests fail.
> 
> While we are there also add some documentation to the flags to make it clear
> that this is opt-out.
> 
> Setting the environment variable "GALLIVM_PERF=disable_all" can be used to make
> the follwing tests pass in release mode:
> 
>    dEQP-GLES2.functional.texture.mipmap.2d.affine.*_linear_*
>    dEQP-GLES2.functional.texture.mipmap.cube.generate.*
>    dEQP-GLES2.functional.texture.vertex.2d.filtering.*_mipmap_linear_*
>    dEQP-GLES2.functional.texture.vertex.2d.wrap.*
> 
> Related:
>    https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.freedesktop.org%2Fshow_bug.cgi%3Fid%3D94957&data=02%7C01%7Csroland%40vmware.com%7Cd8a63cda397e40a6d42808d6290556e7%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636741500244575630&sdata=UU5W053FLBScYWpQtw9yANGRDCcKYQdS4eRyl7k9u9k%3D&reserved=0
> 
> Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
> ---
>   src/gallium/auxiliary/gallivm/lp_bld_debug.h      | 13 ++++++++-----
>   src/gallium/auxiliary/gallivm/lp_bld_init.c       | 15 ++++++++++++---
>   src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c |  6 +++---
>   src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c   |  6 +++---
>   4 files changed, 26 insertions(+), 14 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.h b/src/gallium/auxiliary/gallivm/lp_bld_debug.h
> index f96a1afa7a..ce09d789cb 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.h
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.h
> @@ -41,18 +41,21 @@
>   #define GALLIVM_DEBUG_ASM           (1 << 2)
>   #define GALLIVM_DEBUG_NO_OPT        (1 << 3)
>   #define GALLIVM_DEBUG_PERF          (1 << 4)
> -#define GALLIVM_DEBUG_NO_BRILINEAR  (1 << 5)
> -#define GALLIVM_DEBUG_NO_RHO_APPROX (1 << 6)
> -#define GALLIVM_DEBUG_NO_QUAD_LOD   (1 << 7)
> -#define GALLIVM_DEBUG_GC            (1 << 8)
> -#define GALLIVM_DEBUG_DUMP_BC       (1 << 9)
> +#define GALLIVM_DEBUG_GC            (1 << 5)
> +#define GALLIVM_DEBUG_DUMP_BC       (1 << 6)
>   
>   
> +#define GALLIVM_PERF_NO_BRILINEAR  (1 << 0)
> +#define GALLIVM_PERF_NO_RHO_APPROX (1 << 1)
> +#define GALLIVM_PERF_NO_QUAD_LOD   (1 << 2)
> +
>   #ifdef __cplusplus
>   extern "C" {
>   #endif
>   
>   
> +extern unsigned gallivm_perf;
> +
>   #ifdef DEBUG
>   extern unsigned gallivm_debug;
>   #else
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c
> index 1f0a01cde6..c8b2a7fcc9 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
> @@ -59,6 +59,16 @@ static const bool use_mcjit = USE_MCJIT;
>   static bool use_mcjit = FALSE;
>   #endif
>   
> +unsigned gallivm_perf = 0;
> +
> +static const struct debug_named_value lp_bld_perf_flags[] = {
> +   { "no_brilinear", GALLIVM_PERF_NO_BRILINEAR, "disable brilinear optimization" },
> +   { "no_rho_approx", GALLIVM_PERF_NO_RHO_APPROX, "disable rho_approx optimization" },
> +   { "no_quad_lod", GALLIVM_PERF_NO_QUAD_LOD, "disable quad_lod optimization" },
> +   { "disable_all", GALLIVM_PERF_NO_BRILINEAR | GALLIVM_PERF_NO_RHO_APPROX |
> +     GALLIVM_PERF_NO_QUAD_LOD, "disable all optimizations" },
> +   DEBUG_NAMED_VALUE_END
> +};
>   
>   #ifdef DEBUG
>   unsigned gallivm_debug = 0;
> @@ -69,9 +79,6 @@ static const struct debug_named_value lp_bld_debug_flags[] = {
>      { "asm",    GALLIVM_DEBUG_ASM, NULL },
>      { "nopt",   GALLIVM_DEBUG_NO_OPT, NULL },
>      { "perf",   GALLIVM_DEBUG_PERF, NULL },
> -   { "no_brilinear", GALLIVM_DEBUG_NO_BRILINEAR, NULL },
> -   { "no_rho_approx", GALLIVM_DEBUG_NO_RHO_APPROX, NULL },
> -   { "no_quad_lod", GALLIVM_DEBUG_NO_QUAD_LOD, NULL },
>      { "gc",     GALLIVM_DEBUG_GC, NULL },
>      { "dumpbc", GALLIVM_DEBUG_DUMP_BC, NULL },
>      DEBUG_NAMED_VALUE_END
> @@ -420,6 +427,8 @@ lp_build_init(void)
>      gallivm_debug = debug_get_option_gallivm_debug();
>   #endif
>   
> +   gallivm_perf = debug_get_flags_option("GALLIVM_PERF", lp_bld_perf_flags, 0 );
> +
>      lp_set_target_options();
>   
>      util_cpu_detect();
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
> index 8f760f59fe..018cca8f9d 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
> @@ -2825,13 +2825,13 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm,
>      bld.format_desc = util_format_description(static_texture_state->format);
>      bld.dims = dims;
>   
> -   if (gallivm_debug & GALLIVM_DEBUG_NO_QUAD_LOD || op_is_lodq) {
> +   if (gallivm_perf & GALLIVM_PERF_NO_QUAD_LOD || op_is_lodq) {
>         bld.no_quad_lod = TRUE;
>      }
> -   if (gallivm_debug & GALLIVM_DEBUG_NO_RHO_APPROX || op_is_lodq) {
> +   if (gallivm_perf & GALLIVM_PERF_NO_RHO_APPROX || op_is_lodq) {
>         bld.no_rho_approx = TRUE;
>      }
> -   if (gallivm_debug & GALLIVM_DEBUG_NO_BRILINEAR || op_is_lodq) {
> +   if (gallivm_perf & GALLIVM_PERF_NO_BRILINEAR || op_is_lodq) {
>         bld.no_brilinear = TRUE;
>      }
>   
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> index 79ece639e3..5fecad4ea6 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> @@ -2037,7 +2037,7 @@ lp_build_lod_property(
>         lod_property = LP_SAMPLER_LOD_SCALAR;
>      }
>      else if (bld_base->info->processor == PIPE_SHADER_FRAGMENT) {
> -      if (gallivm_debug & GALLIVM_DEBUG_NO_QUAD_LOD) {
> +      if (gallivm_perf & GALLIVM_PERF_NO_QUAD_LOD) {
>            lod_property = LP_SAMPLER_LOD_PER_ELEMENT;
>         }
>         else {
> @@ -2225,7 +2225,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
>          * cases exist in practice.
>          */
>         if (bld->bld_base.info->processor == PIPE_SHADER_FRAGMENT) {
> -         if (gallivm_debug & GALLIVM_DEBUG_NO_QUAD_LOD) {
> +         if (gallivm_perf & GALLIVM_PERF_NO_QUAD_LOD) {
>               lod_property = LP_SAMPLER_LOD_PER_ELEMENT;
>            }
>            else {
> @@ -2394,7 +2394,7 @@ emit_sample(struct lp_build_tgsi_soa_context *bld,
>          * cases exist in practice.
>          */
>         if (bld->bld_base.info->processor == PIPE_SHADER_FRAGMENT) {
> -         if (gallivm_debug & GALLIVM_DEBUG_NO_QUAD_LOD) {
> +         if (gallivm_perf & GALLIVM_PERF_NO_QUAD_LOD) {
>               lod_property = LP_SAMPLER_LOD_PER_ELEMENT;
>            }
>            else {
> 



More information about the mesa-dev mailing list