diff options
author | Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> | 2021-03-12 15:13:30 -0800 |
---|---|---|
committer | Dylan Baker <dylan.c.baker@intel.com> | 2021-03-15 11:37:35 -0700 |
commit | 710ecbadf750bb7417ebd55900c889e8cdecb053 (patch) | |
tree | 36d28d0e67e5c980c535b5022a9afa52a79a2b28 /src | |
parent | afafb94bc6af173def3618d1e90f6f75076b5cce (diff) |
anv: Lower ViewIndex to zero when multiview is disabled
Vulkan spec says
If multiview is enabled in the render pass, this value will be one
of the bits set in the view mask of the subpass the pipeline is
compiled against. If multiview is not enabled in the render pass,
this value will be zero.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4446
Fixes: 0db70703300 ("anv/pipeline: Add shader lowering for multiview")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9574>
(cherry picked from commit f603a2c25a3efd50ff21a125ee59645bf5599475)
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/vulkan/anv_nir_lower_multiview.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/intel/vulkan/anv_nir_lower_multiview.c b/src/intel/vulkan/anv_nir_lower_multiview.c index 0502b1e3df7..07119e3f650 100644 --- a/src/intel/vulkan/anv_nir_lower_multiview.c +++ b/src/intel/vulkan/anv_nir_lower_multiview.c @@ -150,6 +150,21 @@ build_view_index(struct lower_multiview_state *state) return state->view_index; } +static bool +is_load_view_index(const nir_instr *instr, const void *data) +{ + return instr->type == nir_instr_type_intrinsic && + nir_instr_as_intrinsic(instr)->intrinsic == nir_intrinsic_load_view_index; +} + +static nir_ssa_def * +replace_load_view_index_with_zero(struct nir_builder *b, + nir_instr *instr, void *data) +{ + assert(is_load_view_index(instr, data)); + return nir_imm_zero(b, 1, 32); +} + bool anv_nir_lower_multiview(nir_shader *shader, struct anv_graphics_pipeline *pipeline) @@ -157,9 +172,11 @@ anv_nir_lower_multiview(nir_shader *shader, assert(shader->info.stage != MESA_SHADER_COMPUTE); uint32_t view_mask = pipeline->subpass->view_mask; - /* If multiview isn't enabled, we have nothing to do. */ - if (view_mask == 0) - return false; + /* If multiview isn't enabled, just lower the ViewIndex builtin to zero. */ + if (view_mask == 0) { + return nir_shader_lower_instructions(shader, is_load_view_index, + replace_load_view_index_with_zero, NULL); + } /* This pass assumes a single entrypoint */ nir_function_impl *entrypoint = nir_shader_get_entrypoint(shader); |