<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 27, 2017 at 11:32 AM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Make the function take in an image instead of an image view. This<br>
enables us to record relocations for surfaces states created outside of<br>
the anv_CreateImageView path.<br>
<br>
Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
---<br>
src/intel/vulkan/genX_cmd_<wbr>buffer.c | 45 +++++++++++++++++++++---------<wbr>--------<br>
1 file changed, 25 insertions(+), 20 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index 4698270abb..d5cc358aec 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -167,17 +167,20 @@ add_surface_state_reloc(struct anv_cmd_buffer *cmd_buffer,<br>
}<br>
<br>
static void<br>
-add_image_view_relocs(struct anv_cmd_buffer *cmd_buffer,<br>
- const struct anv_image_view *iview,<br>
- enum isl_aux_usage aux_usage,<br>
- struct anv_state state)<br>
+add_image_relocs(struct anv_cmd_buffer * const cmd_buffer,<br>
+ const struct anv_image * const image,<br>
+ const VkImageAspectFlags aspect_mask,<br>
+ const enum isl_aux_usage aux_usage,<br>
+ const struct anv_state state)<br>
{<br>
const struct isl_device *isl_dev = &cmd_buffer->device->isl_dev;<br>
+ const uint32_t surf_offset = image->offset +<br>
+ anv_image_get_surface_for_<wbr>aspect_mask(image, aspect_mask)->offset;<br>
<br>
- add_surface_state_reloc(cmd_<wbr>buffer, state, iview->bo, iview->offset);<br>
+ add_surface_state_reloc(cmd_<wbr>buffer, state, image->bo, surf_offset);<br>
<br>
if (aux_usage != ISL_AUX_USAGE_NONE) {<br>
- uint32_t aux_offset = iview->offset + iview->image->aux_surface.<wbr>offset;<br>
+ uint32_t aux_offset = surf_offset + image->aux_surface.offset;<br></blockquote><div><br></div><div>Ugh... This is not quite the calculation we want (and neither was the old one!) surf_offset is image->offset plus the offset of the main color surface so adding that to aux_surface.offset isn't right. I think you just want image->offset + image->aux_surface.offset. That said, it's always safe because every surface that has aux (color and depth) has surface->offset == 0. We should fix it while we're here anyway.<br><br></div><div>Other than that, this patch seems perfectly reasonable.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
/* On gen7 and prior, the bottom 12 bits of the MCS base address are<br>
* used to store other information. This should be ok, however, because<br>
@@ -191,7 +194,7 @@ add_image_view_relocs(struct anv_cmd_buffer *cmd_buffer,<br>
anv_reloc_list_add(&cmd_<wbr>buffer->surface_relocs,<br>
&cmd_buffer->pool->alloc,<br>
state.offset + isl_dev->ss.aux_addr_offset,<br>
- iview->bo, aux_offset);<br>
+ image->bo, aux_offset);<br>
if (result != VK_SUCCESS)<br>
anv_batch_set_error(&cmd_<wbr>buffer->batch, result);<br>
}<br>
@@ -586,9 +589,9 @@ genX(cmd_buffer_setup_<wbr>attachments)(struct anv_cmd_buffer *cmd_buffer,<br>
.clear_color = clear_color,<br>
.mocs = cmd_buffer->device->default_<wbr>mocs);<br>
<br>
- add_image_view_relocs(cmd_<wbr>buffer, iview,<br>
- state->attachments[i].aux_<wbr>usage,<br>
- state->attachments[i].color_<wbr>rt_state);<br>
+ add_image_relocs(cmd_buffer, iview->image, iview->aspect_mask,<br>
+ state->attachments[i].aux_<wbr>usage,<br>
+ state->attachments[i].color_<wbr>rt_state);<br>
<br>
/* Update the image subresource's fast-clear value as necessary. */<br>
if (state->attachments[i].fast_<wbr>clear) {<br>
@@ -635,9 +638,9 @@ genX(cmd_buffer_setup_<wbr>attachments)(struct anv_cmd_buffer *cmd_buffer,<br>
.clear_color = clear_color,<br>
.mocs = cmd_buffer->device->default_<wbr>mocs);<br>
<br>
- add_image_view_relocs(cmd_<wbr>buffer, iview,<br>
- state->attachments[i].input_<wbr>aux_usage,<br>
- state->attachments[i].input_<wbr>att_state);<br>
+ add_image_relocs(cmd_buffer, iview->image, iview->aspect_mask,<br>
+ state->attachments[i].input_<wbr>aux_usage,<br>
+ state->attachments[i].input_<wbr>att_state);<br>
}<br>
}<br>
<br>
@@ -1252,8 +1255,9 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,<br>
desc->image_view->no_aux_<wbr>sampler_surface_state :<br>
desc->image_view->sampler_<wbr>surface_state;<br>
assert(surface_state.alloc_<wbr>size);<br>
- add_image_view_relocs(cmd_<wbr>buffer, desc->image_view,<br>
- desc->aux_usage, surface_state);<br>
+ add_image_relocs(cmd_buffer, desc->image_view->image,<br>
+ desc->image_view->aspect_mask,<br>
+ desc->aux_usage, surface_state);<br>
break;<br>
case VK_DESCRIPTOR_TYPE_INPUT_<wbr>ATTACHMENT:<br>
assert(stage == MESA_SHADER_FRAGMENT);<br>
@@ -1265,8 +1269,9 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,<br>
desc->image_view->no_aux_<wbr>sampler_surface_state :<br>
desc->image_view->sampler_<wbr>surface_state;<br>
assert(surface_state.alloc_<wbr>size);<br>
- add_image_view_relocs(cmd_<wbr>buffer, desc->image_view,<br>
- desc->aux_usage, surface_state);<br>
+ add_image_relocs(cmd_buffer, desc->image_view->image,<br>
+ desc->image_view->aspect_mask,<br>
+ desc->aux_usage, surface_state);<br>
} else {<br>
/* For color input attachments, we create the surface state at<br>
* vkBeginRenderPass time so that we can include aux and clear<br>
@@ -1284,9 +1289,9 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,<br>
? desc->image_view->writeonly_<wbr>storage_surface_state<br>
: desc->image_view->storage_<wbr>surface_state;<br>
assert(surface_state.alloc_<wbr>size);<br>
- add_image_view_relocs(cmd_<wbr>buffer, desc->image_view,<br>
- desc->image_view->image->aux_<wbr>usage,<br>
- surface_state);<br>
+ add_image_relocs(cmd_buffer, desc->image_view->image,<br>
+ desc->image_view->aspect_mask,<br>
+ desc->image_view->image->aux_<wbr>usage, surface_state);<br>
<br>
struct brw_image_param *image_param =<br>
&cmd_buffer->state.push_<wbr>constants[stage]->images[<wbr>image++];<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.12.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>