<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Dec 12, 2018 at 7:15 PM Rafael Antognolli <<a href="mailto:rafael.antognolli@intel.com">rafael.antognolli@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, Dec 10, 2018 at 01:49:43PM -0600, Jason Ekstrand wrote:<br>
> On Fri, Dec 7, 2018 at 6:06 PM Rafael Antognolli <<a href="mailto:rafael.antognolli@intel.com" target="_blank">rafael.antognolli@intel.com</a>><br>
> wrote:<br>
> <br>
> We now have multiple BOs in the block pool, but sometimes we still<br>
> reference only the first one in some instructions, and use relative<br>
> offsets in others. So we must be sure to add all the BOs from the block<br>
> pool to the validation list when submitting commands.<br>
> ---<br>
> src/intel/vulkan/anv_batch_chain.c | 47 ++++++++++++++++++++++++++----<br>
> 1 file changed, 42 insertions(+), 5 deletions(-)<br>
> <br>
> diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/<br>
> anv_batch_chain.c<br>
> index bec4d647b7e..65df28ccb91 100644<br>
> --- a/src/intel/vulkan/anv_batch_chain.c<br>
> +++ b/src/intel/vulkan/anv_batch_chain.c<br>
> @@ -1356,6 +1356,36 @@ relocate_cmd_buffer(struct anv_cmd_buffer<br>
> *cmd_buffer,<br>
> return true;<br>
> }<br>
> <br>
> +static void<br>
> +anv_reloc_list_add_dep(struct anv_cmd_buffer *cmd_buffer,<br>
> + struct anv_bo_list *bo_list)<br>
> +{<br>
> + struct anv_bo_list *iter;<br>
> + struct anv_bo *bo;<br>
> + struct anv_reloc_list *relocs = cmd_buffer->batch.relocs;<br>
> +<br>
> + anv_block_pool_foreach_bo(bo_list, iter, bo) {<br>
> + _mesa_set_add(relocs->deps, bo);<br>
> + }<br>
> +}<br>
> +<br>
> +static void<br>
> +anv_batch_bos_add(struct anv_cmd_buffer *cmd_buffer)<br>
> +{<br>
> + struct anv_bo_list *bo_list;<br>
> +<br>
> + bo_list = cmd_buffer->device->dynamic_state_pool.block_pool.bos;<br>
> + anv_reloc_list_add_dep(cmd_buffer, bo_list);<br>
> +<br>
> + bo_list = cmd_buffer->device->instruction_state_pool.block_pool.bos;<br>
> + anv_reloc_list_add_dep(cmd_buffer, bo_list);<br>
> +<br>
> + if (cmd_buffer->device->instance->physicalDevice.use_softpin) {<br>
> + bo_list = cmd_buffer->device->binding_table_pool.block_pool.bos;<br>
> + anv_reloc_list_add_dep(cmd_buffer, bo_list);<br>
> <br>
> <br>
> I don't think want to add things to the command buffer's dependency set this<br>
> late (at submit time). Instead, I think we want to just do anv_execbuf_add_bo<br>
> for each of them directly at the top of setup_execbuf_for_cmd_buffer.<br>
> <br>
> <br>
> + }<br>
> +}<br>
> +<br>
> static VkResult<br>
> setup_execbuf_for_cmd_buffer(struct anv_execbuf *execbuf,<br>
> struct anv_cmd_buffer *cmd_buffer)<br>
> @@ -1364,13 +1394,20 @@ setup_execbuf_for_cmd_buffer(struct anv_execbuf<br>
> *execbuf,<br>
> struct anv_state_pool *ss_pool =<br>
> &cmd_buffer->device->surface_state_pool;<br>
> <br>
> + anv_batch_bos_add(cmd_buffer);<br>
> +<br>
> adjust_relocations_from_state_pool(ss_pool, &cmd_buffer-><br>
> surface_relocs,<br>
> cmd_buffer->last_ss_pool_center);<br>
> - VkResult result = anv_execbuf_add_bo(execbuf, ss_pool-><a href="http://block_pool.bo" rel="noreferrer" target="_blank">block_pool.bo</a>,<br>
> - &cmd_buffer->surface_relocs, 0,<br>
> - &cmd_buffer->device->alloc);<br>
> - if (result != VK_SUCCESS)<br>
> - return result;<br>
> + VkResult result;<br>
> + struct anv_bo *bo;<br>
> + struct anv_bo_list *iter;<br>
> + anv_block_pool_foreach_bo(ss_pool->block_pool.bos, iter, bo) {<br>
> + result = anv_execbuf_add_bo(execbuf, bo,<br>
> + &cmd_buffer->surface_relocs, 0,<br>
> + &cmd_buffer->device->alloc);<br>
> <br>
> <br>
> I don't think we want to pass the relocation list on every BO. Instead, we<br>
> should have a softpin case where we walk the list and don't provide any<br>
> relocations and a non-softpin case where we assert that there is only one BO<br>
> and do provide the relocations.<br>
> <br>
<br>
So, in the case of softpin, we need to pass the surface relocations at<br>
some point, because the BO dependency is stored there. Unless we store<br>
it somewhere else.<br>
<br>
If we use:<br>
<br>
anv_execbuf_add_bo(execbuf, bo, NULL, 0, &cmd_buffer->device->alloc);<br>
<br>
for the surface state pool, it seems like we end up missing some BOs in<br>
the execbuf.<br></blockquote><div><br></div><div>You're right. We need to at least handle the BO set in the reloc data structure. I'm not sure what the best way to do that is. I guess we could just process it on the first one or something like that. processing the BO set does involve a qsort so we probably don't want to do it too many extra times.</div><div><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> <br>
> + if (result != VK_SUCCESS)<br>
> + return result;<br>
> + }<br>
> <br>
> /* First, we walk over all of the bos we've seen and add them and their<br>
> * relocations to the validate list.<br>
> --<br>
> 2.17.1<br>
> <br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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/mailman/listinfo/mesa-dev</a><br>
> <br>
<br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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/mailman/listinfo/mesa-dev</a><br>
<br>
</blockquote></div></div>