[v5,17/19] anv: Use clear address for HiZ fast clears too.

Submitted by Rafael Antognolli on March 29, 2018, 5:58 p.m.

Details

Message ID 20180329175853.23728-18-rafael.antognolli@intel.com
State New
Headers show
Series "Use clear color address in surface state." ( rev: 7 6 5 ) in Mesa

Not browsing as part of any series.

Commit Message

Rafael Antognolli March 29, 2018, 5:58 p.m.
Store the default clear address for HiZ fast clears on a global bo, and
point to it when needed.

Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
---
 src/intel/vulkan/anv_device.c  | 19 +++++++++++++++++++
 src/intel/vulkan/anv_image.c   | 10 +++++++---
 src/intel/vulkan/anv_private.h |  1 +
 3 files changed, 27 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index d400a1328b4..7522b7865c2 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1422,6 +1422,20 @@  vk_priority_to_gen(int priority)
    }
 }
 
+static void
+anv_device_init_hiz_clear_batch(struct anv_device *device)
+{
+   anv_bo_init_new(&device->hiz_clear_bo, device, 4096);
+   uint32_t *map = anv_gem_mmap(device, device->hiz_clear_bo.gem_handle,
+                                0, 4096, 0);
+
+   union isl_color_value hiz_clear = { .u32 = { 0, } };
+   hiz_clear.f32[0] = ANV_HZ_FC_VAL;
+
+   memcpy(map, hiz_clear.u32, sizeof(hiz_clear.u32));
+   anv_gem_munmap(map, device->hiz_clear_bo.size);
+}
+
 VkResult anv_CreateDevice(
     VkPhysicalDevice                            physicalDevice,
     const VkDeviceCreateInfo*                   pCreateInfo,
@@ -1602,6 +1616,9 @@  VkResult anv_CreateDevice(
 
    anv_device_init_trivial_batch(device);
 
+   if (device->info.gen >= 10)
+      anv_device_init_hiz_clear_batch(device);
+
    anv_scratch_pool_init(device, &device->scratch_pool);
 
    anv_queue_init(device, &device->queue);
@@ -1695,6 +1712,8 @@  void anv_DestroyDevice(
    anv_gem_close(device, device->workaround_bo.gem_handle);
 
    anv_gem_close(device, device->trivial_batch_bo.gem_handle);
+   if (device->info.gen >= 10)
+      anv_gem_close(device, device->hiz_clear_bo.gem_handle);
 
    anv_state_pool_finish(&device->surface_state_pool);
    anv_state_pool_finish(&device->instruction_state_pool);
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index da4601ce20e..a941559eb3a 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -1061,9 +1061,13 @@  anv_image_fill_surface_state(struct anv_device *device,
 
    struct anv_address clear_address = { .bo = NULL };
    state_inout->clear_address = 0;
-   if (device->info.gen >= 10 && aux_usage != ISL_AUX_USAGE_NONE &&
-       aux_usage != ISL_AUX_USAGE_HIZ) {
-      clear_address = anv_image_get_clear_color_addr(device, image, aspect);
+
+   if (device->info.gen >= 10 && aux_usage != ISL_AUX_USAGE_NONE) {
+      if (aux_usage == ISL_AUX_USAGE_HIZ) {
+         clear_address = (struct anv_address) { .bo = &device->hiz_clear_bo };
+      } else {
+         clear_address = anv_image_get_clear_color_addr(device, image, aspect);
+      }
    }
 
    if (view_usage == ISL_SURF_USAGE_STORAGE_BIT &&
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 1e352576e22..3d0adfda558 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -895,6 +895,7 @@  struct anv_device {
 
     struct anv_bo                               workaround_bo;
     struct anv_bo                               trivial_batch_bo;
+    struct anv_bo                               hiz_clear_bo;
 
     struct anv_pipeline_cache                   blorp_shader_cache;
     struct blorp_context                        blorp;