[Mesa-dev] [PATCH 21/22] anv: Enable sampling from HiZ
Chery, Nanley G
nanley.g.chery at intel.com
Thu Jan 12 19:23:12 UTC 2017
Thanks for noticing this. I actually had a patch to handle this that must have gotten lost in my rebasing efforts. I'll send it in the v2.
My email isn't working properly, so sorry for any formatting errors.
________________________________
From: Jason Ekstrand [jason at jlekstrand.net]
Sent: Thursday, January 12, 2017 10:38 AM
To: Nanley Chery
Cc: mesa-dev at lists.freedesktop.org; Chery, Nanley G
Subject: Re: [Mesa-dev] [PATCH 21/22] anv: Enable sampling from HiZ
On Wed, Jan 11, 2017 at 5:55 PM, Nanley Chery <nanleychery at gmail.com<mailto:nanleychery at gmail.com>> wrote:
Signed-off-by: Nanley Chery <nanley.g.chery at intel.com<mailto:nanley.g.chery at intel.com>>
---
src/intel/vulkan/TODO | 1 -
src/intel/vulkan/anv_image.c | 19 ++++++++++++++++---
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/intel/vulkan/TODO b/src/intel/vulkan/TODO
index 37fd16b437..38acc0dd5b 100644
--- a/src/intel/vulkan/TODO
+++ b/src/intel/vulkan/TODO
@@ -8,7 +8,6 @@ Missing Features:
- Sparse memory
Performance:
- - Sampling from HiZ (Nanley)
- Multi-{sampled/gen8,LOD} HiZ
- Compressed multisample support
- Pushing pieces of UBOs?
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 7d5beeabbe..ee563685bb 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -538,10 +538,22 @@ anv_CreateImageView(VkDevice _device,
iview->isl.usage = 0;
}
- /* Sampling from HiZ is not yet enabled */
+ /* If the HiZ buffer can be sampled from, set the constant clear color.
+ * If it cannot, disable the isl aux usage flag.
+ */
+ float red_clear_color = 0.0f;
enum isl_aux_usage surf_usage = image->aux_usage;
- if (surf_usage == ISL_AUX_USAGE_HIZ)
- surf_usage = ISL_AUX_USAGE_NONE;
+ if (image->aux_usage == ISL_AUX_USAGE_HIZ) {
+ if (anv_can_sample_with_hiz(device->info.gen, image->samples)) {
+ /* When a HiZ buffer is sampled on gen9+, ensure that
+ * the constant fast clear value is set in the surface state.
+ */
+ if (device->info.gen >= 9)
+ red_clear_color = ANV_HZ_FC_VAL;
+ } else {
+ surf_usage = ISL_AUX_USAGE_NONE;
+ }
+ }
I realized this morning that this doesn't actually do everything we need. If we're going to use a layout-based approach to HiZ, we need two surface states, one with HiZ and one without and we need to select which one to put in the binding table based on layout. Otherwise, if they sample from an image in LAYOUT_GENERAL and the HiZ data doesn't match the depth data, we'll get the wrong values. I don't think this will be all that hard to solve, but we should solve it.
/* Input attachment surfaces for color are allocated and filled
* out at BeginRenderPass time because they need compression information.
@@ -560,6 +572,7 @@ anv_CreateImageView(VkDevice _device,
iview->sampler_surface_state.map,
.surf = &surface->isl,
.view = &view,
+ .clear_color.f32 = { red_clear_color,},
.aux_surf = &image->aux_surface.isl,
.aux_usage = surf_usage,
.mocs = device->default_mocs);
--
2.11.0
_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org<mailto:mesa-dev at lists.freedesktop.org>
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170112/938f7979/attachment.html>
More information about the mesa-dev
mailing list