From: Neil Roberts Date: Thu, 3 Oct 2019 23:59:10 +0000 (-0400) Subject: glsl/standalone: Add an option to lower the precision X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=32cd3bd85014a6fbbabc3a26a16c05e8e98a8485;p=mesa.git glsl/standalone: Add an option to lower the precision Adds a --lower-precision option that just sets the LowerPrecision compiler option. That way it can be used in unit tests to test the precision lowering pass. Reviewed-by: Alyssa Rosenzweig Reviewed-by: Kristian H. Kristensen Part-of: --- diff --git a/src/compiler/glsl/main.cpp b/src/compiler/glsl/main.cpp index 2ff561e011d..c826c279fac 100644 --- a/src/compiler/glsl/main.cpp +++ b/src/compiler/glsl/main.cpp @@ -46,6 +46,7 @@ const struct option compiler_opts[] = { { "dump-builder", no_argument, &options.dump_builder, 1 }, { "link", no_argument, &options.do_link, 1 }, { "just-log", no_argument, &options.just_log, 1 }, + { "lower-precision", no_argument, &options.lower_precision, 1 }, { "version", required_argument, NULL, 'v' }, { NULL, 0, NULL, 0 } }; diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp index 46733d490ec..4b473501622 100644 --- a/src/compiler/glsl/standalone.cpp +++ b/src/compiler/glsl/standalone.cpp @@ -446,6 +446,14 @@ standalone_compile_shader(const struct standalone_options *_options, initialize_context(ctx, options->glsl_version > 130 ? API_OPENGL_CORE : API_OPENGL_COMPAT); } + if (options->lower_precision) { + for (unsigned i = MESA_SHADER_VERTEX; i <= MESA_SHADER_FRAGMENT; i++) { + struct gl_shader_compiler_options *options = + &ctx->Const.ShaderCompilerOptions[i]; + options->LowerPrecision = true; + } + } + struct gl_shader_program *whole_program; whole_program = rzalloc (NULL, struct gl_shader_program); diff --git a/src/compiler/glsl/standalone.h b/src/compiler/glsl/standalone.h index d9e14f798a3..2c2d9238162 100644 --- a/src/compiler/glsl/standalone.h +++ b/src/compiler/glsl/standalone.h @@ -36,6 +36,7 @@ struct standalone_options { int dump_builder; int do_link; int just_log; + int lower_precision; }; struct gl_shader_program;