nir/lower_io: Add option to implement mediump as 32-bit.
For drivers that don't lower mediump shader inputs / outputs to 16-bit, it's better to ignore the mediump flag completely, letting mediump inputs / outputs work like normal 32-bit IO. Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29435>
This commit is contained in:
@@ -3657,6 +3657,13 @@ typedef enum {
|
||||
|
||||
nir_io_16bit_input_output_support = BITFIELD_BIT(2),
|
||||
|
||||
/**
|
||||
* Implement mediump inputs and outputs as normal 32-bit IO.
|
||||
* Causes the mediump flag to be not set for IO semantics, essentially
|
||||
* destroying any mediump-related IO information in the shader.
|
||||
*/
|
||||
nir_io_mediump_is_32bit = BITFIELD_BIT(3),
|
||||
|
||||
/* Options affecting the GLSL compiler are below. */
|
||||
|
||||
/**
|
||||
|
||||
@@ -272,6 +272,16 @@ get_io_offset(nir_builder *b, nir_deref_instr *deref,
|
||||
return offset;
|
||||
}
|
||||
|
||||
static bool
|
||||
is_medium_precision(const nir_shader *shader, const nir_variable *var)
|
||||
{
|
||||
if (shader->options->io_options & nir_io_mediump_is_32bit)
|
||||
return false;
|
||||
|
||||
return var->data.precision == GLSL_PRECISION_MEDIUM ||
|
||||
var->data.precision == GLSL_PRECISION_LOW;
|
||||
}
|
||||
|
||||
static nir_def *
|
||||
emit_load(struct lower_io_state *state,
|
||||
nir_def *array_index, nir_variable *var, nir_def *offset,
|
||||
@@ -351,9 +361,7 @@ emit_load(struct lower_io_state *state,
|
||||
semantics.location = var->data.location;
|
||||
semantics.num_slots = get_number_of_slots(state, var);
|
||||
semantics.fb_fetch_output = var->data.fb_fetch_output;
|
||||
semantics.medium_precision =
|
||||
var->data.precision == GLSL_PRECISION_MEDIUM ||
|
||||
var->data.precision == GLSL_PRECISION_LOW;
|
||||
semantics.medium_precision = is_medium_precision(b->shader, var);
|
||||
semantics.high_dvec2 = high_dvec2;
|
||||
semantics.per_primitive = var->data.per_primitive;
|
||||
/* "per_vertex" is misnamed. It means "explicit interpolation with
|
||||
@@ -503,9 +511,7 @@ emit_store(struct lower_io_state *state, nir_def *data,
|
||||
semantics.num_slots = get_number_of_slots(state, var);
|
||||
semantics.dual_source_blend_index = var->data.index;
|
||||
semantics.gs_streams = gs_streams;
|
||||
semantics.medium_precision =
|
||||
var->data.precision == GLSL_PRECISION_MEDIUM ||
|
||||
var->data.precision == GLSL_PRECISION_LOW;
|
||||
semantics.medium_precision = is_medium_precision(b->shader, var);
|
||||
semantics.per_view = var->data.per_view;
|
||||
semantics.invariant = var->data.invariant;
|
||||
|
||||
@@ -631,9 +637,7 @@ lower_interpolate_at(nir_intrinsic_instr *intrin, struct lower_io_state *state,
|
||||
nir_io_semantics semantics = { 0 };
|
||||
semantics.location = var->data.location;
|
||||
semantics.num_slots = get_number_of_slots(state, var);
|
||||
semantics.medium_precision =
|
||||
var->data.precision == GLSL_PRECISION_MEDIUM ||
|
||||
var->data.precision == GLSL_PRECISION_LOW;
|
||||
semantics.medium_precision = is_medium_precision(b->shader, var);
|
||||
|
||||
nir_def *load =
|
||||
nir_load_interpolated_input(&state->builder,
|
||||
|
||||
Reference in New Issue
Block a user