<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 27, 2018 at 11:46 AM, Caio Marcelo de Oliveira Filho <span dir="ltr"><<a href="mailto:caio.oliveira@intel.com" target="_blank">caio.oliveira@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If view mask has only one bit set, view index is effectively a<br>
constant, so doesn't need to be passed to the next stages, just always<br>
set it.<br>
<br>
Part of this was in the original patch that added<br>
anv_nir_lower_multiview.c but disabled.<br>
---<br>
src/intel/vulkan/anv_nir_<wbr>lower_multiview.c | 17 +++++++++++------<br>
1 file changed, 11 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_nir_<wbr>lower_multiview.c b/src/intel/vulkan/anv_nir_<wbr>lower_multiview.c<br>
index d2aefdee62..365a70d757 100644<br>
--- a/src/intel/vulkan/anv_nir_<wbr>lower_multiview.c<br>
+++ b/src/intel/vulkan/anv_nir_<wbr>lower_multiview.c<br>
@@ -72,7 +72,8 @@ build_view_index(struct lower_multiview_state *state)<br>
b->cursor = nir_before_block(nir_start_<wbr>block(b->impl));<br>
<br>
assert(state->view_mask != 0);<br>
- if (0 && _mesa_bitcount(state->view_<wbr>mask) == 1) {<br>
+ if (_mesa_bitcount(state->view_<wbr>mask) == 1) {<br></blockquote><div><br></div><div>Yes, I think it's probably safe to turn this on now. Originally, I had it commented out because I was afraid of not getting enough test coverage. For all I know, we still aren't getting enough test coverage but I think we've proven by now that the calculations below work.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ /* Set the view index directly. */<br>
state->view_index = nir_imm_int(b, ffs(state->view_mask) - 1);<br>
} else if (state->builder.shader->info.<wbr>stage == MESA_SHADER_VERTEX) {<br>
/* We only support 16 viewports */<br>
@@ -210,11 +211,15 @@ anv_nir_lower_multiview(nir_<wbr>shader *shader, uint32_t view_mask)<br>
assert(view_index->parent_<wbr>instr->block == nir_start_block(entrypoint));<br>
b->cursor = nir_after_instr(view_index-><wbr>parent_instr);<br>
<br>
- nir_variable *view_index_out =<br>
- nir_variable_create(shader, nir_var_shader_out,<br>
- glsl_int_type(), "view index");<br>
- view_index_out->data.location = VARYING_SLOT_VIEW_INDEX;<br>
- nir_store_var(b, view_index_out, view_index, 0x1);<br>
+ /* Unless there is only one possible view index (that would be set<br>
+ * directly), pass it to the next stage. */<br></blockquote><div><br></div><div>With multi-line comments, we usually put the "*/" on its own line.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ if (_mesa_bitcount(state.view_<wbr>mask) != 1) {<br>
+ nir_variable *view_index_out =<br>
+ nir_variable_create(shader, nir_var_shader_out,<br>
+ glsl_int_type(), "view index");<br>
+ view_index_out->data.location = VARYING_SLOT_VIEW_INDEX;<br>
+ nir_store_var(b, view_index_out, view_index, 0x1);<br>
+ }<br>
<br>
nir_variable *layer_id_out =<br>
nir_variable_create(shader, nir_var_shader_out,<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.16.2<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>