Commit 0a763c0c authored by Rob Clark's avatar Rob Clark 💬 Committed by Marge Bot

glsl/lower_precision: split out const lowering

Some hw can narrow 32b const/uniform to 16b on load.. and in particular
lowering constants to 16b would break const->uniform lowering.  Allow
them to lower temps to 16b, while skipping consts.

Initially it is set to the same value as LowerPrecisionTemporaries, to
preserve the current behavior.
Signed-off-by: Rob Clark's avatarRob Clark <robdclark@chromium.org>
Reviewed-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: default avatarMarek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Part-of: <!6189>
parent 4f060549
......@@ -1028,6 +1028,8 @@ lower_variables_visitor::visit(ir_variable *var)
/* Lower constant initializers. */
if (var->constant_value &&
var->type == var->constant_value->type) {
if (!options->LowerPrecisionConstants)
return visit_continue;
var->constant_value =
var->constant_value->clone(ralloc_parent(var), NULL);
lower_constant(var->constant_value);
......@@ -1035,6 +1037,8 @@ lower_variables_visitor::visit(ir_variable *var)
if (var->constant_initializer &&
var->type == var->constant_initializer->type) {
if (!options->LowerPrecisionConstants)
return visit_continue;
var->constant_initializer =
var->constant_initializer->clone(ralloc_parent(var), NULL);
lower_constant(var->constant_initializer);
......
......@@ -442,6 +442,7 @@ standalone_compile_shader(const struct standalone_options *_options,
options->LowerPrecisionInt16 = true;
options->LowerPrecisionDerivatives = true;
options->LowerPrecisionTemporaries = true;
options->LowerPrecisionConstants = true;
}
}
......
......@@ -3210,6 +3210,13 @@ struct gl_shader_compiler_options
GLboolean LowerPrecisionInt16;
GLboolean LowerPrecisionDerivatives;
/**
* This enables lowering of 16b constants. Some drivers may not
* to lower constants to 16b (ie. if the hw can do automatic
* narrowing on constant load)
*/
GLboolean LowerPrecisionConstants;
/**
* This enables 16-bit phis in NIR, 16-bit loop counters, 16-bit indirect
* arrays, etc.
......
......@@ -348,6 +348,7 @@ void st_init_limits(struct pipe_screen *screen,
screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_INT16);
options->LowerPrecisionTemporaries =
screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_GLSL_16BIT_TEMPS);
options->LowerPrecisionConstants = options->LowerPrecisionTemporaries;
}
c->MaxUserAssignableUniformLocations =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment