From f4b4d6cf23e8cc4a0d86b0588b23b456f691d830 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Thu, 25 Apr 2019 12:00:49 -0700 Subject: [PATCH] freedreno/ir3: rename frag_vcoord -> ij_pixel Since this is what the value actually is. Cleanup the name before adding more different i,j related values for sample-shading. Signed-off-by: Rob Clark --- src/freedreno/ir3/ir3_compiler_nir.c | 16 +++++++++++++--- src/freedreno/ir3/ir3_context.h | 8 ++------ src/freedreno/ir3/ir3_shader.c | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 41d297a4c33..8347520f6d5 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -95,7 +95,7 @@ create_frag_input(struct ir3_context *ctx, bool use_ldlv, unsigned n) instr->cat6.type = TYPE_U32; instr->cat6.iim_val = 1; } else { - instr = ir3_BARY_F(block, inloc, 0, ctx->frag_vcoord, 0); + instr = ir3_BARY_F(block, inloc, 0, ctx->ij_pixel, 0); instr->regs[2]->wrmask = 0x3; } @@ -1170,7 +1170,11 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr) break; case nir_intrinsic_load_barycentric_centroid: case nir_intrinsic_load_barycentric_pixel: - ir3_split_dest(b, dst, ctx->frag_vcoord, 0, 2); + /* NOTE: we still pre-create ij_pixel just to keep things working with + * nir producers that create "old style" frag shader inputs (ie. just + * load_input, vs load_barycentric_* + load_interpolated_input) + */ + ir3_split_dest(b, dst, ctx->ij_pixel, 0, 2); break; case nir_intrinsic_load_interpolated_input: idx = nir_intrinsic_base(intr); @@ -2557,6 +2561,12 @@ emit_instructions(struct ir3_context *ctx) /* for fragment shader, the vcoord input register is used as the * base for bary.f varying fetch instrs: + * + * TODO defer creating ctx->ij_pixel and corresponding sysvals + * until emit_intrinsic when we know they are actually needed. + * For now, we defer creating ctx->ij_centroid, etc, since we + * only need ij_pixel for "old style" varying inputs (ie. + * tgsi_to_nir) */ struct ir3_instruction *vcoord = NULL; if (ctx->so->type == MESA_SHADER_FRAGMENT) { @@ -2565,7 +2575,7 @@ emit_instructions(struct ir3_context *ctx) vcoord = create_input_compmask(ctx, 0, 0x3); ir3_split_dest(ctx->block, xy, vcoord, 0, 2); - ctx->frag_vcoord = ir3_create_collect(ctx, xy, 2); + ctx->ij_pixel = ir3_create_collect(ctx, xy, 2); } /* Setup inputs: */ diff --git a/src/freedreno/ir3/ir3_context.h b/src/freedreno/ir3/ir3_context.h index 5589386edfa..8c1dc45e42b 100644 --- a/src/freedreno/ir3/ir3_context.h +++ b/src/freedreno/ir3/ir3_context.h @@ -58,18 +58,14 @@ struct ir3_context { nir_function_impl *impl; /* For fragment shaders, varyings are not actual shader inputs, - * instead the hw passes a varying-coord which is used with + * instead the hw passes a ij coord which is used with * bary.f. * * But NIR doesn't know that, it still declares varyings as * inputs. So we do all the input tracking normally and fix * things up after compile_instructions() - * - * NOTE that frag_vcoord is the hardware position (possibly it - * is actually an index or tag or some such.. it is *not* - * values that can be directly used for gl_FragCoord..) */ - struct ir3_instruction *frag_vcoord; + struct ir3_instruction *ij_pixel; /* for fragment shaders, for gl_FrontFacing and gl_FragCoord: */ struct ir3_instruction *frag_face, *frag_coord; diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index 03c3e31f913..fa4f432e606 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -407,7 +407,7 @@ ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin, FILE *out) dump_output(out, so, VARYING_SLOT_PSIZ, "psize"); break; case MESA_SHADER_FRAGMENT: - dump_reg(out, "pos (bary)", + dump_reg(out, "pos (ij_pixel)", ir3_find_sysval_regid(so, SYSTEM_VALUE_BARYCENTRIC_PIXEL)); dump_output(out, so, FRAG_RESULT_DEPTH, "posz"); if (so->color0_mrt) { -- 2.30.2