aco: Setup tessellation evaluation shader variables.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3964>
This commit is contained in:
Timur Kristóf
2020-02-27 19:56:35 +01:00
committed by Marge Bot
parent 80d281c6dc
commit 0e8f4baede
@@ -766,23 +766,27 @@ setup_vs_variables(isel_context *ctx, nir_shader *nir)
void setup_gs_variables(isel_context *ctx, nir_shader *nir)
{
assert(ctx->stage == vertex_geometry_gs || ctx->stage == geometry_gs);
if (ctx->stage == vertex_geometry_gs) {
if (ctx->stage == vertex_geometry_gs || ctx->stage == tess_eval_geometry_gs) {
nir_foreach_variable(variable, &nir->inputs) {
variable->data.driver_location = util_bitcount64(ctx->input_masks[nir->info.stage] & ((1ull << variable->data.location) - 1ull)) * 4;
}
} else {
} else if (ctx->stage == geometry_gs) {
//TODO: make this more compact
nir_foreach_variable(variable, &nir->inputs) {
variable->data.driver_location = shader_io_get_unique_index((gl_varying_slot)variable->data.location) * 4;
}
} else {
unreachable("Unsupported GS stage.");
}
nir_foreach_variable(variable, &nir->outputs) {
variable->data.driver_location = variable->data.location * 4;
}
if (ctx->stage == vertex_geometry_gs)
ctx->program->info->gs.es_type = MESA_SHADER_VERTEX; /* tesselation shaders are not yet supported */
ctx->program->info->gs.es_type = MESA_SHADER_VERTEX;
else if (ctx->stage == tess_eval_geometry_gs)
ctx->program->info->gs.es_type = MESA_SHADER_TESS_EVAL;
}
void
@@ -830,6 +834,33 @@ setup_tcs_variables(isel_context *ctx, nir_shader *nir)
}
}
void
setup_tes_variables(isel_context *ctx, nir_shader *nir)
{
ctx->tcs_num_patches = ctx->args->options->key.tes.num_patches;
nir_foreach_variable(variable, &nir->inputs) {
variable->data.driver_location = shader_io_get_unique_index((gl_varying_slot) variable->data.location) * 4;
}
nir_foreach_variable(variable, &nir->outputs) {
if (ctx->stage == tess_eval_vs)
variable->data.driver_location = variable->data.location * 4;
else if (ctx->stage == tess_eval_es)
variable->data.driver_location = shader_io_get_unique_index((gl_varying_slot) variable->data.location) * 4;
else if (ctx->stage == tess_eval_geometry_gs)
variable->data.driver_location = util_bitcount64(ctx->output_masks[nir->info.stage] & ((1ull << variable->data.location) - 1ull)) * 4;
else
unreachable("Unsupported TES shader stage");
}
if (ctx->stage == tess_eval_vs) {
radv_vs_output_info *outinfo = &ctx->program->info->tes.outinfo;
setup_vs_output_info(ctx, nir, outinfo->export_prim_id,
ctx->options->key.vs_common_out.export_clip_dists, outinfo);
}
}
void
setup_variables(isel_context *ctx, nir_shader *nir)
{
@@ -859,6 +890,10 @@ setup_variables(isel_context *ctx, nir_shader *nir)
setup_tcs_variables(ctx, nir);
break;
}
case MESA_SHADER_TESS_EVAL: {
setup_tes_variables(ctx, nir);
break;
}
default:
unreachable("Unhandled shader stage.");
}