[Mesa-dev] [PATCH 08/13] anv: convert anv_layout_to_aux_usage to use plane
Lionel Landwerlin
lionel.g.landwerlin at intel.com
Mon Nov 5 15:36:02 UTC 2018
This will help with the creation of image views where the aspect of
the view doesn't necessarly match the aspect of the image plane.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
src/intel/vulkan/anv_blorp.c | 2 +-
src/intel/vulkan/anv_image.c | 26 +++++++++-----------------
src/intel/vulkan/anv_private.h | 2 +-
src/intel/vulkan/genX_cmd_buffer.c | 21 ++++++++-------------
4 files changed, 19 insertions(+), 32 deletions(-)
diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
index 29bddc46bda..319e7929c82 100644
--- a/src/intel/vulkan/anv_blorp.c
+++ b/src/intel/vulkan/anv_blorp.c
@@ -200,7 +200,7 @@ get_blorp_surf_for_anv_image(const struct anv_device *device,
uint32_t plane = anv_format_aspect_to_plane(image->format, aspect);
if (layout != ANV_IMAGE_LAYOUT_EXPLICIT_AUX)
- aux_usage = anv_layout_to_aux_usage(&device->info, image, aspect, layout);
+ aux_usage = anv_layout_to_aux_usage(&device->info, image, plane, layout);
const struct anv_surface *surface = &image->planes[plane].surface;
*blorp_surf = (struct blorp_surf) {
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index b2ca1fdacbd..df1b025d248 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -803,7 +803,7 @@ void anv_GetImageSubresourceLayout(
enum isl_aux_usage
anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
const struct anv_image * const image,
- const VkImageAspectFlagBits aspect,
+ const uint32_t plane,
const VkImageLayout layout)
{
/* Validate the inputs. */
@@ -814,13 +814,6 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
/* The layout of a NULL image is not properly defined. */
assert(image != NULL);
- /* The aspect must be exactly one of the image aspects. */
- assert(util_bitcount(aspect) == 1 && (aspect & image->aspects));
-
- /* Determine the optimal buffer. */
-
- uint32_t plane = anv_format_aspect_to_plane(image->format, aspect);
-
/* If there is no auxiliary surface allocated, we must use the one and only
* main buffer.
*/
@@ -831,7 +824,7 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
assert(image->tiling == VK_IMAGE_TILING_OPTIMAL);
/* Stencil has no aux */
- assert(aspect != VK_IMAGE_ASPECT_STENCIL_BIT);
+ assert(image->format->planes[plane].aspect != VK_IMAGE_ASPECT_STENCIL_BIT);
switch (layout) {
@@ -856,7 +849,7 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
case VK_IMAGE_LAYOUT_GENERAL:
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
- if (aspect == VK_IMAGE_ASPECT_DEPTH_BIT) {
+ if (image->format->planes[plane].aspect == VK_IMAGE_ASPECT_DEPTH_BIT) {
/* This buffer could be a depth buffer used in a transfer operation.
* BLORP currently doesn't use HiZ for transfer operations so we must
* use the main buffer for this layout. TODO: Enable HiZ in BLORP.
@@ -875,7 +868,7 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
assert((image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) == 0);
/* Fall-through */
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
- if (aspect == VK_IMAGE_ASPECT_DEPTH_BIT) {
+ if (image->format->planes[plane].aspect == VK_IMAGE_ASPECT_DEPTH_BIT) {
if (anv_can_sample_with_hiz(devinfo, image))
return ISL_AUX_USAGE_HIZ;
else
@@ -903,7 +896,7 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
/* Rendering Layouts */
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
- assert(aspect & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
+ assert(image->format->planes[plane].aspect & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE) {
assert(image->samples == 1);
return ISL_AUX_USAGE_CCS_D;
@@ -914,7 +907,7 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL:
- assert(aspect == VK_IMAGE_ASPECT_DEPTH_BIT);
+ assert(image->format->planes[plane].aspect == VK_IMAGE_ASPECT_DEPTH_BIT);
return ISL_AUX_USAGE_HIZ;
case VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR:
@@ -966,7 +959,7 @@ anv_layout_to_fast_clear_type(const struct gen_device_info * const devinfo,
* default depth value.
*/
enum isl_aux_usage aux_usage =
- anv_layout_to_aux_usage(devinfo, image, aspect, layout);
+ anv_layout_to_aux_usage(devinfo, image, plane, layout);
return aux_usage == ISL_AUX_USAGE_HIZ ?
ANV_FAST_CLEAR_DEFAULT_VALUE : ANV_FAST_CLEAR_NONE;
}
@@ -1391,10 +1384,9 @@ anv_CreateImageView(VkDevice _device,
iview->planes[vplane].general_sampler_surface_state.state = alloc_surface_state(device);
enum isl_aux_usage general_aux_usage =
- anv_layout_to_aux_usage(&device->info, image, 1UL << iaspect_bit,
- VK_IMAGE_LAYOUT_GENERAL);
+ anv_layout_to_aux_usage(&device->info, image, iplane, VK_IMAGE_LAYOUT_GENERAL);
enum isl_aux_usage optimal_aux_usage =
- anv_layout_to_aux_usage(&device->info, image, 1UL << iaspect_bit,
+ anv_layout_to_aux_usage(&device->info, image, iplane,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
anv_image_fill_surface_state(device, image, 1ULL << iaspect_bit,
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 621f65ff33f..c390aee7cb2 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2931,7 +2931,7 @@ anv_image_copy_to_shadow(struct anv_cmd_buffer *cmd_buffer,
enum isl_aux_usage
anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
const struct anv_image *image,
- const VkImageAspectFlagBits aspect,
+ const uint32_t plane,
const VkImageLayout layout);
enum anv_fast_clear_type
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 0446d704e6d..2b4507f5344 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -249,8 +249,7 @@ color_attachment_compute_aux_usage(struct anv_device * device,
}
att_state->aux_usage =
- anv_layout_to_aux_usage(&device->info, iview->image,
- VK_IMAGE_ASPECT_COLOR_BIT,
+ anv_layout_to_aux_usage(&device->info, iview->image, 0,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
/* If we don't have aux, then we should have returned early in the layer
@@ -400,8 +399,7 @@ depth_stencil_attachment_compute_aux_usage(struct anv_device *device,
return;
const enum isl_aux_usage first_subpass_aux_usage =
- anv_layout_to_aux_usage(&device->info, iview->image,
- VK_IMAGE_ASPECT_DEPTH_BIT,
+ anv_layout_to_aux_usage(&device->info, iview->image, 0,
pass_att->first_subpass_layout);
if (first_subpass_aux_usage != ISL_AUX_USAGE_HIZ)
return;
@@ -457,11 +455,9 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,
VkImageLayout final_layout)
{
const bool hiz_enabled = ISL_AUX_USAGE_HIZ ==
- anv_layout_to_aux_usage(&cmd_buffer->device->info, image,
- VK_IMAGE_ASPECT_DEPTH_BIT, initial_layout);
+ anv_layout_to_aux_usage(&cmd_buffer->device->info, image, 0, initial_layout);
const bool enable_hiz = ISL_AUX_USAGE_HIZ ==
- anv_layout_to_aux_usage(&cmd_buffer->device->info, image,
- VK_IMAGE_ASPECT_DEPTH_BIT, final_layout);
+ anv_layout_to_aux_usage(&cmd_buffer->device->info, image, 0, final_layout);
enum isl_aux_op hiz_op;
if (hiz_enabled && !enable_hiz) {
@@ -1063,9 +1059,9 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
}
const enum isl_aux_usage initial_aux_usage =
- anv_layout_to_aux_usage(devinfo, image, aspect, initial_layout);
+ anv_layout_to_aux_usage(devinfo, image, plane, initial_layout);
const enum isl_aux_usage final_aux_usage =
- anv_layout_to_aux_usage(devinfo, image, aspect, final_layout);
+ anv_layout_to_aux_usage(devinfo, image, plane, final_layout);
/* The current code assumes that there is no mixing of CCS_E and CCS_D.
* We can handle transitions between CCS_D/E to and from NONE. What we
@@ -1388,7 +1384,7 @@ genX(BeginCommandBuffer)(
enum isl_aux_usage aux_usage =
anv_layout_to_aux_usage(&cmd_buffer->device->info, iview->image,
- VK_IMAGE_ASPECT_DEPTH_BIT, layout);
+ 0, layout);
cmd_buffer->state.hiz_enabled = aux_usage == ISL_AUX_USAGE_HIZ;
}
@@ -3628,8 +3624,7 @@ cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
transition_depth_buffer(cmd_buffer, image,
att_state->current_layout, target_layout);
att_state->aux_usage =
- anv_layout_to_aux_usage(&cmd_buffer->device->info, image,
- VK_IMAGE_ASPECT_DEPTH_BIT, target_layout);
+ anv_layout_to_aux_usage(&cmd_buffer->device->info, image, 0, target_layout);
}
att_state->current_layout = target_layout;
--
2.19.1
More information about the mesa-dev
mailing list