From: Timur Kristóf Date: Thu, 27 Feb 2020 18:56:35 +0000 (+0100) Subject: aco: Setup tessellation evaluation shader variables. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0e8f4baede5de386e71c0c04f05ca8f8df813bba;p=mesa.git aco: Setup tessellation evaluation shader variables. Signed-off-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- diff --git a/src/amd/compiler/aco_instruction_selection_setup.cpp b/src/amd/compiler/aco_instruction_selection_setup.cpp index 46e61e4a77e..558c6a7eabb 100644 --- a/src/amd/compiler/aco_instruction_selection_setup.cpp +++ b/src/amd/compiler/aco_instruction_selection_setup.cpp @@ -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."); }