Re: [Mesa-dev] [PATCH 24/29] anv/cmd_buffer: Do subpass image transitions in begin/end_subpass
On Tue, Nov 28, 2017 at 10:13:52AM -0800, Jason Ekstrand wrote: > On Tue, Nov 28, 2017 at 10:07 AM, Jason Ekstrand> wrote: > > > This patch causes a perf drop in sascha gears. I'm investigating. > > > > Found it! Read below. > > > > On Mon, Nov 27, 2017 at 7:06 PM, Jason Ekstrand > > wrote: > > > >> --- > >> src/intel/vulkan/genX_cmd_buffer.c | 187 +- > >> --- > >> 1 file changed, 65 insertions(+), 122 deletions(-) > >> > >> diff --git a/src/intel/vulkan/genX_cmd_buffer.c > >> b/src/intel/vulkan/genX_cmd_buffer.c > >> index 7901b0c..2c4ab38 100644 > >> --- a/src/intel/vulkan/genX_cmd_buffer.c > >> +++ b/src/intel/vulkan/genX_cmd_buffer.c > >> @@ -2982,120 +2982,6 @@ cmd_buffer_emit_depth_stencil(struct > >> anv_cmd_buffer *cmd_buffer) > >> cmd_buffer->state.hiz_enabled = info.hiz_usage == ISL_AUX_USAGE_HIZ; > >> } > >> > >> - > >> -/** > >> - * @brief Perform any layout transitions required at the beginning > >> and/or end > >> - *of the current subpass for depth buffers. > >> - * > >> - * TODO: Consider preprocessing the attachment reference array at render > >> pass > >> - * create time to determine if no layout transition is needed at > >> the > >> - * beginning and/or end of each subpass. > >> - * > >> - * @param cmd_buffer The command buffer the transition is happening > >> within. > >> - * @param subpass_end If true, marks that the transition is happening at > >> the > >> - *end of the subpass. > >> - */ > >> -static void > >> -cmd_buffer_subpass_transition_layouts(struct anv_cmd_buffer * const > >> cmd_buffer, > >> - const bool subpass_end) > >> -{ > >> - /* We need a non-NULL command buffer. */ > >> - assert(cmd_buffer); > >> - > >> - const struct anv_cmd_state * const cmd_state = _buffer->state; > >> - const struct anv_subpass * const subpass = cmd_state->subpass; > >> - > >> - /* This function must be called within a subpass. */ > >> - assert(subpass); > >> - > >> - /* If there are attachment references, the array shouldn't be NULL. > >> -*/ > >> - if (subpass->attachment_count > 0) > >> - assert(subpass->attachments); > >> - > >> - /* Iterate over the array of attachment references. */ > >> - for (const VkAttachmentReference *att_ref = subpass->attachments; > >> -att_ref < subpass->attachments + subpass->attachment_count; > >> att_ref++) { > >> - > >> - /* If the attachment is unused, we can't perform a layout > >> transition. */ > >> - if (att_ref->attachment == VK_ATTACHMENT_UNUSED) > >> - continue; > >> - > >> - /* This attachment index shouldn't go out of bounds. */ > >> - assert(att_ref->attachment < cmd_state->pass->attachment_count); > >> - > >> - const struct anv_render_pass_attachment * const att_desc = > >> - _state->pass->attachments[att_ref->attachment]; > >> - struct anv_attachment_state * const att_state = > >> - _buffer->state.attachments[att_ref->attachment]; > >> - > >> - /* The attachment should not be used in a subpass after its last. > >> */ > >> - assert(att_desc->last_subpass_idx >= > >> anv_get_subpass_id(cmd_state)); > >> - > >> - if (subpass_end && anv_get_subpass_id(cmd_state) < > >> - att_desc->last_subpass_idx) { > >> - /* We're calling this function on a buffer twice in one subpass > >> and > >> - * this is not the last use of the buffer. The layout should > >> not have > >> - * changed from the first call and no transition is necessary. > >> - */ > >> - assert(att_state->current_layout == att_ref->layout || > >> -att_state->current_layout == > >> -VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); > >> - continue; > >> - } > >> - > >> - /* The attachment index must be less than the number of attachments > >> - * within the framebuffer. > >> - */ > >> - assert(att_ref->attachment < cmd_state->framebuffer->attach > >> ment_count); > >> - > >> - const struct anv_image_view * const iview = > >> - cmd_state->framebuffer->attachments[att_ref->attachment]; > >> - const struct anv_image * const image = iview->image; > >> - > >> - /* Get the appropriate target layout for this attachment. */ > >> - VkImageLayout target_layout; > >> - > >> - /* A resolve is necessary before use as an input attachment if the > >> clear > >> - * color or auxiliary buffer usage isn't supported by the sampler. > >> - */ > >> - const bool input_needs_resolve = > >> -(att_state->fast_clear && !att_state->clear_color_is_zero_one) > >> || > >> -att_state->input_aux_usage != att_state->aux_usage; > >> - if (subpass_end) { > >> - target_layout = att_desc->final_layout; > >> - } else if (iview->aspect_mask &
Re: [Mesa-dev] [PATCH 24/29] anv/cmd_buffer: Do subpass image transitions in begin/end_subpass
On Mon, Nov 27, 2017 at 07:06:14PM -0800, Jason Ekstrand wrote: > --- > src/intel/vulkan/genX_cmd_buffer.c | 187 > + > 1 file changed, 65 insertions(+), 122 deletions(-) > > diff --git a/src/intel/vulkan/genX_cmd_buffer.c > b/src/intel/vulkan/genX_cmd_buffer.c > index 7901b0c..2c4ab38 100644 > --- a/src/intel/vulkan/genX_cmd_buffer.c > +++ b/src/intel/vulkan/genX_cmd_buffer.c > @@ -2982,120 +2982,6 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer > *cmd_buffer) > cmd_buffer->state.hiz_enabled = info.hiz_usage == ISL_AUX_USAGE_HIZ; > } > > - > -/** > - * @brief Perform any layout transitions required at the beginning and/or end > - *of the current subpass for depth buffers. > - * > - * TODO: Consider preprocessing the attachment reference array at render pass > - * create time to determine if no layout transition is needed at the > - * beginning and/or end of each subpass. > - * > - * @param cmd_buffer The command buffer the transition is happening within. > - * @param subpass_end If true, marks that the transition is happening at the > - *end of the subpass. > - */ > -static void > -cmd_buffer_subpass_transition_layouts(struct anv_cmd_buffer * const > cmd_buffer, > - const bool subpass_end) > -{ > - /* We need a non-NULL command buffer. */ > - assert(cmd_buffer); > - > - const struct anv_cmd_state * const cmd_state = _buffer->state; > - const struct anv_subpass * const subpass = cmd_state->subpass; > - > - /* This function must be called within a subpass. */ > - assert(subpass); > - > - /* If there are attachment references, the array shouldn't be NULL. > -*/ > - if (subpass->attachment_count > 0) > - assert(subpass->attachments); > - > - /* Iterate over the array of attachment references. */ > - for (const VkAttachmentReference *att_ref = subpass->attachments; > -att_ref < subpass->attachments + subpass->attachment_count; > att_ref++) { > - > - /* If the attachment is unused, we can't perform a layout transition. > */ > - if (att_ref->attachment == VK_ATTACHMENT_UNUSED) > - continue; > - > - /* This attachment index shouldn't go out of bounds. */ > - assert(att_ref->attachment < cmd_state->pass->attachment_count); > - > - const struct anv_render_pass_attachment * const att_desc = > - _state->pass->attachments[att_ref->attachment]; > - struct anv_attachment_state * const att_state = > - _buffer->state.attachments[att_ref->attachment]; > - > - /* The attachment should not be used in a subpass after its last. */ > - assert(att_desc->last_subpass_idx >= anv_get_subpass_id(cmd_state)); > - > - if (subpass_end && anv_get_subpass_id(cmd_state) < > - att_desc->last_subpass_idx) { > - /* We're calling this function on a buffer twice in one subpass and > - * this is not the last use of the buffer. The layout should not > have > - * changed from the first call and no transition is necessary. > - */ > - assert(att_state->current_layout == att_ref->layout || > -att_state->current_layout == > -VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); > - continue; > - } > - > - /* The attachment index must be less than the number of attachments > - * within the framebuffer. > - */ > - assert(att_ref->attachment < cmd_state->framebuffer->attachment_count); > - > - const struct anv_image_view * const iview = > - cmd_state->framebuffer->attachments[att_ref->attachment]; > - const struct anv_image * const image = iview->image; > - > - /* Get the appropriate target layout for this attachment. */ > - VkImageLayout target_layout; > - > - /* A resolve is necessary before use as an input attachment if the > clear > - * color or auxiliary buffer usage isn't supported by the sampler. > - */ > - const bool input_needs_resolve = > -(att_state->fast_clear && !att_state->clear_color_is_zero_one) || > -att_state->input_aux_usage != att_state->aux_usage; > - if (subpass_end) { > - target_layout = att_desc->final_layout; > - } else if (iview->aspect_mask & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV && > - !input_needs_resolve) { > - /* Layout transitions before the final only help to enable sampling > as > - * an input attachment. If the input attachment supports sampling > - * using the auxiliary surface, we can skip such transitions by > making > - * the target layout one that is CCS-aware. > - */ > - target_layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; > - } else { > - target_layout = att_ref->layout; > - } > - > - /* Perform the layout transition. */ > - if (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT) { > -
Re: [Mesa-dev] [PATCH 24/29] anv/cmd_buffer: Do subpass image transitions in begin/end_subpass
On Tue, Nov 28, 2017 at 10:07 AM, Jason Ekstrandwrote: > This patch causes a perf drop in sascha gears. I'm investigating. > Found it! Read below. > On Mon, Nov 27, 2017 at 7:06 PM, Jason Ekstrand > wrote: > >> --- >> src/intel/vulkan/genX_cmd_buffer.c | 187 +- >> --- >> 1 file changed, 65 insertions(+), 122 deletions(-) >> >> diff --git a/src/intel/vulkan/genX_cmd_buffer.c >> b/src/intel/vulkan/genX_cmd_buffer.c >> index 7901b0c..2c4ab38 100644 >> --- a/src/intel/vulkan/genX_cmd_buffer.c >> +++ b/src/intel/vulkan/genX_cmd_buffer.c >> @@ -2982,120 +2982,6 @@ cmd_buffer_emit_depth_stencil(struct >> anv_cmd_buffer *cmd_buffer) >> cmd_buffer->state.hiz_enabled = info.hiz_usage == ISL_AUX_USAGE_HIZ; >> } >> >> - >> -/** >> - * @brief Perform any layout transitions required at the beginning >> and/or end >> - *of the current subpass for depth buffers. >> - * >> - * TODO: Consider preprocessing the attachment reference array at render >> pass >> - * create time to determine if no layout transition is needed at >> the >> - * beginning and/or end of each subpass. >> - * >> - * @param cmd_buffer The command buffer the transition is happening >> within. >> - * @param subpass_end If true, marks that the transition is happening at >> the >> - *end of the subpass. >> - */ >> -static void >> -cmd_buffer_subpass_transition_layouts(struct anv_cmd_buffer * const >> cmd_buffer, >> - const bool subpass_end) >> -{ >> - /* We need a non-NULL command buffer. */ >> - assert(cmd_buffer); >> - >> - const struct anv_cmd_state * const cmd_state = _buffer->state; >> - const struct anv_subpass * const subpass = cmd_state->subpass; >> - >> - /* This function must be called within a subpass. */ >> - assert(subpass); >> - >> - /* If there are attachment references, the array shouldn't be NULL. >> -*/ >> - if (subpass->attachment_count > 0) >> - assert(subpass->attachments); >> - >> - /* Iterate over the array of attachment references. */ >> - for (const VkAttachmentReference *att_ref = subpass->attachments; >> -att_ref < subpass->attachments + subpass->attachment_count; >> att_ref++) { >> - >> - /* If the attachment is unused, we can't perform a layout >> transition. */ >> - if (att_ref->attachment == VK_ATTACHMENT_UNUSED) >> - continue; >> - >> - /* This attachment index shouldn't go out of bounds. */ >> - assert(att_ref->attachment < cmd_state->pass->attachment_count); >> - >> - const struct anv_render_pass_attachment * const att_desc = >> - _state->pass->attachments[att_ref->attachment]; >> - struct anv_attachment_state * const att_state = >> - _buffer->state.attachments[att_ref->attachment]; >> - >> - /* The attachment should not be used in a subpass after its last. >> */ >> - assert(att_desc->last_subpass_idx >= >> anv_get_subpass_id(cmd_state)); >> - >> - if (subpass_end && anv_get_subpass_id(cmd_state) < >> - att_desc->last_subpass_idx) { >> - /* We're calling this function on a buffer twice in one subpass >> and >> - * this is not the last use of the buffer. The layout should >> not have >> - * changed from the first call and no transition is necessary. >> - */ >> - assert(att_state->current_layout == att_ref->layout || >> -att_state->current_layout == >> -VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); >> - continue; >> - } >> - >> - /* The attachment index must be less than the number of attachments >> - * within the framebuffer. >> - */ >> - assert(att_ref->attachment < cmd_state->framebuffer->attach >> ment_count); >> - >> - const struct anv_image_view * const iview = >> - cmd_state->framebuffer->attachments[att_ref->attachment]; >> - const struct anv_image * const image = iview->image; >> - >> - /* Get the appropriate target layout for this attachment. */ >> - VkImageLayout target_layout; >> - >> - /* A resolve is necessary before use as an input attachment if the >> clear >> - * color or auxiliary buffer usage isn't supported by the sampler. >> - */ >> - const bool input_needs_resolve = >> -(att_state->fast_clear && !att_state->clear_color_is_zero_one) >> || >> -att_state->input_aux_usage != att_state->aux_usage; >> - if (subpass_end) { >> - target_layout = att_desc->final_layout; >> - } else if (iview->aspect_mask & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV >> && >> - !input_needs_resolve) { >> - /* Layout transitions before the final only help to enable >> sampling as >> - * an input attachment. If the input attachment supports >> sampling >> - * using the auxiliary surface, we can skip such transitions by >> making
Re: [Mesa-dev] [PATCH 24/29] anv/cmd_buffer: Do subpass image transitions in begin/end_subpass
This patch causes a perf drop in sascha gears. I'm investigating. On Mon, Nov 27, 2017 at 7:06 PM, Jason Ekstrandwrote: > --- > src/intel/vulkan/genX_cmd_buffer.c | 187 +- > --- > 1 file changed, 65 insertions(+), 122 deletions(-) > > diff --git a/src/intel/vulkan/genX_cmd_buffer.c > b/src/intel/vulkan/genX_cmd_buffer.c > index 7901b0c..2c4ab38 100644 > --- a/src/intel/vulkan/genX_cmd_buffer.c > +++ b/src/intel/vulkan/genX_cmd_buffer.c > @@ -2982,120 +2982,6 @@ cmd_buffer_emit_depth_stencil(struct > anv_cmd_buffer *cmd_buffer) > cmd_buffer->state.hiz_enabled = info.hiz_usage == ISL_AUX_USAGE_HIZ; > } > > - > -/** > - * @brief Perform any layout transitions required at the beginning and/or > end > - *of the current subpass for depth buffers. > - * > - * TODO: Consider preprocessing the attachment reference array at render > pass > - * create time to determine if no layout transition is needed at the > - * beginning and/or end of each subpass. > - * > - * @param cmd_buffer The command buffer the transition is happening > within. > - * @param subpass_end If true, marks that the transition is happening at > the > - *end of the subpass. > - */ > -static void > -cmd_buffer_subpass_transition_layouts(struct anv_cmd_buffer * const > cmd_buffer, > - const bool subpass_end) > -{ > - /* We need a non-NULL command buffer. */ > - assert(cmd_buffer); > - > - const struct anv_cmd_state * const cmd_state = _buffer->state; > - const struct anv_subpass * const subpass = cmd_state->subpass; > - > - /* This function must be called within a subpass. */ > - assert(subpass); > - > - /* If there are attachment references, the array shouldn't be NULL. > -*/ > - if (subpass->attachment_count > 0) > - assert(subpass->attachments); > - > - /* Iterate over the array of attachment references. */ > - for (const VkAttachmentReference *att_ref = subpass->attachments; > -att_ref < subpass->attachments + subpass->attachment_count; > att_ref++) { > - > - /* If the attachment is unused, we can't perform a layout > transition. */ > - if (att_ref->attachment == VK_ATTACHMENT_UNUSED) > - continue; > - > - /* This attachment index shouldn't go out of bounds. */ > - assert(att_ref->attachment < cmd_state->pass->attachment_count); > - > - const struct anv_render_pass_attachment * const att_desc = > - _state->pass->attachments[att_ref->attachment]; > - struct anv_attachment_state * const att_state = > - _buffer->state.attachments[att_ref->attachment]; > - > - /* The attachment should not be used in a subpass after its last. */ > - assert(att_desc->last_subpass_idx >= anv_get_subpass_id(cmd_state)) > ; > - > - if (subpass_end && anv_get_subpass_id(cmd_state) < > - att_desc->last_subpass_idx) { > - /* We're calling this function on a buffer twice in one subpass > and > - * this is not the last use of the buffer. The layout should not > have > - * changed from the first call and no transition is necessary. > - */ > - assert(att_state->current_layout == att_ref->layout || > -att_state->current_layout == > -VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); > - continue; > - } > - > - /* The attachment index must be less than the number of attachments > - * within the framebuffer. > - */ > - assert(att_ref->attachment < cmd_state->framebuffer-> > attachment_count); > - > - const struct anv_image_view * const iview = > - cmd_state->framebuffer->attachments[att_ref->attachment]; > - const struct anv_image * const image = iview->image; > - > - /* Get the appropriate target layout for this attachment. */ > - VkImageLayout target_layout; > - > - /* A resolve is necessary before use as an input attachment if the > clear > - * color or auxiliary buffer usage isn't supported by the sampler. > - */ > - const bool input_needs_resolve = > -(att_state->fast_clear && !att_state->clear_color_is_zero_one) > || > -att_state->input_aux_usage != att_state->aux_usage; > - if (subpass_end) { > - target_layout = att_desc->final_layout; > - } else if (iview->aspect_mask & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV > && > - !input_needs_resolve) { > - /* Layout transitions before the final only help to enable > sampling as > - * an input attachment. If the input attachment supports sampling > - * using the auxiliary surface, we can skip such transitions by > making > - * the target layout one that is CCS-aware. > - */ > - target_layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; > - } else { > - target_layout = att_ref->layout; > - } > - > - /* Perform
[Mesa-dev] [PATCH 24/29] anv/cmd_buffer: Do subpass image transitions in begin/end_subpass
--- src/intel/vulkan/genX_cmd_buffer.c | 187 + 1 file changed, 65 insertions(+), 122 deletions(-) diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 7901b0c..2c4ab38 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -2982,120 +2982,6 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer) cmd_buffer->state.hiz_enabled = info.hiz_usage == ISL_AUX_USAGE_HIZ; } - -/** - * @brief Perform any layout transitions required at the beginning and/or end - *of the current subpass for depth buffers. - * - * TODO: Consider preprocessing the attachment reference array at render pass - * create time to determine if no layout transition is needed at the - * beginning and/or end of each subpass. - * - * @param cmd_buffer The command buffer the transition is happening within. - * @param subpass_end If true, marks that the transition is happening at the - *end of the subpass. - */ -static void -cmd_buffer_subpass_transition_layouts(struct anv_cmd_buffer * const cmd_buffer, - const bool subpass_end) -{ - /* We need a non-NULL command buffer. */ - assert(cmd_buffer); - - const struct anv_cmd_state * const cmd_state = _buffer->state; - const struct anv_subpass * const subpass = cmd_state->subpass; - - /* This function must be called within a subpass. */ - assert(subpass); - - /* If there are attachment references, the array shouldn't be NULL. -*/ - if (subpass->attachment_count > 0) - assert(subpass->attachments); - - /* Iterate over the array of attachment references. */ - for (const VkAttachmentReference *att_ref = subpass->attachments; -att_ref < subpass->attachments + subpass->attachment_count; att_ref++) { - - /* If the attachment is unused, we can't perform a layout transition. */ - if (att_ref->attachment == VK_ATTACHMENT_UNUSED) - continue; - - /* This attachment index shouldn't go out of bounds. */ - assert(att_ref->attachment < cmd_state->pass->attachment_count); - - const struct anv_render_pass_attachment * const att_desc = - _state->pass->attachments[att_ref->attachment]; - struct anv_attachment_state * const att_state = - _buffer->state.attachments[att_ref->attachment]; - - /* The attachment should not be used in a subpass after its last. */ - assert(att_desc->last_subpass_idx >= anv_get_subpass_id(cmd_state)); - - if (subpass_end && anv_get_subpass_id(cmd_state) < - att_desc->last_subpass_idx) { - /* We're calling this function on a buffer twice in one subpass and - * this is not the last use of the buffer. The layout should not have - * changed from the first call and no transition is necessary. - */ - assert(att_state->current_layout == att_ref->layout || -att_state->current_layout == -VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - continue; - } - - /* The attachment index must be less than the number of attachments - * within the framebuffer. - */ - assert(att_ref->attachment < cmd_state->framebuffer->attachment_count); - - const struct anv_image_view * const iview = - cmd_state->framebuffer->attachments[att_ref->attachment]; - const struct anv_image * const image = iview->image; - - /* Get the appropriate target layout for this attachment. */ - VkImageLayout target_layout; - - /* A resolve is necessary before use as an input attachment if the clear - * color or auxiliary buffer usage isn't supported by the sampler. - */ - const bool input_needs_resolve = -(att_state->fast_clear && !att_state->clear_color_is_zero_one) || -att_state->input_aux_usage != att_state->aux_usage; - if (subpass_end) { - target_layout = att_desc->final_layout; - } else if (iview->aspect_mask & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV && - !input_needs_resolve) { - /* Layout transitions before the final only help to enable sampling as - * an input attachment. If the input attachment supports sampling - * using the auxiliary surface, we can skip such transitions by making - * the target layout one that is CCS-aware. - */ - target_layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - } else { - target_layout = att_ref->layout; - } - - /* Perform the layout transition. */ - if (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT) { - transition_depth_buffer(cmd_buffer, image, - att_state->current_layout, target_layout); - att_state->aux_usage = -anv_layout_to_aux_usage(_buffer->device->info, image, -VK_IMAGE_ASPECT_DEPTH_BIT, target_layout); -