diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 019a3bb1c7a..391cfbd4f2f 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -4950,6 +4950,14 @@ setup_input(struct ir3_context *ctx, nir_intrinsic_instr *intr) compmask = clip_cull_mask >> 4; } + if (ctx->so->type == MESA_SHADER_FRAGMENT && + (BITFIELD64_BIT(slot) & VARYING_BITS_COLOR) && + intr->intrinsic == nir_intrinsic_load_interpolated_input) { + nir_intrinsic_instr *baryc = nir_def_as_intrinsic(intr->src[0].ssa); + if (nir_intrinsic_interp_mode(baryc) == INTERP_MODE_NONE) + so->inputs[n].rasterflat = true; + } + /* for a4xx+ rasterflat */ if (so->inputs[n].rasterflat && ctx->so->key.rasterflat) coord = NULL; @@ -5177,9 +5185,14 @@ setup_output(struct ir3_context *ctx, nir_intrinsic_instr *intr) so->writes_stencilref = true; break; default: - slot += io.dual_source_blend_index; /* For dual-src blend */ - if (io.dual_source_blend_index > 0) + if (io.dual_source_blend_index > 0 || + /* Implement the "dual_color_blend_by_location" workaround for + * Unigine Heaven and Unigine Valley, by forcing on dual-source + * blending when there are two outputs. + */ + (slot == FRAG_RESULT_DATA1 && so->key.force_dual_color_blend)) so->dual_src_blend = true; + slot += io.dual_source_blend_index; /* For dual-src blend */ if (slot >= FRAG_RESULT_DATA0) break; ir3_context_error(ctx, "unknown FS output name: %s\n", @@ -5297,25 +5310,6 @@ emit_instructions(struct ir3_context *ctx) nir_function_impl *fxn = nir_shader_get_entrypoint(ctx->s); - /* some varying setup which can't be done in setup_input(): */ - if (ctx->so->type == MESA_SHADER_FRAGMENT) { - nir_foreach_shader_in_variable (var, ctx->s) { - /* set rasterflat flag for front/back color */ - if (var->data.interpolation == INTERP_MODE_NONE) { - switch (var->data.location) { - case VARYING_SLOT_COL0: - case VARYING_SLOT_COL1: - case VARYING_SLOT_BFC0: - case VARYING_SLOT_BFC1: - ctx->so->inputs[var->data.driver_location].rasterflat = true; - break; - default: - break; - } - } - } - } - if (uses_load_input(ctx->so)) { ctx->so->inputs_count = ctx->s->num_inputs; compile_assert(ctx, ctx->so->inputs_count < ARRAY_SIZE(ctx->so->inputs)); diff --git a/src/freedreno/ir3/ir3_context.c b/src/freedreno/ir3/ir3_context.c index ba3744a41e4..7ca03f5a7e8 100644 --- a/src/freedreno/ir3/ir3_context.c +++ b/src/freedreno/ir3/ir3_context.c @@ -191,21 +191,6 @@ ir3_context_init(struct ir3_compiler *compiler, struct ir3_shader *shader, ir3_ibo_mapping_init(&so->image_mapping, ctx->s->info.num_textures); - /* Implement the "dual_color_blend_by_location" workaround for Unigine Heaven - * and Unigine Valley, by remapping FRAG_RESULT_DATA1 to be the 2nd color - * channel of FRAG_RESULT_DATA0. - */ - if ((so->type == MESA_SHADER_FRAGMENT) && so->key.force_dual_color_blend) { - nir_variable *var = nir_find_variable_with_location( - ctx->s, nir_var_shader_out, FRAG_RESULT_DATA1); - if (var) { - var->data.location = FRAG_RESULT_DATA0; - var->data.index = 1; - nir_shader_gather_info(ctx->s, nir_shader_get_entrypoint(ctx->s)); - so->dual_src_blend = true; - } - } - return ctx; } diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index db49fc590f2..a1ab7835b02 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -905,14 +905,8 @@ ir3_nir_post_finalize(struct ir3_shader *shader) * you'd end up with an incorrect f2f16(i2i32(load_input())) instead of * load_input). */ - uint64_t mediump_varyings = 0; - nir_foreach_shader_in_variable(var, s) { - if ((var->data.precision == GLSL_PRECISION_MEDIUM || - var->data.precision == GLSL_PRECISION_LOW) && - var->data.interpolation != INTERP_MODE_FLAT) { - mediump_varyings |= BITFIELD64_BIT(var->data.location); - } - } + uint64_t mediump_varyings = s->info.linear_varyings | + s->info.perspective_varyings; if (mediump_varyings) { NIR_PASS(_, s, nir_lower_mediump_io, nir_var_shader_in,