v3dv/pipeline: clean up io lowering

We had 4 really small functions for the io lowering (which main
purpose is getting locations assigned).

This commit merge them to 2 slightly bigger functions. It also fix a
typo were a vs lowering was calling nir_assign_io_var_locations using
MESA_SHADER_FRAGMENT.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Alejandro Piñeiro
2020-03-04 12:40:15 +01:00
committed by Marge Bot
parent 8da4de7c16
commit 1811c034db
+10 -29
View File
@@ -529,45 +529,30 @@ lower_pipeline_layout_info(nir_shader *shader,
static void
lower_fs_inputs(nir_shader *nir)
lower_fs_io(nir_shader *nir)
{
nir_assign_io_var_locations(nir, nir_var_shader_in, &nir->num_inputs,
MESA_SHADER_FRAGMENT);
NIR_PASS_V(nir, nir_lower_io, nir_var_shader_in, type_size_vec4, 0);
nir_assign_io_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
MESA_SHADER_FRAGMENT);
NIR_PASS_V(nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
type_size_vec4, 0);
}
static void
lower_vs_inputs(struct nir_shader *nir)
lower_vs_io(struct nir_shader *nir)
{
nir_assign_io_var_locations(nir, nir_var_shader_in, &nir->num_inputs,
MESA_SHADER_VERTEX);
/* FIXME: if we call the following pass, we get a crash later. Likely
* because it overlaps with v3d_nir_lower_io. Need further research though.
*/
/* NIR_PASS_V(nir, nir_lower_io, nir_var_shader_in, type_size_vec4, 0); */
}
static void
lower_fs_outputs(nir_shader *nir)
{
nir_assign_io_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
MESA_SHADER_FRAGMENT);
NIR_PASS_V(nir, nir_lower_io, nir_var_shader_out, type_size_vec4, 0);
}
static void
lower_vs_outputs(nir_shader *nir)
{
nir_assign_io_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
MESA_SHADER_FRAGMENT);
MESA_SHADER_VERTEX);
/* FIXME: if we call nir_lower_io, we get a crash later. Likely because it
* overlaps with v3d_nir_lower_io. Need further research though.
*/
/* NIR_PASS_V(nir, nir_lower_io, nir_var_shader_out, type_size_vec4, 0); */
}
static void
@@ -1108,8 +1093,7 @@ pipeline_compile_graphics(struct v3dv_pipeline *pipeline,
pCreateInfo->pInputAssemblyState;
pipeline->vs->topology = vk_to_pipe_prim_type[ia_info->topology];
lower_vs_inputs(p_stage->nir);
lower_vs_outputs(p_stage->nir);
lower_vs_io(p_stage->nir);
/* Note that at this point we would compile twice, one for vs and
* other for vs_bin. For now we are maintaining two pipeline_stage
@@ -1127,10 +1111,7 @@ pipeline_compile_graphics(struct v3dv_pipeline *pipeline,
pipeline_populate_v3d_fs_key(&p_stage->key.fs, pCreateInfo,
p_stage);
/* FIXME: create a per-build method with all the lowering
* needed. perhaps move to shader_compile_module_to_nir? */
lower_fs_inputs(p_stage->nir);
lower_fs_outputs(p_stage->nir);
lower_fs_io(p_stage->nir);
compile_pipeline_stage(pipeline->fs);
break;