[Mesa-dev] [PATCH v2 12/12] anv: Use clear address for HiZ fast clears too.
Rafael Antognolli
rafael.antognolli at intel.com
Fri Jan 19 19:54:47 UTC 2018
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 at intel.com>
---
src/intel/vulkan/anv_device.c | 19 +++++++++++++++++++
src/intel/vulkan/anv_image.c | 11 ++++++++---
src/intel/vulkan/anv_private.h | 1 +
3 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 777abd87578..625386d68c2 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1174,6 +1174,20 @@ anv_device_init_trivial_batch(struct anv_device *device)
anv_gem_munmap(map, device->trivial_batch_bo.size);
}
+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,
@@ -1305,6 +1319,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);
@@ -1395,6 +1412,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 cc0274e73bc..e0be74c35ed 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -940,10 +940,15 @@ anv_image_fill_surface_state(struct anv_device *device,
bool use_clear_address = false;
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, view_in->base_level);
+
+ if (device->info.gen >= 10 && aux_usage != ISL_AUX_USAGE_NONE) {
use_clear_address = true;
+ 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, view_in->base_level);
+ }
}
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 f0ac96489c9..5fee8264bab 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -864,6 +864,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;
--
2.14.3
More information about the mesa-dev
mailing list