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 <alyssa.rosenzweig@collabora.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3885>
This commit is contained in:
Neil Roberts 2019-10-03 19:59:10 -04:00 committed by Marge Bot
parent b83f4b9fa2
commit 32cd3bd850
3 changed files with 10 additions and 0 deletions

View File

@ -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 }
};

View File

@ -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);

View File

@ -36,6 +36,7 @@ struct standalone_options {
int dump_builder;
int do_link;
int just_log;
int lower_precision;
};
struct gl_shader_program;