freedreno/ir3: convert to "new style" frag inputs
authorRob Clark <robdclark@gmail.com>
Sat, 23 Mar 2019 15:38:37 +0000 (11:38 -0400)
committerRob Clark <robdclark@gmail.com>
Sat, 30 Mar 2019 16:56:01 +0000 (12:56 -0400)
Add support for load_barycentric_pixel, load_interpolated_input, and
friends.  For now, this retains support for old-style inputs, which can
probably be dropped with some ttn work.

Prep work for sample-shading support.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/freedreno/ir3/ir3_compiler_nir.c
src/freedreno/ir3/ir3_nir.c

index ec741ae92d9ae778cbcc20239d034d4bb7cf7808..4171324ccdb38f46c26040be99b861345e91392c 100644 (file)
@@ -1172,6 +1172,34 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr)
        case nir_intrinsic_load_ubo:
                emit_intrinsic_load_ubo(ctx, intr, dst);
                break;
+       case nir_intrinsic_load_barycentric_centroid:
+       case nir_intrinsic_load_barycentric_pixel:
+               ir3_split_dest(b, dst, ctx->frag_vcoord, 0, 2);
+               break;
+       case nir_intrinsic_load_interpolated_input:
+               idx = nir_intrinsic_base(intr);
+               comp = nir_intrinsic_component(intr);
+               src = ir3_get_src(ctx, &intr->src[0]);
+               const_offset = nir_src_as_const_value(intr->src[1]);
+               if (const_offset) {
+                       struct ir3_instruction *coord = ir3_create_collect(ctx, src, 2);
+                       idx += const_offset->u32[0];
+                       for (int i = 0; i < intr->num_components; i++) {
+                               unsigned inloc = idx * 4 + i + comp;
+                               if (ctx->so->inputs[idx * 4].bary) {
+                                       dst[i] = ir3_BARY_F(b, create_immed(b, inloc), 0, coord, 0);
+                               } else {
+                                       /* for non-varyings use the pre-setup input, since
+                                        * that is easier than mapping things back to a
+                                        * nir_variable to figure out what it is.
+                                        */
+                                       dst[i] = ctx->ir->inputs[inloc];
+                               }
+                       }
+               } else {
+                       ir3_context_error(ctx, "unhandled");
+               }
+               break;
        case nir_intrinsic_load_input:
                idx = nir_intrinsic_base(intr);
                comp = nir_intrinsic_component(intr);
@@ -1181,6 +1209,7 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr)
                        for (int i = 0; i < intr->num_components; i++) {
                                unsigned n = idx * 4 + i + comp;
                                dst[i] = ctx->ir->inputs[n];
+                               compile_assert(ctx, ctx->ir->inputs[n]);
                        }
                } else {
                        src = ir3_get_src(ctx, &intr->src[0]);
index 61ebc615155af3e3312034b4f6bb0a96f6b75192..8b66615a6e01a0f35477d4568d39befdc3764bfb 100644 (file)
@@ -49,11 +49,12 @@ static const nir_shader_compiler_options options = {
                .vertex_id_zero_based = true,
                .lower_extract_byte = true,
                .lower_extract_word = true,
-               .lower_all_io_to_temps = true,
+               .lower_all_io_to_elements = true,
                .lower_helper_invocation = true,
                .lower_bitfield_insert_to_shifts = true,
                .lower_bitfield_extract_to_shifts = true,
                .lower_bfm = true,
+               .use_interpolated_input_intrinsics = true,
 };
 
 /* we don't want to lower vertex_id to _zero_based on newer gpus: */
@@ -75,11 +76,12 @@ static const nir_shader_compiler_options options_a6xx = {
                .vertex_id_zero_based = false,
                .lower_extract_byte = true,
                .lower_extract_word = true,
-               .lower_all_io_to_temps = true,
+               .lower_all_io_to_elements = true,
                .lower_helper_invocation = true,
                .lower_bitfield_insert_to_shifts = true,
                .lower_bitfield_extract_to_shifts = true,
                .lower_bfm = true,
+               .use_interpolated_input_intrinsics = true,
 };
 
 const nir_shader_compiler_options *