shader->selector->info.writes_z + shader->selector->info.writes_stencil +
shader->selector->info.writes_samplemask + 1 /* SampleMaskIn */;
- num_returns = MAX2(num_returns, num_return_sgprs + PS_EPILOG_SAMPLEMASK_MIN_LOC + 1);
-
for (i = 0; i < num_return_sgprs; i++)
ac_add_return(&ctx->args, AC_ARG_SGPR);
for (; i < num_returns; i++)
fprintf(f, " epilog.last_cbuf = %u\n", key->ps.part.epilog.last_cbuf);
fprintf(f, " epilog.alpha_func = %u\n", key->ps.part.epilog.alpha_func);
fprintf(f, " epilog.alpha_to_one = %u\n", key->ps.part.epilog.alpha_to_one);
- fprintf(f, " epilog.poly_line_smoothing = %u\n",
- key->ps.part.epilog.poly_line_smoothing);
fprintf(f, " epilog.clamp_color = %u\n", key->ps.part.epilog.clamp_color);
+ fprintf(f, " mono.poly_line_smoothing = %u\n", key->ps.mono.poly_line_smoothing);
fprintf(f, " mono.interpolate_at_sample_force_center = %u\n",
key->ps.mono.interpolate_at_sample_force_center);
fprintf(f, " mono.fbfetch_msaa = %u\n", key->ps.mono.fbfetch_msaa);
assert(G_0286CC_ANCILLARY_ENA(shader->config.spi_ps_input_addr));
}
- /* The sample mask input is always enabled, because the API shader always
- * passes it through to the epilog. Disable it here if it's unused.
- */
- if (!shader->key.ps.part.epilog.poly_line_smoothing && !shader->selector->info.reads_samplemask)
- shader->config.spi_ps_input_ena &= C_0286CC_SAMPLE_COVERAGE_ENA;
-
return true;
}
}
}
-static LLVMValueRef si_scale_alpha_by_sample_mask(struct si_shader_context *ctx, LLVMValueRef alpha,
- unsigned samplemask_param)
+static LLVMValueRef si_get_coverage_from_sample_mask(struct si_shader_context *ctx)
{
LLVMValueRef coverage;
/* alpha = alpha * popcount(coverage) / SI_NUM_SMOOTH_AA_SAMPLES */
- coverage = LLVMGetParam(ctx->main_fn, samplemask_param);
+ coverage = LLVMGetParam(ctx->main_fn, SI_PARAM_SAMPLE_COVERAGE);
coverage = ac_build_bit_count(&ctx->ac, ac_to_integer(&ctx->ac, coverage));
coverage = LLVMBuildUIToFP(ctx->ac.builder, coverage, ctx->ac.f32, "");
- coverage = LLVMBuildFMul(ctx->ac.builder, coverage,
- LLVMConstReal(ctx->ac.f32, 1.0 / SI_NUM_SMOOTH_AA_SAMPLES), "");
-
- if (LLVMTypeOf(alpha) == ctx->ac.f16)
- coverage = LLVMBuildFPTrunc(ctx->ac.builder, coverage, ctx->ac.f16, "");
-
- return LLVMBuildFMul(ctx->ac.builder, alpha, coverage, "");
+ return LLVMBuildFMul(ctx->ac.builder, coverage,
+ LLVMConstReal(ctx->ac.f32, 1.0 / SI_NUM_SMOOTH_AA_SAMPLES), "");
}
struct si_ps_exports {
}
static void si_export_mrt_color(struct si_shader_context *ctx, LLVMValueRef *color, unsigned index,
- unsigned first_color_export, unsigned samplemask_param,
- unsigned color_type, struct si_ps_exports *exp)
+ unsigned first_color_export, unsigned color_type,
+ struct si_ps_exports *exp)
{
int i;
if (index == 0 && ctx->shader->key.ps.part.epilog.alpha_func != PIPE_FUNC_ALWAYS)
si_alpha_test(ctx, color[3]);
- /* Line & polygon smoothing */
- if (ctx->shader->key.ps.part.epilog.poly_line_smoothing)
- color[3] = si_scale_alpha_by_sample_mask(ctx, color[3], samplemask_param);
-
/* If last_cbuf > 0, FS_COLOR0_WRITES_ALL_CBUFS is true. */
if (ctx->shader->key.ps.part.epilog.last_cbuf > 0) {
assert(exp->num == first_color_export);
struct si_shader *shader = ctx->shader;
struct si_shader_info *info = &shader->selector->info;
LLVMBuilderRef builder = ctx->ac.builder;
- unsigned i, j, first_vgpr, vgpr;
+ unsigned i, j, vgpr;
LLVMValueRef *addrs = abi->outputs;
LLVMValueRef color[8][4] = {};
}
}
+ LLVMValueRef smoothing_coverage = NULL;
+ if (ctx->shader->key.ps.mono.poly_line_smoothing)
+ smoothing_coverage = si_get_coverage_from_sample_mask(ctx);
+
/* Fill the return structure. */
ret = ctx->return_value;
SI_SGPR_ALPHA_REF, "");
/* Set VGPRs */
- first_vgpr = vgpr = SI_SGPR_ALPHA_REF + 1;
+ vgpr = SI_SGPR_ALPHA_REF + 1;
for (i = 0; i < ARRAY_SIZE(color); i++) {
if (!color[i][0])
continue;
if (LLVMTypeOf(color[i][0]) == ctx->ac.f16) {
+ if (smoothing_coverage) {
+ color[i][3] = LLVMBuildFMul(builder, color[i][3],
+ LLVMBuildFPTrunc(builder, smoothing_coverage, ctx->ac.f16, ""), "");
+ }
+
for (j = 0; j < 2; j++) {
LLVMValueRef tmp = ac_build_gather_values(&ctx->ac, &color[i][j * 2], 2);
tmp = LLVMBuildBitCast(builder, tmp, ctx->ac.f32, "");
}
vgpr += 2;
} else {
+ if (smoothing_coverage)
+ color[i][3] = LLVMBuildFMul(builder, color[i][3], smoothing_coverage, "");
+
for (j = 0; j < 4; j++)
ret = LLVMBuildInsertValue(builder, ret, color[i][j], vgpr++, "");
}
if (samplemask)
ret = LLVMBuildInsertValue(builder, ret, samplemask, vgpr++, "");
- /* Add the input sample mask for smoothing at the end. */
- if (vgpr < first_vgpr + PS_EPILOG_SAMPLEMASK_MIN_LOC)
- vgpr = first_vgpr + PS_EPILOG_SAMPLEMASK_MIN_LOC;
- ret = LLVMBuildInsertValue(builder, ret, LLVMGetParam(ctx->main_fn, SI_PARAM_SAMPLE_COVERAGE),
- vgpr++, "");
-
ctx->return_value = ret;
}
ctx->args.num_sgprs_used + util_bitcount(key->ps_epilog.colors_written) * 4 +
key->ps_epilog.writes_z + key->ps_epilog.writes_stencil + key->ps_epilog.writes_samplemask;
- required_num_params =
- MAX2(required_num_params, ctx->args.num_sgprs_used + PS_EPILOG_SAMPLEMASK_MIN_LOC + 1);
-
while (ctx->args.arg_count < required_num_params)
ac_add_arg(&ctx->args, AC_ARG_VGPR, 1, AC_ARG_FLOAT, NULL);
color[i] = LLVMGetParam(ctx->main_fn, vgpr++);
}
- si_export_mrt_color(ctx, color, output_index, first_color_export,
- ctx->args.arg_count - 1, color_type, &exp);
+ si_export_mrt_color(ctx, color, output_index, first_color_export, color_type, &exp);
}
if (exp.num) {