summaryrefslogtreecommitdiff
path: root/src/intel
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2017-07-11 08:53:42 -0700
committerJason Ekstrand <jason.ekstrand@intel.com>2017-07-22 21:41:12 -0700
commit1e32c8303ad917ef8380b6a66f008900f17a9e7c (patch)
tree6cce2fedc969835eb065d40c8dcaf1416d5de650 /src/intel
parent628bfaf1c6f207ee01c59e236cef3fae942d6c55 (diff)
anv: Separate surface states by layout instead of aux_usage
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/vulkan/anv_descriptor_set.c5
-rw-r--r--src/intel/vulkan/anv_image.c56
-rw-r--r--src/intel/vulkan/anv_private.h21
-rw-r--r--src/intel/vulkan/genX_cmd_buffer.c29
4 files changed, 58 insertions, 53 deletions
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c
index 4b58b0be95c..91387c065e4 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -615,12 +615,9 @@ anv_descriptor_set_write_image_view(struct anv_descriptor_set *set,
*desc = (struct anv_descriptor) {
.type = type,
+ .layout = info->imageLayout,
.image_view = image_view,
.sampler = sampler,
- .aux_usage = image_view == NULL ? ISL_AUX_USAGE_NONE :
- anv_layout_to_aux_usage(devinfo, image_view->image,
- image_view->aspect_mask,
- info->imageLayout),
};
}
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 70a8c28baca..c7069cff825 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -748,54 +748,50 @@ anv_CreateImageView(VkDevice _device,
if (image->usage & VK_IMAGE_USAGE_SAMPLED_BIT ||
(image->usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT &&
!(iview->aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT))) {
- iview->sampler_surface_state = alloc_surface_state(device);
- iview->no_aux_sampler_surface_state = alloc_surface_state(device);
+ iview->optimal_sampler_surface_state = alloc_surface_state(device);
+ iview->general_sampler_surface_state = alloc_surface_state(device);
- /* Sampling is performed in one of two buffer configurations in anv: with
- * an auxiliary buffer or without it. Sampler states aren't always needed
- * for both configurations, but are currently created unconditionally for
- * simplicity.
- *
- * TODO: Consider allocating each surface state only when necessary.
- */
-
- /* Create a sampler state with the optimal aux_usage for sampling. This
- * may use the aux_buffer.
- */
- const enum isl_aux_usage surf_usage =
+ iview->general_sampler_aux_usage =
+ anv_layout_to_aux_usage(&device->info, image, iview->aspect_mask,
+ VK_IMAGE_LAYOUT_GENERAL);
+ iview->optimal_sampler_aux_usage =
anv_layout_to_aux_usage(&device->info, image, iview->aspect_mask,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
/* If this is a HiZ buffer we can sample from with a programmable clear
* value (SKL+), define the clear value to the optimal constant.
*/
- const float red_clear_color = surf_usage == ISL_AUX_USAGE_HIZ &&
- device->info.gen >= 9 ?
- ANV_HZ_FC_VAL : 0.0f;
+ union isl_color_value clear_color = { .u32 = { 0, } };
+ if ((iview->aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) &&
+ device->info.gen >= 9)
+ clear_color.f32[0] = ANV_HZ_FC_VAL;
struct isl_view view = iview->isl;
view.usage |= ISL_SURF_USAGE_TEXTURE_BIT;
+
isl_surf_fill_state(&device->isl_dev,
- iview->sampler_surface_state.map,
+ iview->optimal_sampler_surface_state.map,
.surf = &surface->isl,
.view = &view,
- .clear_color.f32 = { red_clear_color,},
+ .clear_color = clear_color,
.aux_surf = &image->aux_surface.isl,
- .aux_usage = surf_usage,
+ .aux_usage = iview->optimal_sampler_aux_usage,
.mocs = device->default_mocs);
- /* Create a sampler state that only uses the main buffer. */
isl_surf_fill_state(&device->isl_dev,
- iview->no_aux_sampler_surface_state.map,
+ iview->general_sampler_surface_state.map,
.surf = &surface->isl,
.view = &view,
+ .clear_color = clear_color,
+ .aux_surf = &image->aux_surface.isl,
+ .aux_usage = iview->general_sampler_aux_usage,
.mocs = device->default_mocs);
- anv_state_flush(device, iview->sampler_surface_state);
- anv_state_flush(device, iview->no_aux_sampler_surface_state);
+ anv_state_flush(device, iview->optimal_sampler_surface_state);
+ anv_state_flush(device, iview->general_sampler_surface_state);
} else {
- iview->sampler_surface_state.alloc_size = 0;
- iview->no_aux_sampler_surface_state.alloc_size = 0;
+ iview->optimal_sampler_surface_state.alloc_size = 0;
+ iview->general_sampler_surface_state.alloc_size = 0;
}
/* NOTE: This one needs to go last since it may stomp isl_view.format */
@@ -866,14 +862,14 @@ anv_DestroyImageView(VkDevice _device, VkImageView _iview,
if (!iview)
return;
- if (iview->sampler_surface_state.alloc_size > 0) {
+ if (iview->optimal_sampler_surface_state.alloc_size > 0) {
anv_state_pool_free(&device->surface_state_pool,
- iview->sampler_surface_state);
+ iview->optimal_sampler_surface_state);
}
- if (iview->no_aux_sampler_surface_state.alloc_size > 0) {
+ if (iview->general_sampler_surface_state.alloc_size > 0) {
anv_state_pool_free(&device->surface_state_pool,
- iview->no_aux_sampler_surface_state);
+ iview->general_sampler_surface_state);
}
if (iview->storage_surface_state.alloc_size > 0) {
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 9bc6db8b88f..faf78498918 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1077,13 +1077,9 @@ struct anv_descriptor {
union {
struct {
+ VkImageLayout layout;
struct anv_image_view *image_view;
struct anv_sampler *sampler;
-
- /* Used to determine whether or not we need the surface state to have
- * the auxiliary buffer enabled.
- */
- enum isl_aux_usage aux_usage;
};
struct {
@@ -2164,14 +2160,19 @@ struct anv_image_view {
VkFormat vk_format;
VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */
- /** RENDER_SURFACE_STATE when using image as a sampler surface. */
- struct anv_state sampler_surface_state;
+ /**
+ * RENDER_SURFACE_STATE when using image as a sampler surface with an image
+ * layout of SHADER_READ_ONLY_OPTIMAL or DEPTH_STENCIL_READ_ONLY_OPTIMAL.
+ */
+ enum isl_aux_usage optimal_sampler_aux_usage;
+ struct anv_state optimal_sampler_surface_state;
/**
- * RENDER_SURFACE_STATE when using image as a sampler surface with the
- * auxiliary buffer disabled.
+ * RENDER_SURFACE_STATE when using image as a sampler surface with an image
+ * layout of GENERAL.
*/
- struct anv_state no_aux_sampler_surface_state;
+ enum isl_aux_usage general_sampler_aux_usage;
+ struct anv_state general_sampler_surface_state;
/**
* RENDER_SURFACE_STATE when using image as a storage image. Separate states
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index ad49799c84e..280efcc2245 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -1584,28 +1584,39 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
continue;
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
- case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
- surface_state = desc->aux_usage == ISL_AUX_USAGE_NONE ?
- desc->image_view->no_aux_sampler_surface_state :
- desc->image_view->sampler_surface_state;
+ case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: {
+ enum isl_aux_usage aux_usage;
+ if (desc->layout == VK_IMAGE_LAYOUT_GENERAL) {
+ surface_state = desc->image_view->general_sampler_surface_state;
+ aux_usage = desc->image_view->general_sampler_aux_usage;
+ } else {
+ surface_state = desc->image_view->optimal_sampler_surface_state;
+ aux_usage = desc->image_view->optimal_sampler_aux_usage;
+ }
assert(surface_state.alloc_size);
add_image_relocs(cmd_buffer, desc->image_view->image,
desc->image_view->aspect_mask,
- desc->aux_usage, surface_state);
+ aux_usage, surface_state);
break;
+ }
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
assert(stage == MESA_SHADER_FRAGMENT);
if (desc->image_view->aspect_mask != VK_IMAGE_ASPECT_COLOR_BIT) {
/* For depth and stencil input attachments, we treat it like any
* old texture that a user may have bound.
*/
- surface_state = desc->aux_usage == ISL_AUX_USAGE_NONE ?
- desc->image_view->no_aux_sampler_surface_state :
- desc->image_view->sampler_surface_state;
+ enum isl_aux_usage aux_usage;
+ if (desc->layout == VK_IMAGE_LAYOUT_GENERAL) {
+ surface_state = desc->image_view->general_sampler_surface_state;
+ aux_usage = desc->image_view->general_sampler_aux_usage;
+ } else {
+ surface_state = desc->image_view->optimal_sampler_surface_state;
+ aux_usage = desc->image_view->optimal_sampler_aux_usage;
+ }
assert(surface_state.alloc_size);
add_image_relocs(cmd_buffer, desc->image_view->image,
desc->image_view->aspect_mask,
- desc->aux_usage, surface_state);
+ aux_usage, surface_state);
} else {
/* For color input attachments, we create the surface state at
* vkBeginRenderPass time so that we can include aux and clear