[Mesa-dev] [PATCH 5/7] radv: enable lower to scalar nir pass

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Tue Oct 24 23:30:00 UTC 2017


On Mon, Oct 23, 2017 at 2:10 AM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> This will allow dead components of varyings to be removed.
> ---
>  src/amd/vulkan/radv_pipeline.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
> index 669d9a4858..2a25a423a2 100644
> --- a/src/amd/vulkan/radv_pipeline.c
> +++ b/src/amd/vulkan/radv_pipeline.c
> @@ -1722,20 +1722,31 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
>         for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
>                 if (pStages[i]) {
>                         modules[i] = radv_shader_module_from_handle(pStages[i]->module);
>                         if (modules[i]->nir)
>                                 _mesa_sha1_compute(modules[i]->nir->info.name,
>                                                    strlen(modules[i]->nir->info.name),
>                                                    modules[i]->sha1);
>                 }
>         }
>
> +       /* Determine first and last stage. */
> +       unsigned first = MESA_SHADER_STAGES;
> +       unsigned last = 0;
> +       for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
> +               if (!pStages[i])
> +                       continue;
> +               if (first == MESA_SHADER_STAGES)
> +                       first = i;
> +               last = i;
> +       }
> +

Can we move this till after checking the cache? Otherwise

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>


>         radv_hash_shaders(hash, pStages, pipeline->layout, keys, get_hash_flags(device));
>         memcpy(gs_copy_hash, hash, 20);
>         gs_copy_hash[0] ^= 1;
>
>         if (modules[MESA_SHADER_GEOMETRY]) {
>                 struct radv_shader_variant *variants[MESA_SHADER_STAGES] = {0};
>                 radv_create_shader_variants_from_pipeline_cache(device, cache, gs_copy_hash, variants);
>                 pipeline->gs_copy_shader = variants[MESA_SHADER_GEOMETRY];
>         }
>
> @@ -1759,20 +1770,33 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
>         for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
>                 const VkPipelineShaderStageCreateInfo *stage = pStages[i];
>
>                 if (!modules[i])
>                         continue;
>
>                 nir[i] = radv_shader_compile_to_nir(device, modules[i],
>                                                     stage ? stage->pName : "main", i,
>                                                     stage ? stage->pSpecializationInfo : NULL);
>                 pipeline->active_stages |= mesa_to_vk_shader_stage(i);
> +
> +               if (first != last) {
> +                       nir_variable_mode mask = 0;
> +
> +                       if (i != first)
> +                               mask = mask | nir_var_shader_in;
> +
> +                       if (i != last)
> +                               mask = mask | nir_var_shader_out;
> +
> +                       nir_lower_io_to_scalar_early(nir[i], mask);
> +                       radv_optimize_nir(nir[i]);
> +               }
>         }
>
>         if (nir[MESA_SHADER_TESS_CTRL]) {
>                 /* TODO: This is no longer used as a key we should refactor this */
>                 if (keys)
>                         keys[MESA_SHADER_TESS_CTRL].tcs.primitive_mode = nir[MESA_SHADER_TESS_EVAL]->info.tess.primitive_mode;
>
>                 keys[MESA_SHADER_TESS_CTRL].tcs.tes_reads_tess_factors = !!(nir[MESA_SHADER_TESS_EVAL]->info.inputs_read & (VARYING_BIT_TESS_LEVEL_INNER | VARYING_BIT_TESS_LEVEL_OUTER));
>                 nir_lower_tes_patch_vertices(nir[MESA_SHADER_TESS_EVAL], nir[MESA_SHADER_TESS_CTRL]->info.tess.tcs_vertices_out);
>         }
> --
> 2.13.6
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list