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 <robdclark@chromium.org>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6189>
/* Lower constant initializers. */
if (var->constant_value &&
var->type == var->constant_value->type) {
/* 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);
var->constant_value =
var->constant_value->clone(ralloc_parent(var), NULL);
lower_constant(var->constant_value);
if (var->constant_initializer &&
var->type == var->constant_initializer->type) {
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);
var->constant_initializer =
var->constant_initializer->clone(ralloc_parent(var), NULL);
lower_constant(var->constant_initializer);
options->LowerPrecisionInt16 = true;
options->LowerPrecisionDerivatives = true;
options->LowerPrecisionTemporaries = true;
options->LowerPrecisionInt16 = true;
options->LowerPrecisionDerivatives = true;
options->LowerPrecisionTemporaries = true;
+ options->LowerPrecisionConstants = true;
GLboolean LowerPrecisionInt16;
GLboolean LowerPrecisionDerivatives;
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.
/**
* This enables 16-bit phis in NIR, 16-bit loop counters, 16-bit indirect
* arrays, etc.
screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_INT16);
options->LowerPrecisionTemporaries =
screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_GLSL_16BIT_TEMPS);
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 =
}
c->MaxUserAssignableUniformLocations =