summaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan
diff options
context:
space:
mode:
authorNanley Chery <[email protected]>2017-01-31 11:04:42 -0800
committerNanley Chery <[email protected]>2017-03-02 13:17:54 -0800
commitefc2222323b662ca20a23044a5d4b79157152fe5 (patch)
treeff6e1e4dc8d75538bb25a7801643ed0d250a58ef /src/intel/vulkan
parentf3621f4e71a68aae76093ee2232d4027057c2e19 (diff)
anv/image: Create an additional surface state for sampling
This will be used to sample a depth input attachment without having to pass through the HiZ buffer. Signed-off-by: Nanley Chery <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/intel/vulkan')
-rw-r--r--src/intel/vulkan/anv_image.c22
-rw-r--r--src/intel/vulkan/anv_private.h6
2 files changed, 27 insertions, 1 deletions
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 16a60833e02..95ba12c928d 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -692,8 +692,19 @@ anv_CreateImageView(VkDevice _device,
(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);
- /* Select the optimal aux_usage for sampling. */
+ /* 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 =
anv_layout_to_aux_usage(&device->info, image, iview->aspect_mask,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
@@ -716,9 +727,18 @@ anv_CreateImageView(VkDevice _device,
.aux_usage = surf_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,
+ .surf = &surface->isl,
+ .view = &view,
+ .mocs = device->default_mocs);
+
anv_state_flush(device, iview->sampler_surface_state);
+ anv_state_flush(device, iview->no_aux_sampler_surface_state);
} else {
iview->sampler_surface_state.alloc_size = 0;
+ iview->no_aux_sampler_surface_state.alloc_size = 0;
}
/* NOTE: This one needs to go last since it may stomp isl_view.format */
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 49ca510998f..b12012d36c6 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1819,6 +1819,12 @@ struct anv_image_view {
struct anv_state sampler_surface_state;
/**
+ * RENDER_SURFACE_STATE when using image as a sampler surface with the
+ * auxiliary buffer disabled.
+ */
+ struct anv_state no_aux_sampler_surface_state;
+
+ /**
* RENDER_SURFACE_STATE when using image as a storage image. Separate states
* for write-only and readable, using the real format for write-only and the
* lowered format for readable.